add debounce for searching msisdn on disbursement saldo
This commit is contained in:
@ -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);
|
||||||
fetchCustomerMsisdn([{ id: 'msisdn', desc: false }], e.target.value);
|
const timer = setTimeout(() => {
|
||||||
|
fetchCustomerMsisdn([{ id: 'msisdn', desc: false }], e.target.value);
|
||||||
|
}, 500);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMsisdnSelect = (msisdn: string) => {
|
const handleMsisdnSelect = (msisdn: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user