@appcorp/fusion-storybook 0.1.78 → 0.1.80

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.
Files changed (39) hide show
  1. package/base-modules/admission/context.d.ts +1 -1
  2. package/base-modules/admission/context.js +38 -26
  3. package/base-modules/attendance/context.d.ts +1 -1
  4. package/base-modules/attendance/context.js +37 -18
  5. package/base-modules/campus/context.d.ts +1 -1
  6. package/base-modules/campus/context.js +40 -21
  7. package/base-modules/class/context.js +15 -8
  8. package/base-modules/course/context.d.ts +1 -1
  9. package/base-modules/course/context.js +37 -18
  10. package/base-modules/discount-code/context.d.ts +1 -1
  11. package/base-modules/discount-code/context.js +29 -20
  12. package/base-modules/enrollment/context.d.ts +1 -1
  13. package/base-modules/enrollment/context.js +37 -18
  14. package/base-modules/expense/context.d.ts +1 -1
  15. package/base-modules/expense/context.js +31 -20
  16. package/base-modules/family/context.d.ts +1 -1
  17. package/base-modules/family/context.js +36 -21
  18. package/base-modules/family-member/context.d.ts +1 -1
  19. package/base-modules/family-member/context.js +37 -21
  20. package/base-modules/fee-structure/context.d.ts +1 -1
  21. package/base-modules/fee-structure/context.js +29 -20
  22. package/base-modules/rbac/context.d.ts +1 -1
  23. package/base-modules/rbac/context.js +26 -22
  24. package/base-modules/section/context.d.ts +1 -1
  25. package/base-modules/section/context.js +26 -19
  26. package/base-modules/student-fee/context.d.ts +1 -1
  27. package/base-modules/student-fee/context.js +30 -20
  28. package/base-modules/student-profile/context.d.ts +1 -1
  29. package/base-modules/student-profile/context.js +34 -22
  30. package/base-modules/subject/context.d.ts +2 -2
  31. package/base-modules/subject/context.js +54 -30
  32. package/base-modules/teacher/context.d.ts +1 -1
  33. package/base-modules/teacher/context.js +29 -22
  34. package/base-modules/user/context.d.ts +1 -1
  35. package/base-modules/user/context.js +27 -20
  36. package/base-modules/workspace-user/context.d.ts +1 -1
  37. package/base-modules/workspace-user/context.js +32 -19
  38. package/package.json +1 -1
  39. package/tsconfig.build.tsbuildinfo +1 -1
@@ -242,12 +242,15 @@ export const useEnrollmentModule = () => {
242
242
  payload: { key: field, value },
243
243
  });
244
244
  }, [dispatch]);
245
- const handlePageChange = useCallback((page) => {
245
+ const handlePageChange = useCallback((pageOrEvent) => {
246
+ const page = typeof pageOrEvent === "number" && !isNaN(pageOrEvent)
247
+ ? pageOrEvent
248
+ : state.currentPage + 1;
246
249
  dispatch({
247
250
  type: ENROLLMENT_ACTION_TYPES.SET_CURRENT_PAGE,
248
251
  payload: { currentPage: page },
249
252
  });
250
- }, [dispatch]);
253
+ }, [dispatch, state.currentPage]);
251
254
  const handlePageLimitChange = useCallback((k, value) => {
252
255
  const val = Object.assign({}, value);
253
256
  dispatch({
@@ -392,32 +395,48 @@ export const useEnrollmentModule = () => {
392
395
  type: ENROLLMENT_ACTION_TYPES.SET_CURRENT_PAGE,
393
396
  payload: { currentPage: 1 },
394
397
  });
395
- listFetchNow();
396
398
  closeDrawer();
397
- }, [dispatch, listFetchNow, closeDrawer]);
399
+ }, [dispatch, closeDrawer]);
398
400
  // ==========================================================================
399
401
  // 1.4.9 EFFECTS
400
402
  // ==========================================================================
403
+ // Keep the latest fetch function in a ref so the fetch effect can call it
404
+ // without depending on listFetchNow's unstable identity.
401
405
  useEffect(() => {
402
406
  listFetchNowRef.current = listFetchNow;
403
407
  });
