@appcorp/fusion-storybook 0.1.64 → 0.1.66
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.
- package/base-modules/admission/context.d.ts +1 -1
- package/base-modules/admission/context.js +138 -117
- package/base-modules/admission/page.d.ts +3 -0
- package/base-modules/admission/page.js +8 -5
- package/base-modules/family/context.d.ts +24 -22
- package/base-modules/family/context.js +122 -90
- package/base-modules/family/page.d.ts +3 -0
- package/base-modules/family/page.js +8 -7
- package/base-modules/family-member/context.d.ts +7 -5
- package/base-modules/family-member/context.js +160 -130
- package/base-modules/family-member/page.d.ts +3 -0
- package/base-modules/family-member/page.js +8 -7
- package/base-modules/student-profile/context.d.ts +35 -69
- package/base-modules/student-profile/context.js +241 -221
- package/base-modules/student-profile/page.d.ts +14 -4
- package/base-modules/student-profile/page.js +19 -12
- package/base-modules/teacher/context.d.ts +24 -21
- package/base-modules/teacher/context.js +188 -152
- package/base-modules/teacher/form.js +1 -1
- package/base-modules/teacher/page.d.ts +13 -7
- package/base-modules/teacher/page.js +18 -12
- package/base-modules/teacher/validate.d.ts +1 -0
- package/base-modules/teacher/validate.js +1 -0
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.d.ts +2 -2
|
@@ -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: (
|
|
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
|
|
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:
|
|
143
|
-
? { filterEnabled: String(
|
|
144
|
-
: {})), (
|
|
145
|
-
? { filterAdmissionStatus:
|
|
146
|
-
: {})), (
|
|
147
|
-
? { filterStartDate:
|
|
148
|
-
: {})), (
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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:
|
|
165
|
-
admissionNotes:
|
|
166
|
-
admissionStatus:
|
|
167
|
-
bForm:
|
|
168
|
-
city:
|
|
169
|
-
classForAdmission:
|
|
170
|
-
country:
|
|
171
|
-
discountCode:
|
|
172
|
-
dob:
|
|
173
|
-
emergencyContact:
|
|
174
|
-
enabled: (_a =
|
|
175
|
-
fatherCnic:
|
|
176
|
-
fatherFirstName:
|
|
177
|
-
fatherLastName:
|
|
178
|
-
fatherMobile:
|
|
179
|
-
fatherOccupation:
|
|
180
|
-
fatherOrganization:
|
|
181
|
-
firstName:
|
|
182
|
-
gender:
|
|
183
|
-
hafiz: (_b =
|
|
184
|
-
id:
|
|
185
|
-
lastName:
|
|
186
|
-
motherCnic:
|
|
187
|
-
motherFirstName:
|
|
188
|
-
motherLastName:
|
|
189
|
-
motherMobile:
|
|
190
|
-
notes:
|
|
191
|
-
orphan: (_c =
|
|
192
|
-
postalCode:
|
|
193
|
-
previousSchool:
|
|
194
|
-
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:
|
|
197
|
-
state:
|
|
201
|
+
siblings: state.siblings || "",
|
|
202
|
+
state: state.state || "",
|
|
198
203
|
});
|
|
199
204
|
}, [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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:
|
|
236
|
-
const deleteParams = useMemo(() => ({ 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((
|
|
241
|
-
generateThemeToast({
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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((
|
|
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:
|
|
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)) }));
|
|
@@ -123,30 +123,10 @@ export declare const FamilyStateContextProvider: import("react").FC<{
|
|
|
123
123
|
children: React.ReactNode;
|
|
124
124
|
}>;
|
|
125
125
|
export declare const useFamilyModule: () => {
|
|
126
|
-
state: {
|
|
127
|
-
items: FamilyBE[];
|
|
128
|
-
count: number;
|
|
129
|
-
currentPage: number;
|
|
130
|
-
pageLimit: number;
|
|
131
|
-
searchQuery: string;
|
|
132
|
-
disableSaveButton: boolean;
|
|
133
|
-
drawer: string | null;
|
|
134
|
-
address: string;
|
|
135
|
-
city: string;
|
|
136
|
-
country: string;
|
|
137
|
-
enabled: boolean;
|
|
138
|
-
errors: Record<string, string>;
|
|
139
|
-
familyCode: string;
|
|
140
|
-
filterEnabled: boolean | undefined;
|
|
141
|
-
id: string;
|
|
142
|
-
postalCode: string;
|
|
143
|
-
stateProvince: string;
|
|
144
|
-
userId: string;
|
|
145
|
-
};
|
|
146
|
-
dispatch: import("react").Dispatch<any>;
|
|
147
126
|
applyFilters: () => void;
|
|
148
127
|
byIdLoading: boolean;
|
|
149
128
|
clearFilters: () => void;
|
|
129
|
+
clearSearch: () => void;
|
|
150
130
|
deleteLoading: boolean;
|
|
151
131
|
handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
|
|
152
132
|
handleCloseDrawer: () => void;
|
|
@@ -156,7 +136,7 @@ export declare const useFamilyModule: () => {
|
|
|
156
136
|
handleFilters: () => void;
|
|
157
137
|
handleMoreActions: () => void;
|
|
158
138
|
handlePageChange: (page: number) => void;
|
|
159
|
-
handlePageLimitChange: (
|
|
139
|
+
handlePageLimitChange: (_k: string, value: object) => void;
|
|
160
140
|
handleSearch: (query: string) => void;
|
|
161
141
|
handleSubmit: () => void;
|
|
162
142
|
handleView: (row?: TableRow) => void;
|
|
@@ -167,7 +147,29 @@ export declare const useFamilyModule: () => {
|
|
|
167
147
|
order: number;
|
|
168
148
|
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
169
149
|
}[];
|
|
150
|
+
listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
|
|
170
151
|
listLoading: boolean;
|
|
171
152
|
rowActions: RowAction[];
|
|
172
153
|
updateLoading: boolean;
|
|
154
|
+
state: {
|
|
155
|
+
items: FamilyBE[];
|
|
156
|
+
count: number;
|
|
157
|
+
currentPage: number;
|
|
158
|
+
pageLimit: number;
|
|
159
|
+
searchQuery: string;
|
|
160
|
+
disableSaveButton: boolean;
|
|
161
|
+
drawer: string | null;
|
|
162
|
+
address: string;
|
|
163
|
+
city: string;
|
|
164
|
+
country: string;
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
errors: Record<string, string>;
|
|
167
|
+
familyCode: string;
|
|
168
|
+
filterEnabled: boolean | undefined;
|
|
169
|
+
id: string;
|
|
170
|
+
postalCode: string;
|
|
171
|
+
stateProvince: string;
|
|
172
|
+
userId: string;
|
|
173
|
+
};
|
|
174
|
+
dispatch: React.Dispatch<any>;
|
|
173
175
|
};
|