import { useState, useEffect} from 'react';
import { connect } from '@umijs/max';
import { ConfigProvider } from 'antd';
import PagesMainCompanyListTable from '@/components/Render/Main/Company/List/table'
import PagesMainCompanyListCreate from '@/components/Render/Main/Company/List/create'
import PagesMainCompanyListHr from '@/components/Render/Main/Company/List/hr'


const CompanyListPage: 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',
                    }
                }}
            >
                <PagesMainCompanyListTable getId={getId}></PagesMainCompanyListTable>
                <PagesMainCompanyListCreate id={id}></PagesMainCompanyListCreate>
                <PagesMainCompanyListHr id={id}></PagesMainCompanyListHr>
            </ConfigProvider>
        </>
    );
};

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