@appcorp/fusion-storybook 0.5.13 → 0.5.17

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 (52) hide show
  1. package/base-modules/class/context/use-class-module.d.ts +55 -0
  2. package/base-modules/class/context/use-class-module.js +421 -0
  3. package/base-modules/class/context.d.ts +27 -52
  4. package/base-modules/class/context.js +18 -415
  5. package/base-modules/class/filter.js +16 -6
  6. package/base-modules/class/form.js +19 -3
  7. package/base-modules/class/more-actions.js +48 -10
  8. package/base-modules/class/page.js +15 -5
  9. package/base-modules/class/validate.d.ts +2 -2
  10. package/base-modules/class/validate.js +7 -3
  11. package/base-modules/class/view.js +2 -4
  12. package/base-modules/discount-code/context/use-discount-code-module.d.ts +65 -0
  13. package/base-modules/discount-code/context/use-discount-code-module.js +402 -0
  14. package/base-modules/discount-code/context.d.ts +32 -80
  15. package/base-modules/discount-code/context.js +14 -430
  16. package/base-modules/discount-code/filter.d.ts +1 -10
  17. package/base-modules/discount-code/filter.js +34 -8
  18. package/base-modules/discount-code/form.js +9 -35
  19. package/base-modules/discount-code/page.js +39 -19
  20. package/base-modules/discount-code/validate.d.ts +2 -1
  21. package/base-modules/discount-code/validate.js +10 -3
  22. package/base-modules/discount-code/view.js +15 -4
  23. package/base-modules/enrollment/context.d.ts +6 -0
  24. package/base-modules/enrollment/context.js +69 -25
  25. package/base-modules/enrollment/date.d.ts +8 -0
  26. package/base-modules/enrollment/date.js +21 -0
  27. package/base-modules/enrollment/filter.js +1 -1
  28. package/base-modules/enrollment/form.js +55 -24
  29. package/base-modules/enrollment/more-actions.js +47 -10
  30. package/base-modules/enrollment/page.js +11 -14
  31. package/base-modules/enrollment/validate.d.ts +1 -0
  32. package/base-modules/enrollment/validate.js +3 -1
  33. package/base-modules/enrollment/view.js +11 -19
  34. package/base-modules/expense/context/expense-api-provider.js +22 -9
  35. package/base-modules/expense/context/shared.d.ts +35 -0
  36. package/base-modules/expense/context/shared.js +11 -3
  37. package/base-modules/expense/context/use-expense-module.d.ts +7 -1
  38. package/base-modules/expense/context/use-expense-module.js +58 -55
  39. package/base-modules/expense/filter.js +25 -57
  40. package/base-modules/expense/form.js +17 -74
  41. package/base-modules/expense/page.js +60 -29
  42. package/base-modules/expense/validate.d.ts +17 -11
  43. package/base-modules/expense/validate.js +35 -14
  44. package/constants.d.ts +1 -3
  45. package/constants.js +0 -2
  46. package/package.json +1 -1
  47. package/tsconfig.build.tsbuildinfo +1 -1
  48. package/utils/resolve-rbac-permissions.js +10 -6
  49. package/base-modules/discount-code/more-actions.d.ts +0 -9
  50. package/base-modules/discount-code/more-actions.js +0 -13
  51. package/base-modules/expense/more-actions.d.ts +0 -1
  52. package/base-modules/expense/more-actions.js +0 -265
