@appcorp/fusion-storybook 0.1.66 → 0.1.68

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 (40) hide show
  1. package/base-modules/attendance/context.d.ts +5 -4
  2. package/base-modules/attendance/context.js +142 -111
  3. package/base-modules/attendance/page.d.ts +2 -0
  4. package/base-modules/attendance/page.js +8 -10
  5. package/base-modules/class/context.d.ts +19 -22
  6. package/base-modules/class/context.js +161 -134
  7. package/base-modules/class/page.d.ts +14 -6
  8. package/base-modules/class/page.js +25 -18
  9. package/base-modules/course/context.d.ts +4 -3
  10. package/base-modules/course/context.js +184 -142
  11. package/base-modules/course/page.d.ts +2 -0
  12. package/base-modules/course/page.js +7 -4
  13. package/base-modules/enrollment/context.d.ts +5 -4
  14. package/base-modules/enrollment/context.js +136 -105
  15. package/base-modules/enrollment/page.d.ts +2 -1
  16. package/base-modules/enrollment/page.js +8 -8
  17. package/base-modules/expense/context.d.ts +5 -4
  18. package/base-modules/expense/context.js +140 -126
  19. package/base-modules/expense/page.d.ts +3 -0
  20. package/base-modules/expense/page.js +8 -4
  21. package/base-modules/fee-structure/context.d.ts +6 -4
  22. package/base-modules/fee-structure/context.js +158 -119
  23. package/base-modules/fee-structure/page.d.ts +13 -7
  24. package/base-modules/fee-structure/page.js +18 -12
  25. package/base-modules/section/context.d.ts +19 -16
  26. package/base-modules/section/context.js +156 -117
  27. package/base-modules/section/page.d.ts +13 -6
  28. package/base-modules/section/page.js +23 -18
  29. package/base-modules/student-fee/context.d.ts +5 -3
  30. package/base-modules/student-fee/context.js +147 -130
  31. package/base-modules/student-fee/page.d.ts +3 -0
  32. package/base-modules/student-fee/page.js +8 -4
  33. package/base-modules/student-profile/context.js +5 -5
  34. package/base-modules/subject/context.d.ts +2 -1
  35. package/base-modules/subject/context.js +63 -44
  36. package/base-modules/subject/page.d.ts +13 -6
  37. package/base-modules/subject/page.js +24 -19
  38. package/base-modules/teacher/context.js +1 -1
  39. package/package.json +8 -8
  40. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
- import { RowAction, TableRow } from "@appcorp/shadcn/components/enhanced-table";
1
+ import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
2
2
  import { AttendanceBE, ATTENDANCE_STATUS, SchoolBE, StudentProfileBE } from "../../type";
