import { useRequest } from '@sa/hooks'; import { Button, Drawer, Flex, Form, Input, Radio, Select } from 'antd'; import type { FC } from 'react'; import { enableStatusOptions, userGenderOptions } from '@/constants/business'; import { useFormRules } from '@/features/form'; import { fetchGetAllRoles } from '@/service/api'; interface OptionsProps { label: string; value: string; } type Model = Pick< Api.SystemManage.User, 'nickName' | 'status' | 'userEmail' | 'userGender' | 'userName' | 'userPhone' | 'userRoles' >; type RuleKey = Extract; function getOptions(item: Api.SystemManage.AllRole) { return { label: item.roleName, value: item.roleCode }; } const UserOperateDrawer: FC = ({ form, handleSubmit, onClose, open, operateType }) => { const { t } = useTranslation(); const { data, run } = useRequest(fetchGetAllRoles, { manual: true }); const { defaultRequiredRule } = useFormRules(); const roleOptions: OptionsProps[] = data ? data.map(getOptions) : []; const rules: Record = { status: defaultRequiredRule, userName: defaultRequiredRule }; useUpdateEffect(() => { if (open) { run(); } }, [open]); return ( } onClose={onClose} >
{userGenderOptions.map(item => ( {t(item.label)} ))} {enableStatusOptions.map(item => ( {t(item.label)} ))}