import { useState, useEffect} from 'react';
import { connect } from '@umijs/max';
import { ConfigProvider } from 'antd';
import PagesMainFairListTable from '@/components/Render/Main/Fair/List/table'
import PagesMainFairListCreate from '@/components/Render/Main/Fair/List/create'
import PagesMainFairListDetail from '@/components/Render/Main/Fair/List/detail'


const FairListPage: 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',
                    }
                }}
            >
                <PagesMainFairListTable getId={getId}></PagesMainFairListTable>
                <PagesMainFairListCreate id={id}></PagesMainFairListCreate>
                <PagesMainFairListDetail id={id}></PagesMainFairListDetail>
            </ConfigProvider>
        </>
    );
};

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