408
+ // Initial load via cache; re-fetch directly from API on page/pageLimit/filter/search changes.
404
409
  useEffect(() => {
410
+ var _a;
405
411
  if (!schoolId)
406
412
  return;
407
- (async () => {
408
- try {
409
- const { count, items } = await getCachedEnrollments({
410
- params: listParams,
411
- });
412
- dispatch({
413
- type: ENROLLMENT_ACTION_TYPES.SET_ITEMS,
414
- payload: { items: items || [], count: count || 0 },
415
- });
416
- }
417
- catch (_a) {
418
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
419
- }
420
- })();
413
+ const currentPage = Number(listParams.currentPage) || 1;
414
+ const currentPageLimit = Number(listParams.pageLimit) || pageLimit;
415
+ const isDefaultLoad = currentPage === 1 &&
416
+ currentPageLimit === pageLimit &&
417
+ !listParams.searchQuery &&
418
+ listParams.filterEnabled === undefined;
419
+ if (isDefaultLoad) {
420
+ (async () => {
421
+ try {
422
+ const { count, items } = await getCachedEnrollments({
423
+ params: listParams,
424
+ });
425
+ dispatch({
426
+ type: ENROLLMENT_ACTION_TYPES.SET_ITEMS,
427
+ payload: { items: items || [], count: count || 0 },
428
+ });
429
+ }
430
+ catch (_a) {
431
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
432
+ }
433
+ })();
434
+ }
435
+ else {
436
+ // Bypass cache for pagination, pageLimit, filter and search changes.
437
+ // Use ref to avoid the infinite-loop caused by listFetchNow's unstable identity.
438
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
439
+ }
421
440
  }, [listParams, dispatch, showToast, schoolId, t]);
422
441
  // ==========================================================================
423
442
  // 1.4.10 RETURN
@@ -199,7 +199,7 @@ export declare const useExpenseModule: () => {
199
199
  handleEdit: (row?: TableRow) => void;
200
200
  handleFilters: () => void;
201
201
  handleMoreActions: () => void;
202
- handlePageChange: (page: number) => void;
202
+ handlePageChange: (page: number | unknown) => void;
203
203
  handlePageLimitChange: (k: string, value: object) => void;
204
204
  handleSearch: (query: string) => void;
205
205
  handleSubmit: () => void;
@@ -155,6 +155,12 @@ export const useExpenseModule = () => {
155
155
  }), [state, schoolId]);
156
156
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
157
157
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
158
+ const isDefaultListState = state.currentPage === 1 &&
159
+ state.pageLimit === pageLimit &&
160
+ !debouncedQuery &&
161
+ state.filterEnabled === undefined &&
162
+ !state.filterCategory &&
163
+ !state.filterStatus;
158
164
  // ============================================================================
159
165
  // 1.4.3 UTILITIES
160
166
  // ============================================================================
@@ -320,11 +326,12 @@ export const useExpenseModule = () => {
320
326
  });
321
327
  }, [dispatch]);
