@@ -299,7 +298,34 @@ const DetailApprovalTransaction = () => {
kind = 'RETURN';
} else if (transactionDetails?.kind === 'E') {
kind = 'REWARD';
+ } else if (transactionDetails?.kind === 'L') {
+ kind = 'PURCHASE LOJA';
+ } else if (transactionDetails?.kind === 'B') {
+ kind = 'TOP UP P24';
+ } else if (transactionDetails?.kind === 'A') {
+ kind = 'TRANSFER AGENT';
+ } else if (transactionDetails?.kind === 'M') {
+ kind = 'WITHDRAWAL AGENT';
+ } else if (transactionDetails?.kind === 'O') {
+ kind = 'TOPUP AGENT';
+ } else if (transactionDetails?.kind === 'S') {
+ kind = 'TOPUP P24';
+ } else if (transactionDetails?.kind === 'I') {
+ kind = 'WITHDRAW MERCHANT';
+ } else if (transactionDetails?.kind === 'D') {
+ kind = 'DONATION';
+ } else if (transactionDetails?.kind === 'F') {
+ kind = 'FEE';
+ } else if (transactionDetails?.kind === 'V') {
+ kind = 'REVERSAL';
+ } else if (transactionDetails?.kind === 'C') {
+ kind = 'CASHBACK CASH';
+ } else if (transactionDetails?.kind === 'H') {
+ kind = 'CASHBACK POINT';
+ } else if (transactionDetails?.kind === 'J') {
+ kind = 'WITHDRAW ADMIN';
}
+
return kind;
})()}
@@ -419,7 +445,7 @@ const DetailApprovalTransaction = () => {
Info
-
+
Transaction Date
{transactionDetails?.transaction_date
@@ -436,9 +462,7 @@ const DetailApprovalTransaction = () => {
Full Name
-
- {transactionDetails?.origin_customer?.fullname ?? transactionDetails?.origin_customer?.origin_name}
-
+
{transactionDetails?.origin_name ?? ""}
Amount
@@ -502,7 +526,34 @@ const DetailApprovalTransaction = () => {
kind = 'RETURN';
} else if (transactionDetails?.kind === 'E') {
kind = 'REWARD';
+ } else if (transactionDetails?.kind === 'L') {
+ kind = 'PURCHASE LOJA';
+ } else if (transactionDetails?.kind === 'B') {
+ kind = 'TOP UP P24';
+ } else if (transactionDetails?.kind === 'A') {
+ kind = 'TRANSFER AGENT';
+ } else if (transactionDetails?.kind === 'M') {
+ kind = 'WITHDRAWAL AGENT';
+ } else if (transactionDetails?.kind === 'O') {
+ kind = 'TOPUP AGENT';
+ } else if (transactionDetails?.kind === 'S') {
+ kind = 'TOPUP P24';
+ } else if (transactionDetails?.kind === 'I') {
+ kind = 'WITHDRAW MERCHANT';
+ } else if (transactionDetails?.kind === 'D') {
+ kind = 'DONATION';
+ } else if (transactionDetails?.kind === 'F') {
+ kind = 'FEE';
+ } else if (transactionDetails?.kind === 'V') {
+ kind = 'REVERSAL';
+ } else if (transactionDetails?.kind === 'C') {
+ kind = 'CASHBACK CASH';
+ } else if (transactionDetails?.kind === 'H') {
+ kind = 'CASHBACK POINT';
+ } else if (transactionDetails?.kind === 'J') {
+ kind = 'WITHDRAW ADMIN';
}
+
return kind;
})()}
@@ -526,6 +577,30 @@ const DetailApprovalTransaction = () => {
{transactionDetails?.transfer.destination_iban}
+
+ Transfer Type
+
+ Transfer Type
+
+
+
+
+
Transfer Type
+
+ {
+ (() => {
+ if (transactionDetails?.transfer.type === "S") {
+ return "SEND";
+ } else if (transactionDetails?.transfer.type === "R") {
+ return "RECEIVE";
+ } else {
+ return "UNKNOWN";
+ }
+ })()
+ }
+
+
+
)}
@@ -535,14 +610,12 @@ const DetailApprovalTransaction = () => {
Full Name
-
- {transactionDetails?.origin_customer?.fullname ?? transactionDetails?.origin_customer?.origin_name}
-
+
{transactionDetails?.origin_name ?? ""}
-
+ {/*
Phone Number
{transactionDetails?.origin_customer?.msisdn ?? transactionDetails?.origin_msisdn}
-
+
*/}
Email
{transactionDetails?.origin_customer?.email ?? "-"}
@@ -801,8 +874,9 @@ const DetailApprovalTransaction = () => {
- {transactionDetails?.log_approve && transactionDetails?.log_approve.length > 0 ? (
- transactionDetails.log_approve.map((log: { created_at: string; status: string; updated_at: string }, index: number) => (
+ {[...transactionDetails.log_approve]
+ .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
+ .map((log: { created_at: string; status: string; updated_at: string }, index: number) => (
|
{(() => {
@@ -815,13 +889,15 @@ const DetailApprovalTransaction = () => {
status = 'REJECT';
} else if (log.status === 'T') {
status = 'NO NEED';
+ } else {
+ status = log.status || 'UNKNOWN';
}
return status;
})()}
|
{new Date(log.created_at).toLocaleString('sv-SE', {
- timeZone: 'Asia/Jakarta', // kalau kamu mau waktu lokal (optional)
+ timeZone: 'Asia/Jakarta',
year: 'numeric',
month: '2-digit',
day: '2-digit',
@@ -829,18 +905,11 @@ const DetailApprovalTransaction = () => {
minute: '2-digit',
second: '2-digit',
hour12: false,
- }).replace(' ', ' ')}
+ })}
|
{/* {log.updated_at} | */}
- ))
- ) : (
-
- |
- No logs available
- |
-
- )}
+ ))}
@@ -848,6 +917,7 @@ const DetailApprovalTransaction = () => {
)}
+
{activeTab === 'p24' && (
P24 Logs
diff --git a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx
index f9133d4..bc7306a 100644
--- a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx
+++ b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx
@@ -367,7 +367,7 @@ const DetailTransaction = () => {
Full Name
-
{transactionDetails?.origin_customer?.origin_name ?? ""}
+
{transactionDetails?.origin_name ?? ""}
Amount
@@ -456,22 +456,24 @@ const DetailTransaction = () => {
kind = 'TRANSFER AGENT';
} else if (transactionDetails?.kind === 'M') {
kind = 'WITHDRAWAL AGENT';
- }else if( transactionDetails?.kind === 'O') {
+ } else if (transactionDetails?.kind === 'O') {
kind = 'TOPUP AGENT';
- }else if (transactionDetails?.kind === 'S') {
+ } else if (transactionDetails?.kind === 'S') {
kind = 'TOPUP P24';
- }else if (transactionDetails?.kind === 'I') {
+ } else if (transactionDetails?.kind === 'I') {
kind = 'WITHDRAW MERCHANT';
- }else if (transactionDetails?.kind === 'D') {
+ } else if (transactionDetails?.kind === 'D') {
kind = 'DONATION';
- }else if (transactionDetails?.kind === 'F') {
+ } else if (transactionDetails?.kind === 'F') {
kind = 'FEE';
- }else if (transactionDetails?.kind === 'V') {
+ } else if (transactionDetails?.kind === 'V') {
kind = 'REVERSAL';
- }else if( transactionDetails?.kind === 'C') {
+ } else if (transactionDetails?.kind === 'C') {
kind = 'CASHBACK CASH';
- }else if( transactionDetails?.kind === 'H') {
+ } else if (transactionDetails?.kind === 'H') {
kind = 'CASHBACK POINT';
+ } else if (transactionDetails?.kind === 'J') {
+ kind = 'WITHDRAW ADMIN';
}
return kind;
@@ -499,7 +501,7 @@ const DetailTransaction = () => {
Info
-
+
Transaction Date
{transactionDetails?.transaction_date
@@ -516,7 +518,7 @@ const DetailTransaction = () => {
Full Name
-
{transactionDetails?.origin_customer?.origin_name ?? ""}
+
{transactionDetails?.origin_name ?? ""}
Amount
@@ -589,12 +591,39 @@ const DetailTransaction = () => {
kind = 'TOP UP';
} else if (transactionDetails?.kind === 'R') {
kind = 'RETURN';
- } else if (transactionDetails?.kind === 'E') {
} else if (transactionDetails?.kind === 'E') {
kind = 'REWARD';
+ } else if (transactionDetails?.kind === 'L') {
+ kind = 'PURCHASE LOJA';
+ } else if (transactionDetails?.kind === 'B') {
+ kind = 'TOP UP P24';
+ } else if (transactionDetails?.kind === 'A') {
+ kind = 'TRANSFER AGENT';
+ } else if (transactionDetails?.kind === 'M') {
+ kind = 'WITHDRAWAL AGENT';
+ } else if (transactionDetails?.kind === 'O') {
+ kind = 'TOPUP AGENT';
+ } else if (transactionDetails?.kind === 'S') {
+ kind = 'TOPUP P24';
+ } else if (transactionDetails?.kind === 'I') {
+ kind = 'WITHDRAW MERCHANT';
+ } else if (transactionDetails?.kind === 'D') {
+ kind = 'DONATION';
+ } else if (transactionDetails?.kind === 'F') {
+ kind = 'FEE';
+ } else if (transactionDetails?.kind === 'V') {
+ kind = 'REVERSAL';
+ } else if (transactionDetails?.kind === 'C') {
+ kind = 'CASHBACK CASH';
+ } else if (transactionDetails?.kind === 'H') {
+ kind = 'CASHBACK POINT';
+ } else if (transactionDetails?.kind === 'J') {
+ kind = 'WITHDRAW ADMIN';
}
+
return kind;
})()}
+
@@ -614,6 +643,30 @@ const DetailTransaction = () => {
{transactionDetails?.transfer.destination_iban}
+
+ Transfer Type
+
+ Transfer Type
+
+
+
+
+
Transfer Type
+
+ {
+ (() => {
+ if (transactionDetails?.transfer.type === "S") {
+ return "SEND";
+ } else if (transactionDetails?.transfer.type === "R") {
+ return "RECEIVE";
+ } else {
+ return "UNKNOWN";
+ }
+ })()
+ }
+
+
+
)}
@@ -623,13 +676,13 @@ const DetailTransaction = () => {
Full Name
-
{transactionDetails?.origin_customer?.origin_name}
+
{transactionDetails?.origin_name}
-
+ {/*
Phone Number
{transactionDetails?.origin_msisdn}
{transactionDetails?.origin_customer?.origin_name ?? ""}
-
+
*/}
Phone Number
{transactionDetails?.origin_customer?.msisdn ?? transactionDetails?.origin_msisdn}
@@ -893,8 +946,9 @@ const DetailTransaction = () => {
- {transactionDetails?.log_approve && transactionDetails?.log_approve.length > 0 ? (
- transactionDetails.log_approve.map((log: { created_at: string; status: string; updated_at: string }, index: number) => (
+ {[...transactionDetails.log_approve]
+ .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
+ .map((log: { created_at: string; status: string; updated_at: string }, index: number) => (
|
{(() => {
@@ -907,13 +961,15 @@ const DetailTransaction = () => {
status = 'REJECT';
} else if (log.status === 'T') {
status = 'NO NEED';
+ } else {
+ status = log.status || 'UNKNOWN';
}
return status;
})()}
|
{new Date(log.created_at).toLocaleString('sv-SE', {
- timeZone: 'Asia/Jakarta', // kalau kamu mau waktu lokal (optional)
+ timeZone: 'Asia/Jakarta',
year: 'numeric',
month: '2-digit',
day: '2-digit',
@@ -921,18 +977,11 @@ const DetailTransaction = () => {
minute: '2-digit',
second: '2-digit',
hour12: false,
- }).replace(' ', ' ')}
+ })}
|
{/* {log.updated_at} | */}
- ))
- ) : (
-
- |
- No logs available
- |
-
- )}
+ ))}
diff --git a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx
index 6069da8..8a3b15b 100644
--- a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx
+++ b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx
@@ -90,6 +90,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
case 'V': return 'REVERSAL';
case 'C': return 'CASHBACK CASH';
case 'H': return 'CASHBACK POINT';
+ case 'J': return 'WITHDRAW ADMIN';
default: return '_';
}
},
diff --git a/src/pages/transaction/withdrawl-emoney/WithdrawalEmoney.tsx b/src/pages/transaction/withdrawl-emoney/WithdrawalEmoney.tsx
new file mode 100644
index 0000000..bdc05a4
--- /dev/null
+++ b/src/pages/transaction/withdrawl-emoney/WithdrawalEmoney.tsx
@@ -0,0 +1,36 @@
+import { Helmet } from 'react-helmet';
+import { Container } from '@/components';
+import { Breadcrumbs, Link } from '@mui/material';
+import WithdrawInput from './blocks/WithdrawInput';
+import { TransactionWithdrawalEmoneyProvider } from './hooks/TransactionWithdrawalEmoneyContext';
+
+const WithdrawalEmoney = () => {
+ return (
+ <>
+
+ TPAY | Withdrawal Emoney
+
+
+
+
+ TRANSACTION WITHDRAWAL EMONEY
+
+
+
+ Dashboard
+
+
+ Transaction
+
+
+ Withdraw Saldo
+
+
+
+
+
+ >
+ );
+};
+
+export default WithdrawalEmoney;
diff --git a/src/pages/transaction/withdrawl-emoney/blocks/WithdrawInput.tsx b/src/pages/transaction/withdrawl-emoney/blocks/WithdrawInput.tsx
new file mode 100644
index 0000000..b68aef1
--- /dev/null
+++ b/src/pages/transaction/withdrawl-emoney/blocks/WithdrawInput.tsx
@@ -0,0 +1,300 @@
+import { getAuth } from '@/auth';
+import { Alert, Container } from '@/components';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { apiConfig } from '@/config/api.config';
+import { useCallApi } from '@/hooks';
+import { RefreshCw } from 'lucide-react';
+import { useEffect, useRef, useState } from 'react';
+import { toast } from 'sonner';
+
+const WithdrawInput = () => {
+ const initialForm: {
+ msisdn: string;
+ amount: string;
+ pin: string;
+ purpose: string;
+ } = {
+ msisdn: '',
+ amount: '',
+ pin: '',
+ purpose: ''
+ };
+
+ const [form, setForm] = useState(initialForm);
+ const [isLoading, setIsLoading] = useState(false);
+ const [customerMsisdn, setCustomerMsisdn] = useState<{ value: string; label: string }[]>([]);
+ const [searchTerm, setSearchTerm] = useState('');
+ const [dropdownOpen, setDropdownOpen] = useState(false);
+ const { GetData, PostData } = useCallApi();
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [showConfirmation, setShowConfirmation] = useState(false);
+ const parsedUser = getAuth()?.user;
+ const API_URL = apiConfig.transaction;
+ const API_URL_WALLET = apiConfig.service_wallet;
+ const API_URL_CUSTOMER = apiConfig.service_customer;
+ const dropdownRef = useRef
(null);
+
+ const [alert, setAlert] = useState({
+ show: false,
+ message: ''
+ });
+
+ const ResetForm = () => {
+ setForm(initialForm);
+ setAlert({ show: false, message: '' });
+ setSearchTerm('');
+ };
+
+ const fetchCustomerMsisdn = async (sorting: any, filterValue: string) => {
+ const filter: any =
+ filterValue.trim().length === 0
+ ? {}
+ : {
+ or: [
+ { msisdn: { like: `%${filterValue}%` } },
+ { fullname: { like: `%${filterValue}%` } }
+ ]
+ };
+
+ const query: any = {
+ limit: 100,
+ page: 1,
+ with_deleted: false,
+ order_field: sorting[0].id,
+ order_direction: sorting[0].desc ? 'DESC' : 'ASC'
+ };
+
+ if (filter && Object.keys(filter).length > 0) {
+ query.filter = JSON.stringify(filter);
+ // query.page = page + 1;
+ }
+
+ try {
+ const response = await GetData(`${API_URL_CUSTOMER}/customer/list`, query);
+ setCustomerMsisdn(
+ response?.data.list.map((item: any) => ({
+ value: item.msisdn,
+ label: `${item.msisdn} - ${item.fullname}`
+ }))
+ );
+ } catch (error) {
+ toast.error('Failed to fetch customer msisdn');
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ const doPostData = async (form: typeof initialForm) => {
+ setIsSubmitting(true);
+ // console.log(getAuth()?.user.customer.id);
+
+ try {
+ let response = await PostData(`${API_URL}/transaction/transfer`, {
+ msisdn_destination: form.msisdn,
+ amount: form.amount,
+ pin: form.pin,
+ purpose: form.purpose,
+ id_transaction_type: '380f270b-1f44-406f-a196-d6f784d68eb4',
+ id_origin_customer: getAuth()?.user.customer.id,
+ type: 'S'
+ });
+ if (response?.status == true) {
+ toast.success('Success Request Topup');
+ } else {
+ toast.error(`${response?.message?.message}`);
+ }
+ } catch (error: any) {
+ const errorMessage =
+ error?.response?.data?.message || error?.message || 'Something went wrong';
+ toast.error(errorMessage);
+ setAlert({ show: true, message: errorMessage });
+ } finally {
+ setIsSubmitting(false);
+ setShowConfirmation(false);
+ ResetForm();
+ }
+ };
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+
+ if (form.amount == '' || form.msisdn == '' || form.pin == '') {
+ setAlert({
+ show: true,
+ message: 'Please fill in all required fields.'
+ });
+ return;
+ }
+ setAlert({ show: false, message: '' });
+ setShowConfirmation(true);
+ };
+
+ const handleCancelSubmit = () => {
+ setShowConfirmation(false);
+ };
+
+ const handleMsisdnSearch = (e: React.ChangeEvent) => {
+ setIsLoading(true);
+ setSearchTerm(e.target.value);
+ setDropdownOpen(true);
+ const timer = setTimeout(() => {
+ fetchCustomerMsisdn([{ id: 'msisdn', desc: false }], e.target.value);
+ }, 500);
+ return () => clearTimeout(timer);
+ };
+
+ const handleMsisdnSelect = (msisdn: string) => {
+ setForm({ ...form, msisdn });
+ setDropdownOpen(false);
+ setSearchTerm(msisdn);
+ };
+
+ useEffect(() => {
+ fetchCustomerMsisdn([{ id: 'msisdn', desc: false }], '');
+
+ const handleClickOutside = (event: any) => {
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
+ setDropdownOpen(false);
+ }
+ };
+
+ document.addEventListener('mousedown', handleClickOutside);
+ return () => {
+ document.removeEventListener('mousedown', handleClickOutside);
+ };
+ }, []);
+
+ const filteredMsisdn = customerMsisdn
+ .filter((item) => item.label.toLowerCase().includes(searchTerm.toLowerCase()))
+ .slice(0, 10);
+
+ return (
+ <>
+
+
+
+ {alert.show && (
+
+ {alert.message}
+
+ )}
+ {/* form */}
+
+
+
+
+
+ {showConfirmation && (
+
+
+
Confirm Transaction
+
+ Are you sure you want to withdraw saldo of{' '}
+
+ {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(
+ Number(form.amount)
+ )}{' '}
+
+ ?
+
+
+
+
+
+
+
+ )}
+ >
+ );
+};
+
+export default WithdrawInput;
diff --git a/src/pages/transaction/withdrawl-emoney/hooks/TransactionWithdrawalEmoneyContext.tsx b/src/pages/transaction/withdrawl-emoney/hooks/TransactionWithdrawalEmoneyContext.tsx
new file mode 100644
index 0000000..f978f52
--- /dev/null
+++ b/src/pages/transaction/withdrawl-emoney/hooks/TransactionWithdrawalEmoneyContext.tsx
@@ -0,0 +1,58 @@
+import { apiConfig } from '@/config/api.config';
+import { createContext } from 'react';
+
+interface TransactionWithdrawalProps {
+ id: string;
+ customers_id: string;
+ group_id: string;
+ username: string;
+ fullname: string;
+ email: string;
+ status: string;
+ created_at: Date;
+}
+
+interface ContextProps {}
+
+const initialProps: ContextProps = {};
+
+const TransactionWithdrawalEmoneyContext = createContext(initialProps);
+const API_URL = apiConfig.service_customer;
+
+type StatusCode = 'W' | 'Y' | 'N' | 'T';
+
+interface StatusInfo {
+ label: string;
+ bg: string;
+ text: string;
+}
+
+const statusMap: Record = {
+ W: { label: 'Waiting Approval', bg: 'bg-yellow-100', text: 'text-yellow-600' },
+ T: { label: 'No Need', bg: 'bg-blue-100', text: 'text-blue-600' },
+ N: { label: 'Reject', bg: 'bg-red-100', text: 'text-red-600' },
+ Y: { label: 'Approve', bg: 'bg-green-100', text: 'text-green-600' }
+};
+
+export const renderStatusBadge = (statusRaw: string | null | undefined) => {
+ const status = statusRaw as StatusCode;
+ const { label, bg, text } = statusMap[status] ?? {
+ label: 'Unknown',
+ bg: 'bg-gray-100',
+ text: 'text-gray-600'
+ };
+
+ return (
+ {label}
+ );
+};
+
+const TransactionWithdrawalEmoneyProvider = ({ children }: { children: React.ReactNode }) => {
+ return (
+
+ {children}
+
+ );
+};
+
+export { TransactionWithdrawalEmoneyProvider, TransactionWithdrawalEmoneyContext };
diff --git a/src/pages/transaction/withdrawl-emoney/hooks/useTransactionWithdrawalEmoney.tsx b/src/pages/transaction/withdrawl-emoney/hooks/useTransactionWithdrawalEmoney.tsx
new file mode 100644
index 0000000..a86d61e
--- /dev/null
+++ b/src/pages/transaction/withdrawl-emoney/hooks/useTransactionWithdrawalEmoney.tsx
@@ -0,0 +1,12 @@
+import { useContext } from 'react';
+import { TransactionWithdrawalEmoneyContext } from './TransactionWithdrawalEmoneyContext';
+
+const useTransactionWithdrawalEmoneyContext = () => {
+ const context = useContext(TransactionWithdrawalEmoneyContext);
+
+ if (!context) throw new Error('useTransactionWithdrawalEmoney must be used within AuthProvider');
+
+ return context;
+};
+
+export { useTransactionWithdrawalEmoneyContext };
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 (
+ {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' && (
+
+
+
+
+ )}