@appcorp/fusion-storybook 0.2.40 → 0.2.42

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 (98) hide show
  1. package/base-modules/admission/constants.d.ts +5 -17
  2. package/base-modules/admission/constants.js +12 -7
  3. package/base-modules/admission/context/use-admission-module.js +11 -48
  4. package/base-modules/admission/filter.js +23 -3
  5. package/base-modules/admission/form.js +49 -19
  6. package/base-modules/attendance/context.js +3 -37
  7. package/base-modules/attendance/form.js +26 -10
  8. package/base-modules/attendance/more-actions.js +34 -25
  9. package/base-modules/campus/context.js +7 -7
  10. package/base-modules/class/cache.js +0 -1
  11. package/base-modules/class/context.js +10 -48
  12. package/base-modules/class/more-actions.js +0 -2
  13. package/base-modules/course/context.js +3 -37
  14. package/base-modules/course/form.js +91 -292
  15. package/base-modules/discount-code/constants.d.ts +5 -0
  16. package/base-modules/discount-code/constants.js +5 -0
  17. package/base-modules/discount-code/context.d.ts +1 -0
  18. package/base-modules/discount-code/context.js +40 -39
  19. package/base-modules/discount-code/form.js +21 -15
  20. package/base-modules/discount-code/more-actions.js +1 -1
  21. package/base-modules/enrollment/context.js +3 -37
  22. package/base-modules/enrollment/form.js +38 -11
  23. package/base-modules/enrollment/more-actions.js +0 -2
  24. package/base-modules/expense/constants.js +1 -1
  25. package/base-modules/expense/context.js +5 -32
  26. package/base-modules/expense/filter.js +50 -3
  27. package/base-modules/expense/form.js +82 -6
  28. package/base-modules/family/context.js +7 -38
  29. package/base-modules/family-member/context.js +7 -39
  30. package/base-modules/fee-structure/context.js +1 -25
  31. package/base-modules/fee-structure/form.js +77 -89
  32. package/base-modules/fee-structure/more-actions.js +0 -2
  33. package/base-modules/rbac/context.d.ts +1 -0
  34. package/base-modules/rbac/context.js +23 -32
  35. package/base-modules/school/context.js +1 -1
  36. package/base-modules/school/form.js +34 -14
  37. package/base-modules/section/context.d.ts +1 -0
  38. package/base-modules/section/context.js +40 -47
  39. package/base-modules/section/form.js +25 -80
  40. package/base-modules/section/more-actions.js +0 -2
  41. package/base-modules/section/view.js +9 -7
  42. package/base-modules/student-fee/context/use-student-fee-module.d.ts +1 -0
  43. package/base-modules/student-fee/context/use-student-fee-module.js +48 -32
  44. package/base-modules/student-fee/context.d.ts +1 -1
  45. package/base-modules/student-fee/context.js +1 -1
  46. package/base-modules/student-fee/filter.js +23 -3
  47. package/base-modules/student-fee/form.js +93 -174
  48. package/base-modules/student-fee/view.d.ts +7 -1
  49. package/base-modules/student-fee/view.js +17 -20
  50. package/base-modules/student-profile/constants.d.ts +0 -6
  51. package/base-modules/student-profile/constants.js +1 -3
  52. package/base-modules/student-profile/context/use-student-profile-module.d.ts +1 -0
  53. package/base-modules/student-profile/context/use-student-profile-module.js +62 -55
  54. package/base-modules/student-profile/context.d.ts +1 -1
  55. package/base-modules/student-profile/context.js +1 -1
  56. package/base-modules/student-profile/filter.js +23 -3
  57. package/base-modules/student-profile/form.js +35 -3
  58. package/base-modules/subject/context.d.ts +1 -0
  59. package/base-modules/subject/context.js +38 -47
  60. package/base-modules/subject/more-actions.js +0 -2
  61. package/base-modules/teacher/constants.d.ts +0 -6
  62. package/base-modules/teacher/constants.js +0 -2
  63. package/base-modules/teacher/context.d.ts +1 -0
  64. package/base-modules/teacher/context.js +58 -39
  65. package/base-modules/teacher/form.js +46 -11
  66. package/base-modules/teacher/more-actions.js +0 -2
  67. package/base-modules/user/context/use-user-module.d.ts +1 -0
  68. package/base-modules/user/context/use-user-module.js +36 -32
  69. package/base-modules/user/context.js +1 -1
  70. package/base-modules/user/filter.js +6 -4
  71. package/base-modules/user/form.js +29 -5
  72. package/base-modules/user/more-actions.js +9 -7
  73. package/base-modules/user/view.js +3 -1
  74. package/base-modules/workspace/form.js +18 -8
  75. package/base-modules/workspace-user/context.d.ts +2 -1
  76. package/base-modules/workspace-user/context.js +31 -29
  77. package/package.json +1 -1
  78. package/tsconfig.build.tsbuildinfo +1 -1
  79. package/base-modules/admission/cache.d.ts +0 -14
  80. package/base-modules/admission/cache.js +0 -31
  81. package/base-modules/attendance/cache.d.ts +0 -14
  82. package/base-modules/attendance/cache.js +0 -31
  83. package/base-modules/course/cache.d.ts +0 -14
  84. package/base-modules/course/cache.js +0 -31
  85. package/base-modules/enrollment/cache.d.ts +0 -14
  86. package/base-modules/enrollment/cache.js +0 -31
  87. package/base-modules/expense/cache.d.ts +0 -14
  88. package/base-modules/expense/cache.js +0 -31
  89. package/base-modules/family/cache.d.ts +0 -14
  90. package/base-modules/family/cache.js +0 -31
  91. package/base-modules/family-member/cache.d.ts +0 -14
  92. package/base-modules/family-member/cache.js +0 -31
  93. package/base-modules/rbac/cache.d.ts +0 -27
  94. package/base-modules/rbac/cache.js +0 -46
  95. package/base-modules/student-fee/cache.d.ts +0 -15
  96. package/base-modules/student-fee/cache.js +0 -21
  97. package/base-modules/workspace-user/cache.d.ts +0 -14
  98. package/base-modules/workspace-user/cache.js +0 -31
