@appcorp/fusion-storybook 0.1.63 → 0.1.65

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 (81) hide show
  1. package/base-modules/admission/context.d.ts +1 -1
  2. package/base-modules/admission/context.js +138 -117
  3. package/base-modules/admission/page.d.ts +3 -0
  4. package/base-modules/admission/page.js +8 -5
  5. package/base-modules/discount-code/context.d.ts +53 -43
  6. package/base-modules/discount-code/context.js +179 -135
  7. package/base-modules/discount-code/page.d.ts +13 -7
  8. package/base-modules/discount-code/page.js +17 -13
  9. package/base-modules/family/context.d.ts +24 -22
  10. package/base-modules/family/context.js +122 -90
  11. package/base-modules/family/page.d.ts +3 -0
  12. package/base-modules/family/page.js +8 -7
  13. package/base-modules/family-member/context.d.ts +7 -5
  14. package/base-modules/family-member/context.js +160 -130
  15. package/base-modules/family-member/page.d.ts +3 -0
  16. package/base-modules/family-member/page.js +8 -7
  17. package/base-modules/rbac/assign-permissions.d.ts +1 -0
  18. package/base-modules/rbac/assign-permissions.js +53 -0
  19. package/base-modules/rbac/cache.d.ts +27 -0
  20. package/base-modules/rbac/cache.js +46 -0
  21. package/base-modules/rbac/constants.d.ts +17 -0
  22. package/base-modules/rbac/constants.js +28 -0
  23. package/base-modules/rbac/context.d.ts +190 -0
  24. package/base-modules/rbac/context.js +539 -0
  25. package/base-modules/rbac/filter.d.ts +1 -0
  26. package/base-modules/rbac/filter.js +18 -0
  27. package/base-modules/rbac/form.d.ts +1 -0
  28. package/base-modules/rbac/form.js +13 -0
  29. package/base-modules/rbac/more-actions.d.ts +6 -0
  30. package/base-modules/rbac/more-actions.js +10 -0
  31. package/base-modules/rbac/page.d.ts +35 -0
  32. package/base-modules/rbac/page.js +142 -0
  33. package/base-modules/rbac/validate.d.ts +10 -0
  34. package/base-modules/rbac/validate.js +13 -0
  35. package/base-modules/rbac/view.d.ts +1 -0
  36. package/base-modules/rbac/view.js +33 -0
  37. package/base-modules/school/cache.d.ts +9 -0
  38. package/base-modules/school/cache.js +28 -0
  39. package/base-modules/school/constants.d.ts +9 -0
  40. package/base-modules/school/constants.js +17 -0
  41. package/base-modules/school/context.d.ts +157 -0
  42. package/base-modules/school/context.js +285 -0
  43. package/base-modules/school/drawer.d.ts +1 -0
  44. package/base-modules/school/drawer.js +24 -0
  45. package/base-modules/school/filter.d.ts +1 -0
  46. package/base-modules/school/filter.js +13 -0
  47. package/base-modules/school/form.d.ts +1 -0
  48. package/base-modules/school/form.js +30 -0
  49. package/base-modules/school/more-actions.d.ts +1 -0
  50. package/base-modules/school/more-actions.js +13 -0
  51. package/base-modules/school/page.d.ts +24 -0
  52. package/base-modules/school/page.js +41 -0
  53. package/base-modules/school/validate.d.ts +23 -0
  54. package/base-modules/school/validate.js +26 -0
  55. package/base-modules/school/view.d.ts +1 -0
  56. package/base-modules/school/view.js +24 -0
  57. package/base-modules/student-profile/context.d.ts +35 -69
  58. package/base-modules/student-profile/context.js +241 -221
  59. package/base-modules/student-profile/page.d.ts +14 -4
  60. package/base-modules/student-profile/page.js +19 -12
  61. package/base-modules/teacher/context.d.ts +18 -15
  62. package/base-modules/teacher/context.js +188 -154
  63. package/base-modules/teacher/page.d.ts +13 -7
  64. package/base-modules/teacher/page.js +18 -12
  65. package/base-modules/user/context.d.ts +4 -3
  66. package/base-modules/user/context.js +251 -229
  67. package/base-modules/user/page.d.ts +15 -9
  68. package/base-modules/user/page.js +19 -14
  69. package/base-modules/workspace/context.d.ts +14 -13
  70. package/base-modules/workspace/context.js +100 -98
  71. package/base-modules/workspace/drawer.js +3 -1
  72. package/base-modules/workspace/form.js +4 -4
  73. package/base-modules/workspace/page.d.ts +4 -2
  74. package/base-modules/workspace/page.js +15 -1
  75. package/base-modules/workspace-user/constants.js +1 -0
  76. package/base-modules/workspace-user/context.d.ts +19 -0
  77. package/base-modules/workspace-user/context.js +44 -27
  78. package/base-modules/workspace-user/page.d.ts +1 -1
  79. package/base-modules/workspace-user/page.js +22 -11
  80. package/package.json +1 -1
  81. package/tsconfig.build.tsbuildinfo +1 -1
