import { useCallApi } from '@/hooks'; import { useManageWalletContext } from '../hooks/useManageWalletContext'; import { Alert, useDataGrid } from '@/components'; import { useCallback, useState } from 'react'; import { toast } from 'sonner'; import { apiConfig } from '@/config/api.config'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; const API_URL = apiConfig.service_master_data; const DeleteDialog = () => { const { showDeleteDialog, handleDeleteDialog, selectedWallet } = useManageWalletContext(); const { DeleteData } = useCallApi(); const { reload } = useDataGrid(); const [alert, setAlert] = useState({ show: false, message: '' }); const doDeleteWallet = useCallback(async () => { if (!selectedWallet) { toast.error('No wallet selected'); return; } const response = await DeleteData( `${API_URL}/wallet/delete/${selectedWallet.Wallet_id}/false`, { id: selectedWallet.Wallet_id } ); if (response?.status) { setAlert({ show: false, message: '' }); handleDeleteDialog(false, null); toast.success('Success Delete Wallet'); reload(); } else { setAlert({ show: true, message: response?.message }); toast.error('Failed Delete Wallet'); } }, [selectedWallet, handleDeleteDialog, DeleteData, reload]); return ( handleDeleteDialog(open, null)}>

Are you sure?

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

{alert.message}

)}
); }; export default DeleteDialog;