@@ -397,19 +397,19 @@ export const useCampusModule = () => {
397
397
  {
398
398
  enabled: false,
399
399
  handleOnClick: handleMoreActions,
400
- label: t("actionHeaderMoreActions"),
400
+ label: t("actionsButtonMoreActions"),
401
401
  order: 0,
402
402
  },
403
403
  {
404
404
  enabled: true,
405
405
  handleOnClick: handleFilters,
406
- label: t("actionHeaderFilters"),
406
+ label: t("actionsButtonFilters"),
407
407
  order: 1,
408
408
  },
409
409
  {
410
410
  enabled: true,
411
411
  handleOnClick: handleCreate,
412
- label: t("actionHeaderAdd"),
412
+ label: t("actionsButtonAdd"),
413
413
  order: 2,
414
414
  },
415
415
  ], [handleCreate, handleFilters, handleMoreActions, t]);
@@ -417,26 +417,26 @@ export const useCampusModule = () => {
417
417
  {
418
418
  enabled: true,
419
419
  handleOnClick: handleView,
420
- label: t("actionRowView"),
420
+ label: t("actionsButtonView"),
421
421
  order: 1,
422
422
  },
423
423
  {
424
424
  enabled: (row) => (row === null || row === void 0 ? void 0 : row.enabled) === true,
425
425
  handleOnClick: handleEdit,
426
- label: t("actionRowEdit"),
426
+ label: t("actionsButtonEdit"),
427
427
  order: 2,
428
428
  },
429
429
  {
430
430
  enabled: (row) => (row === null || row === void 0 ? void 0 : row.enabled) === false,
431
431
  handleOnClick: handleDelete,
432
- label: t("actionRowDelete"),
432
+ label: t("actionsButtonDelete"),
433
433
  order: 3,
434
434
  variant: "destructive",
435
435
  },
436
436
  {
437
437
  enabled: false,
438
438
  handleOnClick: toggleStatus,
439
- label: t("actionRowToggleStatus"),
439
+ label: t("actionsButtonToggleStatus"),
440
440
  order: 4,
441
441
  },
442
442
  ], [handleDelete, handleEdit, handleView, t, toggleStatus]);
@@ -22,7 +22,6 @@ export const getCachedClasses = ({ params, }) => getCachedData({
22
22
  params,
23
23
  headers: {
24
24
  "Content-Type": "application/json",
25
- // "x-api-token": process.env.NEXT_PUBLIC_API_KEY!,
26
25
  },
27
26
  });
28
27
  export const getCachedClassById = (classId) => getCachedItemById(LS_KEYS.CLASSES, classId);
@@ -28,7 +28,6 @@ import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-com
28
28
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
29
29
  import { CLASS_API_ROUTES, pageLimit } from "./constants";
30
30
  import { classFormValidation } from "./validate";
