import { useState, useEffect} from 'react';
import { connect } from '@umijs/max';
import { ConfigProvider } from 'antd';
import PagesPermissionListTable from '@/components/Render/Permission/List/table'
import PagesPermissionListCreate from '@/components/Render/Permission/List/create'
import PagesPermissionListParent from '@/components/Render/Permission/List/parent'


const PermissionListPage: 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',
                    }
                }}
            >
                <PagesPermissionListTable getId={getId}></PagesPermissionListTable>
                <PagesPermissionListCreate id={id}></PagesPermissionListCreate>
                <PagesPermissionListParent id={id}></PagesPermissionListParent>
                
                
            </ConfigProvider>
        </>
    );
};

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