3
3
  export declare const ATTENDANCE_DRAWER: {
4
4
  readonly FILTER_DRAWER: string;
@@ -120,26 +120,27 @@ export declare const useAttendanceModule: () => {
120
120
  applyFilters: () => void;
121
121
  byIdLoading: boolean;
122
122
  clearFilters: () => void;
123
+ clearSearch: () => void;
124
+ closeDrawer: () => void;
123
125
  deleteLoading: boolean;
124
126
  handleChange: (field: string, value: string | number | boolean | undefined) => void;
125
- handleCloseDrawer: () => void;
126
127
  handleCreate: () => void;
127
128
  handleDelete: (row?: TableRow) => void;
128
129
  handleEdit: (row?: TableRow) => void;
129
130
  handleFilters: () => void;
130
131
  handleMoreActions: () => void;
131
132
  handlePageChange: (page: number) => void;
132
- handlePageLimitChange: (limit: number) => void;
133
+ handlePageLimitChange: (k: string, value: object) => void;
133
134
  handleSearch: (query: string) => void;
134
135
  handleSubmit: () => void;
135
136
  handleView: (row?: TableRow) => void;
136
137
  headerActions: {
137
138
  enabled: boolean;
138
139
  handleOnClick: () => void;
139
- icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
140
140
  label: string;
141
141
  order: number;
142
142
  }[];
143
+ listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
143
144
  listLoading: boolean;
144
145
  rowActions: RowAction[];
145
146
  updateLoading: boolean;
@@ -16,7 +16,9 @@
16
16
  * - `AttendanceProvider` — provider component used by the page
17
17
  * - `useAttendanceModule()` — hook that returns handlers and state
18
18
  */
19
- import { useCallback, useEffect, useMemo } from "react";
19
+ import { useCallback, useEffect, useMemo, useRef } from "react";
20
+ import { useTheme } from "next-themes";
21
+ import { useTranslations } from "next-intl";
20
22
  import { isCreatedOrUpdated, validateForm, } from "@react-pakistan/util-functions";
21
23
  import { useModuleEntityV2, } from "@react-pakistan/util-functions/hooks/use-module-entity-v2";
22
24
  import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
@@ -26,24 +28,21 @@ import { ATTENDANCE_API_ROUTES, pageLimit } from "./constants";
26
28
  import { getCachedAttendances, invalidateAttendancesCache } from "./cache";
27
29
  import { attendanceFormValidation } from "./validate";
28
30
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
29
- import { Edit, Eye, Filter, MoreHorizontal, Plus } from "lucide-react";
30
31
  import { ATTENDANCE_STATUS, } from "../../type";
31
32
  import { getCachedWorkspaceSync } from "../workspace/cache";
32
33
  // ============================================================================
33
- // DRAWER TYPES
34
+ // 1.1 DRAWER TYPES
34
35
  // ============================================================================
35
36
  export const ATTENDANCE_DRAWER = {
36
37
  FILTER_DRAWER: DRAWER_TYPES.FILTER_DRAWER,
37
38
  FORM_DRAWER: DRAWER_TYPES.FORM_DRAWER,
38
- MORE_ACTIONS_DRAWER: "MORE_ACTIONS_DRAWER",
39
+ MORE_ACTIONS_DRAWER: DRAWER_TYPES.MORE_ACTIONS_DRAWER,
39
40
  VIEW_DRAWER: DRAWER_TYPES.VIEW_DRAWER,
40
41
  };
41
- // ============================================================================
42
- // CONFIGURATION
43
- // ============================================================================
44
42
  const attendanceConfig = {
45
43
  name: "Attendance",
46
44
  displayName: "Attendance",
45
+ drawerTypes: DRAWER_TYPES,
47
46
  initialState: {
48
47
  // List Data
49
48
  items: [],
@@ -69,25 +68,31 @@ const attendanceConfig = {
69
68
  school: undefined,
70
69
  studentProfile: undefined,
71
70
  },
72
- drawerTypes: DRAWER_TYPES,
73
71
  };
74
72
  // ============================================================================
75
- // CREATE ATTENDANCE MODULE
73
+ // 1.3 CREATE ATTENDANCE MODULE
76
74
  // ============================================================================
77
75
  export const { actionTypes: ATTENDANCE_ACTION_TYPES, config: attendanceModuleConfig, initialState: initialAttendanceState, Provider: AttendanceProvider, reducer: attendanceReducer, useContext: useAttendanceContext, } = createGenericModule(attendanceConfig);
78
76
  // ============================================================================
79
- // ENHANCED ATTENDANCE HOOK WITH API INTEGRATION
77
+ // 1.4 ENHANCED ATTENDANCE HOOK WITH API INTEGRATION
80
78
  // ============================================================================
81
79
  export const useAttendanceModule = () => {
82
80
  var _a;
83
81
  const context = useAttendanceContext();
84
- const { state, dispatch } = context;
85
- const debouncedQuery = useDebounce(state.searchQuery, 800);
82
+ const { dispatch } = context;
83
+ const state = context.state;
84
+ // ==========================================================================
85
+ // 1.4.1 STATE & CORE HOOKS
86
+ // ==========================================================================
87
+ const t = useTranslations("attendance");
88
+ const { theme } = useTheme();
86
89
  const workspace = getCachedWorkspaceSync();
87
90
  const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
88
- // ============================================================================
89
- // API PARAMETERS
90
- // ============================================================================
91
+ const listFetchNowRef = useRef(null);
92
+ const debouncedQuery = useDebounce(state.searchQuery, 800);
93
+ // ==========================================================================
94
+ // 1.4.2 API PARAMETERS
95
+ // ==========================================================================
91
96
  const listParams = useMemo(() => (Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.filterEnabled !== undefined
92
97
  ? { filterEnabled: String(state.filterEnabled) }
93
98
  : {}))), [
@@ -108,12 +113,16 @@ export const useAttendanceModule = () => {
108
113
  }), [state, schoolId]);
109
114
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
110
115
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
111
- // ============================================================================
112
- // TOAST UTILITY
113
- // ============================================================================
114
- const showToast = useCallback((message, variant) => {
115
- generateThemeToast({ description: message, variant });
116
- }, []);
116
+ // ==========================================================================
117
+ // 1.4.3 UTILITIES
118
+ // ==========================================================================
119
+ const showToast = useCallback((description, variant) => {
120
+ generateThemeToast({
121
+ description,
122
+ theme: theme,
123
+ variant,
124
+ });
125
+ }, [theme]);
117
126
  const resetFormAndCloseDrawer = useCallback(() => {
118
127
  dispatch({
119
128
  type: ATTENDANCE_ACTION_TYPES.SET_ERRORS,
@@ -128,43 +137,44 @@ export const useAttendanceModule = () => {
128
137
  payload: { drawer: null },
129
138
  });
130
139
  }, [dispatch]);
131
- // ============================================================================
132
- // API CALLBACKS
133
- // ============================================================================
134
- const listCallback = ({ data, error }) => {
140
+ // ==========================================================================
141
+ // 1.4.4 API CALLBACKS
142
+ // ==========================================================================
143
+ const listCallback = useCallback(({ data, error }) => {
135
144
  var _a;
136
145
  if (error) {
137
- showToast("Failed to fetch attendance records", TOAST_VARIANT.ERROR);
146
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
138
147
  return;
139
148
  }
140
149
  if (data) {
141
150
  const response = data;
142
- const items = (_a = response.items) !== null && _a !== void 0 ? _a : [];
143
- const count = typeof response.count === "number" ? response.count : 0;
144
151
  dispatch({
145
152
  type: ATTENDANCE_ACTION_TYPES.SET_ITEMS,
146
- payload: { items, count },
153
+ payload: {
154
+ items: (_a = response.items) !== null && _a !== void 0 ? _a : [],
155
+ count: typeof response.count === "number" ? response.count : 0,
156
+ },
147
157
  });
148
158
  }
149
- };
150
- const updateCallback = ({ data, error }) => {
151
- const isCreated = isCreatedOrUpdated(data);
159
+ }, [dispatch, showToast, t]);
160
+ const updateCallback = useCallback(({ data, error }) => {
161
+ var _a;
152
162
  if (error) {
153
- showToast(isCreated
154
- ? "Failed to create attendance record"
155
- : "Failed to update attendance record", TOAST_VARIANT.ERROR);
163
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
156
164
  return;
157
165
  }
158
166
  if (data) {
159
- showToast("Attendance record saved successfully", TOAST_VARIANT.SUCCESS);
167
+ showToast(isCreatedOrUpdated(data)
168
+ ? t("messagesAttendanceCreated")
169
+ : t("messagesAttendanceUpdated"), TOAST_VARIANT.SUCCESS);
160
170
  invalidateAttendancesCache();
161
- listFetchNow();
171
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
162
172
  resetFormAndCloseDrawer();
163
173
  }
164
- };
165
- const byIdCallback = ({ data, error }) => {
174
+ }, [resetFormAndCloseDrawer, showToast, t]);
175
+ const byIdCallback = useCallback(({ data, error }) => {
166
176
  if (error) {
167
- showToast("Failed to fetch attendance details", TOAST_VARIANT.ERROR);
177
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
168
178
  return;
169
179
  }
170
180
  if (data) {
@@ -173,21 +183,43 @@ export const useAttendanceModule = () => {
173
183
  payload: { form: Object.assign(Object.assign({}, data), { filterEnabled: undefined }) },
174
184
  });
175
185
  }
176
- };
177
- const deleteCallback = ({ data, error }) => {
186
+ }, [dispatch, showToast, t]);
187
+ const deleteCallback = useCallback(({ data, error }) => {
188
+ var _a;
178
189
  if (error) {
179
- showToast("Failed to delete attendance record", TOAST_VARIANT.ERROR);
190
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
180
191
  return;
181
192
  }
182
193
  if (data) {
183
- showToast("Attendance record deleted successfully", TOAST_VARIANT.SUCCESS);
194
+ showToast(t("messagesAttendanceDeleted"), TOAST_VARIANT.SUCCESS);
184
195
  invalidateAttendancesCache();
185
- listFetchNow();
196
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
186
197
  }
187
- };
188
- // ============================================================================
189
- // HANDLERS
190
- // ============================================================================
198
+ }, [showToast, t]);
199
+ // ==========================================================================
200
+ // 1.4.5 API HOOKS
201
+ // ==========================================================================
202
+ const { listFetchNow, listLoading, updateFetchNow, updateLoading, byIdFetchNow, deleteFetchNow, deleteLoading, byIdLoading, } = useModuleEntityV2({
203
+ byIdCallback,
204
+ byIdParams,
205
+ deleteCallback,
206
+ deleteParams,
207
+ listCallback,
208
+ listParams,
209
+ listUrl: ATTENDANCE_API_ROUTES.UNIT,
210
+ searchQuery: debouncedQuery,
211
+ unitByIdUrl: ATTENDANCE_API_ROUTES.UNIT,
212
+ unitUrl: ATTENDANCE_API_ROUTES.UNIT,
213
+ updateCallback,
214
+ updateParams,
215
+ headers: {
216
+ "Content-Type": "application/json",
217
+ "x-api-token": process.env.NEXT_PUBLIC_API_KEY,
218
+ },
219
+ });
220
+ // ==========================================================================
221
+ // 1.4.6 HANDLERS
222
+ // ==========================================================================
191
223
  const handleChange = useCallback((field, value) => {
192
224
  dispatch({
193
225
  type: ATTENDANCE_ACTION_TYPES.SET_ERRORS,
@@ -208,13 +240,18 @@ export const useAttendanceModule = () => {
208
240
  payload: { currentPage: page },
209
241
  });
210
242
  }, [dispatch]);
211
- const handlePageLimitChange = useCallback((limit) => {
243
+ const handlePageLimitChange = useCallback((k, value) => {
244
+ const val = Object.assign({}, value);
212
245
  dispatch({
213
246
  type: ATTENDANCE_ACTION_TYPES.SET_PAGE_LIMIT,
214
- payload: { pageLimit: limit },
247
+ payload: { pageLimit: Number(val.option) },
248
+ });
249
+ dispatch({
250
+ type: ATTENDANCE_ACTION_TYPES.SET_CURRENT_PAGE,
251
+ payload: { currentPage: 1 },
215
252
  });
216
253
  }, [dispatch]);
217
- const handleCloseDrawer = useCallback(() => {
254
+ const closeDrawer = useCallback(() => {
218
255
  resetFormAndCloseDrawer();
219
256
  }, [resetFormAndCloseDrawer]);
220
257
  const handleCreate = useCallback(() => {
@@ -246,30 +283,12 @@ export const useAttendanceModule = () => {
246
283
  type: ATTENDANCE_ACTION_TYPES.RESET_FORM,
247
284
  });
248
285
  }, [dispatch]);
249
- // ============================================================================
250
- // API HOOKS
251
- // ============================================================================
252
- const { listFetchNow, listLoading, updateFetchNow, updateLoading, byIdFetchNow, deleteFetchNow, deleteLoading, byIdLoading, } = useModuleEntityV2({
253
- byIdCallback,
254
- byIdParams,
255
- deleteCallback,
256
- deleteParams,
257
- listCallback,
258
- listParams,
259
- listUrl: ATTENDANCE_API_ROUTES.UNIT,
260
- searchQuery: debouncedQuery,
261
- unitByIdUrl: ATTENDANCE_API_ROUTES.UNIT,
262
- unitUrl: ATTENDANCE_API_ROUTES.UNIT,
263
- updateCallback,
264
- updateParams,
265
- headers: {
266
- "Content-Type": "application/json",
267
- "x-api-token": process.env.NEXT_PUBLIC_API_KEY,
268
- },
269
- });
270
- // ============================================================================
271
- // HANDLERS THAT USE API HOOKS (moved after API hooks)
272
- // ============================================================================
286
+ const clearSearch = useCallback(() => {
287
+ dispatch({
288
+ type: ATTENDANCE_ACTION_TYPES.SET_SEARCH_QUERY,
289
+ payload: { searchQuery: "" },
290
+ });
291
+ }, [dispatch]);
273
292
  const handleView = useCallback((row) => {
274
293
  byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
275
294
  dispatch({
@@ -285,12 +304,15 @@ export const useAttendanceModule = () => {
285
304
  });
286
305
  }, [byIdFetchNow, dispatch]);
287
306
  const handleDelete = useCallback((row) => {
288
- if (!confirm("Are you sure you want to delete this attendance record?"))
307
+ if (!confirm(t("messagesDeleteConfirmation")))
289
308
  return;
290
309
  deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
291
310
  body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id }),
292
311
  });
293
- }, [deleteFetchNow]);
312
+ }, [deleteFetchNow, t]);
313
+ // ==========================================================================
314
+ // 1.4.7 NETWORK ACTIONS
315
+ // ==========================================================================
294
316
  const handleSubmit = useCallback(() => {
295
317
  dispatch({
296
318
  type: ATTENDANCE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
@@ -313,64 +335,71 @@ export const useAttendanceModule = () => {
313
335
  type: ATTENDANCE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
314
336
  payload: { disabled: false },
315
337
  });
316
- showToast("Please fix the form errors", TOAST_VARIANT.ERROR);
338
+ showToast(t("messagesFormErrors"), TOAST_VARIANT.ERROR);
317
339
  },
318
340
  });
319
- }, [dispatch, updateParams, updateFetchNow, showToast]);
320
- // ============================================================================
321
- // HEADER / ROW ACTIONS
322
- // ============================================================================
341
+ }, [dispatch, updateParams, updateFetchNow, showToast, t]);
342
+ // ==========================================================================
343
+ // 1.4.8 HEADER & ROW ACTIONS
344
+ // ==========================================================================
323
345
  const headerActions = useMemo(() => [
324
346
  {
325
347
  enabled: false,
326
348
  handleOnClick: handleMoreActions,
327
- icon: MoreHorizontal,
328
- label: "More Actions",
329
- order: 1,
349
+ label: t("actionsButtonMoreActions"),
350
+ order: 0,
330
351
  },
331
352
  {
332
353
  enabled: true,
333
354
  handleOnClick: handleFilters,
334
- icon: Filter,
335
- label: "Filters",
336
- order: 2,
355
+ label: t("actionsButtonFilters"),
356
+ order: 1,
337
357
  },
338
358
  {
339
359
  enabled: true,
340
360
  handleOnClick: handleCreate,
341
- icon: Plus,
342
- label: "Add Attendance",
343
- order: 3,
361
+ label: t("actionsButtonAdd"),
362
+ order: 2,
344
363
  },
345
- ], [handleMoreActions, handleFilters, handleCreate]);
364
+ ], [handleCreate, handleFilters, handleMoreActions, t]);
346
365
  const rowActions = useMemo(() => [
347
366
  {
348
367
  enabled: true,
349
368
  handleOnClick: handleView,
350
- icon: Eye,
351
- label: "View",
352
- order: 1,
369
+ label: t("actionsButtonView"),
370
+ order: 0,
353
371
  },
354
372
  {
355
373
  enabled: true,
356
374
  handleOnClick: handleEdit,
357
- icon: Edit,
358
- label: "Edit",
359
- order: 2,
375
+ label: t("actionsButtonEdit"),
376
+ order: 1,
377
+ },
378
+ {
379
+ enabled: false,
380
+ handleOnClick: handleDelete,
381
+ label: t("actionsButtonDelete"),
382
+ order: 3,
383
+ variant: "destructive",
360
384
  },
361
- ], [handleView, handleEdit]);
385
+ ], [handleDelete, handleEdit, handleView, t]);
362
386
  const applyFilters = useCallback(() => {
363
387
  dispatch({
364
388
  type: ATTENDANCE_ACTION_TYPES.SET_CURRENT_PAGE,
365
389
  payload: { currentPage: 1 },
366
390
  });
367
391
  listFetchNow();
368
- handleCloseDrawer();
369
- }, [dispatch, listFetchNow, handleCloseDrawer]);
370
- // ============================================================================
371
- // EFFECTS
372
- // ============================================================================
392
+ closeDrawer();
393
+ }, [dispatch, listFetchNow, closeDrawer]);
394
+ // ==========================================================================
395
+ // 1.4.9 EFFECTS
396
+ // ==========================================================================
397
+ useEffect(() => {
398
+ listFetchNowRef.current = listFetchNow;
399
+ });
373
400
  useEffect(() => {
401
+ if (!schoolId)
402
+ return;
374
403
  (async () => {
375
404
  try {
376
405
  const { count, items } = await getCachedAttendances({
@@ -382,19 +411,20 @@ export const useAttendanceModule = () => {
382
411
  });
383
412
  }
384
413
  catch (_a) {
385
- showToast("Failed to fetch attendance records", TOAST_VARIANT.ERROR);
414
+ showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
386
415
  }
387
416
  })();
388
- }, [listParams, dispatch, showToast]);
389
- // ============================================================================
390
- // RETURN
391
- // ============================================================================
417
+ }, [listParams, dispatch, showToast, schoolId, t]);
418
+ // ==========================================================================
419
+ // 1.4.10 RETURN
420
+ // ==========================================================================
392
421
  return Object.assign(Object.assign({}, context), { applyFilters,
393
422
  byIdLoading,
394
423
  clearFilters,
424
+ clearSearch,
425
+ closeDrawer,
395
426
  deleteLoading,
396
427
  handleChange,
397
- handleCloseDrawer,
398
428
  handleCreate,
399
429
  handleDelete,
400
430
  handleEdit,
@@ -406,6 +436,7 @@ export const useAttendanceModule = () => {
406
436
  handleSubmit,
407
437
  handleView,
408
438
  headerActions,
439
+ listFetchNow,
409
440
  listLoading,
410
441
  rowActions,
411
442
  updateLoading });
@@ -8,6 +8,8 @@
8
8
  * the component type produced by createGenericModulePage never changes at
9
9
  * runtime, preventing the infinite-remount re-render loop)
