add crud manage menus

This commit is contained in:
Wikzyy
2025-03-06 09:15:17 +07:00
parent f84bf7dde1
commit eb338915da
4 changed files with 6 additions and 37 deletions

View File

@ -32,7 +32,6 @@ const AddDialog = () => {
id_parent: '', id_parent: '',
order_number: 0, order_number: 0,
icon: '', icon: '',
application: '',
status: '' status: ''
}; };
const [formField, setFormField] = useState(initialState); const [formField, setFormField] = useState(initialState);
@ -64,14 +63,13 @@ const AddDialog = () => {
formField.name === '' || formField.name === '' ||
formField.link === '' || formField.link === '' ||
formField.order_number === 0 || formField.order_number === 0 ||
formField.application === '' ||
formField.status === '' formField.status === ''
) { ) {
setAlert({ show: true, message: 'Please fill in all required fields.' }); setAlert({ show: true, message: 'Please fill in all required fields.' });
return; return;
} }
// doCreateMenu(e); doCreateMenu(e);
console.log(formField); console.log(formField);
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
}; };
@ -182,20 +180,6 @@ const AddDialog = () => {
</div> </div>
</div> </div>
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">
Application<span className="text-red-500">*</span>
</label>
<Input
className="input"
type="text"
value={formField.application}
onChange={(e) => setFormField({ ...formField, application: e.target.value })}
/>
</div>
</div>
<div className="w-full"> <div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56"> <label className="form-label flex items-center gap-1 max-w-56">

View File

@ -2,9 +2,9 @@ import { apiConfig } from '@/config/api.config';
import { useManageMenusContext } from '../hooks/useManageMenusContext'; import { useManageMenusContext } from '../hooks/useManageMenusContext';
import { Alert, useDataGrid } from '@/components'; import { Alert, useDataGrid } from '@/components';
import { useCallApi } from '@/hooks'; import { useCallApi } from '@/hooks';
import React, { ChangeEvent, useCallback, useState } from 'react'; import { ChangeEvent, useCallback, useState } from 'react';
import { toast } from 'sonner'; import { toast } from 'sonner';
import { Dialog, DialogContent, DialogFooter, DialogHeader } from '@/components/ui/dialog'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { EnforceSwitch } from '@/components/switch'; import { EnforceSwitch } from '@/components/switch';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
@ -39,6 +39,8 @@ const DeleteDialog = () => {
<Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}> <Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}>
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden"> <DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
<DialogHeader className="p-0 border-0 block"> <DialogHeader className="p-0 border-0 block">
<DialogTitle></DialogTitle>
<DialogDescription></DialogDescription>
<Alert variant="warning"> <Alert variant="warning">
<h3 className="text-lg">Are you sure?</h3> <h3 className="text-lg">Are you sure?</h3>
<span className="text-sm">you will delete this data!</span> <span className="text-sm">you will delete this data!</span>

View File

@ -31,7 +31,6 @@ const EditDialog = () => {
id_parent: '', id_parent: '',
order_number: 0, order_number: 0,
icon: '', icon: '',
application: '',
status: '' status: ''
}; };
const [formField, setFormField] = useState(initialState); const [formField, setFormField] = useState(initialState);
@ -60,14 +59,13 @@ const EditDialog = () => {
formField.name === '' || formField.name === '' ||
formField.link === '' || formField.link === '' ||
formField.order_number === 0 || formField.order_number === 0 ||
formField.application === '' ||
formField.status === '' formField.status === ''
) { ) {
setAlert({ show: true, message: 'Please fill in all required fields.' }); setAlert({ show: true, message: 'Please fill in all required fields.' });
return; return;
} }
// doUpdateMenu(e); doUpdateMenu(e);
console.log(formField); console.log(formField);
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
}; };
@ -178,20 +176,6 @@ const EditDialog = () => {
</div> </div>
</div> </div>
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">
Application<span className="text-red-500">*</span>
</label>
<Input
className="input"
type="text"
value={formField.application}
onChange={(e) => setFormField({ ...formField, application: e.target.value })}
/>
</div>
</div>
<div className="w-full"> <div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56"> <label className="form-label flex items-center gap-1 max-w-56">

View File

@ -24,7 +24,6 @@ interface MenuProps {
id_parent: string; id_parent: string;
order_number: number; order_number: number;
icon: string; icon: string;
application: string;
status: string; status: string;
} }