update manage user & manage reward
This commit is contained in:
@ -17,7 +17,6 @@ interface ContextProps {
|
||||
showDeleteDialog: boolean;
|
||||
handleDeleteDialog: (show: boolean, selected_user: string | null) => void;
|
||||
selectedUser: string | null;
|
||||
roles: RoleListProps[];
|
||||
}
|
||||
|
||||
interface SelectedUser {
|
||||
@ -30,12 +29,6 @@ interface SelectedUser {
|
||||
check_new_password: string;
|
||||
}
|
||||
|
||||
interface RoleListProps {
|
||||
id: string;
|
||||
name: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
const initialProps: ContextProps = {
|
||||
showSearchDialog: false,
|
||||
handleSearchDialog: (show: boolean) => {},
|
||||
@ -45,8 +38,7 @@ const initialProps: ContextProps = {
|
||||
handleAddDialog: () => {},
|
||||
showDeleteDialog: false,
|
||||
handleDeleteDialog: () => {},
|
||||
selectedUser: null,
|
||||
roles: []
|
||||
selectedUser: null
|
||||
};
|
||||
|
||||
const ManageUserContext = createContext<ContextProps>(initialProps);
|
||||
@ -60,7 +52,6 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
|
||||
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
const [selectedUser, setSelectedUser] = useState<string | null>(null);
|
||||
const [roles, setRoles] = useState<RoleListProps[]>([]);
|
||||
const { GetData } = useCallApi();
|
||||
|
||||
/* action */
|
||||
@ -193,39 +184,16 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
|
||||
const response = await GetData(`${API_URL}/user/list`, {
|
||||
limit: limit,
|
||||
page: page + 1,
|
||||
with_deleted: true,
|
||||
with_deleted: false,
|
||||
order_field: sorting[0].id,
|
||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||
filter: JSON.stringify(filter)
|
||||
});
|
||||
console.log('response api:', response);
|
||||
// console.log('response api:', response);
|
||||
|
||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||
};
|
||||
|
||||
const fetchRoles = useCallback(async () => {
|
||||
const params = {
|
||||
limit: 100,
|
||||
page: 1,
|
||||
with_deleted: false,
|
||||
order_field: 'name',
|
||||
order_direction: 'ASC',
|
||||
filter: JSON.stringify({
|
||||
status: 'Y'
|
||||
})
|
||||
};
|
||||
const response = await GetData(`${API_URL}/user_role/list`, params);
|
||||
if (response?.status) {
|
||||
setRoles(() => [...response.data.list]);
|
||||
} else {
|
||||
setRoles(() => []);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
fetchRoles();
|
||||
}, [fetchRoles]);
|
||||
|
||||
return (
|
||||
<ManageUserContext.Provider
|
||||
value={{
|
||||
@ -236,7 +204,6 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
|
||||
selectedUser,
|
||||
showAddDialog,
|
||||
handleAddDialog,
|
||||
roles,
|
||||
showDeleteDialog,
|
||||
handleDeleteDialog
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user