add resetform + change customer title
This commit is contained in:
@ -109,7 +109,6 @@ const AddFeeDialog = () => {
|
|||||||
status: formField.status,
|
status: formField.status,
|
||||||
status_include: formField.status_include
|
status_include: formField.status_include
|
||||||
};
|
};
|
||||||
console.log(payload);
|
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const created_time = new Date();
|
const created_time = new Date();
|
||||||
@ -137,8 +136,6 @@ const AddFeeDialog = () => {
|
|||||||
order_field: sorting[0].id,
|
order_field: sorting[0].id,
|
||||||
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
||||||
});
|
});
|
||||||
console.log('TRANSACTION TYPE LIST: ', response?.data?.list);
|
|
||||||
|
|
||||||
setTransactionTypes(response?.data.list || []);
|
setTransactionTypes(response?.data.list || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching customer', error);
|
console.error('Error fetching customer', error);
|
||||||
@ -151,7 +148,6 @@ const AddFeeDialog = () => {
|
|||||||
const doCreateTransferType = useCallback(
|
const doCreateTransferType = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log(formField);
|
|
||||||
for (const key in formField) {
|
for (const key in formField) {
|
||||||
if (
|
if (
|
||||||
formField[key as keyof typeof formField] === '' ||
|
formField[key as keyof typeof formField] === '' ||
|
||||||
@ -167,7 +163,6 @@ const AddFeeDialog = () => {
|
|||||||
...formField,
|
...formField,
|
||||||
priority: formField.priority ? 'Y' : 'N'
|
priority: formField.priority ? 'Y' : 'N'
|
||||||
});
|
});
|
||||||
// console.log("coba coba:",response);
|
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
toast.success('Success Create Transfer Fee');
|
toast.success('Success Create Transfer Fee');
|
||||||
@ -177,7 +172,6 @@ const AddFeeDialog = () => {
|
|||||||
} else {
|
} else {
|
||||||
setAlert({ show: true, message: response?.message || 'Failed to create transfer fee' });
|
setAlert({ show: true, message: response?.message || 'Failed to create transfer fee' });
|
||||||
}
|
}
|
||||||
console.log(response);
|
|
||||||
},
|
},
|
||||||
[formField]
|
[formField]
|
||||||
);
|
);
|
||||||
@ -190,7 +184,7 @@ const AddFeeDialog = () => {
|
|||||||
<DialogHeader className="p-5 border-0">
|
<DialogHeader className="p-5 border-0">
|
||||||
<div className="flex items-center justify-between flex-wrap grow">
|
<div className="flex items-center justify-between flex-wrap grow">
|
||||||
<div className="flex flex-col justify-center">
|
<div className="flex flex-col justify-center">
|
||||||
<h1 className="text-xl font-semibold leading-none text-gray-900">AddTransfer Fee</h1>
|
<h1 className="text-xl font-semibold leading-none text-gray-900">Add Transfer Fee</h1>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="cursor-pointer hover:opacity-100 opacity-50"
|
className="cursor-pointer hover:opacity-100 opacity-50"
|
||||||
@ -392,7 +386,13 @@ const AddFeeDialog = () => {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-end pt-2.5 gap-5">
|
<div className="flex justify-end pt-2.5 gap-5">
|
||||||
<Button variant={'outline'} type="reset">
|
<Button
|
||||||
|
variant={'outline'}
|
||||||
|
type="reset"
|
||||||
|
onClick={() => {
|
||||||
|
resetForm();
|
||||||
|
}}
|
||||||
|
>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
||||||
|
|||||||
@ -26,7 +26,6 @@ const DeleteDialog = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const doDeleteTransferFee = useCallback(async () => {
|
const doDeleteTransferFee = useCallback(async () => {
|
||||||
console.log("Selected Transfer Fee:", selectedTransferFee, "Type:", typeof selectedTransferFee);
|
|
||||||
const response = await DeleteData(`${API_URL}/transactionfees/delete/${selectedTransferFee}/${enforce}`, {
|
const response = await DeleteData(`${API_URL}/transactionfees/delete/${selectedTransferFee}/${enforce}`, {
|
||||||
id: selectedTransferFee
|
id: selectedTransferFee
|
||||||
});
|
});
|
||||||
@ -42,7 +41,6 @@ const DeleteDialog = () => {
|
|||||||
}
|
}
|
||||||
}, [selectedTransferFee, enforce]);
|
}, [selectedTransferFee, enforce]);
|
||||||
|
|
||||||
// console.log(selectedTransferFee);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showDeleteFeeDialog} onOpenChange={(open) => handleDeleteFeeDialog(open, null)}>
|
<Dialog open={showDeleteFeeDialog} onOpenChange={(open) => handleDeleteFeeDialog(open, null)}>
|
||||||
|
|||||||
@ -105,7 +105,6 @@ const EditFeeDialog = () => {
|
|||||||
} else {
|
} else {
|
||||||
setAlert((prev) => ({ ...prev, show: true, message: response?.message }));
|
setAlert((prev) => ({ ...prev, show: true, message: response?.message }));
|
||||||
}
|
}
|
||||||
console.log(formField);
|
|
||||||
},
|
},
|
||||||
[formField, selectedTransferFee]
|
[formField, selectedTransferFee]
|
||||||
);
|
);
|
||||||
@ -145,10 +144,6 @@ const EditFeeDialog = () => {
|
|||||||
order_field: sorting[0].id,
|
order_field: sorting[0].id,
|
||||||
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
||||||
});
|
});
|
||||||
|
|
||||||
// 🟡 Log daftar pelanggan saja (kalau respons pakai struktur {data: {list: [...]}})
|
|
||||||
console.log('CUSTOMER LIST: ', response?.data?.list);
|
|
||||||
|
|
||||||
setCustomers(response?.data.list || []);
|
setCustomers(response?.data.list || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching customer', error);
|
console.error('Error fetching customer', error);
|
||||||
@ -170,10 +165,6 @@ const EditFeeDialog = () => {
|
|||||||
order_field: sorting[0].id,
|
order_field: sorting[0].id,
|
||||||
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
||||||
});
|
});
|
||||||
|
|
||||||
// 🟡 Log daftar pelanggan saja (kalau respons pakai struktur {data: {list: [...]}})
|
|
||||||
console.log('TRANSACTION TYPE LIST: ', response?.data?.list);
|
|
||||||
|
|
||||||
setTransactionTypes(response?.data.list || []);
|
setTransactionTypes(response?.data.list || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching customer', error);
|
console.error('Error fetching customer', error);
|
||||||
@ -185,7 +176,6 @@ const EditFeeDialog = () => {
|
|||||||
|
|
||||||
const fetchTransactionFee = useCallback(async (id: string) => {
|
const fetchTransactionFee = useCallback(async (id: string) => {
|
||||||
const response = await GetData(`${API_URL}/transactionfees/getdata/${id}`, { id });
|
const response = await GetData(`${API_URL}/transactionfees/getdata/${id}`, { id });
|
||||||
// console.log("API Response:", response);
|
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
setFormField((prev) => ({
|
setFormField((prev) => ({
|
||||||
@ -230,6 +220,24 @@ const EditFeeDialog = () => {
|
|||||||
fetchTransactionFee(selectedTransferFee);
|
fetchTransactionFee(selectedTransferFee);
|
||||||
}
|
}
|
||||||
}, [selectedTransferFee]);
|
}, [selectedTransferFee]);
|
||||||
|
const resetForm = () => {
|
||||||
|
setFormField({
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
minimum_amount: 0,
|
||||||
|
maximum_amount: 0,
|
||||||
|
period_start: '',
|
||||||
|
period_end: '',
|
||||||
|
deduct_amount: 0,
|
||||||
|
deduct_percentage: 0,
|
||||||
|
priority: '',
|
||||||
|
status: '',
|
||||||
|
status_include: '',
|
||||||
|
transaction_type: '',
|
||||||
|
updated_by: '',
|
||||||
|
updated_at: ''
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showEditFeeDialog} onOpenChange={(open) => handleEditFeeDialog(open, null)}>
|
<Dialog open={showEditFeeDialog} onOpenChange={(open) => handleEditFeeDialog(open, null)}>
|
||||||
@ -479,7 +487,10 @@ const EditFeeDialog = () => {
|
|||||||
</Select>
|
</Select>
|
||||||
</div> */}
|
</div> */}
|
||||||
<div className="flex justify-end pt-2.5 gap-5">
|
<div className="flex justify-end pt-2.5 gap-5">
|
||||||
<Button variant={'outline'} type="reset">
|
<Button variant={'outline'} type="reset"
|
||||||
|
onClick={() => {
|
||||||
|
resetForm();
|
||||||
|
}}>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
||||||
|
|||||||
@ -68,9 +68,6 @@ const ManageTransferFeeContextProvider = ({ children }: { children: React.ReactN
|
|||||||
order_direction: sorting[0].desc ? 'ASC' : 'DESC',
|
order_direction: sorting[0].desc ? 'ASC' : 'DESC',
|
||||||
filter: JSON.stringify(filter)
|
filter: JSON.stringify(filter)
|
||||||
});
|
});
|
||||||
console.log('hasilnya', response?.data.list);
|
|
||||||
console.log('transactiontype', response?.data);
|
|
||||||
|
|
||||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||||
};
|
};
|
||||||
const columns = useMemo<ColumnDef<any>[]>(
|
const columns = useMemo<ColumnDef<any>[]>(
|
||||||
|
|||||||
@ -127,8 +127,6 @@ const AddDialog = () => {
|
|||||||
order_field: sorting[0].id,
|
order_field: sorting[0].id,
|
||||||
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
||||||
});
|
});
|
||||||
console.log('CUSTOMER LIST: ', response?.data?.list);
|
|
||||||
|
|
||||||
setCustomers(response?.data.list || []);
|
setCustomers(response?.data.list || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching customer', error);
|
console.error('Error fetching customer', error);
|
||||||
@ -155,7 +153,6 @@ const AddDialog = () => {
|
|||||||
} else {
|
} else {
|
||||||
setWallets([]);
|
setWallets([]);
|
||||||
}
|
}
|
||||||
console.log('WALLET LIST: ', response?.data?.list);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -166,7 +163,6 @@ const AddDialog = () => {
|
|||||||
const doCreateTransferType = useCallback(
|
const doCreateTransferType = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log(formField);
|
|
||||||
for (const key in formField) {
|
for (const key in formField) {
|
||||||
if (
|
if (
|
||||||
formField[key as keyof typeof formField] === '' ||
|
formField[key as keyof typeof formField] === '' ||
|
||||||
@ -187,8 +183,6 @@ const AddDialog = () => {
|
|||||||
toast.success('Success Create Transfer Type');
|
toast.success('Success Create Transfer Type');
|
||||||
reload();
|
reload();
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
||||||
console.log('Berhasil nih, isinya gini:', formField);
|
|
||||||
} else {
|
} else {
|
||||||
setAlert({ show: true, message: response?.message || 'Failed to create transfer type' });
|
setAlert({ show: true, message: response?.message || 'Failed to create transfer type' });
|
||||||
}
|
}
|
||||||
@ -205,7 +199,7 @@ const AddDialog = () => {
|
|||||||
<DialogDescription></DialogDescription>
|
<DialogDescription></DialogDescription>
|
||||||
<div className="flex items-center justify-between flex-wrap grow">
|
<div className="flex items-center justify-between flex-wrap grow">
|
||||||
<div className="flex flex-col justify-center">
|
<div className="flex flex-col justify-center">
|
||||||
<h1 className="text-xl font-semibold leading-none text-gray-900">Transaction Type</h1>
|
<h1 className="text-xl font-semibold leading-none text-gray-900">Addd Transaction Type</h1>
|
||||||
<div className="flex items-center gap-2 text-sm font-normal text-gray-700"></div>
|
<div className="flex items-center gap-2 text-sm font-normal text-gray-700"></div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -401,7 +395,7 @@ const AddDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="flex items-center flex-wrap gap-2.5">
|
<div className="flex items-center flex-wrap gap-2.5">
|
||||||
<label className="form-label max-w-56">Customer Fee Destination</label>
|
<label className="form-label max-w-56">Customer</label>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<Select
|
<Select
|
||||||
value={formField.customer_fee_destination}
|
value={formField.customer_fee_destination}
|
||||||
@ -410,7 +404,7 @@ const AddDialog = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select Wallet" />
|
<SelectValue placeholder="Select Customer" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{customers.map((customer, idx) => (
|
{customers.map((customer, idx) => (
|
||||||
@ -471,7 +465,13 @@ const AddDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-end pt-2.5 gap-5">
|
<div className="flex justify-end pt-2.5 gap-5">
|
||||||
<Button variant={'outline'} type="reset">
|
<Button
|
||||||
|
variant={'outline'}
|
||||||
|
type="reset"
|
||||||
|
onClick={() => {
|
||||||
|
resetForm();
|
||||||
|
}}
|
||||||
|
>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
||||||
|
|||||||
@ -47,7 +47,6 @@ const DeleteDialog = () => {
|
|||||||
}
|
}
|
||||||
}, [selectedTransferType, enforce, DeleteData, handleDeleteDialog, reload]);
|
}, [selectedTransferType, enforce, DeleteData, handleDeleteDialog, reload]);
|
||||||
|
|
||||||
// console.log(selectedTransferType);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}>
|
<Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}>
|
||||||
|
|||||||
@ -72,7 +72,21 @@ const EditDialog = () => {
|
|||||||
message: ''
|
message: ''
|
||||||
});
|
});
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
setFormField(formField);
|
setFormField({
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
wallet_origin: '',
|
||||||
|
wallet_destination: '',
|
||||||
|
wallet_fee_destination: '',
|
||||||
|
customer_fee_destination: '',
|
||||||
|
minimum_amount: 0,
|
||||||
|
maximum_amount: 0,
|
||||||
|
max_transaction_per_day: 0,
|
||||||
|
status_approval: '',
|
||||||
|
status: '',
|
||||||
|
updated_by: '',
|
||||||
|
updated_at: ''
|
||||||
|
});
|
||||||
};
|
};
|
||||||
const [formField, setFormField] = useState({
|
const [formField, setFormField] = useState({
|
||||||
name: '',
|
name: '',
|
||||||
@ -115,7 +129,6 @@ const EditDialog = () => {
|
|||||||
} else {
|
} else {
|
||||||
setAlert((prev) => ({ ...prev, show: true, message: response?.message }));
|
setAlert((prev) => ({ ...prev, show: true, message: response?.message }));
|
||||||
}
|
}
|
||||||
// console.log(formField);
|
|
||||||
},
|
},
|
||||||
[formField, selectedTransferType]
|
[formField, selectedTransferType]
|
||||||
);
|
);
|
||||||
@ -130,7 +143,6 @@ const EditDialog = () => {
|
|||||||
order_field: sorting[0].id,
|
order_field: sorting[0].id,
|
||||||
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
||||||
});
|
});
|
||||||
// console.log('CUSTOMER LIST: ', response?.data?.list);
|
|
||||||
|
|
||||||
setCustomers(response?.data.list || []);
|
setCustomers(response?.data.list || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -165,11 +177,9 @@ const EditDialog = () => {
|
|||||||
|
|
||||||
const fetchTransactionType = useCallback(async (id: string) => {
|
const fetchTransactionType = useCallback(async (id: string) => {
|
||||||
const response = await GetData(`${API_URL}/transactiontype/getdata/${id}`, { id });
|
const response = await GetData(`${API_URL}/transactiontype/getdata/${id}`, { id });
|
||||||
// console.log("API Response:", response);
|
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
console.log('Fetched customer_fee_destination:', response.data);
|
|
||||||
setFormField((prev) => ({
|
setFormField((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
name: response.data.name,
|
name: response.data.name,
|
||||||
@ -209,8 +219,7 @@ const EditDialog = () => {
|
|||||||
fetchTransactionType(selectedTransferType);
|
fetchTransactionType(selectedTransferType);
|
||||||
}
|
}
|
||||||
}, [selectedTransferType]);
|
}, [selectedTransferType]);
|
||||||
// console.log('Form Field Data: ', formField);
|
|
||||||
// console.log('customer list:', customers);
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
||||||
<DialogContent className="container-fixed max-w-[1080px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
<DialogContent className="container-fixed max-w-[1080px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||||
@ -417,7 +426,7 @@ const EditDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="flex items-center flex-wrap gap-2.5">
|
<div className="flex items-center flex-wrap gap-2.5">
|
||||||
<label className="form-label max-w-56">Customer Fee Destination</label>
|
<label className="form-label max-w-56">Select Customer</label>
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<Select
|
<Select
|
||||||
value={formField.customer_fee_destination}
|
value={formField.customer_fee_destination}
|
||||||
@ -426,7 +435,7 @@ const EditDialog = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select Wallet" />
|
<SelectValue placeholder="Select" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{customers.map((customer, idx) => (
|
{customers.map((customer, idx) => (
|
||||||
@ -497,7 +506,10 @@ const EditDialog = () => {
|
|||||||
Transaction Fee Form
|
Transaction Fee Form
|
||||||
</Button> */}
|
</Button> */}
|
||||||
|
|
||||||
<Button variant={'outline'} type="reset">
|
<Button variant={'outline'} type="reset"
|
||||||
|
onClick={() => {
|
||||||
|
resetForm();
|
||||||
|
}}>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
||||||
|
|||||||
Reference in New Issue
Block a user