@appcorp/fusion-storybook 0.5.23 → 0.5.27
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/student-fee/context/student-fee-api-provider.js +20 -14
- package/base-modules/student-fee/context/use-student-fee-module.d.ts +3 -3
- package/base-modules/student-fee/context/use-student-fee-module.js +63 -30
- package/base-modules/student-fee/form.js +8 -24
- package/base-modules/student-fee/more-actions.js +9 -9
- package/base-modules/student-fee/page.js +1 -1
- package/base-modules/student-profile/constants.d.ts +2 -24
- package/base-modules/student-profile/constants.js +2 -68
- package/base-modules/student-profile/context/module-base.d.ts +10 -0
- package/base-modules/student-profile/context/module-base.js +2 -0
- package/base-modules/student-profile/context/use-student-profile-module.d.ts +3 -1
- package/base-modules/student-profile/context/use-student-profile-module.js +113 -71
- package/base-modules/student-profile/filter.js +5 -22
- package/base-modules/student-profile/form.js +22 -46
- package/base-modules/student-profile/page.js +2 -4
- package/base-modules/subject/context.d.ts +7 -0
- package/base-modules/subject/context.js +68 -33
- package/base-modules/subject/form.js +1 -1
- package/base-modules/subject/more-actions.js +34 -13
- package/base-modules/subject/page.js +2 -2
- package/base-modules/subject/validate.js +2 -6
- package/base-modules/subject/view.js +1 -3
- package/base-modules/teacher/context.d.ts +6 -0
- package/base-modules/teacher/context.js +59 -33
- package/base-modules/teacher/date.d.ts +6 -0
- package/base-modules/teacher/date.js +13 -0
- package/base-modules/teacher/form.js +6 -25
- package/base-modules/teacher/more-actions.js +34 -13
- package/base-modules/teacher/validate.js +6 -7
- package/constants.d.ts +0 -2
- package/constants.js +0 -2
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/resolve-rbac-permissions.js +7 -4
- package/base-modules/student-profile/more-actions.d.ts +0 -1
- package/base-modules/student-profile/more-actions.js +0 -257
|
@@ -16,7 +16,7 @@ import { studentProfileFormValidation } from "../validate";
|
|
|
16
16
|
import { getCachedWorkspaceSync } from "../../workspace/cache";
|
|
17
17
|
import { useStudentProfileContext, STUDENT_PROFILE_ACTION_TYPES, STUDENT_PROFILE_DRAWER, } from "./module-base";
|
|
18
18
|
export const useStudentProfileModule = () => {
|
|
19
|
-
var _a, _b, _c;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f;
|
|
20
20
|
const context = useStudentProfileContext();
|
|
21
21
|
const { dispatch } = context;
|
|
22
22
|
const state = context.state;
|
|
@@ -27,20 +27,21 @@ export const useStudentProfileModule = () => {
|
|
|
27
27
|
const debouncedQuery = useDebounce(state.searchQuery, 800);
|
|
28
28
|
const listParams = useMemo(() => {
|
|
29
29
|
var _a;
|
|
30
|
-
return (Object.assign(Object.assign(Object.assign(
|
|
31
|
-
? { filterEnabled: String(state.
|
|
32
|
-
: {})), (state.
|
|
30
|
+
return (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.appliedFilterEnabled !== undefined
|
|
31
|
+
? { filterEnabled: String(state.appliedFilterEnabled) }
|
|
32
|
+
: {})), (state.appliedFilterStatus
|
|
33
|
+
? { filterStatus: state.appliedFilterStatus }
|
|
34
|
+
: {})));
|
|
33
35
|
}, [
|
|
36
|
+
state.appliedFilterEnabled,
|
|
37
|
+
state.appliedFilterStatus,
|
|
34
38
|
state.currentPage,
|
|
35
|
-
state.filterEnabled,
|
|
36
|
-
state.filterGender,
|
|
37
|
-
state.filterStatus,
|
|
38
39
|
state.pageLimit,
|
|
39
40
|
debouncedQuery,
|
|
40
41
|
(_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
41
42
|
]);
|
|
42
43
|
const updateParams = useMemo(() => {
|
|
43
|
-
var _a, _b;
|
|
44
|
+
var _a, _b, _c;
|
|
44
45
|
return ({
|
|
45
46
|
avatar: state.avatar,
|
|
46
47
|
bloodGroup: state.bloodGroup,
|
|
@@ -50,11 +51,12 @@ export const useStudentProfileModule = () => {
|
|
|
50
51
|
emergencyPhone: toE164Phone(state.emergencyPhone, (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.country),
|
|
51
52
|
enabled: state.enabled,
|
|
52
53
|
familyMemberId: state.familyMemberId,
|
|
54
|
+
remarks: (_b = state.remarks) !== null && _b !== void 0 ? _b : null,
|
|
53
55
|
firstName: state.firstName,
|
|
54
56
|
gender: state.gender,
|
|
55
57
|
id: state.id,
|
|
56
58
|
lastName: state.lastName,
|
|
57
|
-
phone: toE164Phone(state.phone, (
|
|
59
|
+
phone: toE164Phone(state.phone, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.country),
|
|
58
60
|
status: state.status,
|
|
59
61
|
studentCode: state.studentCode,
|
|
60
62
|
});
|
|
@@ -72,6 +74,7 @@ export const useStudentProfileModule = () => {
|
|
|
72
74
|
state.id,
|
|
73
75
|
state.lastName,
|
|
74
76
|
state.phone,
|
|
77
|
+
state.remarks,
|
|
75
78
|
state.status,
|
|
76
79
|
state.studentCode,
|
|
77
80
|
(_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country,
|
|
@@ -86,7 +89,18 @@ export const useStudentProfileModule = () => {
|
|
|
86
89
|
});
|
|
87
90
|
}, [theme]);
|
|
88
91
|
const resetFormAndCloseDrawer = useCallback(() => {
|
|
92
|
+
const appliedEnabled = state.appliedFilterEnabled;
|
|
93
|
+
const appliedStatus = state.appliedFilterStatus;
|
|
89
94
|
dispatch({ type: STUDENT_PROFILE_ACTION_TYPES.RESET_FORM });
|
|
95
|
+
dispatch({
|
|
96
|
+
type: STUDENT_PROFILE_ACTION_TYPES.SET_FILTERS,
|
|
97
|
+
payload: {
|
|
98
|
+
filters: {
|
|
99
|
+
appliedFilterEnabled: appliedEnabled,
|
|
100
|
+
appliedFilterStatus: appliedStatus,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
});
|
|
90
104
|
dispatch({
|
|
91
105
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_ERRORS,
|
|
92
106
|
payload: { errors: {} },
|
|
@@ -99,7 +113,7 @@ export const useStudentProfileModule = () => {
|
|
|
99
113
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_DRAWER,
|
|
100
114
|
payload: { drawer: null },
|
|
101
115
|
});
|
|
102
|
-
}, [dispatch]);
|
|
116
|
+
}, [dispatch, state.appliedFilterEnabled, state.appliedFilterStatus]);
|
|
103
117
|
const resetRecordFormState = useCallback(() => {
|
|
104
118
|
dispatch({
|
|
105
119
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_ERRORS,
|
|
@@ -141,37 +155,42 @@ export const useStudentProfileModule = () => {
|
|
|
141
155
|
},
|
|
142
156
|
});
|
|
143
157
|
}, [dispatch]);
|
|
158
|
+
const apiError = (data) => data === null || data === void 0 ? void 0 : data.error;
|
|
144
159
|
const listCallback = useCallback(({ data, error }) => {
|
|
145
|
-
var _a, _b;
|
|
160
|
+
var _a, _b, _c;
|
|
146
161
|
if (error) {
|
|
147
|
-
showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
162
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
148
163
|
return;
|
|
149
164
|
}
|
|
150
165
|
if (data) {
|
|
151
166
|
const response = data;
|
|
152
167
|
dispatch({
|
|
153
168
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_ITEMS,
|
|
154
|
-
payload: { items: (
|
|
169
|
+
payload: { items: (_b = response.items) !== null && _b !== void 0 ? _b : [], count: (_c = response.count) !== null && _c !== void 0 ? _c : 0 },
|
|
155
170
|
});
|
|
156
171
|
}
|
|
157
172
|
}, [dispatch, showToast, t]);
|
|
158
173
|
const updateCallback = useCallback(({ data, error }) => {
|
|
159
|
-
var _a;
|
|
174
|
+
var _a, _b;
|
|
160
175
|
if (error) {
|
|
161
|
-
|
|
176
|
+
dispatch({
|
|
177
|
+
type: STUDENT_PROFILE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
178
|
+
payload: { disabled: false },
|
|
179
|
+
});
|
|
180
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesUpdateFailed"), TOAST_VARIANT.ERROR);
|
|
162
181
|
return;
|
|
163
182
|
}
|
|
164
183
|
if (data) {
|
|
165
184
|
const isCreated = isCreatedOrUpdated(data);
|
|
166
185
|
showToast(isCreated ? t("messagesCreateSuccess") : t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
|
|
167
186
|
resetFormAndCloseDrawer();
|
|
168
|
-
(
|
|
187
|
+
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
169
188
|
}
|
|
170
|
-
}, [resetFormAndCloseDrawer, showToast, t]);
|
|
189
|
+
}, [dispatch, resetFormAndCloseDrawer, showToast, t]);
|
|
171
190
|
const byIdCallback = useCallback(({ data, error }) => {
|
|
172
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
191
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
173
192
|
if (error) {
|
|
174
|
-
showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
|
|
193
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
|
|
175
194
|
return;
|
|
176
195
|
}
|
|
177
196
|
if (data && typeof data === "object" && "id" in data) {
|
|
@@ -187,37 +206,37 @@ export const useStudentProfileModule = () => {
|
|
|
187
206
|
studentCode: sp.studentCode,
|
|
188
207
|
status: sp.status,
|
|
189
208
|
enabled: sp.enabled,
|
|
190
|
-
remarks: (
|
|
191
|
-
discountCodeId: (
|
|
192
|
-
firstName: (
|
|
193
|
-
lastName: (
|
|
194
|
-
dateOfBirth: (
|
|
195
|
-
gender: (
|
|
196
|
-
bloodGroup: (
|
|
197
|
-
phone: (
|
|
198
|
-
email: (
|
|
199
|
-
emergencyPhone: (
|
|
200
|
-
avatar: (
|
|
201
|
-
familyId: (
|
|
202
|
-
address: (
|
|
203
|
-
city: (
|
|
204
|
-
state: (
|
|
205
|
-
country: (
|
|
206
|
-
postalCode: (
|
|
209
|
+
remarks: (_b = sp.remarks) !== null && _b !== void 0 ? _b : null,
|
|
210
|
+
discountCodeId: (_c = sp.discountCodeId) !== null && _c !== void 0 ? _c : null,
|
|
211
|
+
firstName: (_d = fm === null || fm === void 0 ? void 0 : fm.firstName) !== null && _d !== void 0 ? _d : "",
|
|
212
|
+
lastName: (_e = fm === null || fm === void 0 ? void 0 : fm.lastName) !== null && _e !== void 0 ? _e : "",
|
|
213
|
+
dateOfBirth: (_f = fm === null || fm === void 0 ? void 0 : fm.dateOfBirth) !== null && _f !== void 0 ? _f : null,
|
|
214
|
+
gender: (_g = fm === null || fm === void 0 ? void 0 : fm.gender) !== null && _g !== void 0 ? _g : null,
|
|
215
|
+
bloodGroup: (_h = fm === null || fm === void 0 ? void 0 : fm.bloodGroup) !== null && _h !== void 0 ? _h : null,
|
|
216
|
+
phone: (_j = formatPhoneDisplay(fm === null || fm === void 0 ? void 0 : fm.phone)) !== null && _j !== void 0 ? _j : null,
|
|
217
|
+
email: (_k = fm === null || fm === void 0 ? void 0 : fm.email) !== null && _k !== void 0 ? _k : null,
|
|
218
|
+
emergencyPhone: (_l = formatPhoneDisplay(fm === null || fm === void 0 ? void 0 : fm.emergencyPhone)) !== null && _l !== void 0 ? _l : null,
|
|
219
|
+
avatar: (_m = fm === null || fm === void 0 ? void 0 : fm.avatar) !== null && _m !== void 0 ? _m : null,
|
|
220
|
+
familyId: (_o = fm === null || fm === void 0 ? void 0 : fm.familyId) !== null && _o !== void 0 ? _o : "",
|
|
221
|
+
address: (_p = family === null || family === void 0 ? void 0 : family.address) !== null && _p !== void 0 ? _p : null,
|
|
222
|
+
city: (_q = family === null || family === void 0 ? void 0 : family.city) !== null && _q !== void 0 ? _q : null,
|
|
223
|
+
state: (_r = family === null || family === void 0 ? void 0 : family.state) !== null && _r !== void 0 ? _r : null,
|
|
224
|
+
country: (_s = family === null || family === void 0 ? void 0 : family.country) !== null && _s !== void 0 ? _s : null,
|
|
225
|
+
postalCode: (_t = family === null || family === void 0 ? void 0 : family.postalCode) !== null && _t !== void 0 ? _t : null,
|
|
207
226
|
},
|
|
208
227
|
},
|
|
209
228
|
});
|
|
210
229
|
}
|
|
211
230
|
}, [dispatch, showToast, t]);
|
|
212
231
|
const deleteCallback = useCallback(({ data, error }) => {
|
|
213
|
-
var _a;
|
|
232
|
+
var _a, _b;
|
|
214
233
|
if (error) {
|
|
215
|
-
showToast(t("messagesDeleteFailed"), TOAST_VARIANT.ERROR);
|
|
234
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesDeleteFailed"), TOAST_VARIANT.ERROR);
|
|
216
235
|
return;
|
|
217
236
|
}
|
|
218
237
|
if (data) {
|
|
219
238
|
showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
|
|
220
|
-
(
|
|
239
|
+
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
221
240
|
}
|
|
222
241
|
}, [showToast, t]);
|
|
223
242
|
const { byIdFetchNow, byIdLoading, deleteFetchNow, deleteLoading, listFetchNow, listLoading, updateFetchNow, updateLoading, } = useModuleEntityV2({
|
|
@@ -253,10 +272,11 @@ export const useStudentProfileModule = () => {
|
|
|
253
272
|
});
|
|
254
273
|
}, [dispatch]);
|
|
255
274
|
const closeDrawer = useCallback(() => {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
275
|
+
dispatch({
|
|
276
|
+
type: STUDENT_PROFILE_ACTION_TYPES.SET_DRAWER,
|
|
277
|
+
payload: { drawer: null },
|
|
278
|
+
});
|
|
279
|
+
}, [dispatch]);
|
|
260
280
|
const handleCreate = useCallback(() => {
|
|
261
281
|
dispatch({
|
|
262
282
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_DRAWER,
|
|
@@ -280,18 +300,31 @@ export const useStudentProfileModule = () => {
|
|
|
280
300
|
});
|
|
281
301
|
}, [byIdFetchNow, dispatch, resetRecordFormState]);
|
|
282
302
|
const handleDelete = useCallback((row) => {
|
|
303
|
+
var _a;
|
|
283
304
|
if (!confirm(t("messagesDeleteConfirmation")))
|
|
284
305
|
return;
|
|
285
306
|
deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
|
|
286
|
-
body: JSON.stringify({
|
|
307
|
+
body: JSON.stringify({
|
|
308
|
+
id: row === null || row === void 0 ? void 0 : row.id,
|
|
309
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
310
|
+
}),
|
|
287
311
|
});
|
|
288
|
-
}, [deleteFetchNow, t]);
|
|
312
|
+
}, [deleteFetchNow, t, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id]);
|
|
289
313
|
const handleFilters = useCallback(() => {
|
|
314
|
+
dispatch({
|
|
315
|
+
type: STUDENT_PROFILE_ACTION_TYPES.SET_FILTERS,
|
|
316
|
+
payload: {
|
|
317
|
+
filters: {
|
|
318
|
+
filterEnabled: state.appliedFilterEnabled,
|
|
319
|
+
filterStatus: state.appliedFilterStatus,
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
});
|
|
290
323
|
dispatch({
|
|
291
324
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_DRAWER,
|
|
292
325
|
payload: { drawer: STUDENT_PROFILE_DRAWER.FILTER_DRAWER },
|
|
293
326
|
});
|
|
294
|
-
}, [dispatch]);
|
|
327
|
+
}, [dispatch, state.appliedFilterEnabled, state.appliedFilterStatus]);
|
|
295
328
|
const handleMoreActions = useCallback(() => {
|
|
296
329
|
dispatch({
|
|
297
330
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_DRAWER,
|
|
@@ -340,12 +373,21 @@ export const useStudentProfileModule = () => {
|
|
|
340
373
|
});
|
|
341
374
|
}, [dispatch]);
|
|
342
375
|
const applyFilters = useCallback(() => {
|
|
376
|
+
dispatch({
|
|
377
|
+
type: STUDENT_PROFILE_ACTION_TYPES.SET_FILTERS,
|
|
378
|
+
payload: {
|
|
379
|
+
filters: {
|
|
380
|
+
appliedFilterEnabled: state.filterEnabled,
|
|
381
|
+
appliedFilterStatus: state.filterStatus,
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
});
|
|
343
385
|
dispatch({
|
|
344
386
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
345
387
|
payload: { currentPage: 1 },
|
|
346
388
|
});
|
|
347
389
|
closeDrawer();
|
|
348
|
-
}, [dispatch, closeDrawer]);
|
|
390
|
+
}, [dispatch, closeDrawer, state.filterEnabled, state.filterStatus]);
|
|
349
391
|
const clearFilters = useCallback(() => {
|
|
350
392
|
dispatch({
|
|
351
393
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_FILTERS,
|
|
@@ -354,6 +396,8 @@ export const useStudentProfileModule = () => {
|
|
|
354
396
|
filterEnabled: undefined,
|
|
355
397
|
filterStatus: undefined,
|
|
356
398
|
filterGender: undefined,
|
|
399
|
+
appliedFilterEnabled: undefined,
|
|
400
|
+
appliedFilterStatus: undefined,
|
|
357
401
|
},
|
|
358
402
|
},
|
|
359
403
|
});
|
|
@@ -367,20 +411,21 @@ export const useStudentProfileModule = () => {
|
|
|
367
411
|
body: JSON.stringify(Object.assign(Object.assign({}, row), { enabled: !(row === null || row === void 0 ? void 0 : row.enabled) })),
|
|
368
412
|
});
|
|
369
413
|
}, [updateFetchNow]);
|
|
370
|
-
const handleWithdrawStudent = useCallback(
|
|
414
|
+
const handleWithdrawStudent = useCallback((row) => {
|
|
415
|
+
var _a;
|
|
371
416
|
if (!confirm(t("messagesWithdrawConfirmation")))
|
|
372
417
|
return;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
});
|
|
381
|
-
}, [
|
|
418
|
+
updateFetchNow(undefined, {
|
|
419
|
+
body: JSON.stringify({
|
|
420
|
+
id: row === null || row === void 0 ? void 0 : row.id,
|
|
421
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
422
|
+
status: STUDENT_STATUS.INACTIVE,
|
|
423
|
+
enabled: false,
|
|
424
|
+
}),
|
|
425
|
+
});
|
|
426
|
+
}, [t, updateFetchNow, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id]);
|
|
382
427
|
const handleReAdmitStudent = useCallback(async (row) => {
|
|
383
|
-
var _a;
|
|
428
|
+
var _a, _b;
|
|
384
429
|
if (!confirm(t("messagesReAdmitConfirmation")))
|
|
385
430
|
return;
|
|
386
431
|
const { data, error } = await fetchData({
|
|
@@ -390,16 +435,19 @@ export const useStudentProfileModule = () => {
|
|
|
390
435
|
"Content-Type": "application/json",
|
|
391
436
|
// "x-api-token": process.env.NEXT_PUBLIC_API_KEY!,
|
|
392
437
|
},
|
|
393
|
-
body: JSON.stringify({
|
|
438
|
+
body: JSON.stringify({
|
|
439
|
+
studentProfileId: row === null || row === void 0 ? void 0 : row.id,
|
|
440
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
441
|
+
}),
|
|
394
442
|
});
|
|
395
|
-
(
|
|
443
|
+
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
396
444
|
if (data) {
|
|
397
445
|
showToast(t("messagesReAdmitSuccess"), TOAST_VARIANT.SUCCESS);
|
|
398
446
|
}
|
|
399
447
|
if (error) {
|
|
400
448
|
showToast(t("messagesReAdmitFailed"), TOAST_VARIANT.ERROR);
|
|
401
449
|
}
|
|
402
|
-
}, [showToast, t]);
|
|
450
|
+
}, [showToast, t, (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id]);
|
|
403
451
|
const handleSubmit = useCallback(() => {
|
|
404
452
|
dispatch({
|
|
405
453
|
type: STUDENT_PROFILE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
@@ -427,25 +475,19 @@ export const useStudentProfileModule = () => {
|
|
|
427
475
|
});
|
|
428
476
|
}, [dispatch, updateParams, t, showToast, updateFetchNow]);
|
|
429
477
|
const headerActions = useMemo(() => [
|
|
430
|
-
{
|
|
431
|
-
enabled: true,
|
|
432
|
-
handleOnClick: handleMoreActions,
|
|
433
|
-
label: t("actionsButtonMoreActions"),
|
|
434
|
-
order: 1,
|
|
435
|
-
},
|
|
436
478
|
{
|
|
437
479
|
enabled: true,
|
|
438
480
|
handleOnClick: handleFilters,
|
|
439
481
|
label: t("actionsButtonFilters"),
|
|
440
|
-
order:
|
|
482
|
+
order: 1,
|
|
441
483
|
},
|
|
442
484
|
{
|
|
443
485
|
enabled: false,
|
|
444
486
|
handleOnClick: handleCreate,
|
|
445
487
|
label: t("actionsButtonAddStudentProfile"),
|
|
446
|
-
order:
|
|
488
|
+
order: 2,
|
|
447
489
|
},
|
|
448
|
-
], [handleCreate, handleFilters,
|
|
490
|
+
], [handleCreate, handleFilters, t]);
|
|
449
491
|
const rowActions = useMemo(() => [
|
|
450
492
|
{
|
|
451
493
|
enabled: true,
|
|
@@ -497,7 +539,7 @@ export const useStudentProfileModule = () => {
|
|
|
497
539
|
if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
|
|
498
540
|
return;
|
|
499
541
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
500
|
-
}, [dispatch, listParams, (
|
|
542
|
+
}, [dispatch, listParams, (_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id, showToast, t]);
|
|
501
543
|
return Object.assign(Object.assign({}, context), { applyFilters,
|
|
502
544
|
byIdLoading,
|
|
503
545
|
clearFilters,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { EnhancedRadio } from "@appcorp/shadcn/components/enhanced-radio";
|
|
4
|
-
import {
|
|
4
|
+
import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
|
|
5
5
|
import { useTranslations } from "next-intl";
|
|
6
6
|
import { useStudentProfileModule } from "./context";
|
|
7
7
|
import { STATUS_OPTIONS } from "./constants";
|
|
8
|
-
import { STUDENT_PROFILE_API_ROUTES } from "../../constants";
|
|
9
8
|
export const StudentProfileFilter = () => {
|
|
10
9
|
const t = useTranslations("studentProfile");
|
|
11
10
|
const context = useStudentProfileModule();
|
|
12
|
-
const { filterEnabled } = context.state;
|
|
11
|
+
const { filterEnabled, filterStatus } = context.state;
|
|
13
12
|
const { handleChange } = context;
|
|
14
13
|
const filterEnabledValue = filterEnabled === undefined
|
|
15
14
|
? "undefined"
|
|
@@ -21,28 +20,12 @@ export const StudentProfileFilter = () => {
|
|
|
21
20
|
INACTIVE: t("formOptionInactive"),
|
|
22
21
|
GRADUATED: t("formOptionGraduated"),
|
|
23
22
|
TRANSFERRED: t("formOptionTransferred"),
|
|
24
|
-
|
|
23
|
+
DROPPED: t("formOptionDropped"),
|
|
25
24
|
};
|
|
26
|
-
const {
|
|
27
|
-
id: "filterStatus",
|
|
28
|
-
label: t("filterStatusLabel"),
|
|
29
|
-
info: t("filterStatusInfo"),
|
|
30
|
-
options: [...STATUS_OPTIONS].map((opt) => ({
|
|
25
|
+
const filterStatusCombo = (_jsx(EnhancedCombobox, { emptyText: t("filterNoStatusFoundLabel"), id: "filterStatus", info: t("filterStatusInfo"), label: t("filterStatusLabel"), onValueChange: (value) => handleChange("filterStatus", value || undefined), options: [...STATUS_OPTIONS].map((opt) => ({
|
|
31
26
|
value: opt.value,
|
|
32
27
|
label: statusLabelMap[opt.value] || opt.label,
|
|
33
|
-
})),
|
|
34
|
-
value: "filterStatus",
|
|
35
|
-
onValueChange: (value) => handleChange("filterStatus", value),
|
|
36
|
-
searchEndpoint: STUDENT_PROFILE_API_ROUTES.UNIT,
|
|
37
|
-
placeholder: "",
|
|
38
|
-
formatSearchResult: (item) => {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
return ({
|
|
41
|
-
label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
|
|
42
|
-
value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
});
|
|
28
|
+
})), placeholder: t("filterOptionAll"), value: filterStatus || "" }));
|
|
46
29
|
return (_jsx("div", { className: "space-y-4", children: _jsxs("div", { className: "grid grid-cols-1 gap-4", children: [filterStatusCombo, _jsx(EnhancedRadio, { label: t("filterOptionEnabled"), name: "filterEnabled", value: filterEnabledValue, options: [
|
|
47
30
|
{ label: t("filterOptionAll"), value: "undefined" },
|
|
48
31
|
{ label: t("filterOptionEnabled"), value: "true" },
|
|
@@ -3,12 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
4
4
|
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
5
5
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
6
|
+
import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
|
|
6
7
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
7
8
|
import { useTranslations } from "next-intl";
|
|
8
9
|
import { useEffect } from "react";
|
|
9
10
|
import { useStudentProfileModule } from "./context";
|
|
10
11
|
import { STATUS_OPTIONS, GENDER_OPTIONS } from "./constants";
|
|
11
|
-
import {
|
|
12
|
+
import { DISCOUNT_CODE_API_ROUTES } from "../../constants";
|
|
12
13
|
import { formatPhone } from "@react-pakistan/util-functions/general/format-phone";
|
|
13
14
|
import { getTranslatedError } from "../../utils/get-translated-error";
|
|
14
15
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
@@ -16,7 +17,7 @@ import { API_METHODS } from "@react-pakistan/util-functions/constants/api-method
|
|
|
16
17
|
import { DISCOUNT_TYPE } from "../../type";
|
|
17
18
|
import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
|
|
18
19
|
export const StudentProfileForm = () => {
|
|
19
|
-
var _a, _b, _c;
|
|
20
|
+
var _a, _b, _c, _d, _e;
|
|
20
21
|
const t = useTranslations("studentProfile");
|
|
21
22
|
const genderLabelMap = {
|
|
22
23
|
MALE: t("formOptionMale"),
|
|
@@ -24,54 +25,28 @@ export const StudentProfileForm = () => {
|
|
|
24
25
|
OTHER: t("formOptionOther"),
|
|
25
26
|
};
|
|
26
27
|
const context = useStudentProfileModule();
|
|
27
|
-
const {
|
|
28
|
-
const stateValue = context.state.state;
|
|
28
|
+
const { dateOfBirth, discountCodeId, emergencyPhone, enabled, errors, firstName, gender, lastName, phone, remarks, status, } = context.state;
|
|
29
29
|
const { handleChange } = context;
|
|
30
|
-
const {
|
|
31
|
-
id: "gender",
|
|
32
|
-
info: t("formGenderInfo"),
|
|
33
|
-
label: t("formGenderLabel"),
|
|
34
|
-
onValueChange: (value) => handleChange("gender", value),
|
|
35
|
-
options: GENDER_OPTIONS.map((opt) => ({
|
|
30
|
+
const genderCombo = (_jsx(EnhancedCombobox, { emptyText: t("formGenderPlaceholder"), error: getTranslatedError({ errors, key: "gender", t }), id: "gender", info: t("formGenderInfo"), label: t("formGenderLabel"), onValueChange: (value) => handleChange("gender", value || null), options: GENDER_OPTIONS.map((opt) => ({
|
|
36
31
|
value: opt.value,
|
|
37
32
|
label: genderLabelMap[opt.value] || opt.label,
|
|
38
|
-
})),
|
|
39
|
-
|
|
40
|
-
searchEndpoint: STUDENT_PROFILE_API_ROUTES.UNIT,
|
|
41
|
-
formatSearchResult: (item) => {
|
|
42
|
-
var _a, _b;
|
|
43
|
-
return ({
|
|
44
|
-
label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
|
|
45
|
-
value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
value: gender,
|
|
49
|
-
});
|
|
50
|
-
const { enhancedComboboxElement: statusCombo } = useEnhancedCombobox({
|
|
51
|
-
id: "status",
|
|
52
|
-
info: t("formStatusInfo"),
|
|
53
|
-
label: t("formStatusLabel"),
|
|
54
|
-
onValueChange: (value) => handleChange("status", value),
|
|
55
|
-
options: STATUS_OPTIONS.map((opt) => ({
|
|
33
|
+
})), placeholder: t("formGenderPlaceholder"), value: gender || "" }));
|
|
34
|
+
const statusCombo = (_jsx(EnhancedCombobox, { emptyText: t("formStatusPlaceholder"), error: getTranslatedError({ errors, key: "status", t }), id: "status", info: t("formStatusInfo"), label: t("formStatusLabel"), onValueChange: (value) => handleChange("status", value), options: STATUS_OPTIONS.map((opt) => ({
|
|
56
35
|
value: opt.value,
|
|
57
|
-
label: opt.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
value: status,
|
|
70
|
-
});
|
|
36
|
+
label: opt.value === "ACTIVE"
|
|
37
|
+
? t("formOptionActive")
|
|
38
|
+
: opt.value === "INACTIVE"
|
|
39
|
+
? t("formOptionInactive")
|
|
40
|
+
: opt.value === "GRADUATED"
|
|
41
|
+
? t("formOptionGraduated")
|
|
42
|
+
: opt.value === "TRANSFERRED"
|
|
43
|
+
? t("formOptionTransferred")
|
|
44
|
+
: t("formOptionDropped"),
|
|
45
|
+
})), placeholder: t("formStatusPlaceholder"), required: true, value: status }));
|
|
71
46
|
const workspace = getCachedWorkspaceSync();
|
|
72
47
|
const currency = (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : "";
|
|
73
48
|
const { fetchNow: discountCodeFetchNow, data: discountCodes } = useFetch(DISCOUNT_CODE_API_ROUTES.UNIT, {
|
|
74
|
-
params: {
|
|
49
|
+
params: { schoolId: (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id },
|
|
75
50
|
method: API_METHODS.GET,
|
|
76
51
|
});
|
|
77
52
|
useEffect(() => {
|
|
@@ -83,13 +58,14 @@ export const StudentProfileForm = () => {
|
|
|
83
58
|
id: "discountCodeId",
|
|
84
59
|
info: "Optional discount code to apply",
|
|
85
60
|
label: "Discount Code",
|
|
86
|
-
onValueChange: (value) => handleChange("discountCodeId", value),
|
|
87
|
-
options: ((
|
|
61
|
+
onValueChange: (value) => handleChange("discountCodeId", value || null),
|
|
62
|
+
options: ((_d = discountCodes === null || discountCodes === void 0 ? void 0 : discountCodes.items) !== null && _d !== void 0 ? _d : []).map((code) => ({
|
|
88
63
|
value: code.id,
|
|
89
64
|
label: `${code.code} - ${code.discountValue}${code.discountType === DISCOUNT_TYPE.PERCENTAGE ? "%" : currency}`,
|
|
90
65
|
})),
|
|
91
66
|
placeholder: "Select discount code",
|
|
92
67
|
searchEndpoint: DISCOUNT_CODE_API_ROUTES.UNIT,
|
|
68
|
+
searchParams: { schoolId: (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id },
|
|
93
69
|
searchPlaceholder: "Search discount codes...",
|
|
94
70
|
formatSearchResult: (item) => {
|
|
95
71
|
const discountCode = item;
|
|
@@ -110,5 +86,5 @@ export const StudentProfileForm = () => {
|
|
|
110
86
|
}, placeholder: t("formPhonePlaceholder"), type: "tel", value: phone || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "emergencyPhone", t }), id: "emergencyPhone", info: t("formEmergencyPhoneInfo"), label: t("formEmergencyPhoneLabel"), onChange: (e) => {
|
|
111
87
|
var _a;
|
|
112
88
|
return handleChange("emergencyPhone", ((_a = formatPhone(e.target.value)) === null || _a === void 0 ? void 0 : _a.international) || e.target.value);
|
|
113
|
-
}, placeholder: t("formEmergencyPhonePlaceholder"), type: "tel", value: emergencyPhone || "" })] })
|
|
89
|
+
}, placeholder: t("formEmergencyPhonePlaceholder"), type: "tel", value: emergencyPhone || "" })] })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionAcademicInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4", children: [statusCombo, discountCodeIdCombo, _jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "remarks", t }), id: "remarks", info: t("formRemarksInfo"), label: t("formRemarksLabel"), onChange: (e) => handleChange("remarks", e.target.value), placeholder: t("formRemarksPlaceholder"), rows: 4, value: remarks || "" })] }), _jsx(EnhancedCheckbox, { checked: enabled, info: t("formEnabledInfo"), label: t("formEnabledLabel"), onCheckedChange: (checked) => handleChange("enabled", checked) })] })] }));
|
|
114
90
|
};
|
|
@@ -23,7 +23,6 @@ import { createGenericModulePage, } from "@react-pakistan/util-functions/factory
|
|
|
23
23
|
import { useStudentProfileModule, StudentProfileProvider, STUDENT_PROFILE_ACTION_TYPES, } from "./context";
|
|
24
24
|
import { StudentProfileFilter } from "./filter";
|
|
25
25
|
import { StudentProfileForm } from "./form";
|
|
26
|
-
import { StudentProfileMoreActions } from "./more-actions";
|
|
27
26
|
import { StudentProfileView } from "./view";
|
|
28
27
|
import { resolveRbacPermissions } from "../../utils/resolve-rbac-permissions";
|
|
29
28
|
import { RbacNoAccess } from "../../components/rbac-no-access";
|
|
@@ -67,7 +66,7 @@ const tableBodyCols = [
|
|
|
67
66
|
},
|
|
68
67
|
{
|
|
69
68
|
componentType: COMPONENT_TYPE.TEXT,
|
|
70
|
-
key: "
|
|
69
|
+
key: "emergencyPhone",
|
|
71
70
|
textFormatter: (val, row) => {
|
|
72
71
|
var _a;
|
|
73
72
|
const rowItem = row;
|
|
@@ -83,7 +82,6 @@ const tableBodyCols = [
|
|
|
83
82
|
const createComponentInstances = () => ({
|
|
84
83
|
filter: _jsx(StudentProfileFilter, {}),
|
|
85
84
|
form: _jsx(StudentProfileForm, {}),
|
|
86
|
-
moreActions: _jsx(StudentProfileMoreActions, {}),
|
|
87
85
|
view: _jsx(StudentProfileView, {}),
|
|
88
86
|
});
|
|
89
87
|
const createStudentProfileConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave, drawerFilterDescription, drawerFilterTitle, drawerFormDescription, drawerFormTitle, drawerMoreActionsDescription, drawerMoreActionsTitle, drawerViewDescription, drawerViewTitle, tableColumnHeaderActions, tableColumnHeaderClassSection, tableColumnHeaderComputerCode, tableColumnHeaderEmergencyPhone, tableColumnHeaderEnabled, tableColumnHeaderId, tableColumnHeaderName, tableColumnHeaderStudentCode, tableDescription, tableSearchPlaceholder, tableTitle, }) => {
|
|
@@ -111,7 +109,7 @@ const createStudentProfileConfig = ({ dispatch, drawerButtonCancel, drawerButton
|
|
|
111
109
|
drawerViewTitle,
|
|
112
110
|
filterContent: components.filter,
|
|
113
111
|
formContent: components.form,
|
|
114
|
-
moreActionsContent:
|
|
112
|
+
moreActionsContent: null,
|
|
115
113
|
saveLabel: drawerButtonSave,
|
|
116
114
|
searchPlaceholder: tableSearchPlaceholder,
|
|
117
115
|
tableDescription,
|
|
@@ -31,6 +31,7 @@ export declare const SUBJECT_ACTION_TYPES: {
|
|
|
31
31
|
enabled: boolean;
|
|
32
32
|
errors: Record<string, string>;
|
|
33
33
|
filterEnabled: boolean | undefined;
|
|
34
|
+
appliedFilterEnabled: boolean | undefined;
|
|
34
35
|
id: string;
|
|
35
36
|
name: string;
|
|
36
37
|
schoolId: string;
|
|
@@ -47,6 +48,7 @@ export declare const SUBJECT_ACTION_TYPES: {
|
|
|
47
48
|
enabled: boolean;
|
|
48
49
|
errors: Record<string, string>;
|
|
49
50
|
filterEnabled: boolean | undefined;
|
|
51
|
+
appliedFilterEnabled: boolean | undefined;
|
|
50
52
|
id: string;
|
|
51
53
|
name: string;
|
|
52
54
|
schoolId: string;
|
|
@@ -65,6 +67,7 @@ export declare const SUBJECT_ACTION_TYPES: {
|
|
|
65
67
|
enabled: boolean;
|
|
66
68
|
errors: Record<string, string>;
|
|
67
69
|
filterEnabled: boolean | undefined;
|
|
70
|
+
appliedFilterEnabled: boolean | undefined;
|
|
68
71
|
id: string;
|
|
69
72
|
name: string;
|
|
70
73
|
schoolId: string;
|
|
@@ -81,6 +84,7 @@ export declare const SUBJECT_ACTION_TYPES: {
|
|
|
81
84
|
enabled: boolean;
|
|
82
85
|
errors: Record<string, string>;
|
|
83
86
|
filterEnabled: boolean | undefined;
|
|
87
|
+
appliedFilterEnabled: boolean | undefined;
|
|
84
88
|
id: string;
|
|
85
89
|
name: string;
|
|
86
90
|
schoolId: string;
|
|
@@ -97,6 +101,7 @@ export declare const SUBJECT_ACTION_TYPES: {
|
|
|
97
101
|
enabled: boolean;
|
|
98
102
|
errors: Record<string, string>;
|
|
99
103
|
filterEnabled: boolean | undefined;
|
|
104
|
+
appliedFilterEnabled: boolean | undefined;
|
|
100
105
|
id: string;
|
|
101
106
|
name: string;
|
|
102
107
|
schoolId: string;
|
|
@@ -129,6 +134,7 @@ export declare const useSubjectModule: () => {
|
|
|
129
134
|
listLoading: boolean;
|
|
130
135
|
resetRecordFormState: () => void;
|
|
131
136
|
rowActions: RowAction[];
|
|
137
|
+
toggleStatus: (row?: TableRow) => void;
|
|
132
138
|
updateLoading: boolean;
|
|
133
139
|
handleCloseDrawer?: () => void;
|
|
134
140
|
state: {
|
|
@@ -144,6 +150,7 @@ export declare const useSubjectModule: () => {
|
|
|
144
150
|
enabled: boolean;
|
|
145
151
|
errors: Record<string, string>;
|
|
146
152
|
filterEnabled: boolean | undefined;
|
|
153
|
+
appliedFilterEnabled: boolean | undefined;
|
|
147
154
|
id: string;
|
|
148
155
|
name: string;
|
|
149
156
|
schoolId: string;
|