322
328
  const handlePageChange = useCallback((page) => {
329
+ const nextPage = typeof page === "number" ? page : state.currentPage + 1;
323
330
  dispatch({
324
331
  type: EXPENSE_ACTION_TYPES.SET_CURRENT_PAGE,
325
- payload: { currentPage: page },
332
+ payload: { currentPage: nextPage },
326
333
  });
327
- }, [dispatch]);
334
+ }, [dispatch, state.currentPage]);
328
335
  const handlePageLimitChange = useCallback((k, value) => {
329
336
  const val = Object.assign({}, value);
330
337
  dispatch({
@@ -353,9 +360,8 @@ export const useExpenseModule = () => {
353
360
  type: EXPENSE_ACTION_TYPES.SET_CURRENT_PAGE,
354
361
  payload: { currentPage: 1 },
355
362
  });
356
- listFetchNow();
357
363
  closeDrawer();
358
- }, [dispatch, closeDrawer, listFetchNow]);
364
+ }, [dispatch, closeDrawer]);
359
365
  const clearFilters = useCallback(() => {
360
366
  dispatch({
361
367
  type: EXPENSE_ACTION_TYPES.SET_CURRENT_PAGE,
@@ -448,27 +454,32 @@ export const useExpenseModule = () => {
448
454
  // 1.4.9 EFFECTS
449
455
  // ============================================================================
450
456
  useEffect(() => {
457
+ var _a;
451
458
  if (!schoolId)
452
459
  return;
453
- (async () => {
454
- try {
455
- const { count, items } = await getCachedExpenses({
456
- params: listParams,
457
- });
458
- dispatch({
459
- type: EXPENSE_ACTION_TYPES.SET_ITEMS,
460
- payload: { items: items || [], count: count || 0 },
461
- });
462
- }
463
- catch (_a) {
464
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
465
- }
466
- })();
467
- }, [listParams, dispatch, t, showToast, schoolId]);
460
+ if (isDefaultListState) {
461
+ (async () => {
462
+ try {
463
+ const { count, items } = await getCachedExpenses({
464
+ params: listParams,
465
+ });
466
+ dispatch({
467
+ type: EXPENSE_ACTION_TYPES.SET_ITEMS,
468
+ payload: { items: items || [], count: count || 0 },
469
+ });
470
+ }
471
+ catch (_a) {
472
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
473
+ }
474
+ })();
475
+ return;
476
+ }
477
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
478
+ }, [dispatch, isDefaultListState, listParams, schoolId, showToast, t]);
468
479
  // Sync ref to always point at latest listFetchNow (avoids stale closure in callbacks)
469
480
  useEffect(() => {
470
481
  listFetchNowRef.current = listFetchNow;
471
- });
482
+ }, [listFetchNow]);
472
483
  // ============================================================================
473
484
  // 1.4.10 RETURN
474
485
  // ============================================================================
@@ -135,7 +135,7 @@ export declare const useFamilyModule: () => {
135
135
  handleEdit: (row?: TableRow) => void;
136
136
  handleFilters: () => void;
137
137
  handleMoreActions: () => void;
138
- handlePageChange: (page: number) => void;
138
+ handlePageChange: (page: number | unknown) => void;
139
139
  handlePageLimitChange: (_k: string, value: object) => void;
140
140
  handleSearch: (query: string) => void;
141
141
  handleSubmit: () => void;
@@ -133,6 +133,10 @@ export const useFamilyModule = () => {
133
133
  ]);
134
134
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
135
135
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
136
+ const isDefaultListState = state.currentPage === 1 &&
137
+ state.pageLimit === pageLimit &&
138
+ !debouncedQuery &&
139
+ state.filterEnabled === undefined;
136
140
  // ==========================================================================
137
141
  // 1.4.3 UTILITIES
138
142
  // ==========================================================================
@@ -307,11 +311,12 @@ export const useFamilyModule = () => {
307
311
  });
308
312
  }, [dispatch]);