10
10
  * - permission guard
11
+ *
12
+ * Exported utilities: `AttendancePage`
11
13
  */
12
14
  import { FC } from "react";
13
15
  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
  * Attendance Page Component
5
3
  *
@@ -10,7 +8,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
10
8
  * the component type produced by createGenericModulePage never changes at
11
9
  * runtime, preventing the infinite-remount re-render loop)
12
10
  * - permission guard
11
+ *
12
+ * Exported utilities: `AttendancePage`
13
13
  */
14
+ "use client";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
14
16
  import { useMemo } from "react";
15
17
  import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
16
18
  import { createGenericModulePage, } from "@react-pakistan/util-functions/factory/generic-component-factory";
@@ -86,9 +88,12 @@ const createAttendanceConfig = ({ cancelLabel, dispatch, drawerTitle, labelActio
86
88
  },
87
89
  };
88
90
  };
91
+ // ============================================================================
92
+ // STABLE PAGE COMPONENT (created once, outside render)
93
+ // ============================================================================
94
+ const GenericAttendancePage = createGenericModulePage();
89
95
  const AttendancePageInner = (props) => {
90
96
  const context = useAttendanceModule();
91
- // Create component instances with translation props
92
97
  const components = useMemo(() => createComponentInstances({
93
98
  labelAll: props.labelAll,
94
99
  labelEnabled: props.labelEnabled,
@@ -126,10 +131,8 @@ const AttendancePageInner = (props) => {
126
131
  props.labelStatusLate,
127
132
  props.labelStatusPresent,
128
133
  ]);
129
- // Memoize config creation - destructure props to avoid object reference changes
130
134
  const attendanceConfig = useMemo(() => createAttendanceConfig({
131
135
  dispatch: context.dispatch,
132
- drawer: context.state.drawer,
133
136
  cancelLabel: props.cancelLabel,
134
137
  drawerTitle: props.drawerTitle,
135
138
  labelActions: props.labelActions,
@@ -146,7 +149,6 @@ const AttendancePageInner = (props) => {
146
149
  components,
147
150
  }), [
148
151
  context.dispatch,
149
- context.state.drawer,
150
152
  props.cancelLabel,
151
153
  props.drawerTitle,
152
154
  props.labelActions,
@@ -171,8 +173,4 @@ const AttendancePageInner = (props) => {
171
173
  }
172
174
  return (_jsx("div", { className: "p-4", children: _jsx(GenericAttendancePage, { overrideConfig: attendanceConfig, context: context, tableBodyCols: tableBodyCols }) }));
173
175
  };
174
- // ============================================================================
175
- // STABLE PAGE COMPONENT (created once, outside render)
176
- // ============================================================================
177
- const GenericAttendancePage = createGenericModulePage();
178
176
  export const AttendancePage = (props) => (_jsx(AttendanceProvider, { children: _jsx(AttendancePageInner, Object.assign({}, props)) }));
@@ -26,15 +26,14 @@ export declare const CLASS_ACTION_TYPES: {
26
26
  searchQuery: string;
27
27
  disableSaveButton: boolean;
28
28
  drawer: string | null;
29
- isInitialLoading: boolean;
29
+ errors: Record<string, string>;
30
30
  code: string;
31
31
  description: string | null;
32
32
  enabled: boolean;
33
- errors: Record<string, string>;
34
- filterEnabled: boolean | undefined;
35
33
  id: string;
36
34
  name: string;
37
35
  schoolId: string;
36
+ filterEnabled: boolean | undefined;
38
37
  }>, initialClassState: {
39
38
  items: ClassBE[];
40
39
  count: number;
@@ -43,15 +42,14 @@ export declare const CLASS_ACTION_TYPES: {
43
42
  searchQuery: string;
44
43
  disableSaveButton: boolean;
45
44
  drawer: string | null;
46
- isInitialLoading: boolean;
45
+ errors: Record<string, string>;
47
46
  code: string;
48
47
  description: string | null;
49
48
  enabled: boolean;
50
- errors: Record<string, string>;
51
- filterEnabled: boolean | undefined;
52
49
  id: string;
53
50
  name: string;
54
51
  schoolId: string;
52
+ filterEnabled: boolean | undefined;
55
53
  }, ClassProvider: import("react").FC<{
56
54
  children: React.ReactNode;
57
55
  }>, classReducer: (state: {
@@ -62,15 +60,14 @@ export declare const CLASS_ACTION_TYPES: {
62
60
  searchQuery: string;
63
61
  disableSaveButton: boolean;
64
62
  drawer: string | null;
65
- isInitialLoading: boolean;
63
+ errors: Record<string, string>;
66
64
  code: string;
67
65
  description: string | null;
68
66
  enabled: boolean;
69
- errors: Record<string, string>;
70
- filterEnabled: boolean | undefined;
71
67
  id: string;
72
68
  name: string;
73
69
  schoolId: string;
70
+ filterEnabled: boolean | undefined;
74
71
  }, action: any) => {
75
72
  items: ClassBE[];
76
73
  count: number;
@@ -79,15 +76,14 @@ export declare const CLASS_ACTION_TYPES: {
79
76
  searchQuery: string;
80
77
  disableSaveButton: boolean;
81
78
  drawer: string | null;
82
- isInitialLoading: boolean;
79
+ errors: Record<string, string>;
83
80
  code: string;
84
81
  description: string | null;
85
82
  enabled: boolean;
86
- errors: Record<string, string>;
87
- filterEnabled: boolean | undefined;
88
83
  id: string;
89
84
  name: string;
90
85
  schoolId: string;
86
+ filterEnabled: boolean | undefined;
91
87
  }, useClassContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContext<{
92
88
  items: ClassBE[];
93
89
  count: number;
@@ -96,42 +92,44 @@ export declare const CLASS_ACTION_TYPES: {
96
92
  searchQuery: string;
97
93
  disableSaveButton: boolean;
98
94
  drawer: string | null;
99
- isInitialLoading: boolean;
95
+ errors: Record<string, string>;
100
96
  code: string;
101
97
  description: string | null;
102
98
  enabled: boolean;
103
- errors: Record<string, string>;
104
- filterEnabled: boolean | undefined;
105
99
  id: string;
106
100
  name: string;
107
101
  schoolId: string;
102
+ filterEnabled: boolean | undefined;
108
103
  }>;
109
104
  export declare const useClassModule: () => {
110
105
  applyFilters: () => void;
111
106
  byIdLoading: boolean;
112
107
  clearFilters: () => void;
108
+ clearSearch: () => void;
109
+ closeDrawer: () => void;
113
110
  deleteLoading: boolean;
114
- handleChange: (field: string, value: string | number | boolean | undefined) => void;
115
- handleCloseDrawer: () => void;
111
+ handleAvatar: (files: File[]) => void;
112
+ handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
116
113
  handleCreate: () => void;
117
114
  handleDelete: (row?: TableRow) => void;
118
115
  handleEdit: (row?: TableRow) => void;
119
116
  handleFilters: () => void;
120
117
  handleMoreActions: () => void;
121
118
  handlePageChange: (page: number) => void;
122
- handlePageLimitChange: (limit: number) => void;
119
+ handlePageLimitChange: (k: string, value: object) => void;
123
120
  handleSearch: (query: string) => void;
124
121
  handleSubmit: () => void;
125
122
  handleView: (row?: TableRow) => void;
126
123
  headerActions: {
127
124
  enabled: boolean;
128
125
  handleOnClick: () => void;
129
- icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
130
126
  label: string;
131
127
  order: number;
132
128
  }[];
129
+ listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
133
130
  listLoading: boolean;
134
131
  rowActions: RowAction[];
132
+ toggleStatus: (row?: TableRow) => void;
135
133
  updateLoading: boolean;
136
134
  state: {
137
135
  items: ClassBE[];
@@ -141,15 +139,14 @@ export declare const useClassModule: () => {
141
139
  searchQuery: string;
142
140
  disableSaveButton: boolean;
143
141
  drawer: string | null;
144
- isInitialLoading: boolean;
142
+ errors: Record<string, string>;
145
143
  code: string;
146
144
  description: string | null;
147
145
  enabled: boolean;
148
- errors: Record<string, string>;
149
- filterEnabled: boolean | undefined;
150
146
  id: string;
151
147
  name: string;
152
148
  schoolId: string;
149
+ filterEnabled: boolean | undefined;
153
150
  };
154
151
  dispatch: React.Dispatch<any>;
155
152
  };