remove delete feature
This commit is contained in:
@ -3,7 +3,6 @@ import { ManageWalletContextProvider } from './hooks/ManageWalletContext';
|
|||||||
import { Breadcrumbs, Link } from '@mui/material';
|
import { Breadcrumbs, Link } from '@mui/material';
|
||||||
import AddDialog from './blocks/AddDialog';
|
import AddDialog from './blocks/AddDialog';
|
||||||
import EditDialog from './blocks/EditDialog';
|
import EditDialog from './blocks/EditDialog';
|
||||||
import DeleteDialog from './blocks/DeleteDialog';
|
|
||||||
|
|
||||||
const WalletMaster = () => {
|
const WalletMaster = () => {
|
||||||
return (
|
return (
|
||||||
@ -28,7 +27,6 @@ const WalletMaster = () => {
|
|||||||
</div>
|
</div>
|
||||||
<AddDialog />
|
<AddDialog />
|
||||||
<EditDialog />
|
<EditDialog />
|
||||||
<DeleteDialog />
|
|
||||||
</Container>
|
</Container>
|
||||||
</ManageWalletContextProvider>
|
</ManageWalletContextProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,78 +0,0 @@
|
|||||||
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 (
|
|
||||||
<Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}>
|
|
||||||
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden">
|
|
||||||
<DialogHeader className="p-0 border-0 block">
|
|
||||||
<DialogTitle></DialogTitle>
|
|
||||||
<DialogDescription></DialogDescription>
|
|
||||||
<Alert variant="warning">
|
|
||||||
<h3 className="text-lg">Are you sure?</h3>
|
|
||||||
<span className="text-sm">You will delete this data!</span>
|
|
||||||
</Alert>
|
|
||||||
{alert.show && (
|
|
||||||
<Alert variant="danger">
|
|
||||||
<h3>{alert.message}</h3>
|
|
||||||
</Alert>
|
|
||||||
)}
|
|
||||||
</DialogHeader>
|
|
||||||
<DialogFooter className="flex justify-end items-center gap-4 mt-3">
|
|
||||||
<Button variant="outline" onClick={() => handleDeleteDialog(false, null)}>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<Button variant="destructive" onClick={doDeleteWallet}>
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DeleteDialog;
|
|
||||||
@ -131,12 +131,6 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
>
|
>
|
||||||
<KeenIcon icon="notepad-edit" />
|
<KeenIcon icon="notepad-edit" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
|
||||||
onClick={() => handleDeleteDialog(true, row)}
|
|
||||||
>
|
|
||||||
<KeenIcon icon="trash" />
|
|
||||||
</button>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user