@appcorp/fusion-storybook 0.5.21 → 0.5.25
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/school/cache.js +0 -1
- package/base-modules/school/context.d.ts +0 -2
- package/base-modules/school/context.js +77 -18
- package/base-modules/school/drawer.js +1 -3
- package/base-modules/school/form.js +4 -23
- package/base-modules/school/page.js +2 -2
- package/base-modules/section/context.d.ts +6 -0
- package/base-modules/section/context.js +66 -34
- package/base-modules/section/form.js +2 -2
- package/base-modules/section/more-actions.js +71 -16
- package/base-modules/section/page.js +7 -3
- 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/constants.d.ts +3 -3
- 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/school/filter.d.ts +0 -1
- package/base-modules/school/filter.js +0 -13
- package/base-modules/school/more-actions.d.ts +0 -1
- package/base-modules/school/more-actions.js +0 -13
- package/base-modules/student-profile/more-actions.d.ts +0 -1
- package/base-modules/student-profile/more-actions.js +0 -257
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* - Status Options
|
|
9
9
|
* - Gender Options
|
|
10
10
|
*/
|
|
11
|
-
import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
|
|
12
11
|
// ============================================================================
|
|
13
12
|
// PAGE CONFIGURATION
|
|
14
13
|
// ============================================================================
|
|
@@ -16,71 +15,6 @@ export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
|
16
15
|
// ============================================================================
|
|
17
16
|
// TABLE CONFIGURATION
|
|
18
17
|
// ============================================================================
|
|
19
|
-
export const tableHeadItems = [
|
|
20
|
-
{ label: "ID", width: "5%" },
|
|
21
|
-
{ label: "First Name", width: "15%" },
|
|
22
|
-
{ label: "Last Name", width: "15%" },
|
|
23
|
-
{ label: "Computer Number", width: "15%" },
|
|
24
|
-
{ label: "Discount Code", width: "15%" },
|
|
25
|
-
{ label: "Enrolled Class", width: "15%" },
|
|
26
|
-
{ label: "Status", width: "10%" },
|
|
27
|
-
{ label: "Enabled", width: "5%" },
|
|
28
|
-
{ label: "Actions", width: "5%" },
|
|
29
|
-
];
|
|
30
|
-
export const tableBodyCols = [
|
|
31
|
-
{
|
|
32
|
-
componentType: COMPONENT_TYPE.ID,
|
|
33
|
-
key: "id",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
componentType: COMPONENT_TYPE.OBJECT,
|
|
37
|
-
key: ["familyMember:firstName"],
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
componentType: COMPONENT_TYPE.OBJECT,
|
|
41
|
-
key: ["familyMember:lastName"],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
componentType: COMPONENT_TYPE.TEXT,
|
|
45
|
-
key: "computerNumber",
|
|
46
|
-
textFormatter: (value) => {
|
|
47
|
-
const raw = value;
|
|
48
|
-
if (!raw)
|
|
49
|
-
return "N/A";
|
|
50
|
-
const parts = raw.split(":");
|
|
51
|
-
return parts[1] || raw;
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
componentType: COMPONENT_TYPE.TEXT,
|
|
56
|
-
key: "enrollments",
|
|
57
|
-
textFormatter: (value) => {
|
|
58
|
-
var _a, _b, _c, _d;
|
|
59
|
-
const enrollments = value;
|
|
60
|
-
if (!enrollments || enrollments.length === 0)
|
|
61
|
-
return "No enrollments";
|
|
62
|
-
if (enrollments.length === 1) {
|
|
63
|
-
const section = enrollments[0].section;
|
|
64
|
-
const courseCount = (_b = (_a = section === null || section === void 0 ? void 0 : section.courses) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
65
|
-
return courseCount > 0
|
|
66
|
-
? `${(_c = section === null || section === void 0 ? void 0 : section.name) !== null && _c !== void 0 ? _c : "Section"} (${courseCount} subjects)`
|
|
67
|
-
: ((_d = section === null || section === void 0 ? void 0 : section.name) !== null && _d !== void 0 ? _d : "Enrolled");
|
|
68
|
-
}
|
|
69
|
-
return `${enrollments.length} sections`;
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
componentType: COMPONENT_TYPE.TEXT,
|
|
74
|
-
key: "status",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
componentType: COMPONENT_TYPE.BOOLEAN,
|
|
78
|
-
key: "enabled",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
componentType: COMPONENT_TYPE.ACTIONS,
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
18
|
// ============================================================================
|
|
85
19
|
// STATUS OPTIONS
|
|
86
20
|
// ============================================================================
|
|
@@ -89,14 +23,14 @@ export const STATUS_OPTIONS = [
|
|
|
89
23
|
{ label: "Inactive", value: "INACTIVE" },
|
|
90
24
|
{ label: "Graduated", value: "GRADUATED" },
|
|
91
25
|
{ label: "Transferred", value: "TRANSFERRED" },
|
|
92
|
-
{ label: "
|
|
26
|
+
{ label: "Dropped", value: "DROPPED" },
|
|
93
27
|
];
|
|
94
28
|
export const STATUS_BADGE_COLORS = {
|
|
95
29
|
ACTIVE: "bg-green-500/10 text-green-700 dark:text-green-400",
|
|
96
30
|
INACTIVE: "bg-gray-500/10 text-gray-700 dark:text-gray-400",
|
|
97
31
|
GRADUATED: "bg-blue-500/10 text-blue-700 dark:text-blue-400",
|
|
98
32
|
TRANSFERRED: "bg-yellow-500/10 text-yellow-700 dark:text-yellow-400",
|
|
99
|
-
|
|
33
|
+
DROPPED: "bg-red-500/10 text-red-700 dark:text-red-400",
|
|
100
34
|
};
|
|
101
35
|
// ============================================================================
|
|
102
36
|
// GENDER OPTIONS
|
|
@@ -51,6 +51,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
51
51
|
filterEnabled: boolean | undefined;
|
|
52
52
|
filterGender: string | undefined;
|
|
53
53
|
filterStatus: string | undefined;
|
|
54
|
+
appliedFilterEnabled: boolean | undefined;
|
|
55
|
+
appliedFilterStatus: string | undefined;
|
|
54
56
|
}>, initialStudentProfileState: {
|
|
55
57
|
items: StudentProfileBE[];
|
|
56
58
|
count: number;
|
|
@@ -85,6 +87,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
85
87
|
filterEnabled: boolean | undefined;
|
|
86
88
|
filterGender: string | undefined;
|
|
87
89
|
filterStatus: string | undefined;
|
|
90
|
+
appliedFilterEnabled: boolean | undefined;
|
|
91
|
+
appliedFilterStatus: string | undefined;
|
|
88
92
|
}, StudentProfileProvider: import("react").FC<{
|
|
89
93
|
children: React.ReactNode;
|
|
90
94
|
}>, studentProfileReducer: (state: {
|
|
@@ -121,6 +125,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
121
125
|
filterEnabled: boolean | undefined;
|
|
122
126
|
filterGender: string | undefined;
|
|
123
127
|
filterStatus: string | undefined;
|
|
128
|
+
appliedFilterEnabled: boolean | undefined;
|
|
129
|
+
appliedFilterStatus: string | undefined;
|
|
124
130
|
}, action: any) => {
|
|
125
131
|
items: StudentProfileBE[];
|
|
126
132
|
count: number;
|
|
@@ -155,6 +161,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
155
161
|
filterEnabled: boolean | undefined;
|
|
156
162
|
filterGender: string | undefined;
|
|
157
163
|
filterStatus: string | undefined;
|
|
164
|
+
appliedFilterEnabled: boolean | undefined;
|
|
165
|
+
appliedFilterStatus: string | undefined;
|
|
158
166
|
}, useStudentProfileContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
159
167
|
items: StudentProfileBE[];
|
|
160
168
|
count: number;
|
|
@@ -189,4 +197,6 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
189
197
|
filterEnabled: boolean | undefined;
|
|
190
198
|
filterGender: string | undefined;
|
|
191
199
|
filterStatus: string | undefined;
|
|
200
|
+
appliedFilterEnabled: boolean | undefined;
|
|
201
|
+
appliedFilterStatus: string | undefined;
|
|
192
202
|
}>;
|
|
@@ -46,6 +46,8 @@ const studentProfileConfig = {
|
|
|
46
46
|
filterEnabled: undefined,
|
|
47
47
|
filterGender: undefined,
|
|
48
48
|
filterStatus: undefined,
|
|
49
|
+
appliedFilterEnabled: undefined,
|
|
50
|
+
appliedFilterStatus: undefined,
|
|
49
51
|
},
|
|
50
52
|
};
|
|
51
53
|
export const { actionTypes: STUDENT_PROFILE_ACTION_TYPES, config: studentProfileModuleConfig, initialState: initialStudentProfileState, Provider: StudentProfileProvider, reducer: studentProfileReducer, useContext: useStudentProfileContext, } = createGenericModule(studentProfileConfig);
|
|
@@ -20,7 +20,7 @@ export declare const useStudentProfileModule: () => {
|
|
|
20
20
|
handleSearch: (query: string) => void;
|
|
21
21
|
handleSubmit: () => void;
|
|
22
22
|
handleView: (row?: TableRow) => void;
|
|
23
|
-
handleWithdrawStudent: () =>
|
|
23
|
+
handleWithdrawStudent: (row?: TableRow) => void;
|
|
24
24
|
headerActions: {
|
|
25
25
|
enabled: boolean;
|
|
26
26
|
handleOnClick: () => void;
|
|
@@ -68,6 +68,8 @@ export declare const useStudentProfileModule: () => {
|
|
|
68
68
|
filterEnabled: boolean | undefined;
|
|
69
69
|
filterGender: string | undefined;
|
|
70
70
|
filterStatus: string | undefined;
|
|
71
|
+
appliedFilterEnabled: boolean | undefined;
|
|
72
|
+
appliedFilterStatus: string | undefined;
|
|
71
73
|
};
|
|
72
74
|
dispatch: React.Dispatch<any>;
|
|
73
75
|
};
|
|
@@ -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" },
|