import { Alert, useDataGrid } from '@/components'; import { useManageMunicipiosContext } from '../hooks/useManageMunicipiosContext'; import { useCallback, useState } from 'react'; import { apiConfig } from '@/config/api.config'; import { useCallApi } from '@/hooks'; import { toast } from 'sonner'; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { DialogDescription } from '@radix-ui/react-dialog'; import { doSaveLogActivity } from '@/actions/GlobalActions'; const API_URL = apiConfig.service_master_data; const DeleteDialog = () => { const { showDeleteDialog, handleDeleteDialog, selectedMunicipios } = useManageMunicipiosContext(); const { reload } = useDataGrid(); const { DeleteData } = useCallApi(); const [alert, setAlert] = useState({ show: false, message: '' }); const doDeleteMunicipio = useCallback(async () => { if (!selectedMunicipios) { toast.error('No Municipio selected'); return; } const response = await DeleteData(`${API_URL}/municipios/delete/${selectedMunicipios}/false`, { id: selectedMunicipios }); if (response?.status) { setAlert({ show: false, message: '' }); handleDeleteDialog(false, null); toast.success('Success Delete Municipio'); reload(); const createActivity = { module: 'Manage Municipio', description: `Delete Municipio => ${selectedMunicipios}`, action: 'D' }; doSaveLogActivity(createActivity); } else { setAlert({ show: true, message: response?.message }); toast.error('Failed Delete Municipio'); } }, [selectedMunicipios, DeleteData, handleDeleteDialog, reload]); return ( handleDeleteDialog(open, null)}>

Are you sure?

You will delete this data!
{alert.show && (

{alert.message}

)}
); }; export default DeleteDialog;