import { useState, useEffect} from 'react';
import { connect } from '@umijs/max';
import { ConfigProvider } from 'antd';
import PagesPermissionRoleTable from '@/components/Render/Permission/Role/table'
import PagesPermissionRoleCreate from '@/components/Render/Permission/Role/create'
import PagesPermissionRoleDispense from '@/components/Render/Permission/Role/dispense'


const PermissionRolePage: 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',
                    }
                }}
            >
                <PagesPermissionRoleTable getId={getId}></PagesPermissionRoleTable>
                <PagesPermissionRoleCreate id={id}></PagesPermissionRoleCreate>
                <PagesPermissionRoleDispense id={id}></PagesPermissionRoleDispense>

            </ConfigProvider>
        </>
    );
};

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

