import { useState, useEffect} from 'react';
import { connect } from '@umijs/max';
import { ConfigProvider } from 'antd';
import PagesMainAdvertisementListTable from '@/components/Render/Main/Advertisement/List/table'
import PagesMainAdvertisementListCreate from '@/components/Render/Main/Advertisement/List/create'

const AdvertisementListPage: React.FC = ({ dispatch, openModel }: any) => {
    const [id, setId] = useState<number>(0);
    const getId = (value: number) => {
        setId(value)
    }

    useEffect(() => {
        if(!openModel.openModal) {
            setId(0)
        }
    }, [openModel.openModal])

    return (
        <>
            <ConfigProvider
                theme={{
                    token: {
                        colorPrimary: '#4FBE70',
                    }
                }}
            >
                <PagesMainAdvertisementListTable getId={getId}></PagesMainAdvertisementListTable>
                <PagesMainAdvertisementListCreate id={id}></PagesMainAdvertisementListCreate>
            </ConfigProvider>
        </>
    );
};

export default connect(({  openModel }: any) => ({
    openModel
}))(AdvertisementListPage);