@@ -0,0 +1,55 @@
1
+ import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
2
+ import { CampusBE, ClassBE } from "../../../type";
3
+ export declare const useClassModule: () => {
4
+ applyFilters: () => void;
5
+ byIdLoading: boolean;
6
+ campuses: CampusBE[];
7
+ clearFilters: () => void;
8
+ clearSearch: () => void;
9
+ closeDrawer: () => void;
10
+ deleteLoading: boolean;
11
+ handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
12
+ handleCreate: () => void;
13
+ handleDelete: (row?: TableRow) => void;
14
+ handleEdit: (row?: TableRow) => void;
15
+ handleFilters: () => void;
16
+ handlePageChange: (pageOrEvent?: unknown) => void;
17
+ handlePageLimitChange: (_k: string, value: object) => void;
18
+ handleSearch: (query: string) => void;
19
+ handleSubmit: () => void;
20
+ handleView: (row?: TableRow) => void;
21
+ headerActions: {
22
+ enabled: boolean;
23
+ handleOnClick: () => void;
24
+ label: string;
25
+ order: number;
26
+ }[];
27
+ listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
28
+ listLoading: boolean;
29
+ rowActions: RowAction[];
30
+ updateLoading: boolean;
31
+ handleCloseDrawer?: () => void;
32
+ state: {
33
+ items: ClassBE[];
34
+ count: number;
35
+ currentPage: number;
36
+ pageLimit: number;
37
+ searchQuery: string;
38
+ disableSaveButton: boolean;
39
+ drawer: string | null;
40
+ errors: Record<string, string>;
41
+ campusId: string | null;
42
+ campus: CampusBE | undefined;
43
+ code: string;
44
+ description: string;
45
+ enabled: boolean;
46
+ id: string;
47
+ name: string;
48
+ schoolId: string;
49
+ filterEnabled: boolean | undefined;
50
+ filterCampusId: string | undefined;
51
+ appliedFilterEnabled: boolean | undefined;
52
+ appliedFilterCampusId: string | undefined;
53
+ };
54
+ dispatch: React.Dispatch<any>;
55
+ };
@@ -0,0 +1,421 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ /**
14
+ * Class module business logic.
15
+ *
16
+ * Extracted from `context.tsx` so it can be unit-tested without loading the
17
+ * page/components (and their ESM-only UI package).
18
+ */
19
+ import { useCallback, useEffect, useMemo, useRef } from "react";
20
+ import { useTheme } from "next-themes";
21
+ import { useTranslations } from "next-intl";
22
+ import { isCreatedOrUpdated } from "@react-pakistan/util-functions/general/is-created-or-updated";
23
+ import { validateForm } from "@react-pakistan/util-functions/general/validate-form";
24
+ import { useModuleEntityV2, } from "@react-pakistan/util-functions/hooks/use-module-entity-v2";
25
+ import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
26
+ import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
27
+ import { API_METHODS } from "@react-pakistan/util-functions/constants/api-methods";
28
+ import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
29
+ import { CAMPUS_API_ROUTES, CLASS_API_ROUTES } from "../../../constants";
30
+ import { classFormValidation } from "../validate";
31
+ import { getCachedWorkspaceSync } from "../../workspace/cache";
32
+ import { CLASS_ACTION_TYPES, CLASS_DRAWER, useClassContext } from "../context";
33
+ export const useClassModule = () => {
34
+ var _a;
35
+ const context = useClassContext();
36
+ const { dispatch } = context;
37
+ const state = context.state;
38
+ const t = useTranslations("class");
39
+ const { theme } = useTheme();
40
+ const workspace = getCachedWorkspaceSync();
41
+ const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
42
+ const listFetchNowRef = useRef(null);
43
+ const debouncedQuery = useDebounce(state.searchQuery, 800);
44
+ // Enabled campuses for the picker/filter (school-scoped).
45
+ const { data: campusData, fetchNow: fetchCampuses } = useFetch(CAMPUS_API_ROUTES.UNIT, {
46
+ method: API_METHODS.GET,
47
+ params: { schoolId, filterEnabled: "true", pageLimit: 200 },
48
+ });
49
+ const campuses = useMemo(() => { var _a; return (_a = campusData === null || campusData === void 0 ? void 0 : campusData.items) !== null && _a !== void 0 ? _a : []; }, [campusData]);
50
+ const fetchCampusesRef = useRef(fetchCampuses);
51
+ useEffect(() => {
52
+ fetchCampusesRef.current = fetchCampuses;
53
+ }, [fetchCampuses]);
54
+ useEffect(() => {
55
+ if (schoolId)
56
+ fetchCampusesRef.current();
57
+ }, [schoolId]);
58
+ // ---------------------------------------------------------------------------
59
+ // API parameters
60
+ // ---------------------------------------------------------------------------
61
+ const listParams = useMemo(() => (Object.assign(Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.appliedFilterEnabled !== undefined
62
+ ? { filterEnabled: String(state.appliedFilterEnabled) }
63
+ : {})), (state.appliedFilterCampusId
64
+ ? { campusId: state.appliedFilterCampusId }
65
+ : {}))), [
66
+ state.appliedFilterCampusId,
67
+ state.appliedFilterEnabled,
68
+ state.currentPage,
69
+ state.pageLimit,
70
+ debouncedQuery,
71
+ schoolId,
72
+ ]);
73
+ const updateParams = useMemo(() => ({
74
+ campusId: state.campusId || null,
75
+ code: state.code,
76
+ description: state.description,
77
+ enabled: state.enabled,
78
+ id: state.id,
79
+ name: state.name,
80
+ schoolId: state.schoolId || schoolId,
81
+ }), [
82
+ state.campusId,
83
+ state.code,
84
+ state.description,
85
+ state.enabled,
86
+ state.id,
87
+ state.name,
88
+ state.schoolId,
89
+ schoolId,
90
+ ]);
91
+ // Single-record calls must carry the tenant.
92
+ const byIdParams = useMemo(() => ({ id: state.id, schoolId }), [state.id, schoolId]);
93
+ const deleteParams = useMemo(() => ({ id: state.id, schoolId }), [state.id, schoolId]);
94
+ // ---------------------------------------------------------------------------
95
+ // Utilities
96
+ // ---------------------------------------------------------------------------
97
+ const showToast = useCallback((description, variant) => {
98
+ generateThemeToast({
99
+ description,
100
+ theme: theme,
101
+ variant,
102
+ });
103
+ }, [theme]);
104
+ /** Clear the form without touching the applied filters. */
105
+ const resetFormFields = useCallback(() => {
106
+ dispatch({
107
+ type: CLASS_ACTION_TYPES.SET_FORM_DATA,
108
+ payload: {
109
+ form: {
110
+ campusId: null,
111
+ campus: undefined,
112
+ code: "",
113
+ description: "",
114
+ enabled: true,
115
+ id: "",
116
+ name: "",
117
+ schoolId,
118
+ },
119
+ },
120
+ });
121
+ dispatch({
122
+ type: CLASS_ACTION_TYPES.SET_ERRORS,
123
+ payload: { errors: {} },
124
+ });
125
+ dispatch({
126
+ type: CLASS_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
127
+ payload: { disabled: false },
128
+ });
129
+ }, [dispatch, schoolId]);
130
+ const resetFormAndCloseDrawer = useCallback(() => {
131
+ resetFormFields();
132
+ dispatch({
133
+ type: CLASS_ACTION_TYPES.SET_DRAWER,
134
+ payload: { drawer: null },
135
+ });
136
+ }, [dispatch, resetFormFields]);
137
+ // ---------------------------------------------------------------------------
138
+ // API callbacks
139
+ // ---------------------------------------------------------------------------
140
+ const listCallback = useCallback(({ data, error }) => {
141
+ var _a, _b;
142
+ if (error) {
143
+ showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
144
+ return;
145
+ }
146
+ if (data) {
147
+ const response = data;
148
+ dispatch({
149
+ type: CLASS_ACTION_TYPES.SET_ITEMS,
150
+ payload: { items: (_a = response.items) !== null && _a !== void 0 ? _a : [], count: (_b = response.count) !== null && _b !== void 0 ? _b : 0 },
151
+ });
152
+ }
153
+ }, [dispatch, showToast, t]);
154
+ const updateCallback = useCallback(({ data, error }) => {
155
+ if (error) {
156
+ showToast(t("messagesUpdateFailed"), TOAST_VARIANT.ERROR);
157
+ return;
158
+ }
159
+ if (data) {
160
+ const isCreated = isCreatedOrUpdated(data);
161
+ showToast(isCreated ? t("messagesCreateSuccess") : t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
162
+ // `useModuleEntityV2` schedules the list refresh.
163
+ resetFormAndCloseDrawer();
164
+ }
165
+ }, [resetFormAndCloseDrawer, showToast, t]);
166
+ const byIdCallback = useCallback(({ data, error }) => {
167
+ var _a, _b, _c;
168
+ if (error) {
169
+ showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
170
+ return;
171
+ }
172
+ if (data) {
173
+ const record = data;
174
+ dispatch({
175
+ type: CLASS_ACTION_TYPES.SET_FORM_DATA,
176
+ payload: {
177
+ form: Object.assign(Object.assign({}, record), { campusId: (_a = record.campusId) !== null && _a !== void 0 ? _a : null, description: (_b = record.description) !== null && _b !== void 0 ? _b : "", enabled: (_c = record.enabled) !== null && _c !== void 0 ? _c : true }),
178
+ },
179
+ });
180
+ }
181
+ }, [dispatch, showToast, t]);
182
+ const deleteCallback = useCallback(({ data, error }) => {
183
+ if (error) {
184
+ showToast(t("messagesDeleteFailed"), TOAST_VARIANT.ERROR);
185
+ return;
186
+ }
187
+ if (data) {
188
+ showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
189
+ }
190
+ }, [showToast, t]);
191
+ const { byIdFetchNow, byIdLoading, deleteFetchNow, deleteLoading, listFetchNow, listLoading, updateFetchNow, updateLoading, } = useModuleEntityV2({
192
+ byIdCallback,
193
+ byIdParams,
194
+ deleteCallback,
195
+ deleteParams,
196
+ listCallback,
197
+ listParams,
198
+ listUrl: CLASS_API_ROUTES.UNIT,
199
+ searchQuery: debouncedQuery,
200
+ unitByIdUrl: CLASS_API_ROUTES.UNIT,
201
+ unitUrl: CLASS_API_ROUTES.UNIT,
202
+ updateCallback,
203
+ updateParams,
204
+ headers: { "Content-Type": "application/json" },
205
+ });
206
+ // ---------------------------------------------------------------------------
207
+ // Handlers
208
+ // ---------------------------------------------------------------------------
209
+ const handleChange = useCallback((field, value) => {
210
+ let formatted = value;
211
+ if (field === "code" && typeof value === "string") {
212
+ formatted = value.toUpperCase();
213
+ }
214
+ dispatch({
215
+ type: CLASS_ACTION_TYPES.SET_ERRORS,
216
+ payload: { errors: {} },
217
+ });
218
+ dispatch({
219
+ type: CLASS_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
220
+ payload: { disabled: false },
221
+ });
222
+ dispatch({
223
+ type: CLASS_ACTION_TYPES.SET_INPUT_FIELD,
224
+ payload: { key: field, value: formatted !== null && formatted !== void 0 ? formatted : value },
225
+ });
226
+ }, [dispatch]);
227
+ const closeDrawer = useCallback(() => {
228
+ resetFormAndCloseDrawer();
229
+ }, [resetFormAndCloseDrawer]);
230
+ const handleCreate = useCallback(() => {
231
+ resetFormFields();
232
+ dispatch({
233
+ type: CLASS_ACTION_TYPES.SET_DRAWER,
234
+ payload: { drawer: CLASS_DRAWER.FORM_DRAWER },
235
+ });
236
+ }, [dispatch, resetFormFields]);
237
+ const handleView = useCallback((row) => {
238
+ byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
239
+ dispatch({
240
+ type: CLASS_ACTION_TYPES.SET_DRAWER,
241
+ payload: { drawer: CLASS_DRAWER.VIEW_DRAWER },
242
+ });
243
+ }, [byIdFetchNow, dispatch]);
244
+ const handleEdit = useCallback((row) => {
245
+ byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
246
+ dispatch({
247
+ type: CLASS_ACTION_TYPES.SET_DRAWER,
248
+ payload: { drawer: CLASS_DRAWER.FORM_DRAWER },
249
+ });
250
+ }, [byIdFetchNow, dispatch]);
251
+ const handleDelete = useCallback((row) => {
252
+ if (!confirm(t("messagesDeleteConfirmation")))
253
+ return;
254
+ deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
255
+ body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id, schoolId }),
256
+ });
257
+ }, [deleteFetchNow, schoolId, t]);
258
+ const handleFilters = useCallback(() => {
259
+ dispatch({
260
+ type: CLASS_ACTION_TYPES.SET_DRAWER,
261
+ payload: { drawer: CLASS_DRAWER.FILTER_DRAWER },
262
+ });
263
+ }, [dispatch]);
264
+ const handlePageChange = useCallback((pageOrEvent) => {
265
+ const page = typeof pageOrEvent === "number" && !isNaN(pageOrEvent)
266
+ ? pageOrEvent
267
+ : state.currentPage + 1;
268
+ dispatch({
269
+ type: CLASS_ACTION_TYPES.SET_CURRENT_PAGE,
270
+ payload: { currentPage: page },
271
+ });
272
+ }, [dispatch, state.currentPage]);
273
+ const handlePageLimitChange = useCallback((_k, value) => {
274
+ const val = Object.assign({}, value);
275
+ dispatch({
276
+ type: CLASS_ACTION_TYPES.SET_PAGE_LIMIT,
277
+ payload: { pageLimit: Number(val.option) },
278
+ });
279
+ dispatch({
280
+ type: CLASS_ACTION_TYPES.SET_CURRENT_PAGE,
281
+ payload: { currentPage: 1 },
282
+ });
283
+ }, [dispatch]);
284
+ const handleSearch = useCallback((query) => {
285
+ dispatch({
286
+ type: CLASS_ACTION_TYPES.SET_SEARCH_QUERY,
287
+ payload: { searchQuery: query },
288
+ });
289
+ }, [dispatch]);
290
+ const clearSearch = useCallback(() => {
291
+ dispatch({
292
+ type: CLASS_ACTION_TYPES.SET_SEARCH_QUERY,
293
+ payload: { searchQuery: "" },
294
+ });
295
+ }, [dispatch]);
296
+ const applyFilters = useCallback(() => {
297
+ dispatch({
298
+ type: CLASS_ACTION_TYPES.SET_FILTERS,
299
+ payload: {
300
+ filters: {
301
+ appliedFilterEnabled: state.filterEnabled,
302
+ appliedFilterCampusId: state.filterCampusId,
303
+ },
304
+ },
305
+ });
306
+ dispatch({
307
+ type: CLASS_ACTION_TYPES.SET_CURRENT_PAGE,
308
+ payload: { currentPage: 1 },
309
+ });
310
+ closeDrawer();
311
+ }, [closeDrawer, dispatch, state.filterCampusId, state.filterEnabled]);
312
+ const clearFilters = useCallback(() => {
313
+ dispatch({ type: CLASS_ACTION_TYPES.RESET_FORM });
314
+ dispatch({
315
+ type: CLASS_ACTION_TYPES.SET_CURRENT_PAGE,
316
+ payload: { currentPage: 1 },
317
+ });
318
+ }, [dispatch]);
319
+ // ---------------------------------------------------------------------------
320
+ // Submit
321
+ // ---------------------------------------------------------------------------
322
+ const handleSubmit = useCallback(() => {
323
+ dispatch({
324
+ type: CLASS_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
325
+ payload: { disabled: true },
326
+ });
327
+ validateForm({
328
+ params: updateParams,
329
+ schema: classFormValidation,
330
+ successCallback: () => {
331
+ const { id } = updateParams, createParams = __rest(updateParams, ["id"]);
332
+ updateFetchNow(undefined, {
333
+ body: JSON.stringify(id ? updateParams : createParams),
334
+ });
335
+ },
336
+ errorCallback: (errors) => {
337
+ dispatch({
338
+ type: CLASS_ACTION_TYPES.SET_ERRORS,
339
+ payload: { errors },
340
+ });
341
+ dispatch({
342
+ type: CLASS_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
343
+ payload: { disabled: false },
344
+ });
345
+ showToast(t("messagesFormErrors"), TOAST_VARIANT.ERROR);
346
+ },
347
+ });
348
+ }, [dispatch, showToast, t, updateFetchNow, updateParams]);
349
+ // ---------------------------------------------------------------------------
350
+ // Header & row actions
351
+ // ---------------------------------------------------------------------------
352
+ const headerActions = useMemo(() => [
353
+ {
354
+ enabled: true,
355
+ handleOnClick: handleFilters,
356
+ label: t("actionsButtonFilters"),
357
+ order: 1,
358
+ },
359
+ {
360
+ enabled: true,
361
+ handleOnClick: handleCreate,
362
+ label: t("actionsButtonAdd"),
363
+ order: 2,
364
+ },
365
+ ], [handleCreate, handleFilters, t]);
366
+ const rowActions = useMemo(() => [
367
+ {
368
+ enabled: true,
369
+ handleOnClick: handleView,
370
+ label: t("actionsButtonView"),
371
+ order: 1,
372
+ },
373
+ {
374
+ // Always editable so a disabled class can be re-enabled.
375
+ enabled: true,
376
+ handleOnClick: handleEdit,
377
+ label: t("actionsButtonEdit"),
378
+ order: 2,
379
+ },
380
+ {
381
+ // Only active records can be soft-deleted.
382
+ enabled: (row) => (row === null || row === void 0 ? void 0 : row.enabled) === true,
383
+ handleOnClick: handleDelete,
384
+ label: t("actionsButtonDelete"),
385
+ order: 3,
386
+ variant: "destructive",
387
+ },
388
+ ], [handleDelete, handleEdit, handleView, t]);
389
+ // ---------------------------------------------------------------------------
390
+ // Effects
391
+ // ---------------------------------------------------------------------------
392
+ useEffect(() => {
393
+ listFetchNowRef.current = listFetchNow;
394
+ }, [listFetchNow]);
395
+ useEffect(() => {
396
+ var _a;
397
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
398
+ }, [listParams]);
399
+ return Object.assign(Object.assign({}, context), { applyFilters,
400
+ byIdLoading,
401
+ campuses,
402
+ clearFilters,
403
+ clearSearch,
404
+ closeDrawer,
405
+ deleteLoading,
406
+ handleChange,
407
+ handleCreate,
408
+ handleDelete,
409
+ handleEdit,
410
+ handleFilters,
411
+ handlePageChange,
412
+ handlePageLimitChange,
413
+ handleSearch,
414
+ handleSubmit,
415
+ handleView,
416
+ headerActions,
417
+ listFetchNow,
418
+ listLoading,
419
+ rowActions,
420
+ updateLoading });
421
+ };
@@ -1,5 +1,4 @@
1
- import { ClassBE } from "../../type";
2
- import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
1
+ import { CampusBE, ClassBE } from "../../type";
3
2
  export declare const CLASS_DRAWER: {
4
3
  readonly FILTER_DRAWER: string;
5
4
  readonly FORM_DRAWER: string;
@@ -27,6 +26,8 @@ export declare const CLASS_ACTION_TYPES: {
27
26
  disableSaveButton: boolean;
28
27
  drawer: string | null;
29
28
  errors: Record<string, string>;
29
+ campusId: string | null;
30
+ campus: CampusBE | undefined;
30
31
  code: string;
31
32
  description: string;
32
33
  enabled: boolean;
@@ -34,6 +35,9 @@ export declare const CLASS_ACTION_TYPES: {
34
35
  name: string;
35
36
  schoolId: string;
36
37
  filterEnabled: boolean | undefined;
38
+ filterCampusId: string | undefined;
39
+ appliedFilterEnabled: boolean | undefined;
40
+ appliedFilterCampusId: string | undefined;
37
41
  }>, initialClassState: {
38
42
  items: ClassBE[];
39
43
  count: number;
@@ -43,6 +47,8 @@ export declare const CLASS_ACTION_TYPES: {
43
47
  disableSaveButton: boolean;
44
48
  drawer: string | null;
45
49
  errors: Record<string, string>;
50
+ campusId: string | null;
51
+ campus: CampusBE | undefined;
46
52
  code: string;
47
53
  description: string;
48
54
  enabled: boolean;
@@ -50,6 +56,9 @@ export declare const CLASS_ACTION_TYPES: {
50
56
  name: string;
51
57
  schoolId: string;
52
58
  filterEnabled: boolean | undefined;
59
+ filterCampusId: string | undefined;
60
+ appliedFilterEnabled: boolean | undefined;
61
+ appliedFilterCampusId: string | undefined;
53
62
  }, ClassProvider: import("react").FC<{
54
63
  children: React.ReactNode;
55
64
  }>, classReducer: (state: {
@@ -61,6 +70,8 @@ export declare const CLASS_ACTION_TYPES: {
61
70
  disableSaveButton: boolean;
62
71
  drawer: string | null;
63
72
  errors: Record<string, string>;
73
+ campusId: string | null;
74
+ campus: CampusBE | undefined;
64
75
  code: string;
65
76
  description: string;
66
77
  enabled: boolean;
@@ -68,6 +79,9 @@ export declare const CLASS_ACTION_TYPES: {
68
79
  name: string;
69
80
  schoolId: string;
70
81
  filterEnabled: boolean | undefined;
82
+ filterCampusId: string | undefined;
83
+ appliedFilterEnabled: boolean | undefined;
84
+ appliedFilterCampusId: string | undefined;
71
85
  }, action: any) => {
72
86
  items: ClassBE[];
73
87
  count: number;
@@ -77,6 +91,8 @@ export declare const CLASS_ACTION_TYPES: {
77
91
  disableSaveButton: boolean;
78
92
  drawer: string | null;
79
93
  errors: Record<string, string>;
94
+ campusId: string | null;
95
+ campus: CampusBE | undefined;
80
96
  code: string;
81
97
  description: string;
82
98
  enabled: boolean;
@@ -84,6 +100,9 @@ export declare const CLASS_ACTION_TYPES: {
84
100
  name: string;
85
101
  schoolId: string;
86
102
  filterEnabled: boolean | undefined;
103
+ filterCampusId: string | undefined;
104
+ appliedFilterEnabled: boolean | undefined;
105
+ appliedFilterCampusId: string | undefined;
87
106
  }, useClassContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
88
107
  items: ClassBE[];
89
108
  count: number;
@@ -93,6 +112,8 @@ export declare const CLASS_ACTION_TYPES: {
93
112
  disableSaveButton: boolean;
94
113
  drawer: string | null;
95
114
  errors: Record<string, string>;
115
+ campusId: string | null;
116
+ campus: CampusBE | undefined;
96
117
  code: string;
97
118
  description: string;
98
119
  enabled: boolean;
@@ -100,54 +121,8 @@ export declare const CLASS_ACTION_TYPES: {
100
121
  name: string;
101
122
  schoolId: string;
102
123
  filterEnabled: boolean | undefined;
124
+ filterCampusId: string | undefined;
125
+ appliedFilterEnabled: boolean | undefined;
126
+ appliedFilterCampusId: string | undefined;
103
127
  }>;
104
- export declare const useClassModule: () => {
105
- applyFilters: () => void;
106
- byIdLoading: boolean;
107
- clearFilters: () => void;
108
- clearSearch: () => void;
109
- closeDrawer: () => void;
110
- deleteLoading: boolean;
111
- handleAvatar: (files: File[]) => void;
112
- handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
113
- handleCreate: () => void;
114
- handleDelete: (row?: TableRow) => void;
115
- handleEdit: (row?: TableRow) => void;
116
- handleFilters: () => void;
117
- handleMoreActions: () => void;
118
- handlePageChange: (pageOrEvent?: unknown) => void;
119
- handlePageLimitChange: (k: string, value: object) => void;
120
- handleSearch: (query: string) => void;
121
- handleSubmit: () => void;
122
- handleView: (row?: TableRow) => void;
123
- headerActions: {
124
- enabled: boolean;
125
- handleOnClick: () => void;
126
- label: string;
127
- order: number;
128
- }[];
129
- listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
130
- listLoading: boolean;
131
- rowActions: RowAction[];
132
- toggleStatus: (row?: TableRow) => void;
133
- updateLoading: boolean;
134
- handleCloseDrawer?: () => void;
135
- state: {
136
- items: ClassBE[];
137
- count: number;
138
- currentPage: number;
139
- pageLimit: number;
140
- searchQuery: string;
141
- disableSaveButton: boolean;
142
- drawer: string | null;
143
- errors: Record<string, string>;
144
- code: string;
145
- description: string;
146
- enabled: boolean;
147
- id: string;
148
- name: string;
149
- schoolId: string;
150
- filterEnabled: boolean | undefined;
151
- };
152
- dispatch: React.Dispatch<any>;
153
- };
128
+ export { useClassModule } from "./context/use-class-module";