@@ -295,7 +295,7 @@ export declare const useAdmissionModule: () => {
295
295
  handleEdit: (row?: TableRow) => void;
296
296
  handleFilters: () => void;
297
297
  handlePageChange: (page: number) => void;
298
- handlePageLimitChange: (limit: number) => void;
298
+ handlePageLimitChange: (k: string, value: object) => void;
299
299
  handlePrint: (row?: TableRow) => Promise<void>;
300
300
  handleSearch: (query: string) => void;
301
301
  handleSetEndDate: (endDate: string) => void;
@@ -18,7 +18,9 @@
18
18
  * - `ADMISSION_DRAWER` — drawer type constants
19
19
  * - `useAdmissionModule()` — hook that returns state, dispatch, and handlers
20
20
  */
21
- import { useCallback, useEffect, useMemo } from "react";
21
+ import { useCallback, useEffect, useMemo, useRef } from "react";
22
+ import { useTheme } from "next-themes";
23
+ import { useTranslations } from "next-intl";
22
24
  import { validateForm, isCreatedOrUpdated, API_METHODS, fetchData, } from "@react-pakistan/util-functions";
23
25
  import { formatCnic } from "@react-pakistan/util-functions/general/cnic-formatter";
24
26
  import { formatPhone } from "@react-pakistan/util-functions/general/format-phone";
@@ -28,7 +30,6 @@ import { createGenericModule } from "@react-pakistan/util-functions/factory/gene
28
30
  import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
29
31
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
30
32
  import { ADMISSION_STATUS, GENDER, } from "../../type";
31
- import { useTranslations } from "next-intl";
32
33
  import { ADMISSION_API_ROUTES, pageLimit } from "./constants";
33
34
  import { admissionFormValidation } from "./validate";
34
35
  import { getCachedAdmissions, invalidateAdmissionsCache } from "./cache";
@@ -39,7 +40,7 @@ import { invalidateFamilyMembersCache } from "../family-member/cache";
39
40
  import { invalidateStudentProfilesCache } from "../student-profile/cache";
40
41
  import { Filter, Plus } from "lucide-react";
41
42
  // ============================================================================
42
- // DRAWER TYPES
43
+ // 1.1 DRAWER TYPES
43
44
  // ============================================================================
44
45
  export const ADMISSION_DRAWER = {
45
46
  FILTER_DRAWER: DRAWER_TYPES.FILTER_DRAWER,
@@ -48,7 +49,7 @@ export const ADMISSION_DRAWER = {
48
49
  VIEW_DRAWER: DRAWER_TYPES.VIEW_DRAWER,
49
50
  };
50
51
  // ============================================================================
51
- // CONFIGURATION
52
+ // 1.2 MODULE CONFIGURATION
52
53
  // ============================================================================
53
54
  const admissionConfig = {
54
55
  name: "Admission",
@@ -121,125 +122,133 @@ const admissionConfig = {
121
122
  drawerTypes: DRAWER_TYPES,
122
123
  };
123
124
  // ============================================================================
124
- // CREATE ADMISSION MODULE
125
+ // 1.3 CREATE ADMISSION MODULE
125
126
  // ============================================================================
126
127
  export const { actionTypes: ADMISSION_ACTION_TYPES, config: admissionModuleConfig, initialState: initialAdmissionState, Provider: AdmissionProvider, reducer: admissionReducer, useContext: useAdmissionContext, } = createGenericModule(admissionConfig);
127
128
  // ============================================================================
128
- // ENHANCED ADMISSION HOOK WITH API INTEGRATION
129
+ // 1.4 ENHANCED ADMISSION HOOK WITH API INTEGRATION
129
130
  // ============================================================================
130
131
  export const useAdmissionModule = () => {
131
132
  var _a, _b, _c, _d, _e, _f;
133
+ // ============================================================================
134
+ // 1.4.1 STATE & CORE HOOKS
135
+ // ============================================================================
132
136
  const context = useAdmissionContext();
133
137
  const { dispatch } = context;
138
+ const state = context.state;
134
139
  const t = useTranslations("admission");
140
+ const { theme } = useTheme();
135
141
  const workspace = getCachedWorkspaceSync();
136
- const debouncedQuery = useDebounce(context.state.searchQuery, 800);
142
+ const listFetchNowRef = useRef(null);
143
+ const debouncedQuery = useDebounce(state.searchQuery, 800);
137
144
  // ============================================================================
138
- // API PARAMETERS
145
+ // 1.4.2 API PARAMETERS
139
146
  // ============================================================================
140
147
  const listParams = useMemo(() => {
141
148
  var _a;
142
- return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ currentPage: context.state.currentPage, pageLimit: context.state.pageLimit, schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (context.state.filterEnabled !== undefined
143
- ? { filterEnabled: String(context.state.filterEnabled) }
144
- : {})), (context.state.filterAdmissionStatus
145
- ? { filterAdmissionStatus: context.state.filterAdmissionStatus }
146
- : {})), (context.state.filterStartDate
147
- ? { filterStartDate: context.state.filterStartDate }
148
- : {})), (context.state.filterEndDate
149
- ? { filterEndDate: context.state.filterEndDate }
150
- : {})));
149
+ return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.filterEnabled !== undefined
150
+ ? { filterEnabled: String(state.filterEnabled) }
151
+ : {})), (state.filterAdmissionStatus
152
+ ? { filterAdmissionStatus: state.filterAdmissionStatus }
153
+ : {})), (state.filterStartDate
154
+ ? { filterStartDate: state.filterStartDate }
155
+ : {})), (state.filterEndDate ? { filterEndDate: state.filterEndDate } : {})));
151
156
  }, [
152
- context.state.currentPage,
153
- context.state.filterAdmissionStatus,
154
- context.state.filterEnabled,
155
- context.state.filterEndDate,
156
- context.state.filterStartDate,
157
- context.state.pageLimit,
157
+ state.currentPage,
158
+ state.filterAdmissionStatus,
159
+ state.filterEnabled,
160
+ state.filterEndDate,
161
+ state.filterStartDate,
162
+ state.pageLimit,
158
163
  debouncedQuery,
159
164
  (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
160
165
  ]);
