fix loading page, add delete edit manage menu, search manage user

This commit is contained in:
Raja Oktafrianto
2025-03-28 10:06:57 +07:00
parent 1200301479
commit e5844a9f2e
7 changed files with 150 additions and 83 deletions

View File

@ -4,7 +4,14 @@ import { Alert, useDataGrid } from '@/components';
import { useCallApi } from '@/hooks';
import { ChangeEvent, useCallback, useState } from 'react';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog';
import { EnforceSwitch } from '@/components/switch';
import { Button } from '@/components/ui/button';
@ -13,14 +20,13 @@ const DeleteDialog = () => {
const { showDeleteDialog, handleDeleteDialog, selectedMenu }: any = useManageMenusContext();
const { reload } = useDataGrid();
const { DeleteData } = useCallApi();
const [enforce, setEnforce] = useState(false);
const [alert, setAlert] = useState({
show: false,
message: ''
});
const doDeleteMenu = async () => {
const response = await DeleteData(`${API_URL}/menus/delete/${selectedMenu.id}/${enforce}`, {
const response = await DeleteData(`${API_URL}/menus/delete/${selectedMenu.id}/false`, {
id: selectedMenu.id
});
@ -44,15 +50,6 @@ const DeleteDialog = () => {
<Alert variant="warning">
<h3 className="text-lg">Are you sure?</h3>
<span className="text-sm">you will delete this data!</span>
<div className="mt-2 flex items-center gap-x-2">
<label className="form-label max-w-56">Hard Delete</label>
<EnforceSwitch
enforce={enforce}
onChange={(e: ChangeEvent<HTMLInputElement>) => {
setEnforce(e.target.checked);
}}
/>
</div>
</Alert>
{alert.show && (
<Alert variant="danger">