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();
for (const key in formField) {
if (
formField[key as keyof typeof formField] === '' ||
formField[key as keyof typeof formField] === 0
) {
formField[key as keyof typeof formField] === '' ) {
setAlert({ show: true, message: 'All fields must be filled out' });
return;
}
@ -163,7 +161,7 @@ const AddFeeDialog = () => {
...formField
});
if (response?.status) {
toast.success('Success Create Transfer Fee');
// toast.success('Success Create Transfer Fee');
reload();
resetForm();
handleAddFeeDialog(false);
@ -225,7 +223,7 @@ const AddFeeDialog = () => {
/>
</div>
<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
className="input"
value={formField.minimum_amount}
@ -242,7 +240,7 @@ const AddFeeDialog = () => {
/>
</div>
<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
className="input"
value={formField.maximum_amount}
@ -283,7 +281,7 @@ const AddFeeDialog = () => {
/>
</div>
<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
className="input"
value={formField.deduct_amount}
@ -300,7 +298,7 @@ const AddFeeDialog = () => {
/>
</div>
<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
className="input"
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 { Alert, useDataGrid } from '@/components';
import { useCallback, useState } from 'react';
@ -6,7 +6,6 @@ import { apiConfig } from '@/config/api.config';
import { toast } from 'sonner';
import { useCallApi } from '@/hooks';
import { useManageTransferFeeContext } from '../hooks/useManageTransferFeeContext';
import { DialogDescription } from '@radix-ui/react-dialog';
const API_URL = apiConfig.service_transaction;
@ -27,10 +26,10 @@ const DeleteDialog = () => {
if (response?.status) {
setAlert({ show: false, message: '' });
handleDeleteFeeDialog(false, null);
toast.success('Success Delete Product');
// toast.success('Success Delete Transaction Fee');
reload();
} else {
toast.error('Failed Delete Product');
// toast.error('Failed Delete Transaction Fee');
setAlert({ show: true, message: response?.message });
}
}, [selectedTransferFee]);

View File

@ -96,10 +96,11 @@ const EditFeeDialog = () => {
async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const response = await PutData(`${API_URL}/transactionfees/update/${selectedTransferFee}`, {
...formField, });
...formField
});
if (response?.status) {
handleEditFeeDialog(false, null);
toast.success('Success Update User');
// toast.success('Success Update Transaction Fee');
reload();
} else {
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-body grid gap-5 p-0">
<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
className="input"
type="text"
@ -264,7 +267,9 @@ const EditFeeDialog = () => {
/>
</div>
<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
className="input"
type="text"
@ -276,7 +281,9 @@ const EditFeeDialog = () => {
/>
</div>
<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
className="input"
value={formField.minimum_amount}
@ -293,7 +300,9 @@ const EditFeeDialog = () => {
/>
</div>
<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
className="input"
value={formField.maximum_amount}
@ -310,7 +319,9 @@ const EditFeeDialog = () => {
/>
</div>
<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
className="input"
type="date"
@ -322,7 +333,9 @@ const EditFeeDialog = () => {
/>
</div>
<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
className="input"
type="date"
@ -334,7 +347,8 @@ const EditFeeDialog = () => {
/>
</div>
<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
className="input"
value={formField.deduct_amount}
@ -351,7 +365,8 @@ const EditFeeDialog = () => {
/>
</div>
<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
className="input"
value={formField.deduct_percentage}
@ -368,7 +383,9 @@ const EditFeeDialog = () => {
/>
</div>
<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
value={formField.transaction_type}
onValueChange={(transaction_type) =>
@ -388,7 +405,9 @@ const EditFeeDialog = () => {
</Select>
</div>
<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
value={formField.status}
onValueChange={(value) => setFormField({ ...formField, status: value })}
@ -403,7 +422,9 @@ const EditFeeDialog = () => {
</Select>
</div>
<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
value={formField.status_include}
onValueChange={(value) =>
@ -420,7 +441,9 @@ const EditFeeDialog = () => {
</Select>
</div>
<div className="w-full">
<label className="form-label">Priority <span className="text-red-500">*</span></label>
<label className="form-label">
Priority <span className="text-red-500">*</span>
</label>
<Select
value={formField.priority}
onValueChange={(value) => setFormField({ ...formField, priority: value })}

View File

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

View File

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

View File

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