butuh install packagee react number format

This commit is contained in:
bagusajisaputroo
2025-03-24 09:55:20 +07:00
parent 03e670ef09
commit 5422ce9381
13 changed files with 2733 additions and 0 deletions

View File

@ -0,0 +1,87 @@
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Alert, useDataGrid } from '@/components';
import { ChangeEvent, useCallback, useState } from 'react';
import { apiConfig } from '@/config/api.config';
import { toast } from 'sonner';
import { useCallApi } from '@/hooks';
import { doSaveLogActivity } from '@/actions/GlobalActions';
import { EnforceSwitch } from '@/components/switch';
import { useContext } from 'react';
import { useManageTransferFeeContext } from '../hooks/useManageTransferFeeContext';
import { ManageTransferFeeContext } from '../hooks/ManageTransferFeeContext';
import { DialogDescription } from '@radix-ui/react-dialog';
import { useManageAccessTypeContext } from '@/pages/access/access-type/hooks/useManageAccessTypeContext';
const API_URL = apiConfig.service_transaction;
const DeleteDialog = () => {
const { showDeleteFeeDialog, handleDeleteFeeDialog, selectedTransferFee } = useManageTransferFeeContext();
const { reload } = useDataGrid();
const { DeleteData } = useCallApi();
const [enforce, setEnforce] = useState(false);
const [alert, setAlert] = useState({
show: false,
message: ''
});
const doDeleteTransferFee = useCallback(async () => {
console.log("Selected Transfer Fee:", selectedTransferFee, "Type:", typeof selectedTransferFee);
const response = await DeleteData(`${API_URL}/transactionfees/delete/${selectedTransferFee}/${enforce}`, {
id: selectedTransferFee
});
if (response?.status) {
setAlert((prev) => ({ ...prev, show: false, message: '' }));
handleDeleteFeeDialog(false, null);
toast.success('Success Delete Product');
reload();
} else {
toast.error('Failed Delete Product');
setAlert((prev) => ({ ...prev, show: true, message: response?.message }));
}
}, [selectedTransferFee, enforce]);
// console.log(selectedTransferFee);
return (
<Dialog open={showDeleteFeeDialog} onOpenChange={(open) => handleDeleteFeeDialog(open, null)}>
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
<DialogHeader className="p-0 border-0 block">
<DialogTitle className="text-lg">Delete Transfer Type</DialogTitle>
<DialogDescription className="text-sm">Delete Transfer Type</DialogDescription>
<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">
<h3>{alert.message}</h3>
</Alert>
)}
</DialogHeader>
<DialogFooter className="flex justify-end items-center gap-4 mt-3">
<Button variant={'outline'} onClick={() => handleDeleteFeeDialog(false, null)}>
Cancel
</Button>
<Button variant={'destructive'} onClick={() => doDeleteTransferFee()}>
Delete
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
};
export default DeleteDialog;
export { DeleteDialog };