@appcorp/fusion-storybook 0.2.42 → 0.2.45
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/filter.js +2 -2
- package/base-modules/admission/form.js +4 -4
- package/base-modules/attendance/filter.js +3 -1
- package/base-modules/attendance/form.js +2 -2
- package/base-modules/attendance/more-actions.js +2 -2
- package/base-modules/class/more-actions.js +47 -22
- package/base-modules/course/form.js +6 -6
- package/base-modules/discount-code/form.js +2 -2
- package/base-modules/enrollment/form.js +5 -5
- package/base-modules/enrollment/more-actions.js +48 -23
- package/base-modules/expense/filter.js +9 -3
- package/base-modules/expense/form.js +6 -6
- package/base-modules/fee-structure/form.js +6 -6
- package/base-modules/fee-structure/more-actions.js +45 -20
- package/base-modules/rbac/context.js +1 -1
- package/base-modules/rbac/form.js +3 -1
- package/base-modules/school/form.js +4 -1
- package/base-modules/section/form.js +2 -2
- package/base-modules/section/more-actions.js +47 -22
- package/base-modules/student-fee/filter.js +4 -1
- package/base-modules/student-fee/form.js +10 -7
- package/base-modules/student-profile/filter.js +3 -3
- package/base-modules/student-profile/form.js +4 -4
- package/base-modules/subject/more-actions.js +47 -22
- package/base-modules/teacher/form.js +2 -2
- package/base-modules/teacher/more-actions.js +45 -20
- package/base-modules/user/form.js +2 -2
- package/base-modules/workspace/form.js +2 -2
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -32,8 +32,8 @@ export const AdmissionFilter = () => {
|
|
|
32
32
|
label: t("filterAdmissionStatusLabel"),
|
|
33
33
|
info: t("filterByAdmissionStatus"),
|
|
34
34
|
options: ADMISSION_STATUS_OPTIONS.map((opt) => ({
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
value: opt.value,
|
|
36
|
+
label: admissionStatusLabelMap[opt.value] || opt.label,
|
|
37
37
|
})),
|
|
38
38
|
value: filterAdmissionStatus || "",
|
|
39
39
|
onValueChange: (value) => handleChange("filterAdmissionStatus", value),
|
|
@@ -44,8 +44,8 @@ export const AdmissionForm = () => {
|
|
|
44
44
|
required: true,
|
|
45
45
|
onValueChange: (value) => handleChange("gender", value),
|
|
46
46
|
options: GENDER_OPTIONS.map((g) => ({
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
value: g.value,
|
|
48
|
+
label: genderLabelMap[g.value] || g.label,
|
|
49
49
|
})),
|
|
50
50
|
placeholder: t("formGenderPlaceholder"),
|
|
51
51
|
searchEndpoint: ADMISSION_API_ROUTES.UNIT,
|
|
@@ -63,8 +63,8 @@ export const AdmissionForm = () => {
|
|
|
63
63
|
.map((code) => {
|
|
64
64
|
var _a;
|
|
65
65
|
return ({
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
value: code.code,
|
|
67
|
+
label: `${code.code} - ${code.discountValue}${code.discountType === "PERCENTAGE" ? "%" : (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.currency}`,
|
|
68
68
|
});
|
|
69
69
|
}),
|
|
70
70
|
placeholder: t("formDiscountCodePlaceholder"),
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useAttendanceModule } from "./context";
|
|
4
4
|
import { EnhancedRadio } from "@appcorp/shadcn/components/enhanced-radio";
|
|
5
|
+
import { useTranslations } from "next-intl";
|
|
5
6
|
export const AttendanceFilter = ({ labelAll, labelEnabled, labelDisabled, }) => {
|
|
7
|
+
const t = useTranslations("attendance");
|
|
6
8
|
const { state, handleChange } = useAttendanceModule();
|
|
7
9
|
const { filterEnabled } = state;
|
|
8
10
|
const filterEnabledValue = filterEnabled === undefined
|
|
@@ -10,7 +12,7 @@ export const AttendanceFilter = ({ labelAll, labelEnabled, labelDisabled, }) =>
|
|
|
10
12
|
: filterEnabled
|
|
11
13
|
? "true"
|
|
12
14
|
: "false";
|
|
13
|
-
return (_jsx("div", { className: "space-y-4", children: _jsx("div", { className: "grid grid-cols-1 gap-4", children: _jsx(EnhancedRadio, { label: "
|
|
15
|
+
return (_jsx("div", { className: "space-y-4", children: _jsx("div", { className: "grid grid-cols-1 gap-4", children: _jsx(EnhancedRadio, { label: t("filterOptionEnabled"), name: "filterEnabled", value: filterEnabledValue, options: [
|
|
14
16
|
{ label: labelAll, value: "undefined" },
|
|
15
17
|
{ label: labelEnabled, value: "true" },
|
|
16
18
|
{ label: labelDisabled, value: "false" },
|
|
@@ -24,8 +24,8 @@ export const AttendanceForm = () => {
|
|
|
24
24
|
label: t("formOptionStatus"),
|
|
25
25
|
onValueChange: (value) => handleChange("status", value),
|
|
26
26
|
options: ATTENDANCE_STATUS_OPTIONS.map((opt) => ({
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
value: opt.value,
|
|
28
|
+
label: attendanceStatusLabelMap[opt.value] || opt.label,
|
|
29
29
|
})),
|
|
30
30
|
placeholder: t("formStatusPlaceholder"),
|
|
31
31
|
required: true,
|
|
@@ -20,8 +20,8 @@ export const AttendanceMoreActions = ({ labelAttendanceStatus, labelCourse, labe
|
|
|
20
20
|
label: labelCourse,
|
|
21
21
|
onValueChange: (value) => setCourseId(value),
|
|
22
22
|
options: [{ id: "", code: "" }].map((c) => ({
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
value: c.id,
|
|
24
|
+
label: c.code.trim(),
|
|
25
25
|
})),
|
|
26
26
|
placeholder: labelCoursePlaceholder,
|
|
27
27
|
required: true,
|
|
@@ -67,13 +67,17 @@ async function pollBulkJob(jobId, signal, onProgress) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function formatErrorSummary(
|
|
70
|
+
function formatErrorSummary(
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
+
t, errors) {
|
|
71
73
|
if (!(errors === null || errors === void 0 ? void 0 : errors.length))
|
|
72
74
|
return "";
|
|
73
|
-
const lines = errors
|
|
75
|
+
const lines = errors
|
|
76
|
+
.slice(0, 5)
|
|
77
|
+
.map((e) => t("messagesBulkRowError", { row: e.row, error: e.error }));
|
|
74
78
|
const remaining = errors.length - 5;
|
|
75
79
|
if (remaining > 0)
|
|
76
|
-
lines.push(
|
|
80
|
+
lines.push(t("messagesBulkMoreRows", { count: remaining }));
|
|
77
81
|
return lines.join("\n");
|
|
78
82
|
}
|
|
79
83
|
export const ClassMoreActions = () => {
|
|
@@ -106,7 +110,7 @@ export const ClassMoreActions = () => {
|
|
|
106
110
|
const text = await file.text();
|
|
107
111
|
const records = converter.csv2json(text);
|
|
108
112
|
if (!Array.isArray(records) || records.length === 0) {
|
|
109
|
-
showErrorToast("
|
|
113
|
+
showErrorToast(t("messagesBulkCsvEmpty"));
|
|
110
114
|
return;
|
|
111
115
|
}
|
|
112
116
|
// Client-side validation — basic required field check
|
|
@@ -116,53 +120,71 @@ export const ClassMoreActions = () => {
|
|
|
116
120
|
const msgs = [];
|
|
117
121
|
if (method === "POST") {
|
|
118
122
|
if (!((_b = row.code) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
119
|
-
msgs.push("
|
|
123
|
+
msgs.push(t("validationRequiredCode"));
|
|
120
124
|
if (!((_c = row.name) === null || _c === void 0 ? void 0 : _c.trim()))
|
|
121
|
-
msgs.push("
|
|
125
|
+
msgs.push(t("validationRequiredName"));
|
|
122
126
|
}
|
|
123
127
|
else {
|
|
124
128
|
if (!((_d = row.id) === null || _d === void 0 ? void 0 : _d.trim()))
|
|
125
|
-
msgs.push("
|
|
129
|
+
msgs.push(t("validationRequiredIdForUpdate"));
|
|
126
130
|
}
|
|
127
131
|
if (msgs.length > 0) {
|
|
128
132
|
validationErrors.push({ row: i + 1, messages: msgs });
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
if (validationErrors.length > 0) {
|
|
132
|
-
const
|
|
136
|
+
const errorsList = validationErrors
|
|
133
137
|
.slice(0, 5)
|
|
134
|
-
.map((e) =>
|
|
138
|
+
.map((e) => t("messagesBulkRowError", {
|
|
139
|
+
row: e.row,
|
|
140
|
+
error: e.messages.join("; "),
|
|
141
|
+
}))
|
|
135
142
|
.join("\n");
|
|
136
143
|
const remaining = validationErrors.length - 5;
|
|
137
|
-
|
|
144
|
+
const errorsStr = remaining > 0
|
|
145
|
+
? `${errorsList}\n${t("messagesBulkMoreRows", { count: remaining })}`
|
|
146
|
+
: errorsList;
|
|
147
|
+
showErrorToast(t("messagesBulkValidationFailed", {
|
|
148
|
+
count: validationErrors.length,
|
|
149
|
+
errors: errorsStr,
|
|
150
|
+
}));
|
|
138
151
|
return;
|
|
139
152
|
}
|
|
140
153
|
try {
|
|
141
|
-
showInfoToast(
|
|
154
|
+
showInfoToast(t("messagesBulkJobQueued", { action: label, count: records.length }));
|
|
142
155
|
let jobId;
|
|
143
156
|
try {
|
|
144
157
|
jobId = await submitBulkJob(text, method, signal);
|
|
145
158
|
}
|
|
146
159
|
catch (submitError) {
|
|
147
|
-
showErrorToast(
|
|
160
|
+
showErrorToast(t("messagesBulkJobSubmitFailed", {
|
|
161
|
+
action: label,
|
|
162
|
+
error: submitError instanceof Error
|
|
163
|
+
? submitError.message
|
|
164
|
+
: t("unknownError"),
|
|
165
|
+
}));
|
|
148
166
|
return;
|
|
149
167
|
}
|
|
150
168
|
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
151
|
-
showInfoToast(
|
|
169
|
+
showInfoToast(t("messagesBulkProgress", { processed, total }));
|
|
152
170
|
});
|
|
153
171
|
if (signal.aborted)
|
|
154
172
|
return;
|
|
155
173
|
if (status.status === "completed") {
|
|
156
174
|
const r = status.results;
|
|
157
175
|
if (r && ((_e = r.errors) === null || _e === void 0 ? void 0 : _e.length) > 0) {
|
|
158
|
-
const summary = formatErrorSummary(r.errors);
|
|
159
|
-
showSuccessToast(
|
|
176
|
+
const summary = formatErrorSummary(t, r.errors);
|
|
177
|
+
showSuccessToast(`${t("messagesBulkResults", { created: r.created, updated: r.updated, skipped: r.skipped })}\n${summary}`);
|
|
160
178
|
}
|
|
161
179
|
else if (r) {
|
|
162
|
-
showSuccessToast(
|
|
180
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
181
|
+
created: r.created,
|
|
182
|
+
updated: r.updated,
|
|
183
|
+
skipped: r.skipped,
|
|
184
|
+
}));
|
|
163
185
|
}
|
|
164
186
|
else {
|
|
165
|
-
showSuccessToast("
|
|
187
|
+
showSuccessToast(t("messagesBulkSuccess"));
|
|
166
188
|
}
|
|
167
189
|
const schoolId = ((_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id) || "";
|
|
168
190
|
fetch(`${CLASS_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
@@ -189,17 +211,20 @@ export const ClassMoreActions = () => {
|
|
|
189
211
|
else {
|
|
190
212
|
const r = status.results;
|
|
191
213
|
const detail = ((_g = r === null || r === void 0 ? void 0 : r.errors) === null || _g === void 0 ? void 0 : _g.length)
|
|
192
|
-
? formatErrorSummary(r.errors)
|
|
193
|
-
: "
|
|
194
|
-
showErrorToast(
|
|
214
|
+
? formatErrorSummary(t, r.errors)
|
|
215
|
+
: t("unknownError");
|
|
216
|
+
showErrorToast(`${t("messagesBulkFailed", { action: label })}\n${detail}`);
|
|
195
217
|
}
|
|
196
218
|
}
|
|
197
219
|
catch (error) {
|
|
198
220
|
if (error.message === "Polling cancelled")
|
|
199
221
|
return;
|
|
200
|
-
showErrorToast(
|
|
222
|
+
showErrorToast(t("messagesBulkFailedDetail", {
|
|
223
|
+
action: label,
|
|
224
|
+
error: error instanceof Error ? error.message : t("unknownError"),
|
|
225
|
+
}));
|
|
201
226
|
}
|
|
202
|
-
}, [dispatch]);
|
|
227
|
+
}, [dispatch, t]);
|
|
203
228
|
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
204
229
|
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
205
230
|
const create = [
|
|
@@ -45,8 +45,8 @@ export const CourseForm = () => {
|
|
|
45
45
|
options: sections === null || sections === void 0 ? void 0 : sections.map((section) => {
|
|
46
46
|
var _a;
|
|
47
47
|
return ({
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
value: section.id,
|
|
49
|
+
label: ((_a = section.class) === null || _a === void 0 ? void 0 : _a.code)
|
|
50
50
|
? `${section.class.code}-${section.name}`
|
|
51
51
|
: section.name,
|
|
52
52
|
});
|
|
@@ -68,8 +68,8 @@ export const CourseForm = () => {
|
|
|
68
68
|
handleChange("subjectLabel", ((_a = subjects === null || subjects === void 0 ? void 0 : subjects.find((s) => s.id === value)) === null || _a === void 0 ? void 0 : _a.name) || "");
|
|
69
69
|
},
|
|
70
70
|
options: subjects === null || subjects === void 0 ? void 0 : subjects.map((subject) => ({
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
value: subject.id,
|
|
72
|
+
label: subject.name,
|
|
73
73
|
})),
|
|
74
74
|
placeholder: t("formSubjectPlaceholder"),
|
|
75
75
|
required: true,
|
|
@@ -92,8 +92,8 @@ export const CourseForm = () => {
|
|
|
92
92
|
: "");
|
|
93
93
|
},
|
|
94
94
|
options: teachers === null || teachers === void 0 ? void 0 : teachers.map((teacher) => ({
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
value: teacher.id,
|
|
96
|
+
label: `${teacher.firstName || ""} ${teacher.lastName || ""}`.trim() ||
|
|
97
97
|
teacher.teacherCode ||
|
|
98
98
|
teacher.id,
|
|
99
99
|
})),
|
|
@@ -34,8 +34,8 @@ export const DiscountCodeForm = () => {
|
|
|
34
34
|
label: t("formDiscountTypeLabel"),
|
|
35
35
|
onValueChange: (value) => handleChange("discountType", value),
|
|
36
36
|
options: DISCOUNT_TYPE_OPTIONS.map((opt) => ({
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
value: opt.value,
|
|
38
|
+
label: discountTypeLabelMap[opt.value] || opt.label,
|
|
39
39
|
})),
|
|
40
40
|
placeholder: t("formDiscountTypePlaceholder"),
|
|
41
41
|
required: true,
|
|
@@ -23,7 +23,7 @@ import { useTranslations } from "next-intl";
|
|
|
23
23
|
// COMPONENT
|
|
24
24
|
// ============================================================================
|
|
25
25
|
export const EnrollmentForm = () => {
|
|
26
|
-
const { state: { enabled, enrollmentDate, errors, sectionId, studentProfileId
|
|
26
|
+
const { state: { enabled, enrollmentDate, errors, sectionId, studentProfileId }, handleChange, } = useEnrollmentModule();
|
|
27
27
|
const t = useTranslations("enrollment");
|
|
28
28
|
const { enhancedComboboxElement: studentProfileIdCombo } = useEnhancedCombobox({
|
|
29
29
|
emptyText: t("formNoStudentEmpty"),
|
|
@@ -32,8 +32,8 @@ export const EnrollmentForm = () => {
|
|
|
32
32
|
label: t("formStudentLabel"),
|
|
33
33
|
onValueChange: (value) => handleChange("studentProfileId", value),
|
|
34
34
|
options: (getCachedStudentProfilesSync().items || []).map((s) => ({
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
value: s.id,
|
|
36
|
+
label: s.studentCode || s.id,
|
|
37
37
|
})),
|
|
38
38
|
placeholder: t("formStudentPlaceholder"),
|
|
39
39
|
required: true,
|
|
@@ -50,8 +50,8 @@ export const EnrollmentForm = () => {
|
|
|
50
50
|
options: (getCachedSectionsSync().items || []).map((s) => {
|
|
51
51
|
var _a;
|
|
52
52
|
return ({
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
value: s.id,
|
|
54
|
+
label: ((_a = s.class) === null || _a === void 0 ? void 0 : _a.code) ? `${s.class.code}-${s.name}` : s.name,
|
|
55
55
|
});
|
|
56
56
|
}),
|
|
57
57
|
placeholder: t("sectionPlaceholder"),
|
|
@@ -67,13 +67,15 @@ async function pollBulkJob(jobId, signal, onProgress) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function formatErrorSummary(errors) {
|
|
70
|
+
function formatErrorSummary(t, errors) {
|
|
71
71
|
if (!(errors === null || errors === void 0 ? void 0 : errors.length))
|
|
72
72
|
return "";
|
|
73
|
-
const lines = errors
|
|
73
|
+
const lines = errors
|
|
74
|
+
.slice(0, 5)
|
|
75
|
+
.map((e) => t("messagesBulkRowError", { row: e.row, error: e.error }));
|
|
74
76
|
const remaining = errors.length - 5;
|
|
75
77
|
if (remaining > 0)
|
|
76
|
-
lines.push(
|
|
78
|
+
lines.push(t("messagesBulkMoreRows", { count: remaining }));
|
|
77
79
|
return lines.join("\n");
|
|
78
80
|
}
|
|
79
81
|
export const EnrollmentMoreActions = () => {
|
|
@@ -106,7 +108,7 @@ export const EnrollmentMoreActions = () => {
|
|
|
106
108
|
const text = await file.text();
|
|
107
109
|
const records = converter.csv2json(text);
|
|
108
110
|
if (!Array.isArray(records) || records.length === 0) {
|
|
109
|
-
showErrorToast("
|
|
111
|
+
showErrorToast(t("messagesBulkCsvEmpty"));
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
// Client-side validation — basic required field check
|
|
@@ -116,15 +118,15 @@ export const EnrollmentMoreActions = () => {
|
|
|
116
118
|
const msgs = [];
|
|
117
119
|
if (method === "POST") {
|
|
118
120
|
if (!((_b = row.studentProfileId) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
119
|
-
msgs.push("
|
|
121
|
+
msgs.push(t("validationRequiredStudentProfileId"));
|
|
120
122
|
if (!((_c = row.sectionId) === null || _c === void 0 ? void 0 : _c.trim()))
|
|
121
|
-
msgs.push("
|
|
123
|
+
msgs.push(t("validationRequiredSectionId"));
|
|
122
124
|
if (!((_d = row.enrollmentDate) === null || _d === void 0 ? void 0 : _d.trim()))
|
|
123
|
-
msgs.push("
|
|
125
|
+
msgs.push(t("validationRequiredEnrollmentDate"));
|
|
124
126
|
}
|
|
125
127
|
else {
|
|
126
128
|
if (!((_e = row.id) === null || _e === void 0 ? void 0 : _e.trim()))
|
|
127
|
-
msgs.push("
|
|
129
|
+
msgs.push(t("validationRequiredIdForUpdate"));
|
|
128
130
|
}
|
|
129
131
|
if (msgs.length > 0) {
|
|
130
132
|
validationErrors.push({ row: i + 1, messages: msgs });
|
|
@@ -133,38 +135,58 @@ export const EnrollmentMoreActions = () => {
|
|
|
133
135
|
if (validationErrors.length > 0) {
|
|
134
136
|
const summary = validationErrors
|
|
135
137
|
.slice(0, 5)
|
|
136
|
-
.map((e) =>
|
|
138
|
+
.map((e) => t("messagesBulkRowError", {
|
|
139
|
+
row: e.row,
|
|
140
|
+
error: e.messages.join("; "),
|
|
141
|
+
}))
|
|
137
142
|
.join("\n");
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
showErrorToast(t("messagesBulkValidationFailed", {
|
|
144
|
+
count: validationErrors.length,
|
|
145
|
+
errors: summary,
|
|
146
|
+
}));
|
|
140
147
|
return;
|
|
141
148
|
}
|
|
142
149
|
try {
|
|
143
|
-
showInfoToast(
|
|
150
|
+
showInfoToast(t("messagesBulkJobQueued", { action: label, count: records.length }));
|
|
144
151
|
let jobId;
|
|
145
152
|
try {
|
|
146
153
|
jobId = await submitBulkJob(text, method, signal);
|
|
147
154
|
}
|
|
148
155
|
catch (submitError) {
|
|
149
|
-
showErrorToast(
|
|
156
|
+
showErrorToast(t("messagesBulkJobSubmitFailed", {
|
|
157
|
+
action: label,
|
|
158
|
+
error: submitError instanceof Error
|
|
159
|
+
? submitError.message
|
|
160
|
+
: t("unknownError"),
|
|
161
|
+
}));
|
|
150
162
|
return;
|
|
151
163
|
}
|
|
152
164
|
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
153
|
-
showInfoToast(
|
|
165
|
+
showInfoToast(t("messagesBulkProgress", { processed, total }));
|
|
154
166
|
});
|
|
155
167
|
if (signal.aborted)
|
|
156
168
|
return;
|
|
157
169
|
if (status.status === "completed") {
|
|
158
170
|
const r = status.results;
|
|
159
171
|
if (r && ((_f = r.errors) === null || _f === void 0 ? void 0 : _f.length) > 0) {
|
|
160
|
-
const summary = formatErrorSummary(r.errors);
|
|
161
|
-
showSuccessToast(
|
|
172
|
+
const summary = formatErrorSummary(t, r.errors);
|
|
173
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
174
|
+
created: r.created,
|
|
175
|
+
updated: r.updated,
|
|
176
|
+
skipped: r.skipped,
|
|
177
|
+
}) +
|
|
178
|
+
"\n" +
|
|
179
|
+
summary);
|
|
162
180
|
}
|
|
163
181
|
else if (r) {
|
|
164
|
-
showSuccessToast(
|
|
182
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
183
|
+
created: r.created,
|
|
184
|
+
updated: r.updated,
|
|
185
|
+
skipped: r.skipped,
|
|
186
|
+
}));
|
|
165
187
|
}
|
|
166
188
|
else {
|
|
167
|
-
showSuccessToast("
|
|
189
|
+
showSuccessToast(t("messagesBulkSuccess"));
|
|
168
190
|
}
|
|
169
191
|
const schoolId = ((_g = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _g === void 0 ? void 0 : _g.id) || "";
|
|
170
192
|
fetch(`${ENROLLMENT_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
@@ -191,17 +213,20 @@ export const EnrollmentMoreActions = () => {
|
|
|
191
213
|
else {
|
|
192
214
|
const r = status.results;
|
|
193
215
|
const detail = ((_h = r === null || r === void 0 ? void 0 : r.errors) === null || _h === void 0 ? void 0 : _h.length)
|
|
194
|
-
? formatErrorSummary(r.errors)
|
|
195
|
-
: "
|
|
196
|
-
showErrorToast(
|
|
216
|
+
? formatErrorSummary(t, r.errors)
|
|
217
|
+
: t("unknownError");
|
|
218
|
+
showErrorToast(t("messagesBulkFailed", { action: label }) + "\n" + detail);
|
|
197
219
|
}
|
|
198
220
|
}
|
|
199
221
|
catch (error) {
|
|
200
222
|
if (error.message === "Polling cancelled")
|
|
201
223
|
return;
|
|
202
|
-
showErrorToast(
|
|
224
|
+
showErrorToast(t("messagesBulkFailedDetail", {
|
|
225
|
+
action: label,
|
|
226
|
+
error: error instanceof Error ? error.message : t("unknownError"),
|
|
227
|
+
}));
|
|
203
228
|
}
|
|
204
|
-
}, [dispatch]);
|
|
229
|
+
}, [dispatch, t]);
|
|
205
230
|
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
206
231
|
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
207
232
|
const create = [
|
|
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
import { EnhancedRadio } from "@appcorp/shadcn/components/enhanced-radio";
|
|
10
10
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
11
11
|
import { useExpenseModule } from "./context";
|
|
12
|
-
import { EXPENSE_CATEGORY_OPTIONS, EXPENSE_STATUS_OPTIONS, EXPENSE_API_ROUTES } from "./constants";
|
|
12
|
+
import { EXPENSE_CATEGORY_OPTIONS, EXPENSE_STATUS_OPTIONS, EXPENSE_API_ROUTES, } from "./constants";
|
|
13
13
|
import { useTranslations } from "next-intl";
|
|
14
14
|
export const ExpenseFilter = () => {
|
|
15
15
|
const { state, handleChange } = useExpenseModule();
|
|
@@ -49,7 +49,10 @@ export const ExpenseFilter = () => {
|
|
|
49
49
|
info: t("filterByCategory"),
|
|
50
50
|
label: t("filterCategoryLabel"),
|
|
51
51
|
onValueChange: (value) => handleChange("filterCategory", value),
|
|
52
|
-
options: EXPENSE_CATEGORY_OPTIONS.map((opt) => ({
|
|
52
|
+
options: EXPENSE_CATEGORY_OPTIONS.map((opt) => ({
|
|
53
|
+
value: opt.value,
|
|
54
|
+
label: categoryLabelMap[opt.value] || opt.label,
|
|
55
|
+
})),
|
|
53
56
|
placeholder: t("filterAllCategoriesLabel"),
|
|
54
57
|
searchEndpoint: EXPENSE_API_ROUTES.UNIT,
|
|
55
58
|
searchPlaceholder: t("filterSearchCategoriesLabel"),
|
|
@@ -61,7 +64,10 @@ export const ExpenseFilter = () => {
|
|
|
61
64
|
info: t("filterByStatus"),
|
|
62
65
|
label: t("filterOptionStatus"),
|
|
63
66
|
onValueChange: (value) => handleChange("filterStatus", value),
|
|
64
|
-
options: EXPENSE_STATUS_OPTIONS.map((opt) => ({
|
|
67
|
+
options: EXPENSE_STATUS_OPTIONS.map((opt) => ({
|
|
68
|
+
value: opt.value,
|
|
69
|
+
label: statusLabelMap[opt.value] || opt.label,
|
|
70
|
+
})),
|
|
65
71
|
placeholder: t("filterAllStatusesLabel"),
|
|
66
72
|
searchEndpoint: EXPENSE_API_ROUTES.UNIT,
|
|
67
73
|
searchPlaceholder: t("filterSearchStatusLabel"),
|
|
@@ -60,8 +60,8 @@ export const ExpenseForm = () => {
|
|
|
60
60
|
label: t("formCategoryLabel"),
|
|
61
61
|
onValueChange: (value) => handleChange("category", value),
|
|
62
62
|
options: EXPENSE_CATEGORY_OPTIONS.map((opt) => ({
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
value: opt.value,
|
|
64
|
+
label: categoryLabelMap[opt.value] || opt.label,
|
|
65
65
|
})),
|
|
66
66
|
placeholder: t("formCategoryPlaceholder"),
|
|
67
67
|
required: true,
|
|
@@ -76,8 +76,8 @@ export const ExpenseForm = () => {
|
|
|
76
76
|
label: t("formOptionStatus"),
|
|
77
77
|
onValueChange: (value) => handleChange("status", value),
|
|
78
78
|
options: EXPENSE_STATUS_OPTIONS.map((opt) => ({
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
value: opt.value,
|
|
80
|
+
label: statusLabelMap[opt.value] || opt.label,
|
|
81
81
|
})),
|
|
82
82
|
placeholder: t("formStatusPlaceholder"),
|
|
83
83
|
required: true,
|
|
@@ -92,8 +92,8 @@ export const ExpenseForm = () => {
|
|
|
92
92
|
label: t("formPaymentMethodLabel"),
|
|
93
93
|
onValueChange: (value) => handleChange("paymentMethod", value),
|
|
94
94
|
options: PAYMENT_METHOD_OPTIONS.map((opt) => ({
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
value: opt.value,
|
|
96
|
+
label: paymentMethodLabelMap[opt.value] || opt.label,
|
|
97
97
|
})),
|
|
98
98
|
placeholder: t("formPaymentMethodPlaceholder"),
|
|
99
99
|
searchEndpoint: EXPENSE_API_ROUTES.UNIT,
|
|
@@ -51,8 +51,8 @@ export const FeeStructureForm = () => {
|
|
|
51
51
|
label: t("formOptionFeeType"),
|
|
52
52
|
onValueChange: (value) => handleChange("feeType", value),
|
|
53
53
|
options: FEE_TYPE_OPTIONS.map((opt) => ({
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
value: opt.value,
|
|
55
|
+
label: feeTypeLabelMap[opt.value] || opt.label,
|
|
56
56
|
})),
|
|
57
57
|
placeholder: t("formFeeTypePlaceholder"),
|
|
58
58
|
required: true,
|
|
@@ -67,8 +67,8 @@ export const FeeStructureForm = () => {
|
|
|
67
67
|
label: t("formOptionFrequency"),
|
|
68
68
|
onValueChange: (value) => handleChange("frequency", value),
|
|
69
69
|
options: FREQUENCY_OPTIONS.map((opt) => ({
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
value: opt.value,
|
|
71
|
+
label: frequencyLabelMap[opt.value] || opt.label,
|
|
72
72
|
})),
|
|
73
73
|
placeholder: t("formFrequencyPlaceholder"),
|
|
74
74
|
searchEndpoint: FEE_STRUCTURE_API_ROUTES.UNIT,
|
|
@@ -82,8 +82,8 @@ export const FeeStructureForm = () => {
|
|
|
82
82
|
label: t("formClassLabel"),
|
|
83
83
|
onValueChange: (value) => handleChange("classId", value || null),
|
|
84
84
|
options: classes === null || classes === void 0 ? void 0 : classes.map((cls) => ({
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
value: cls.id,
|
|
86
|
+
label: `${cls.name} (${cls.code})`,
|
|
87
87
|
})),
|
|
88
88
|
placeholder: t("formClassPlaceholder"),
|
|
89
89
|
searchEndpoint: FEE_STRUCTURE_API_ROUTES.UNIT,
|