31
- import { getCachedClasses, invalidateClassesCache } from "./cache";
32
31
  import { getCachedWorkspaceSync } from "../workspace/cache";
33
32
  // ============================================================================
34
33
  // 1.1 DRAWER TYPES
@@ -159,7 +158,6 @@ export const useClassModule = () => {
159
158
  }
160
159
  if (data) {
161
160
  const isCreated = isCreatedOrUpdated(data);
162
- invalidateClassesCache();
163
161
  showToast(isCreated ? t("messagesCreateSuccess") : t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
164
162
  resetFormAndCloseDrawer();
165
163
  (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
@@ -184,7 +182,6 @@ export const useClassModule = () => {
184
182
  return;
185
183
  }
186
184
  if (data) {
187
- invalidateClassesCache();
188
185
  showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
189
186
  (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
190
187
  }
@@ -378,19 +375,19 @@ export const useClassModule = () => {
378
375
  {
379
376
  enabled: true,
380
377
  handleOnClick: handleMoreActions,
381
- label: t("actionHeaderMoreActions"),
378
+ label: t("actionsButtonMoreActions"),
382
379
  order: 0,
383
380
  },
384
381
  {
385
382
  enabled: true,
386
383
  handleOnClick: handleFilters,
387
- label: t("actionHeaderFilters"),
384
+ label: t("actionsButtonFilters"),
388
385
  order: 1,
389
386
  },
390
387
  {
391
388
  enabled: true,
392
389
  handleOnClick: handleCreate,
393
- label: t("actionHeaderAdd"),
390
+ label: t("actionsButtonAdd"),
394
391
  order: 2,
395
392
  },
396
393
  ], [handleCreate, handleFilters, handleMoreActions, t]);
@@ -398,74 +395,39 @@ export const useClassModule = () => {
398
395
  {
399
396
  enabled: true,
400
397
  handleOnClick: handleView,
401
- label: t("actionRowView"),
398
+ label: t("actionsButtonView"),
402
399
  order: 1,
403
400
  },
404
401
  {
405
402
  enabled: (row) => (row === null || row === void 0 ? void 0 : row.enabled) === true,
406
403
  handleOnClick: handleEdit,
407
- label: t("actionRowEdit"),
404
+ label: t("actionsButtonEdit"),
408
405
  order: 2,
409
406
  },
410
407
  {
411
408
  enabled: (row) => (row === null || row === void 0 ? void 0 : row.enabled) === false,
412
409
  handleOnClick: handleDelete,
413
- label: t("actionRowDelete"),
410
+ label: t("actionsButtonDelete"),
414
411
  order: 3,
415
412
  variant: "destructive",
416
413
  },
417
414
  {
418
415
  enabled: false,
419
416
  handleOnClick: toggleStatus,
420
- label: t("actionRowToggleStatus"),
417
+ label: t("actionsButtonToggleStatus"),
421
418
  order: 4,
422
419
  },
423
420
  ], [handleDelete, handleEdit, handleView, t, toggleStatus]);
424
421
  // ============================================================================
425
422
  // 1.4.9 EFFECTS
426
423
  // ============================================================================
427
- // Always keep the ref current so the main effect can call the latest listFetchNow
428
- // without including it in the dependency array (listFetchNow changes identity every
429
- // render because useModuleEntityV2 passes an inline headers object to useFetch).
430
- // Declared first so the ref is populated before the fetch effect runs.
431
424
  useEffect(() => {
432
425
  listFetchNowRef.current = listFetchNow;
433
- });
434
- // Initial load via cache; re-fetch directly from API on page/pageLimit/filter/search changes.
435
- // listFetchNow is intentionally excluded from deps — it changes every render due to the
436
- // inline headers object in useModuleEntityV2. We call it via the stable ref instead.
426
+ }, [listFetchNow]);
437
427
  useEffect(() => {
438
428
  var _a;
439
- if (!schoolId)
440
- return;
441
- const currentPage = Number(listParams.currentPage) || 1;
442
- const currentPageLimit = Number(listParams.pageLimit) || pageLimit;
443
- const isDefaultLoad = currentPage === 1 &&
444
- currentPageLimit === pageLimit &&
445
- !listParams.searchQuery &&
446
- listParams.filterEnabled === undefined;
447
- if (isDefaultLoad) {
448
- (async () => {
449
- try {
450
- const { count, items } = await getCachedClasses({
451
- params: listParams,
452
- });
453
- dispatch({
454
- type: CLASS_ACTION_TYPES.SET_ITEMS,
455
- payload: { items: items || [], count: count || 0 },
456
- });
457
- }
458
- catch (_a) {
459
- showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
460
- }
461
- })();
462
- }
463
- else {
464
- // Bypass cache for pagination, pageLimit, filter and search changes.
465
- // Use ref to avoid the infinite-loop caused by listFetchNow's unstable identity.
466
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
467
- }
468
- }, [dispatch, listParams, schoolId, showToast, t]);
429
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
430
+ }, [listParams]);
469
431
  // ============================================================================
