fixing transasction type and transaction fee

This commit is contained in:
bagusajisaputroo
2025-03-28 11:26:34 +07:00
parent c66dd3ec85
commit f4b14f4d63
6 changed files with 71 additions and 51 deletions

View File

@ -150,9 +150,7 @@ const AddFeeDialog = () => {
e.preventDefault(); e.preventDefault();
for (const key in formField) { for (const key in formField) {
if ( if (
formField[key as keyof typeof formField] === '' || formField[key as keyof typeof formField] === '' ) {
formField[key as keyof typeof formField] === 0
) {
setAlert({ show: true, message: 'All fields must be filled out' }); setAlert({ show: true, message: 'All fields must be filled out' });
return; return;
} }
@ -163,7 +161,7 @@ const AddFeeDialog = () => {
...formField ...formField
}); });
if (response?.status) { if (response?.status) {
toast.success('Success Create Transfer Fee'); // toast.success('Success Create Transfer Fee');
reload(); reload();
resetForm(); resetForm();
handleAddFeeDialog(false); handleAddFeeDialog(false);
@ -225,7 +223,7 @@ const AddFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Minimum Amount <span className="text-red-500">*</span></label> <label className="form-label">Minimum Amount</label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.minimum_amount} value={formField.minimum_amount}
@ -242,7 +240,7 @@ const AddFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Maximum Amount <span className="text-red-500">*</span></label> <label className="form-label">Maximum Amount</label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.maximum_amount} value={formField.maximum_amount}
@ -283,7 +281,7 @@ const AddFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Deduct Amount <span className="text-red-500">*</span></label> <label className="form-label">Deduct Amount</label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.deduct_amount} value={formField.deduct_amount}
@ -300,7 +298,7 @@ const AddFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Deduct Percentage <span className="text-red-500">*</span></label> <label className="form-label">Deduct Percentage</label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.deduct_percentage} value={formField.deduct_percentage}

View File

@ -1,4 +1,4 @@
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle , DialogDescription} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Alert, useDataGrid } from '@/components'; import { Alert, useDataGrid } from '@/components';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
@ -6,7 +6,6 @@ import { apiConfig } from '@/config/api.config';
import { toast } from 'sonner'; import { toast } from 'sonner';
import { useCallApi } from '@/hooks'; import { useCallApi } from '@/hooks';
import { useManageTransferFeeContext } from '../hooks/useManageTransferFeeContext'; import { useManageTransferFeeContext } from '../hooks/useManageTransferFeeContext';
import { DialogDescription } from '@radix-ui/react-dialog';
const API_URL = apiConfig.service_transaction; const API_URL = apiConfig.service_transaction;
@ -27,10 +26,10 @@ const DeleteDialog = () => {
if (response?.status) { if (response?.status) {
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
handleDeleteFeeDialog(false, null); handleDeleteFeeDialog(false, null);
toast.success('Success Delete Product'); // toast.success('Success Delete Transaction Fee');
reload(); reload();
} else { } else {
toast.error('Failed Delete Product'); // toast.error('Failed Delete Transaction Fee');
setAlert({ show: true, message: response?.message }); setAlert({ show: true, message: response?.message });
} }
}, [selectedTransferFee]); }, [selectedTransferFee]);

View File

