diff --git a/src/pages/transfer/transferfee/blocks/EditDialog.tsx b/src/pages/transfer/transferfee/blocks/EditDialog.tsx
index c42823f..b8077b5 100644
--- a/src/pages/transfer/transferfee/blocks/EditDialog.tsx
+++ b/src/pages/transfer/transferfee/blocks/EditDialog.tsx
@@ -343,13 +343,19 @@ const EditFeeDialog = () => {
hasFetchedRef.current = false;
}
}, [selectedTransferFee, showEditFeeDialog, fetchTransactionFee]);
-
const handleCloseDialog = () => {
setFormField(initialState);
setAlert({ show: false, message: '' });
+ setCustomerSearchTerm('');
+ setOpen(false);
handleEditFeeDialog(false, null);
};
-
+ useEffect(() => {
+ if (!showEditFeeDialog) {
+ setCustomerSearchTerm('');
+ setOpen(false);
+ }
+ }, [showEditFeeDialog]);
const renderSelectWithLoading = (
value: string,
onChangeHandler: (value: string) => void,
@@ -668,36 +674,51 @@ const EditFeeDialog = () => {
-{formField.credit_to === 'I' && (
+ {formField.credit_to === 'I' && (
Credit Destination *
-
-
-
- {customers.find(
- (customer) => customer.id === formField.credit_destination
- )?.username || 'Select Customer'}
-
-
-
-
-
-
- No Customer found.
-
- {customers.map((customer) => (
- {
+
+
setOpen(!open)}
+ >
+
+ {customers.find(customer => customer.id === formField.credit_destination)?.username || 'Search customer...'}
+
+
+
+
+
+
+ {open && (
+
+
+ setCustomerSearchTerm(e.target.value)}
+ autoComplete="off"
+ // Prevent clicks from closing the dropdown
+ onClick={(e) => e.stopPropagation()}
+ // Auto focus the input when opened
+ autoFocus
+ />
+
+
+ {customers
+ .filter(customer =>
+ customer.username.toLowerCase().includes(customerSearchTerm.toLowerCase()) ||
+ customer.msisdn.includes(customerSearchTerm)
+ )
+ .map(customer => (
+
{
setFormField({
...formField,
credit_destination: customer.id
@@ -706,17 +727,23 @@ const EditFeeDialog = () => {
}}
>
{customer.username}
-
+
))}
-
-
-
-
-
+ {customers.filter(customer =>
+ customer.username.toLowerCase().includes(customerSearchTerm.toLowerCase()) ||
+ customer.msisdn.includes(customerSearchTerm)
+ ).length === 0 && (
+
No customer found
+ )}
+
+
+ )}
+
)}
+