@appcorp/fusion-storybook 0.2.39 → 0.2.40
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.
|
@@ -85,8 +85,8 @@ export const useCampusModule = () => {
|
|
|
85
85
|
const { theme } = useTheme();
|
|
86
86
|
const workspace = getCachedWorkspaceSync();
|
|
87
87
|
const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
|
|
88
|
-
const listFetchNowRef = useRef(null);
|
|
89
88
|
const debouncedQuery = useDebounce(state.searchQuery, 800);
|
|
89
|
+
const listFetchNowRef = useRef(null);
|
|
90
90
|
// ============================================================================
|
|
91
91
|
// 1.4.2 API PARAMETERS
|
|
92
92
|
// ============================================================================
|
|
@@ -191,7 +191,6 @@ export const useCampusModule = () => {
|
|
|
191
191
|
}
|
|
192
192
|
if (data) {
|
|
193
193
|
const isCreated = isCreatedOrUpdated(data);
|
|
194
|
-
// invalidateCampusesCache();
|
|
195
194
|
showToast(isCreated ? t("messagesCreateSuccess") : t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
|
|
196
195
|
resetFormAndCloseDrawer();
|
|
197
196
|
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
@@ -219,7 +218,6 @@ export const useCampusModule = () => {
|
|
|
219
218
|
return;
|
|
220
219
|
}
|
|
221
220
|
if (data) {
|
|
222
|
-
// invalidateCampusesCache();
|
|
223
221
|
showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
|
|
224
222
|
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
225
223
|
}
|
|
@@ -445,42 +443,13 @@ export const useCampusModule = () => {
|
|
|
445
443
|
// ============================================================================
|
|
446
444
|
// 1.4.9 EFFECTS
|
|
447
445
|
// ============================================================================
|
|
448
|
-
// Keep the latest fetch function in a ref so the fetch effect can call it
|
|
449
|
-
// without depending on listFetchNow's unstable identity.
|
|
450
446
|
useEffect(() => {
|
|
451
|
-
listFetchNow
|
|
452
|
-
|
|
447
|
+
listFetchNowRef.current = listFetchNow;
|
|
448
|
+
}, [listFetchNow]);
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
var _a;
|
|
451
|
+
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
453
452
|
}, [listParams]);
|
|
454
|
-
// Initial load via cache; re-fetch directly from API on page/pageLimit/filter/search changes.
|
|
455
|
-
// useEffect(() => {
|
|
456
|
-
// if (!schoolId) return;
|
|
457
|
-
// const currentPage = Number(listParams.currentPage) || 1;
|
|
458
|
-
// const currentPageLimit = Number(listParams.pageLimit) || pageLimit;
|
|
459
|
-
// const isDefaultLoad =
|
|
460
|
-
// currentPage === 1 &&
|
|
461
|
-
// currentPageLimit === pageLimit &&
|
|
462
|
-
// !listParams.searchQuery &&
|
|
463
|
-
// listParams.filterEnabled === undefined;
|
|
464
|
-
// if (isDefaultLoad) {
|
|
465
|
-
// (async () => {
|
|
466
|
-
// try {
|
|
467
|
-
// const { count, items } = await getCachedCampuses({
|
|
468
|
-
// params: listParams,
|
|
469
|
-
// });
|
|
470
|
-
// dispatch({
|
|
471
|
-
// type: CAMPUS_ACTION_TYPES.SET_ITEMS,
|
|
472
|
-
// payload: { items: items || [], count: count || 0 },
|
|
473
|
-
// });
|
|
474
|
-
// } catch {
|
|
475
|
-
// showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
476
|
-
// }
|
|
477
|
-
// })();
|
|
478
|
-
// } else {
|
|
479
|
-
// // Bypass cache for pagination, pageLimit, filter and search changes.
|
|
480
|
-
// // Use ref to avoid the infinite-loop caused by listFetchNow's unstable identity.
|
|
481
|
-
// listFetchNowRef.current?.();
|
|
482
|
-
// }
|
|
483
|
-
// }, [dispatch, listParams, schoolId, showToast, t]);
|
|
484
453
|
// ============================================================================
|
|
485
454
|
// 1.4.10 RETURN
|
|
486
455
|
// ============================================================================
|