@ -96,10 +96,11 @@ const EditFeeDialog = () => {
async (e: React.FormEvent<HTMLFormElement>) => { async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault(); e.preventDefault();
const response = await PutData(`${API_URL}/transactionfees/update/${selectedTransferFee}`, { const response = await PutData(`${API_URL}/transactionfees/update/${selectedTransferFee}`, {
...formField, }); ...formField
});
if (response?.status) { if (response?.status) {
handleEditFeeDialog(false, null); handleEditFeeDialog(false, null);
toast.success('Success Update User'); // toast.success('Success Update Transaction Fee');
reload(); reload();
} else { } else {
setAlert((prev) => ({ ...prev, show: true, message: response?.message })); setAlert((prev) => ({ ...prev, show: true, message: response?.message }));
@ -252,7 +253,9 @@ const EditFeeDialog = () => {
<div className="card flex flex-col gap-5"> <div className="card flex flex-col gap-5">
<div className="card-body grid gap-5 p-0"> <div className="card-body grid gap-5 p-0">
<div className="w-full"> <div className="w-full">
<label className="form-label">Transfer Free Name <span className="text-red-500">*</span></label> <label className="form-label">
Transfer Free Name <span className="text-red-500">*</span>
</label>
<Input <Input
className="input" className="input"
type="text" type="text"
@ -264,7 +267,9 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Description <span className="text-red-500">*</span></label> <label className="form-label">
Description <span className="text-red-500">*</span>
</label>
<Input <Input
className="input" className="input"
type="text" type="text"
@ -276,7 +281,9 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Minimum Amount <span className="text-red-500">*</span></label> <label className="form-label">
Minimum Amount
</label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.minimum_amount} value={formField.minimum_amount}
@ -293,7 +300,9 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Maximum Amount <span className="text-red-500">*</span></label> <label className="form-label">
Maximum Amount
</label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.maximum_amount} value={formField.maximum_amount}
@ -310,7 +319,9 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Period Start <span className="text-red-500">*</span></label> <label className="form-label">
Period Start <span className="text-red-500">*</span>
</label>
<Input <Input
className="input" className="input"
type="date" type="date"
@ -322,7 +333,9 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Period End <span className="text-red-500">*</span></label> <label className="form-label">
Period End <span className="text-red-500">*</span>
</label>
<Input <Input
className="input" className="input"
type="date" type="date"
@ -334,7 +347,8 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Deduct Amount <span className="text-red-500">*</span></label> <label className="form-label">
Deduct Amount</label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.deduct_amount} value={formField.deduct_amount}
@ -351,7 +365,8 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Deduct Percentage <span className="text-red-500">*</span></label> <label className="form-label">
Deduct Percentage </label>
<NumericFormat <NumericFormat
className="input" className="input"
value={formField.deduct_percentage} value={formField.deduct_percentage}
@ -368,7 +383,9 @@ const EditFeeDialog = () => {
/> />
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Transacsion Type ID <span className="text-red-500">*</span></label> <label className="form-label">
Transacsion Type ID <span className="text-red-500">*</span>
</label>
<Select <Select
value={formField.transaction_type} value={formField.transaction_type}
onValueChange={(transaction_type) => onValueChange={(transaction_type) =>
@ -388,7 +405,9 @@ const EditFeeDialog = () => {
</Select> </Select>
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Status <span className="text-red-500">*</span></label> <label className="form-label">
Status <span className="text-red-500">*</span>
</label>
<Select <Select
value={formField.status} value={formField.status}
onValueChange={(value) => setFormField({ ...formField, status: value })} onValueChange={(value) => setFormField({ ...formField, status: value })}
@ -403,7 +422,9 @@ const EditFeeDialog = () => {
</Select> </Select>
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Status Included <span className="text-red-500">*</span></label> <label className="form-label">
Status Included <span className="text-red-500">*</span>
</label>
<Select <Select
value={formField.status_include} value={formField.status_include}
onValueChange={(value) => onValueChange={(value) =>
@ -420,20 +441,22 @@ const EditFeeDialog = () => {
</Select> </Select>
</div> </div>
<div className="w-full"> <div className="w-full">
<label className="form-label">Priority <span className="text-red-500">*</span></label> <label className="form-label">
<Select Priority <span className="text-red-500">*</span>
value={formField.priority} </label>
onValueChange={(value) => setFormField({ ...formField, priority: value })} <Select
> value={formField.priority}
<SelectTrigger> onValueChange={(value) => setFormField({ ...formField, priority: value })}
<SelectValue placeholder="Select Priority" /> >
</SelectTrigger> <SelectTrigger>
<SelectContent> <SelectValue placeholder="Select Priority" />
<SelectItem value="Y">Yes</SelectItem> </SelectTrigger>
<SelectItem value="N">No</SelectItem> <SelectContent>
</SelectContent> <SelectItem value="Y">Yes</SelectItem>
</Select> <SelectItem value="N">No</SelectItem>
</div> </SelectContent>
</Select>
</div>
{/* <div className="w-full"> {/* <div className="w-full">
<label className="form-label">Priotity <span className="text-red-500">*</span></label> <label className="form-label">Priotity <span className="text-red-500">*</span></label>

View File

@ -10,10 +10,10 @@ import { EditFeeDialog } from '../blocks/EditDialog';
interface ContextProps { interface ContextProps {
showEditFeeDialog: boolean; showEditFeeDialog: boolean;
handleEditFeeDialog: (show: boolean, selectedTransferFee: string | null) => void; handleEditFeeDialog: (show: boolean, selected_TransferFee: string | null) => void;
showAddFeeDialog: boolean; showAddFeeDialog: boolean;
handleAddFeeDialog: (show: boolean) => void; handleAddFeeDialog: (show: boolean) => void;
handleDeleteFeeDialog: (show: boolean, selectedTransferFee: string | null) => void; handleDeleteFeeDialog: (show: boolean, selected_TransferFee: string | null) => void;
showDeleteFeeDialog: boolean; showDeleteFeeDialog: boolean;
selectedTransferFee: string | null; selectedTransferFee: string | null;
} }
@ -39,8 +39,8 @@ const ManageTransferFeeContextProvider = ({ children }: { children: React.ReactN
const [selectedTransferFee, setSelectedTransferFee] = useState<string | null>(null); const [selectedTransferFee, setSelectedTransferFee] = useState<string | null>(null);
const { GetData } = useCallApi(); const { GetData } = useCallApi();
const handleEditFeeDialog = useCallback((show: boolean, selectedTransferFee: string | null) => { const handleEditFeeDialog = useCallback((show: boolean, selected_TransferFee: string | null) => {
setSelectedTransferFee(show ? selectedTransferFee : null); setSelectedTransferFee(show ? selected_TransferFee : null);
setShowEditFeeDialog(show); setShowEditFeeDialog(show);
}, []); }, []);
@ -48,8 +48,8 @@ const ManageTransferFeeContextProvider = ({ children }: { children: React.ReactN
setShowAddFeeDialog(show); setShowAddFeeDialog(show);
}, []); }, []);
const handleDeleteFeeDialog = useCallback((show: boolean, selectedTransferFee: string | null) => { const handleDeleteFeeDialog = useCallback((show: boolean, selected_TransferFee: string | null) => {
setSelectedTransferFee(show ? selectedTransferFee : null); setSelectedTransferFee(show ? selected_TransferFee : null);
setShowDeleteFeeDialog(show); setShowDeleteFeeDialog(show);
}, []); }, []);
const doGetTransferFeeListData = async ( const doGetTransferFeeListData = async (
@ -62,7 +62,7 @@ const ManageTransferFeeContextProvider = ({ children }: { children: React.ReactN
filter = filter.length == 0 ? {} : { any: filter[0].value.toLowerCase() }; filter = filter.length == 0 ? {} : { any: filter[0].value.toLowerCase() };
const response = await GetData(`${API_URL}/transactionfees/list`, { const response = await GetData(`${API_URL}/transactionfees/list`, {
limit: limit, limit: limit,
page: 1, page: page+1,
with_deleted: false, with_deleted: false,
order_field: sorting[0].id, order_field: sorting[0].id,
order_direction: sorting[0].desc ? 'ASC' : 'DESC', order_direction: sorting[0].desc ? 'ASC' : 'DESC',
@ -203,9 +203,9 @@ const ManageTransferFeeContextProvider = ({ children }: { children: React.ReactN
return ( return (
<div className="container mx-auto py-5"> <div className="container mx-auto py-5">
<div className="flex justify-between items-center mb-4"> <div className="flex justify-between items-center mt-6">
<h1 className="text-2xl font-semibold">Manage Transaction Fee</h1> <h1 className="text-xl font-semibold text-gray-900">Manage Transaction Fee</h1>
</div> </div>
<ManageTransferFeeContext.Provider <ManageTransferFeeContext.Provider
value={{ value={{
showEditFeeDialog, showEditFeeDialog,

View File

@ -34,7 +34,7 @@ const DeleteDialog = () => {
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
handleDeleteDialog(false, null); handleDeleteDialog(false, null);
reload(); reload();
setTimeout(() => toast.success('Success Delete Product'), 0); setTimeout(() => toast.success('Success Delete Transaction Type'), 0);
} else { } else {
setAlert({ show: true, message: response?.message }); setAlert({ show: true, message: response?.message });
setTimeout(() => toast.error('Failed Delete Product'), 0); setTimeout(() => toast.error('Failed Delete Product'), 0);

View File

@ -124,7 +124,7 @@ const EditDialog = () => {
}); });
if (response?.status) { if (response?.status) {
handleEditDialog(false, null); handleEditDialog(false, null);
toast.success('Success Update User'); toast.success('Success Update Transfer Type');
reload(); reload();
} else { } else {
setAlert((prev) => ({ ...prev, show: true, message: response?.message })); setAlert((prev) => ({ ...prev, show: true, message: response?.message }));