add debounce for searching msisdn on disbursement saldo

This commit is contained in:
Wikzyy
2025-04-24 14:33:08 +07:00
parent ebd21c089a
commit 77831a2dec

View File

@ -43,12 +43,11 @@ const TransactionDisbursement = () => {
}); });
const fetchCustomerMsisdn = async (sorting: any, filterValue: string) => { const fetchCustomerMsisdn = async (sorting: any, filterValue: string) => {
setIsLoading(true);
const filter: any = const filter: any =
filterValue.trim().length === 0 ? {} : { msisdn: { like: `%${filterValue}%` } }; filterValue.trim().length === 0 ? {} : { msisdn: { like: `%${filterValue}%` } };
const query: any = { const query: any = {
limit: 50, limit: 1,
page: 1, page: 1,
with_deleted: false, with_deleted: false,
order_field: sorting[0].id, order_field: sorting[0].id,
@ -152,9 +151,13 @@ const TransactionDisbursement = () => {
}; };
const handleMsisdnSearch = (e: React.ChangeEvent<HTMLInputElement>) => { const handleMsisdnSearch = (e: React.ChangeEvent<HTMLInputElement>) => {
setIsLoading(true);
setSearchTerm(e.target.value); setSearchTerm(e.target.value);
setDropdownOpen(true); setDropdownOpen(true);
const timer = setTimeout(() => {
fetchCustomerMsisdn([{ id: 'msisdn', desc: false }], e.target.value); fetchCustomerMsisdn([{ id: 'msisdn', desc: false }], e.target.value);
}, 500);
return () => clearTimeout(timer);
}; };
const handleMsisdnSelect = (msisdn: string) => { const handleMsisdnSelect = (msisdn: string) => {