470
432
  // 1.4.10 RETURN
471
433
  // ============================================================================
@@ -7,7 +7,6 @@ import converter from "json-2-csv";
7
7
  import { Timeline } from "../../components/timeline";
8
8
  import { useTranslations } from "next-intl";
9
9
  import { CLASS_API_ROUTES, pageLimit } from "./constants";
10
- import { invalidateClassesCache } from "./cache";
11
10
  import { CLASS_ACTION_TYPES, useClassContext } from "./context";
12
11
  import { useRef, useEffect, useCallback } from "react";
13
12
  const workspace = getCachedWorkspaceSync();
@@ -165,7 +164,6 @@ export const ClassMoreActions = () => {
165
164
  else {
166
165
  showSuccessToast("Bulk operation completed successfully");
167
166
  }
168
- invalidateClassesCache();
169
167
  const schoolId = ((_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id) || "";
170
168
  fetch(`${CLASS_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
171
169
  headers: {
@@ -25,7 +25,6 @@ import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
25
25
  import { createGenericModule } from "@react-pakistan/util-functions/factory/generic-module-factory";
26
26
  import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
27
27
  import { COURSE_API_ROUTES, pageLimit } from "./constants";
28
- import { getCachedCourses, invalidateCoursesCache } from "./cache";
29
28
  import { courseFormValidation } from "./validate";
30
29
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
31
30
  import { getCachedWorkspaceSync } from "../workspace/cache";
@@ -167,7 +166,6 @@ export const useCourseModule = () => {
167
166
  showToast(isCreatedOrUpdated(data)
168
167
  ? t("messagesCourseCreated")
169
168
  : t("messagesCourseUpdated"), TOAST_VARIANT.SUCCESS);
170
- invalidateCoursesCache();
171
169
  (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
172
170
  resetFormAndCloseDrawer();
173
171
  }
@@ -247,7 +245,6 @@ export const useCourseModule = () => {
247
245
  }
248
246
  if (data) {
249
247
  showToast(t("messagesCourseDeleted"), TOAST_VARIANT.SUCCESS);
250
- invalidateCoursesCache();
251
248
  (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
252
249
  }
253
250
  }, [showToast, t]);
@@ -456,44 +453,13 @@ export const useCourseModule = () => {
456
453
  // ==========================================================================
457
454
  // 1.4.9 EFFECTS
458
455
  // ==========================================================================
459
- // Keep the latest fetch function in a ref so the fetch effect can call it
460
- // without depending on listFetchNow's unstable identity.
461
456
  useEffect(() => {
462
457
  listFetchNowRef.current = listFetchNow;
463
- });
464
- // Initial load via cache; re-fetch directly from API on page/pageLimit/filter/search changes.
458
+ }, [listFetchNow]);
465
459
  useEffect(() => {
466
460
  var _a;
467
- if (!schoolId)
468
- return;
469
- const currentPage = Number(listParams.currentPage) || 1;
470
- const currentPageLimit = Number(listParams.pageLimit) || pageLimit;
471
- const isDefaultLoad = currentPage === 1 &&
472
- currentPageLimit === pageLimit &&
473
- !listParams.searchQuery &&
474
- listParams.filterEnabled === undefined;
475
- if (isDefaultLoad) {
476
- (async () => {
477
- try {
478
- const { count, items } = await getCachedCourses({
479
- params: listParams,
480
- });
481
- dispatch({
482
- type: COURSE_ACTION_TYPES.SET_ITEMS,
483
- payload: { items: items || [], count: count || 0 },
484
- });
485
- }
486
- catch (_a) {
487
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
488
- }
489
- })();
490
- }
491
- else {
492
- // Bypass cache for pagination, pageLimit, filter and search changes.
493
- // Use ref to avoid the infinite-loop caused by listFetchNow's unstable identity.
494
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
495
- }
496
- }, [listParams, dispatch, showToast, schoolId, t]);
461
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
462
+ }, [listParams]);
497
463
  // ==========================================================================
498
464
  // 1.4.10 RETURN
499
465
  // ==========================================================================