|
|
@@ -1,4 +1,4 @@
|
|
|
-import {addUser, editUser, getAllDepartment, getAllRoleList, getUserInfo} from '@apis';
|
|
|
+import {addUser, editUser, getUserInfo} from '@apis';
|
|
|
import {yupResolver} from '@hookform/resolvers/yup';
|
|
|
import {AddUserParams} from '@models';
|
|
|
import {useMutation, useQuery} from '@tanstack/react-query';
|
|
|
@@ -115,42 +115,6 @@ export function useFormState(
|
|
|
return [{isLoading, formInstance}, {onSubmit}] as const;
|
|
|
}
|
|
|
|
|
|
-export function useOptions() {
|
|
|
- const {data: roleOptions} = useQuery(
|
|
|
- [getAllRoleList.name],
|
|
|
- async function() {
|
|
|
- const data = await getAllRoleList();
|
|
|
-
|
|
|
- if (data.msg === '200')
|
|
|
- return data.data.map(({id, roleName}) => ({value: String(id), label: roleName}));
|
|
|
-
|
|
|
- return [];
|
|
|
- }
|
|
|
- ,
|
|
|
- {initialData: [], retry: 3},
|
|
|
- );
|
|
|
-
|
|
|
- const {data: departmentOptions} = useQuery(
|
|
|
- [getAllDepartment.name],
|
|
|
- async function() {
|
|
|
- const data = await getAllDepartment();
|
|
|
-
|
|
|
- if (data.msg === '200')
|
|
|
- return data.data.map(
|
|
|
- ({id, departmentName}) => ({
|
|
|
- value: String(id), label: departmentName,
|
|
|
- }),
|
|
|
- );
|
|
|
-
|
|
|
- return [];
|
|
|
- }
|
|
|
- ,
|
|
|
- {initialData: [], retry: 3},
|
|
|
- );
|
|
|
-
|
|
|
- return {roleOptions, departmentOptions};
|
|
|
-}
|
|
|
-
|
|
|
export function useField() {
|
|
|
return useFormContext<FormState>();
|
|
|
}
|