309
313
  const handlePageChange = useCallback((page) => {
314
+ const nextPage = typeof page === "number" ? page : state.currentPage + 1;
310
315
  dispatch({
311
316
  type: FAMILY_ACTION_TYPES.SET_CURRENT_PAGE,
312
- payload: { currentPage: page },
317
+ payload: { currentPage: nextPage },
313
318
  });
314
- }, [dispatch]);
319
+ }, [dispatch, state.currentPage]);
315
320
  const handlePageLimitChange = useCallback((_k, value) => {
316
321
  const val = Object.assign({}, value);
317
322
  dispatch({
@@ -340,9 +345,8 @@ export const useFamilyModule = () => {
340
345
  type: FAMILY_ACTION_TYPES.SET_CURRENT_PAGE,
341
346
  payload: { currentPage: 1 },
342
347
  });
343
- listFetchNow();
344
348
  handleCloseDrawer();
345
- }, [dispatch, listFetchNow, handleCloseDrawer]);
349
+ }, [dispatch, handleCloseDrawer]);
346
350
  const clearFilters = useCallback(() => {
347
351
  dispatch({
348
352
  type: FAMILY_ACTION_TYPES.SET_FILTERS,
@@ -428,27 +432,38 @@ export const useFamilyModule = () => {
428
432
  // 1.4.9 EFFECTS
429
433
  // ==========================================================================
430
434
  useEffect(() => {
431
- var _a;
435
+ var _a, _b;
432
436
  if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
433
437
  return;
434
- (async () => {
435
- try {
436
- const { count, items } = await getCachedFamilies({
437
- params: listParams,
438
- });
439
- dispatch({
440
- type: FAMILY_ACTION_TYPES.SET_ITEMS,
441
- payload: { items: items || [], count: count || 0 },
442
- });
443
- }
444
- catch (_a) {
445
- showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
446
- }
447
- })();
448
- }, [listParams, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id, dispatch, showToast, t]);
438
+ if (isDefaultListState) {
439
+ (async () => {
440
+ try {
441
+ const { count, items } = await getCachedFamilies({
442
+ params: listParams,
443
+ });
444
+ dispatch({
445
+ type: FAMILY_ACTION_TYPES.SET_ITEMS,
446
+ payload: { items: items || [], count: count || 0 },
447
+ });
448
+ }
449
+ catch (_a) {
450
+ showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
451
+ }
452
+ })();
453
+ return;
454
+ }
455
+ (_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
456
+ }, [
457
+ isDefaultListState,
458
+ listParams,
459
+ (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
460
+ dispatch,
461
+ showToast,
462
+ t,
463
+ ]);
449
464
  useEffect(() => {
450
465
  listFetchNowRef.current = listFetchNow;
451
- });
466
+ }, [listFetchNow]);
452
467
  // ==========================================================================
453
468
  // 1.4.10 RETURN
454
469
  // ==========================================================================
@@ -169,7 +169,7 @@ export declare const useFamilyMemberModule: () => {
169
169
  handleEdit: (row?: TableRow) => void;
170
170
  handleFilters: () => void;
171
171
  handleMoreActions: () => void;
172
- handlePageChange: (page: number) => void;
172
+ handlePageChange: (page: number | unknown) => void;
173
173
  handlePageLimitChange: (_k: string, value: object) => void;
174
174
  handleSearch: (query: string) => void;
175
175
  handleSubmit: () => void;
@@ -158,6 +158,11 @@ export const useFamilyMemberModule = () => {
158
158
  ]);
159
159
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
160
160
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
161
+ const isDefaultListState = state.currentPage === 1 &&
162
+ state.pageLimit === pageLimit &&
163
+ !debouncedQuery &&
164
+ state.filterEnabled === undefined &&
165
+ !state.familyId;
161
166
  // ============================================================================
162
167
  // 1.4.3 UTILITIES
163
168
  // ============================================================================
@@ -306,11 +311,12 @@ export const useFamilyMemberModule = () => {
306
311
  setField(key, value);
307
312
  }, [dispatch, setField]);
308
313
  const handlePageChange = useCallback((page) => {
314
+ const nextPage = typeof page === "number" ? page : state.currentPage + 1;
309
315
  dispatch({
310
316
  type: FAMILY_MEMBER_ACTION_TYPES.SET_CURRENT_PAGE,
311
- payload: { currentPage: page },
317
+ payload: { currentPage: nextPage },
312
318
  });
313
- }, [dispatch]);
319
+ }, [dispatch, state.currentPage]);
314
320
  const handlePageLimitChange = useCallback((_k, value) => {
315
321
  const val = Object.assign({}, value);
316
322
  dispatch({
@@ -381,9 +387,8 @@ export const useFamilyMemberModule = () => {
381
387
  type: FAMILY_MEMBER_ACTION_TYPES.SET_CURRENT_PAGE,
382
388
  payload: { currentPage: 1 },
383
389
  });
384
- listFetchNow();
385
390
  handleCloseDrawer();
386
- }, [dispatch, listFetchNow, handleCloseDrawer]);
391
+ }, [dispatch, handleCloseDrawer]);
387
392
  const clearFilters = useCallback(() => {
388
393
  dispatch({
389
394
  type: FAMILY_MEMBER_ACTION_TYPES.SET_FILTERS,
@@ -469,27 +474,38 @@ export const useFamilyMemberModule = () => {
469
474
  // 1.4.9 EFFECTS
470
475
  // ============================================================================
471
476
  useEffect(() => {
472
- var _a;
477
+ var _a, _b;
473
478
  if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
474
479
  return;
475
- (async () => {
476
- try {
477
- const { count, items } = await getCachedFamilyMembers({
478
- params: listParams,
479
- });
480
- dispatch({
481
- type: FAMILY_MEMBER_ACTION_TYPES.SET_ITEMS,
482
- payload: { items: items || [], count: count || 0 },
483
- });
484
- }
485
- catch (_a) {
486
- showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
487
- }
488
- })();
489
- }, [listParams, dispatch, showToast, t, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id]);
480
+ if (isDefaultListState) {
481
+ (async () => {
482
+ try {
483
+ const { count, items } = await getCachedFamilyMembers({
484
+ params: listParams,
485
+ });
486
+ dispatch({
487
+ type: FAMILY_MEMBER_ACTION_TYPES.SET_ITEMS,
488
+ payload: { items: items || [], count: count || 0 },
489
+ });
490
+ }
491
+ catch (_a) {
492
+ showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
493
+ }
494
+ })();
495
+ return;
496
+ }
497
+ (_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
498
+ }, [
499
+ dispatch,
500
+ isDefaultListState,
501
+ listParams,
502
+ showToast,
503
+ t,
504
+ (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
505
+ ]);
490
506
  useEffect(() => {
491
507
  listFetchNowRef.current = listFetchNow;
492
- });
508
+ }, [listFetchNow]);
493
509
  // ============================================================================
494
510
  // 1.4.10 RETURN
495
511
  // ============================================================================
@@ -124,7 +124,7 @@ export declare const useFeeStructureModule: () => {
124
124
  handleEdit: (row?: TableRow) => void;
125
125
  handleFilters: () => void;
126
126
  handleMoreActions: () => void;
127
- handlePageChange: (page: number) => void;
127
+ handlePageChange: (page: number | unknown) => void;
128
128
  handlePageLimitChange: (k: string, value: object) => void;
129
129
  handleSearch: (query: string) => void;
130
130
  handleSubmit: () => void;
@@ -103,6 +103,10 @@ export const useFeeStructureModule = () => {
103
103
  const updateParams = useMemo(() => (Object.assign(Object.assign(Object.assign({}, (state.id ? { id: state.id } : {})), (!state.id ? { schoolId } : {})), { amount: Number(state.amount), description: state.description || null, enabled: state.enabled, feeType: state.feeType, frequency: state.frequency || null, name: state.name })), [state, schoolId]);
104
104
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
105
105
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
106
+ const isDefaultListState = state.currentPage === 1 &&
107
+ state.pageLimit === pageLimit &&
108
+ !debouncedQuery &&
109
+ state.filterEnabled === undefined;
106
110
  // ============================================================================
107
111
  // 1.4.3 UTILITIES
108
112
  // ============================================================================
@@ -265,11 +269,12 @@ export const useFeeStructureModule = () => {
265
269
  });
266
270
  }, [dispatch]);
267
271
  const handlePageChange = useCallback((page) => {
272
+ const nextPage = typeof page === "number" ? page : state.currentPage + 1;
268
273
  dispatch({
269
274
  type: FEE_STRUCTURE_ACTION_TYPES.SET_CURRENT_PAGE,
270
- payload: { currentPage: page },
275
+ payload: { currentPage: nextPage },
271
276
  });
272
- }, [dispatch]);
277
+ }, [dispatch, state.currentPage]);
273
278
  const handlePageLimitChange = useCallback((k, value) => {
274
279
  const val = Object.assign({}, value);
275
280
  dispatch({
@@ -298,9 +303,8 @@ export const useFeeStructureModule = () => {
298
303
  type: FEE_STRUCTURE_ACTION_TYPES.SET_CURRENT_PAGE,
299
304
  payload: { currentPage: 1 },
300
305
  });
301
- listFetchNow();
302
306
  closeDrawer();
303
- }, [dispatch, listFetchNow, closeDrawer]);
307
+ }, [dispatch, closeDrawer]);
304
308
  const clearFilters = useCallback(() => {
305
309
  dispatch({
306
310
  type: FEE_STRUCTURE_ACTION_TYPES.SET_FILTERS,
@@ -399,27 +403,32 @@ export const useFeeStructureModule = () => {
399
403
  // 1.4.9 EFFECTS
400
404
  // ============================================================================
401
405
  useEffect(() => {
406
+ var _a;
402
407
  if (!schoolId)
403
408
  return;
404
- (async () => {
405
- try {
406
- const { count, items } = await getCachedFeeStructures({
407
- params: listParams,
408
- });
409
- dispatch({
410
- type: FEE_STRUCTURE_ACTION_TYPES.SET_ITEMS,
411
- payload: { items: items || [], count: count || 0 },
412
- });
413
- }
414
- catch (_a) {
415
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
416
- }
417
- })();
418
- }, [listParams, dispatch, showToast, t, schoolId]);
409
+ if (isDefaultListState) {
410
+ (async () => {
411
+ try {
412
+ const { count, items } = await getCachedFeeStructures({
413
+ params: listParams,
414
+ });
415
+ dispatch({
416
+ type: FEE_STRUCTURE_ACTION_TYPES.SET_ITEMS,
417
+ payload: { items: items || [], count: count || 0 },
418
+ });
419
+ }
420
+ catch (_a) {
421
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
422
+ }
423
+ })();
424
+ return;
425
+ }
426
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
427
+ }, [dispatch, isDefaultListState, listParams, showToast, t, schoolId]);
419
428
  // Sync ref to always point at latest listFetchNow (avoids stale closure in callbacks)
420
429
  useEffect(() => {
421
430
  listFetchNowRef.current = listFetchNow;
422
- });
431
+ }, [listFetchNow]);
423
432
  // ============================================================================
424
433
  // 1.4.10 RETURN
425
434
  // ============================================================================
@@ -126,7 +126,7 @@ export declare const useRbacModule: () => {
126
126
  handleFilters: () => void;
127
127
  handleMoreActions: () => void;
128
128
  handleNextClick: () => void;
129
- handlePageChange: (page: number) => void;
129
+ handlePageChange: (page: number | unknown) => void;
130
130
  handlePageLimitChange: (k: string, value: object) => void;
131
131
  handlePreviousClick: () => void;
132
132
  handleSearch: (query: string) => void;
@@ -104,6 +104,7 @@ export const useRbacModule = () => {
104
104
  }), [state.id, state.name, state.description]);
