diff --git a/src/pages/transfer/transferfee/blocks/AddDialog.tsx b/src/pages/transfer/transferfee/blocks/AddDialog.tsx index 13469dc..612ac36 100644 --- a/src/pages/transfer/transferfee/blocks/AddDialog.tsx +++ b/src/pages/transfer/transferfee/blocks/AddDialog.tsx @@ -114,7 +114,8 @@ const AddFeeDialog = () => { deduct_from_account: '', credit_to: '', credit_destination: '00000000-0000-0000-0000-000000000000', - credit_destination_account: '' + credit_destination_account: '', + deduct_when: 'A' }; const [formField, setFormField] = useState(initialState); @@ -389,13 +390,19 @@ const AddFeeDialog = () => { ); }; + useEffect(() => { + if (formField.status_include === 'N') { + setFormField((prev) => ({ ...prev, deduct_when: 'A' })); + } + }, [formField.status_include]); + return ( { if (!open) { - handleAddFeeDialog(open); - handleCloseDialog(); + handleAddFeeDialog(open); + handleCloseDialog(); } }} > @@ -835,6 +842,25 @@ const AddFeeDialog = () => { + {formField.status_include === 'Y' && ( +
+ + +
+ )}
-
-
-
{ placeholder="Enter Minimum Amount" />
-
{ placeholder="Enter Maximum Amount" />
-
-
-
{ placeholder="Enter Deduct Amount" />
-
{ placeholder="Enter Deduct Percentage" />
-
+ {formField.deduct_from === 'I' && ( +
+ +
+
setOpenDeductOrigin(!openDeductOrigin)} + > + + {customers.find((customer) => customer.id === formField.deduct_origin) + ?.username || 'Search customer...'} + +
-{formField.deduct_from === 'I' && ( -
- -
-
setOpenDeductOrigin(!openDeductOrigin)} - > - - {customers.find((customer) => customer.id === formField.deduct_origin)?.username || 'Search customer...'} - -
- - {openDeductOrigin && ( -
-
- setCustomerSearchTerm(e.target.value)} - autoComplete="off" - onClick={(e) => e.stopPropagation()} - autoFocus - /> -
-
- {customers - .filter( - (customer) => - customer.username.toLowerCase().includes(customerSearchTerm.toLowerCase()) || - customer.msisdn.includes(customerSearchTerm) - ) - .map((customer) => ( -
{ - setFormField({ ...formField, deduct_origin: customer.id }); - setOpenDeductOrigin(false); - }} - > - {customer.username} -
- ))} - {customers.filter( - (customer) => - customer.username.toLowerCase().includes(customerSearchTerm.toLowerCase()) || - customer.msisdn.includes(customerSearchTerm) - ).length === 0 && ( -
No customer found
- )} -
-
- )} -
-
-)} - - + {openDeductOrigin && ( +
+
+ setCustomerSearchTerm(e.target.value)} + autoComplete="off" + onClick={(e) => e.stopPropagation()} + autoFocus + /> +
+
+ {customers + .filter( + (customer) => + customer.username + .toLowerCase() + .includes(customerSearchTerm.toLowerCase()) || + customer.msisdn.includes(customerSearchTerm) + ) + .map((customer) => ( +
{ + setFormField({ ...formField, deduct_origin: customer.id }); + setOpenDeductOrigin(false); + }} + > + {customer.username} +
+ ))} + {customers.filter( + (customer) => + customer.username + .toLowerCase() + .includes(customerSearchTerm.toLowerCase()) || + customer.msisdn.includes(customerSearchTerm) + ).length === 0 && ( +
+ No customer found +
+ )} +
+
+ )} +
+
+ )}
+ {formField.credit_to === 'I' && ( +
+ +
+
setOpenCreditDestination(!openCreditDestination)} + > + + {customers.find( + (customer) => customer.id === formField.credit_destination + )?.username || 'Search customer...'} + +
-{formField.credit_to === 'I' && ( -
- -
-
setOpenCreditDestination(!openCreditDestination)} - > - - {customers.find((customer) => customer.id === formField.credit_destination) - ?.username || 'Search customer...'} - -
- - {openCreditDestination && ( -
-
- setCustomerSearchTerm(e.target.value)} - autoComplete="off" - onClick={(e) => e.stopPropagation()} - autoFocus - /> -
-
- {customers - .filter( - (customer) => - customer.username - .toLowerCase() - .includes(customerSearchTerm.toLowerCase()) || - customer.msisdn.includes(customerSearchTerm) - ) - .map((customer) => ( -
{ - setFormField({ - ...formField, - credit_destination: customer.id - }); - setOpenCreditDestination(false); - }} - > - {customer.username} -
- ))} - {customers.filter( - (customer) => - customer.username - .toLowerCase() - .includes(customerSearchTerm.toLowerCase()) || - customer.msisdn.includes(customerSearchTerm) - ).length === 0 && ( -
No customer found
- )} -
-
- )} -
-
-)} - - + {openCreditDestination && ( +
+
+ setCustomerSearchTerm(e.target.value)} + autoComplete="off" + onClick={(e) => e.stopPropagation()} + autoFocus + /> +
+
+ {customers + .filter( + (customer) => + customer.username + .toLowerCase() + .includes(customerSearchTerm.toLowerCase()) || + customer.msisdn.includes(customerSearchTerm) + ) + .map((customer) => ( +
{ + setFormField({ + ...formField, + credit_destination: customer.id + }); + setOpenCreditDestination(false); + }} + > + {customer.username} +
+ ))} + {customers.filter( + (customer) => + customer.username + .toLowerCase() + .includes(customerSearchTerm.toLowerCase()) || + customer.msisdn.includes(customerSearchTerm) + ).length === 0 && ( +
+ No customer found +
+ )} +
+
+ )} +
+
+ )}
-
-
- + {formField.status_include === 'Y' && ( +
+ + +
+ )}
@@ -362,7 +363,7 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React ], [handleEditDialog, handleDeleteDialog] ); - +console.log(selectedTransferType) const doGetTransferTypeListData = async ( page: number, limit: number, @@ -400,6 +401,7 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React }); } + const response = await GetData(`${API_URL}/transactiontype/list`, { limit: limit, page: page + 1, @@ -408,7 +410,7 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React order_direction: orderDirection, filter: JSON.stringify(filterObject) }); - // console.log(response); + console.log(response); return { data: response?.data.list, totalCount: response?.data.total_count }; };