import { PageContainer } from "@ant-design/pro-components"
import { columns } from "./tableConfig"
import { useAjax } from "@/Hook/useAjax"
import { useModel } from "@umijs/max"
import { getAllKfs, getCustoms } from "@/services/miniApp/entWeChat"
import { useEffect } from "react"
import MyProTable from "@/components/MyProTable"

const Page: React.FC = () => {
    let { initialState } = useModel("@@initialState")
    let getList = useAjax((params) => getCustoms(params), { type: 'table' })
    let GetAllKfs = useAjax((params) => getAllKfs(params))
    let publicData = {
        appId: initialState?.selectApp?.id || "",
        appType: initialState?.selectApp?.appType || ""
    }
    useEffect(()=>{
        GetAllKfs.run(publicData)
    },[])
    return <PageContainer title={false}
    >
        <MyProTable<any, any>
          scroll={{ x: 'max-content' }}
            params={publicData}
            headerTitle={"企微用户列表"}
            rowKey={(r) => r.corpUserId}
            search={{
                labelWidth: 120,
            }}
            request={async (params) => {
                if(params.corpId){
                    return await getList.run(params)
                }
            }}
            columns={columns(GetAllKfs?.data?.data)}
        />
    </PageContainer>

}
export default Page