105
105
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
106
106
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
107
+ const isDefaultListState = state.currentPage === 1 && state.pageLimit === pageLimit && !debouncedQuery;
107
108
  // ============================================================================
108
109
  // 1.4.3 UTILITIES
109
110
  // ============================================================================
@@ -236,11 +237,12 @@ export const useRbacModule = () => {
236
237
  });
237
238
  }, [dispatch, state.currentPage]);
238
239
  const handlePageChange = useCallback((page) => {
240
+ const nextPage = typeof page === "number" ? page : state.currentPage + 1;
239
241
  dispatch({
240
242
  type: RBAC_ACTION_TYPES.SET_CURRENT_PAGE,
241
- payload: { currentPage: page },
243
+ payload: { currentPage: nextPage },
242
244
  });
243
- }, [dispatch]);
245
+ }, [dispatch, state.currentPage]);
244
246
  const handlePageLimitChange = useCallback((k, value) => {
245
247
  const val = Object.assign({}, value);
246
248
  dispatch({
@@ -314,9 +316,8 @@ export const useRbacModule = () => {
314
316
  type: RBAC_ACTION_TYPES.SET_CURRENT_PAGE,
315
317
  payload: { currentPage: 1 },
316
318
  });
317
- listFetchNow === null || listFetchNow === void 0 ? void 0 : listFetchNow();
318
319
  closeDrawer();
319
- }, [dispatch, listFetchNow, closeDrawer]);
320
+ }, [dispatch, closeDrawer]);
320
321
  const clearFilters = useCallback(() => {
321
322
  dispatch({
322
323
  type: RBAC_ACTION_TYPES.SET_CURRENT_PAGE,
@@ -468,26 +469,29 @@ export const useRbacModule = () => {
468
469
  // ============================================================================
469
470
  // Initial load + re-fetch on page/search change via cache
470
471
  useEffect(() => {
471
- (async () => {
472
- try {
473
- const { count, items } = await getCachedRoles({
474
- params: listParams,
475
- });
476
- dispatch({
477
- type: RBAC_ACTION_TYPES.SET_ITEMS,
478
- payload: { items: items || [], count: count || 0 },
479
- });
480
- }
481
- catch (_a) {
482
- showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
483
- }
484
- })();
485
- }, [dispatch, listParams, showToast, t]);
472
+ var _a;
473
+ if (isDefaultListState) {
474
+ (async () => {
475
+ try {
476
+ const { count, items } = await getCachedRoles({
477
+ params: listParams,
478
+ });
479
+ dispatch({
480
+ type: RBAC_ACTION_TYPES.SET_ITEMS,
481
+ payload: { items: items || [], count: count || 0 },
482
+ });
483
+ }
484
+ catch (_a) {
485
+ showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
486
+ }
487
+ })();
488
+ return;
489
+ }
490
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
491
+ }, [dispatch, isDefaultListState, listParams, showToast, t]);
486
492
  // Sync listFetchNow into ref so callbacks can trigger re-fetch
487
493
  useEffect(() => {
488
- if (listFetchNow) {
489
- listFetchNowRef.current = listFetchNow;
490
- }
494
+ listFetchNowRef.current = listFetchNow;
491
495
  }, [listFetchNow]);
492
496
  // ============================================================================
493
497
  // 1.4.10 RETURN
@@ -115,7 +115,7 @@ export declare const useSectionModule: () => {
115
115
  handleEdit: (row?: TableRow) => void;
116
116
  handleFilters: () => void;
117
117
  handleMoreActions: () => void;
118
- handlePageChange: (page: number) => void;
118
+ handlePageChange: (pageOrEvent?: unknown) => void;
119
119
  handlePageLimitChange: (k: string, value: object) => void;
120
120
  handleSearch: (query: string) => void;
121
121
  handleSubmit: () => void;