finance-shared 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -25189,27 +25189,20 @@ const SearchableAutocomplete = memo(
|
|
|
25189
25189
|
});
|
|
25190
25190
|
}
|
|
25191
25191
|
}, []);
|
|
25192
|
-
const fetchDebouncedOptions =
|
|
25193
|
-
|
|
25194
|
-
|
|
25195
|
-
|
|
25196
|
-
|
|
25197
|
-
|
|
25198
|
-
|
|
25199
|
-
|
|
25200
|
-
|
|
25201
|
-
|
|
25202
|
-
|
|
25203
|
-
}, 1e3),
|
|
25204
|
-
[fetchOptions]
|
|
25205
|
-
);
|
|
25192
|
+
const fetchDebouncedOptions = useDebounce(async (search) => {
|
|
25193
|
+
setLoading2(true);
|
|
25194
|
+
try {
|
|
25195
|
+
const results = await fetchOptions(search, 0);
|
|
25196
|
+
setOptions(results);
|
|
25197
|
+
} catch (err) {
|
|
25198
|
+
console.error("Error fetching options:", err);
|
|
25199
|
+
} finally {
|
|
25200
|
+
setLoading2(false);
|
|
25201
|
+
}
|
|
25202
|
+
}, 1e3);
|
|
25206
25203
|
useEffect(() => {
|
|
25207
25204
|
if (isTyping) {
|
|
25208
|
-
|
|
25209
|
-
fetchDebouncedOptions(searchTerm);
|
|
25210
|
-
} else {
|
|
25211
|
-
fetchDebouncedOptions("");
|
|
25212
|
-
}
|
|
25205
|
+
fetchDebouncedOptions(searchTerm || "");
|
|
25213
25206
|
}
|
|
25214
25207
|
}, [searchTerm, isTyping, fetchDebouncedOptions]);
|
|
25215
25208
|
const loadMoreOptions = useCallback(async () => {
|
|
@@ -25253,10 +25246,12 @@ const SearchableAutocomplete = memo(
|
|
|
25253
25246
|
}
|
|
25254
25247
|
}
|
|
25255
25248
|
}, [onChange, fetchOptions]);
|
|
25256
|
-
const handleInputChange = useCallback((_event, inputValue) => {
|
|
25257
|
-
|
|
25258
|
-
|
|
25259
|
-
|
|
25249
|
+
const handleInputChange = useCallback((_event, inputValue, reason) => {
|
|
25250
|
+
if (reason === "input") {
|
|
25251
|
+
setSearchTerm(inputValue);
|
|
25252
|
+
setIsTyping(true);
|
|
25253
|
+
setPageIndex(0);
|
|
25254
|
+
}
|
|
25260
25255
|
}, []);
|
|
25261
25256
|
const listboxProps = useMemo(() => ({
|
|
25262
25257
|
onScroll: handleScroll
|
|
@@ -25307,30 +25302,26 @@ const MemberAutoComplete = ({
|
|
|
25307
25302
|
const dispatch = useDispatch();
|
|
25308
25303
|
const loading = useSelector(getIsUserListLoading);
|
|
25309
25304
|
const pagination = useSelector(getUserListPaginationData);
|
|
25310
|
-
const
|
|
25305
|
+
const hasMoreDataRef = useRef(true);
|
|
25311
25306
|
useEffect(() => {
|
|
25312
25307
|
return () => {
|
|
25313
25308
|
dispatch(setUserSearchKeyword(""));
|
|
25314
25309
|
dispatch(setUserListPagination({ pageIndex: 0 }));
|
|
25315
|
-
|
|
25310
|
+
hasMoreDataRef.current = true;
|
|
25316
25311
|
};
|
|
25317
25312
|
}, [dispatch]);
|
|
25318
|
-
const handleOptionChange = (value2) => {
|
|
25313
|
+
const handleOptionChange = useCallback((value2) => {
|
|
25319
25314
|
onChange(value2);
|
|
25320
25315
|
dispatch(setIsUserListLoading(false));
|
|
25321
|
-
};
|
|
25322
|
-
const fetchUserOptions = async (searchTerm, pageIndex) => {
|
|
25323
|
-
if (pageIndex > 0 && !
|
|
25324
|
-
return [];
|
|
25325
|
-
}
|
|
25316
|
+
}, [onChange, dispatch]);
|
|
25317
|
+
const fetchUserOptions = useCallback(async (searchTerm, pageIndex) => {
|
|
25318
|
+
if (pageIndex > 0 && !hasMoreDataRef.current) return [];
|
|
25326
25319
|
dispatch(setUserSearchKeyword(searchTerm));
|
|
25327
25320
|
dispatch(setUserListPagination({ pageIndex }));
|
|
25328
25321
|
const newOptions = await dispatch(getUserList(roleIds, tenantId, pageIndex, searchTerm));
|
|
25329
|
-
if (!newOptions ||
|
|
25330
|
-
|
|
25331
|
-
if (pageIndex > 0)
|
|
25332
|
-
return [];
|
|
25333
|
-
}
|
|
25322
|
+
if (!newOptions || newOptions.length === 0) {
|
|
25323
|
+
hasMoreDataRef.current = false;
|
|
25324
|
+
if (pageIndex > 0) return [];
|
|
25334
25325
|
}
|
|
25335
25326
|
return (newOptions == null ? void 0 : newOptions.map((item) => {
|
|
25336
25327
|
var _a, _b;
|
|
@@ -25339,7 +25330,7 @@ const MemberAutoComplete = ({
|
|
|
25339
25330
|
label: ((_a = item == null ? void 0 : item.additionalDetails) == null ? void 0 : _a.nationalId) ? `${item.userName} (${(_b = item == null ? void 0 : item.additionalDetails) == null ? void 0 : _b.nationalId})` : item.userName
|
|
25340
25331
|
};
|
|
25341
25332
|
})) || [];
|
|
25342
|
-
};
|
|
25333
|
+
}, [dispatch, roleIds, tenantId]);
|
|
25343
25334
|
return /* @__PURE__ */ jsx(
|
|
25344
25335
|
SearchableAutocomplete,
|
|
25345
25336
|
{
|