161
166
  const updateParams = useMemo(() => {
162
167
  var _a, _b, _c, _d;
163
168
  return ({
164
- address: context.state.address || "",
165
- admissionNotes: context.state.admissionNotes || "",
166
- admissionStatus: context.state.status || ADMISSION_STATUS.PENDING,
167
- bForm: context.state.bForm || "",
168
- city: context.state.city || "",
169
- classForAdmission: context.state.classForAdmission || "",
170
- country: context.state.country || "",
171
- discountCode: context.state.discountCode || "",
172
- dob: context.state.dob || null,
173
- emergencyContact: context.state.emergencyContact || "",
174
- enabled: (_a = context.state.enabled) !== null && _a !== void 0 ? _a : true,
175
- fatherCnic: context.state.fatherCnic || "",
176
- fatherFirstName: context.state.fatherFirstName || "",
177
- fatherLastName: context.state.fatherLastName || "",
178
- fatherMobile: context.state.fatherMobile || "",
179
- fatherOccupation: context.state.fatherOccupation || "",
180
- fatherOrganization: context.state.fatherOrganization || "",
181
- firstName: context.state.firstName || "",
182
- gender: context.state.gender || null,
183
- hafiz: (_b = context.state.hafiz) !== null && _b !== void 0 ? _b : false,
184
- id: context.state.id || "",
185
- lastName: context.state.lastName || "",
186
- motherCnic: context.state.motherCnic || "",
187
- motherFirstName: context.state.motherFirstName || "",
188
- motherLastName: context.state.motherLastName || "",
189
- motherMobile: context.state.motherMobile || "",
190
- notes: context.state.notes || "",
191
- orphan: (_c = context.state.orphan) !== null && _c !== void 0 ? _c : false,
192
- postalCode: context.state.postalCode || "",
193
- previousSchool: context.state.previousSchool || "",
194
- registrationCode: context.state.registrationCode || "",
169
+ address: state.address || "",
170
+ admissionNotes: state.admissionNotes || "",
171
+ admissionStatus: state.status || ADMISSION_STATUS.PENDING,
172
+ bForm: state.bForm || "",
173
+ city: state.city || "",
174
+ classForAdmission: state.classForAdmission || "",
175
+ country: state.country || "",
176
+ discountCode: state.discountCode || "",
177
+ dob: state.dob || null,
178
+ emergencyContact: state.emergencyContact || "",
179
+ enabled: (_a = state.enabled) !== null && _a !== void 0 ? _a : true,
180
+ fatherCnic: state.fatherCnic || "",
181
+ fatherFirstName: state.fatherFirstName || "",
182
+ fatherLastName: state.fatherLastName || "",
183
+ fatherMobile: state.fatherMobile || "",
184
+ fatherOccupation: state.fatherOccupation || "",
185
+ fatherOrganization: state.fatherOrganization || "",
186
+ firstName: state.firstName || "",
187
+ gender: state.gender || null,
188
+ hafiz: (_b = state.hafiz) !== null && _b !== void 0 ? _b : false,
189
+ id: state.id || "",
190
+ lastName: state.lastName || "",
191
+ motherCnic: state.motherCnic || "",
192
+ motherFirstName: state.motherFirstName || "",
193
+ motherLastName: state.motherLastName || "",
194
+ motherMobile: state.motherMobile || "",
195
+ notes: state.notes || "",
196
+ orphan: (_c = state.orphan) !== null && _c !== void 0 ? _c : false,
197
+ postalCode: state.postalCode || "",
198
+ previousSchool: state.previousSchool || "",
199
+ registrationCode: state.registrationCode || "",
195
200
  schoolId: ((_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id) || "",
196
- siblings: context.state.siblings || "",
197
- state: context.state.state || "",
201
+ siblings: state.siblings || "",
202
+ state: state.state || "",
198
203
  });
199
204
  }, [
200
- context.state.address,
201
- context.state.admissionNotes,
202
- context.state.status,
203
- context.state.bForm,
204
- context.state.city,
205
- context.state.classForAdmission,
206
- context.state.country,
207
- context.state.discountCode,
208
- context.state.dob,
209
- context.state.emergencyContact,
210
- context.state.enabled,
211
- context.state.fatherCnic,
212
- context.state.fatherFirstName,
213
- context.state.fatherLastName,
214
- context.state.fatherMobile,
215
- context.state.fatherOccupation,
216
- context.state.fatherOrganization,
217
- context.state.firstName,
218
- context.state.gender,
219
- context.state.hafiz,
220
- context.state.id,
221
- context.state.lastName,
222
- context.state.motherCnic,
223
- context.state.motherFirstName,
224
- context.state.motherLastName,
225
- context.state.motherMobile,
226
- context.state.notes,
227
- context.state.orphan,
228
- context.state.postalCode,
229
- context.state.previousSchool,
230
- context.state.registrationCode,
231
- context.state.siblings,
232
- context.state.state,
205
+ state.address,
206
+ state.admissionNotes,
207
+ state.status,
208
+ state.bForm,
209
+ state.city,
210
+ state.classForAdmission,
211
+ state.country,
212
+ state.discountCode,
213
+ state.dob,
214
+ state.emergencyContact,
215
+ state.enabled,
216
+ state.fatherCnic,
217
+ state.fatherFirstName,
218
+ state.fatherLastName,
219
+ state.fatherMobile,
220
+ state.fatherOccupation,
221
+ state.fatherOrganization,
222
+ state.firstName,
223
+ state.gender,
224
+ state.hafiz,
225
+ state.id,
226
+ state.lastName,
227
+ state.motherCnic,
228
+ state.motherFirstName,
229
+ state.motherLastName,
230
+ state.motherMobile,
231
+ state.notes,
232
+ state.orphan,
233
+ state.postalCode,
234
+ state.previousSchool,
235
+ state.registrationCode,
236
+ state.siblings,
237
+ state.state,
233
238
  (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
234
239
  ]);
235
- const byIdParams = useMemo(() => ({ id: context.state.id }), [context.state.id]);
236
- const deleteParams = useMemo(() => ({ id: context.state.id }), [context.state.id]);
240
+ const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
241
+ const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
237
242
  // ============================================================================
238
- // UTILITIES
243
+ // 1.4.3 UTILITIES
239
244
  // ============================================================================
240
- const showToast = useCallback((message, variant) => {
241
- generateThemeToast({ description: message, variant });
242
- }, []);
245
+ const showToast = useCallback((description, variant) => {
246
+ generateThemeToast({
247
+ description,
248
+ theme: theme,
249
+ variant,
250
+ });
251
+ }, [theme]);
243
252
  const setField = useCallback((key, value) => {
244
253
  var _a, _b, _c;
245
254
  let formatted = value === null
@@ -275,9 +284,9 @@ export const useAdmissionModule = () => {
275
284
  });
276
285
  }, [dispatch]);
277
286
  // ============================================================================
278
- // API CALLBACKS
287
+ // 1.4.4 API CALLBACKS
279
288
  // ============================================================================
280
- const listCallback = ({ data, error }) => {
289
+ const listCallback = useCallback(({ data, error }) => {
281
290
  if (error) {
282
291
  showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
283
292
  return;
@@ -288,21 +297,22 @@ export const useAdmissionModule = () => {
288
297
  payload: { items: data.items || [], count: data.count || 0 },
289
298
  });
290
299
  }
291
- };
292
- const updateCallback = ({ data, error }) => {
300
+ }, [dispatch, showToast, t]);
301
+ const updateCallback = useCallback(({ data, error }) => {
302
+ var _a;
293
303
  const isCreated = isCreatedOrUpdated(data);
294
304
  if (error) {
295
305
  showToast(isCreated ? t("messagesCreateFailed") : t("messagesUpdateFailed"), TOAST_VARIANT.ERROR);
296
306
  return;
297
307
  }
298
308
  if (data) {
299
- showToast(t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
300
309
  invalidateAdmissionsCache();
301
- listFetchNow();
310
+ showToast(t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
302
311
  resetFormAndCloseDrawer();
312
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
303
313
  }
304
- };
305
- const byIdCallback = ({ data, error }) => {
314
+ }, [resetFormAndCloseDrawer, showToast, t]);
315
+ const byIdCallback = useCallback(({ data, error }) => {
306
316
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
307
317
  if (error) {
308
318
  showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
@@ -365,22 +375,23 @@ export const useAdmissionModule = () => {
365
375
  payload: { form: { aiAnalysis } },
366
376
  });
367
377
  }
368
- };
369
- const deleteCallback = ({ data, error }) => {
378
+ }, [dispatch, showToast, t, setField]);
379
+ const deleteCallback = useCallback(({ data, error }) => {
380
+ var _a;
370
381
  if (error) {
371
382
  showToast(t("messagesDeleteFailed"), TOAST_VARIANT.ERROR);
372
383
  return;
373
384
  }
374
385
  if (data) {
375
- showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
376
386
  invalidateAdmissionsCache();
377
- listFetchNow();
387
+ showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
388
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
378
389
  }
379
- };
390
+ }, [showToast, t]);
380
391
  // ============================================================================
381
- // API HOOKS
392
+ // 1.4.5 API HOOKS
382
393
  // ============================================================================
383
- const { listFetchNow, listLoading, updateFetchNow, updateLoading, byIdFetchNow, deleteFetchNow, deleteLoading, byIdLoading, } = useModuleEntityV2({
394
+ const { byIdFetchNow, byIdLoading, deleteFetchNow, deleteLoading, listFetchNow, listLoading, updateFetchNow, updateLoading, } = useModuleEntityV2({
384
395
  byIdCallback,
385
396
  byIdParams,
386
397
  deleteCallback,
@@ -399,7 +410,7 @@ export const useAdmissionModule = () => {
399
410
  },
400
411
  });
401
412
  // ============================================================================
402
- // HANDLERS
413
+ // 1.4.6 HANDLERS
403
414
  // ============================================================================
404
415
  const handleChange = useCallback((field, value) => {
405
416
  dispatch({
@@ -454,10 +465,15 @@ export const useAdmissionModule = () => {
454
465
  payload: { currentPage: page },
455
466
  });
456
467
  }, [dispatch]);
457
- const handlePageLimitChange = useCallback((limit) => {
468
+ const handlePageLimitChange = useCallback((k, value) => {
469
+ const val = Object.assign({}, value);
458
470
  dispatch({
459
471
  type: ADMISSION_ACTION_TYPES.SET_PAGE_LIMIT,
460
- payload: { pageLimit: limit },
472
+ payload: { pageLimit: Number(val.option) },
473
+ });
474
+ dispatch({
475
+ type: ADMISSION_ACTION_TYPES.SET_CURRENT_PAGE,
476
+ payload: { currentPage: 1 },
461
477
  });
462
478
  }, [dispatch]);
463
479
  const handleSearch = useCallback((query) => {
@@ -586,7 +602,7 @@ export const useAdmissionModule = () => {
586
602
  }
587
603
  }, [t, showToast, listFetchNow]);
588
604
  // ============================================================================
589
- // NETWORK ACTIONS
605
+ // 1.4.7 NETWORK ACTIONS
590
606
  // ============================================================================
591
607
  const handleAnalyze = useCallback(async (row) => {
592
608
  var _a, _b, _c;
@@ -725,7 +741,7 @@ export const useAdmissionModule = () => {
725
741
  (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id,
726
742
  ]);
727
743
  // ============================================================================
728
- // HEADER & ROW ACTIONS
744
+ // 1.4.8 HEADER & ROW ACTIONS
729
745
  // ============================================================================
730
746
  const hasGeminiSecrets = Boolean(((_e = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _e === void 0 ? void 0 : _e.GEMINI_API_KEY) && ((_f = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _f === void 0 ? void 0 : _f.GEMINI_MODEL));
731
747
  const headerActions = useMemo(() => [
@@ -802,8 +818,9 @@ export const useAdmissionModule = () => {
802
818
  handleCloseDrawer();
803
819
  }, [dispatch, listFetchNow, handleCloseDrawer]);
804
820
  // ============================================================================
805
- // EFFECTS
821
+ // 1.4.9 EFFECTS
806
822
  // ============================================================================
823
+ // Initial load + re-fetch on page/search/filter change via cache
807
824
  useEffect(() => {
808
825
  if (!(workspace === null || workspace === void 0 ? void 0 : workspace.id))
809
826
  return;
@@ -822,8 +839,12 @@ export const useAdmissionModule = () => {
822
839
  }
823
840
  })();
824
841
  }, [listParams, workspace === null || workspace === void 0 ? void 0 : workspace.id, t, showToast, dispatch]);
842
+ // Sync ref to always point at latest listFetchNow (avoids stale closure in callbacks)
843
+ useEffect(() => {
844
+ listFetchNowRef.current = listFetchNow;
845
+ });
825
846
  // ============================================================================
826
- // RETURN
847
+ // 1.4.10 RETURN
827
848
  // ============================================================================
828
849
  return Object.assign(Object.assign({}, context), { applyFilters,
829
850
  byIdLoading,
@@ -8,6 +8,9 @@
8
8
  * based on drawer type so the component type produced by createGenericModulePage
9
9
  * may change at runtime, but this is acceptable for drawer-based sizing)
10
10
  * - permission guard
11
+ *
12
+ * Exported utilities:
13
+ * - `AdmissionPage` — root component that wraps with AdmissionProvider
11
14
  */
12
15
  import { FC } from "react";
13
16
  import { USER_ROLE } from "../../type";
@@ -1,5 +1,3 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
1
  /**
4
2
  * Admission Page Component
5
3
  *
@@ -10,7 +8,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
10
8
  * based on drawer type so the component type produced by createGenericModulePage
11
9
  * may change at runtime, but this is acceptable for drawer-based sizing)
12
10
  * - permission guard
11
+ *
12
+ * Exported utilities:
13
+ * - `AdmissionPage` — root component that wraps with AdmissionProvider
13
14
  */
15
+ "use client";
16
+ import { jsx as _jsx } from "react/jsx-runtime";
14
17
  import { useMemo } from "react";
15
18
  import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
16
19
  import { createGenericModulePage, } from "@react-pakistan/util-functions/factory/generic-component-factory";
@@ -83,9 +86,6 @@ const createAdmissionConfig = ({ cancelLabel, dispatch, drawer, drawerTitle, lab
83
86
  // STABLE PAGE COMPONENT (created once, outside render)
84
87
  // ============================================================================
85
88
  const GenericAdmissionPage = createGenericModulePage();
86
- // ============================================================================
87
- // INNER PAGE (requires AdmissionProvider context)
88
- // ============================================================================
89
89
  const AdmissionPageInner = (props) => {
90
90
  const context = useAdmissionModule();
91
91
  // Memoize config creation - destructure props to avoid object reference changes
@@ -133,4 +133,7 @@ const AdmissionPageInner = (props) => {
133
133
  }
134
134
  return (_jsx("div", { className: "p-4", children: _jsx(GenericAdmissionPage, { overrideConfig: admissionConfig, context: context, tableBodyCols: tableBodyCols }) }));
135
135
  };
136
+ // ============================================================================
137
+ // PAGE EXPORTS
138
+ // ============================================================================
136
139
  export const AdmissionPage = (props) => (_jsx(AdmissionProvider, { children: _jsx(AdmissionPageInner, Object.assign({}, props)) }));
@@ -1,4 +1,4 @@
1
- import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
1
+ import { type TableRow } from "@appcorp/shadcn/components/enhanced-table";
2
2
  import { DiscountCodeBE } from "../../type";
3
3
  export declare const DISCOUNT_CODE_DRAWER: {
4
4
  readonly FILTER_DRAWER: string;
@@ -19,14 +19,6 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
19
19
  readonly SET_ERRORS: "SET_ERRORS";
20
20
  readonly SET_FILTERS: "SET_FILTERS";
21
21
  }, discountCodeModuleConfig: import("@react-pakistan/util-functions/factory/generic-module-factory").ModuleConfig<{
22
- items: DiscountCodeBE[];
23
- count: number;
24
- currentPage: number;
25
- pageLimit: number;
26
- searchQuery: string;
27
- disableSaveButton: boolean;
28
- drawer: null;
29
- modal: null;
30
22
  code: string;
31
23
  description: string;
32
24
  discountType: string;
@@ -35,15 +27,15 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
35
27
  errors: Record<string, string>;
36
28
  filterEnabled: boolean | undefined;
37
29
  id: string;
38
- }>, initialDiscountCodeState: {
39
- items: DiscountCodeBE[];
40
30
  count: number;
31
+ items: DiscountCodeBE[];
41
32
  currentPage: number;
42
33
  pageLimit: number;
43
34
  searchQuery: string;
44
35
  disableSaveButton: boolean;
45
36
  drawer: null;
46
37
  modal: null;
38
+ }>, initialDiscountCodeState: {
47
39
  code: string;
48
40
  description: string;
49
41
  discountType: string;
@@ -52,17 +44,17 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
52
44
  errors: Record<string, string>;
53
45
  filterEnabled: boolean | undefined;
54
46
  id: string;
55
- }, DiscountCodeProvider: import("react").FC<{
56
- children: React.ReactNode;
57
- }>, discountCodeReducer: (state: {
58
- items: DiscountCodeBE[];
59
47
  count: number;
48
+ items: DiscountCodeBE[];
60
49
  currentPage: number;
61
50
  pageLimit: number;
62
51
  searchQuery: string;
63
52
  disableSaveButton: boolean;
64
53
  drawer: null;
65
54
  modal: null;
55
+ }, DiscountCodeProvider: import("react").FC<{
56
+ children: React.ReactNode;
57
+ }>, discountCodeReducer: (state: {
66
58
  code: string;
67
59
  description: string;
68
60
  discountType: string;
@@ -71,15 +63,15 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
71
63
  errors: Record<string, string>;
72
64
  filterEnabled: boolean | undefined;
73
65
  id: string;
74
- }, action: any) => {
75
- items: DiscountCodeBE[];
76
66
  count: number;
67
+ items: DiscountCodeBE[];
77
68
  currentPage: number;
78
69
  pageLimit: number;
79
70
  searchQuery: string;
80
71
  disableSaveButton: boolean;
81
72
  drawer: null;
82
73
  modal: null;
74
+ }, action: any) => {
83
75
  code: string;
84
76
  description: string;
85
77
  discountType: string;
@@ -88,15 +80,15 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
88
80
  errors: Record<string, string>;
89
81
  filterEnabled: boolean | undefined;
90
82
  id: string;
91
- }, useDiscountCodeStateContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContext<{
92
- items: DiscountCodeBE[];
93
83
  count: number;
84
+ items: DiscountCodeBE[];
94
85
  currentPage: number;
95
86
  pageLimit: number;
96
87
  searchQuery: string;
97
88
  disableSaveButton: boolean;
98
89
  drawer: null;
99
90
  modal: null;
91
+ }, useDiscountCodeStateContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContext<{
100
92
  code: string;
101
93
  description: string;
102
94
  discountType: string;
@@ -105,39 +97,32 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
105
97
  errors: Record<string, string>;
106
98
  filterEnabled: boolean | undefined;
107
99
  id: string;
100
+ count: number;
101
+ items: DiscountCodeBE[];
102
+ currentPage: number;
103
+ pageLimit: number;
104
+ searchQuery: string;
105
+ disableSaveButton: boolean;
106
+ drawer: null;
107
+ modal: null;
108
108
  }>;
109
109
  export declare const useDiscountCodeModule: () => {
110
- state: {
111
- items: DiscountCodeBE[];
112
- count: number;
113
- currentPage: number;
114
- pageLimit: number;
115
- searchQuery: string;
116
- disableSaveButton: boolean;
117
- drawer: null;
118
- modal: null;
119
- code: string;
120
- description: string;
121
- discountType: string;
122
- discountValue: number;
123
- enabled: boolean;
124
- errors: Record<string, string>;
125
- filterEnabled: boolean | undefined;
126
- id: string;
127
- };
128
- dispatch: import("react").Dispatch<any>;
129
110
  applyFilters: () => void;
130
111
  byIdLoading: boolean;
131
112
  clearFilters: () => void;
113
+ clearSearch: () => void;
114
+ closeDrawer: () => void;
132
115
  deleteLoading: boolean;
133
- handleChange: (field: string, value: string | number | boolean | undefined) => void;
134
- handleCloseDrawer: () => void;
116
+ handleChange: (key: string, value: string | number | boolean | string[]) => void;
135
117
  handleCreate: () => void;
136
118
  handleDelete: (row?: TableRow) => void;
137
119
  handleEdit: (row?: TableRow) => void;
138
120
  handleFilters: () => void;
121
+ handleMoreActions: () => void;
122
+ handleNextClick: () => void;
139
123
  handlePageChange: (page: number) => void;
140
- handlePageLimitChange: (limit: number) => void;
124
+ handlePageLimitChange: (k: string, value: object) => void;
125
+ handlePreviousClick: () => void;
141
126
  handleSearch: (query: string) => void;
142
127
  handleSubmit: () => void;
143
128
  handleView: (row?: TableRow) => void;
@@ -146,9 +131,34 @@ export declare const useDiscountCodeModule: () => {
146
131
  handleOnClick: () => void;
147
132
  label: string;
148
133
  order: number;
149
- icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
150
134
  }[];
135
+ listError: Error | undefined;
136
+ listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
151
137
  listLoading: boolean;
152
- rowActions: RowAction[];
138
+ rowActions: {
139
+ enabled: boolean;
140
+ handleOnClick: (row?: TableRow) => void;
141
+ label: string;
142
+ order: number;
143
+ }[];
153
144
  updateLoading: boolean;
145
+ state: {
146
+ code: string;
147
+ description: string;
148
+ discountType: string;
149
+ discountValue: number;
150
+ enabled: boolean;
151
+ errors: Record<string, string>;
152
+ filterEnabled: boolean | undefined;
153
+ id: string;
154
+ count: number;
155
+ items: DiscountCodeBE[];
156
+ currentPage: number;
157
+ pageLimit: number;
158
+ searchQuery: string;
159
+ disableSaveButton: boolean;
160
+ drawer: null;
161
+ modal: null;
162
+ };
163
+ dispatch: React.Dispatch<any>;
154
164
  };