fix loading page, add delete edit manage menu, search manage user
This commit is contained in:
@ -8,6 +8,8 @@ import { ListToolBar } from '../blocks';
|
||||
import { useCallApi } from '@/hooks';
|
||||
|
||||
interface ContextProps {
|
||||
showSearchDialog: boolean;
|
||||
handleSearchDialog: (show: boolean) => void;
|
||||
showEditDialog: boolean;
|
||||
handleEditDialog: (show: boolean, selected_user: string | null) => void;
|
||||
showAddDialog: boolean;
|
||||
@ -35,6 +37,8 @@ interface RoleListProps {
|
||||
}
|
||||
|
||||
const initialProps: ContextProps = {
|
||||
showSearchDialog: false,
|
||||
handleSearchDialog: (show: boolean) => {},
|
||||
showEditDialog: false,
|
||||
handleEditDialog: () => {},
|
||||
showAddDialog: false,
|
||||
@ -52,6 +56,7 @@ const API_URL = apiConfig.service_dashboard;
|
||||
const ManageUserContextProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
/* state */
|
||||
const [showEditDialog, setShowEditDialog] = useState(false);
|
||||
const [showSearchDialog, setShowSearchDialog] = useState(false);
|
||||
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
const [selectedUser, setSelectedUser] = useState<string | null>(null);
|
||||
@ -59,6 +64,10 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
|
||||
const { GetData } = useCallApi();
|
||||
|
||||
/* action */
|
||||
const handleSearchDialog = useCallback((show: boolean) => {
|
||||
setShowSearchDialog(show);
|
||||
}, []);
|
||||
|
||||
const handleEditDialog = useCallback((show: boolean, selected_user: string | null) => {
|
||||
setSelectedUser(show ? selected_user : null);
|
||||
setShowEditDialog(show);
|
||||
@ -219,6 +228,8 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
|
||||
return (
|
||||
<ManageUserContext.Provider
|
||||
value={{
|
||||
showSearchDialog,
|
||||
handleSearchDialog,
|
||||
showEditDialog,
|
||||
handleEditDialog,
|
||||
selectedUser,
|
||||
|
||||
Reference in New Issue
Block a user