@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
|
@@ -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 FeeStructureMoreActions = () => {
|
|
@@ -103,7 +105,7 @@ export const FeeStructureMoreActions = () => {
|
|
|
103
105
|
const text = await file.text();
|
|
104
106
|
const records = converter.csv2json(text);
|
|
105
107
|
if (!Array.isArray(records) || records.length === 0) {
|
|
106
|
-
showErrorToast("
|
|
108
|
+
showErrorToast(t("messagesBulkCsvEmpty"));
|
|
107
109
|
return;
|
|
108
110
|
}
|
|
109
111
|
const validationErrors = [];
|
|
@@ -118,7 +120,7 @@ export const FeeStructureMoreActions = () => {
|
|
|
118
120
|
}
|
|
119
121
|
else {
|
|
120
122
|
if (!((_b = row.id) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
121
|
-
msgs.push("
|
|
123
|
+
msgs.push(t("validationRequiredIdForUpdate"));
|
|
122
124
|
}
|
|
123
125
|
if (msgs.length > 0) {
|
|
124
126
|
validationErrors.push({ row: i + 1, messages: msgs });
|
|
@@ -127,38 +129,58 @@ export const FeeStructureMoreActions = () => {
|
|
|
127
129
|
if (validationErrors.length > 0) {
|
|
128
130
|
const summary = validationErrors
|
|
129
131
|
.slice(0, 5)
|
|
130
|
-
.map((e) =>
|
|
132
|
+
.map((e) => t("messagesBulkRowError", {
|
|
133
|
+
row: e.row,
|
|
134
|
+
error: e.messages.join("; "),
|
|
135
|
+
}))
|
|
131
136
|
.join("\n");
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
showErrorToast(t("messagesBulkValidationFailed", {
|
|
138
|
+
count: validationErrors.length,
|
|
139
|
+
errors: summary,
|
|
140
|
+
}));
|
|
134
141
|
return;
|
|
135
142
|
}
|
|
136
143
|
try {
|
|
137
|
-
showInfoToast(
|
|
144
|
+
showInfoToast(t("messagesBulkJobQueued", { action: label, count: records.length }));
|
|
138
145
|
let jobId;
|
|
139
146
|
try {
|
|
140
147
|
jobId = await submitBulkJob(text, method, signal);
|
|
141
148
|
}
|
|
142
149
|
catch (submitError) {
|
|
143
|
-
showErrorToast(
|
|
150
|
+
showErrorToast(t("messagesBulkJobSubmitFailed", {
|
|
151
|
+
action: label,
|
|
152
|
+
error: submitError instanceof Error
|
|
153
|
+
? submitError.message
|
|
154
|
+
: t("unknownError"),
|
|
155
|
+
}));
|
|
144
156
|
return;
|
|
145
157
|
}
|
|
146
158
|
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
147
|
-
showInfoToast(
|
|
159
|
+
showInfoToast(t("messagesBulkProgress", { processed, total }));
|
|
148
160
|
});
|
|
149
161
|
if (signal.aborted)
|
|
150
162
|
return;
|
|
151
163
|
if (status.status === "completed") {
|
|
152
164
|
const r = status.results;
|
|
153
165
|
if (r && ((_c = r.errors) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
154
|
-
const summary = formatErrorSummary(r.errors);
|
|
155
|
-
showSuccessToast(
|
|
166
|
+
const summary = formatErrorSummary(t, r.errors);
|
|
167
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
168
|
+
created: r.created,
|
|
169
|
+
updated: r.updated,
|
|
170
|
+
skipped: r.skipped,
|
|
171
|
+
}) +
|
|
172
|
+
"\n" +
|
|
173
|
+
summary);
|
|
156
174
|
}
|
|
157
175
|
else if (r) {
|
|
158
|
-
showSuccessToast(
|
|
176
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
177
|
+
created: r.created,
|
|
178
|
+
updated: r.updated,
|
|
179
|
+
skipped: r.skipped,
|
|
180
|
+
}));
|
|
159
181
|
}
|
|
160
182
|
else {
|
|
161
|
-
showSuccessToast("
|
|
183
|
+
showSuccessToast(t("messagesBulkSuccess"));
|
|
162
184
|
}
|
|
163
185
|
const schoolId = ((_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id) || "";
|
|
164
186
|
fetch(`${FEE_STRUCTURE_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
@@ -185,17 +207,20 @@ export const FeeStructureMoreActions = () => {
|
|
|
185
207
|
else {
|
|
186
208
|
const r = status.results;
|
|
187
209
|
const detail = ((_e = r === null || r === void 0 ? void 0 : r.errors) === null || _e === void 0 ? void 0 : _e.length)
|
|
188
|
-
? formatErrorSummary(r.errors)
|
|
189
|
-
: "
|
|
190
|
-
showErrorToast(
|
|
210
|
+
? formatErrorSummary(t, r.errors)
|
|
211
|
+
: t("unknownError");
|
|
212
|
+
showErrorToast(t("messagesBulkFailed", { action: label }) + "\n" + detail);
|
|
191
213
|
}
|
|
192
214
|
}
|
|
193
215
|
catch (error) {
|
|
194
216
|
if (error.message === "Polling cancelled")
|
|
195
217
|
return;
|
|
196
|
-
showErrorToast(
|
|
218
|
+
showErrorToast(t("messagesBulkFailedDetail", {
|
|
219
|
+
action: label,
|
|
220
|
+
error: error instanceof Error ? error.message : t("unknownError"),
|
|
221
|
+
}));
|
|
197
222
|
}
|
|
198
|
-
}, [dispatch]);
|
|
223
|
+
}, [dispatch, t]);
|
|
199
224
|
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
200
225
|
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
201
226
|
const create = [
|
|
@@ -282,7 +282,7 @@ export const useRbacModule = () => {
|
|
|
282
282
|
type: RBAC_ACTION_TYPES.SET_DRAWER,
|
|
283
283
|
payload: { drawer: RBAC_DRAWER.FORM_DRAWER },
|
|
284
284
|
});
|
|
285
|
-
}, [byIdFetchNow, dispatch]);
|
|
285
|
+
}, [byIdFetchNow, dispatch, resetRecordFormState]);
|
|
286
286
|
const handleDelete = useCallback((row) => {
|
|
287
287
|
if (!confirm(t("messagesDeleteConfirmation")))
|
|
288
288
|
return;
|
|
@@ -9,7 +9,9 @@ import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
|
9
9
|
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
10
10
|
import { useRbacModule } from "./context";
|
|
11
11
|
import { AssignPermissions } from "./assign-permissions";
|
|
12
|
+
import { useTranslations } from "next-intl";
|
|
12
13
|
export const RbacForm = () => {
|
|
14
|
+
const t = useTranslations("rbac");
|
|
13
15
|
const { state, handleChange } = useRbacModule();
|
|
14
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { id: "name", label: "
|
|
16
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { id: "name", label: t("formNameLabel"), required: true, type: "text", value: state.name || "", onChange: (e) => handleChange("name", e.target.value), error: state.errors.name, placeholder: t("formNamePlaceholder"), info: t("formNameInfo") }), _jsx(EnhancedInput, { id: "description", label: t("formDescriptionLabel"), type: "text", value: state.description || "", onChange: (e) => handleChange("description", e.target.value || undefined), error: state.errors.description, placeholder: t("formDescriptionPlaceholder"), info: t("formDescriptionInfo") })] }), state.id && (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-sm font-medium", children: t("viewSectionPermissions") }), _jsx(AssignPermissions, {})] })] }))] }));
|
|
15
17
|
};
|
|
@@ -24,7 +24,10 @@ export const SchoolForm = () => {
|
|
|
24
24
|
info: t("formCurrencyInfo"),
|
|
25
25
|
label: t("formCurrencyLabel"),
|
|
26
26
|
onValueChange: (value) => handleChange("currency", value),
|
|
27
|
-
options: Object.values(CURRENCY).map((c) => ({
|
|
27
|
+
options: Object.values(CURRENCY).map((c) => ({
|
|
28
|
+
value: c,
|
|
29
|
+
label: c,
|
|
30
|
+
})),
|
|
28
31
|
placeholder: t("formCurrencyPlaceholder"),
|
|
29
32
|
required: true,
|
|
30
33
|
searchEndpoint: SCHOOL_API_ROUTES.UNIT,
|
|
@@ -31,8 +31,8 @@ export const SectionForm = () => {
|
|
|
31
31
|
label: t("formClassLabel"),
|
|
32
32
|
onValueChange: (value) => handleChange("classId", value),
|
|
33
33
|
options: (classes === null || classes === void 0 ? void 0 : classes.map((cls) => ({
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
value: cls.id,
|
|
35
|
+
label: `${cls.name} (${cls.code})`,
|
|
36
36
|
}))) || [],
|
|
37
37
|
placeholder: t("formClassPlaceholder"),
|
|
38
38
|
required: true,
|
|
@@ -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 SectionMoreActions = () => {
|
|
@@ -106,7 +108,7 @@ export const SectionMoreActions = () => {
|
|
|
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,13 +118,13 @@ export const SectionMoreActions = () => {
|
|
|
116
118
|
const msgs = [];
|
|
117
119
|
if (method === "POST") {
|
|
118
120
|
if (!((_b = row.name) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
119
|
-
msgs.push("
|
|
121
|
+
msgs.push(t("validationRequiredName"));
|
|
120
122
|
if (!((_c = row.classId) === null || _c === void 0 ? void 0 : _c.trim()))
|
|
121
|
-
msgs.push("
|
|
123
|
+
msgs.push(t("validationRequiredClassId"));
|
|
122
124
|
}
|
|
123
125
|
else {
|
|
124
126
|
if (!((_d = row.id) === null || _d === void 0 ? void 0 : _d.trim()))
|
|
125
|
-
msgs.push("
|
|
127
|
+
msgs.push(t("validationRequiredIdForUpdate"));
|
|
126
128
|
}
|
|
127
129
|
if (msgs.length > 0) {
|
|
128
130
|
validationErrors.push({ row: i + 1, messages: msgs });
|
|
@@ -131,38 +133,58 @@ export const SectionMoreActions = () => {
|
|
|
131
133
|
if (validationErrors.length > 0) {
|
|
132
134
|
const summary = validationErrors
|
|
133
135
|
.slice(0, 5)
|
|
134
|
-
.map((e) =>
|
|
136
|
+
.map((e) => t("messagesBulkRowError", {
|
|
137
|
+
row: e.row,
|
|
138
|
+
error: e.messages.join("; "),
|
|
139
|
+
}))
|
|
135
140
|
.join("\n");
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
showErrorToast(t("messagesBulkValidationFailed", {
|
|
142
|
+
count: validationErrors.length,
|
|
143
|
+
errors: summary,
|
|
144
|
+
}));
|
|
138
145
|
return;
|
|
139
146
|
}
|
|
140
147
|
try {
|
|
141
|
-
showInfoToast(
|
|
148
|
+
showInfoToast(t("messagesBulkJobQueued", { action: label, count: records.length }));
|
|
142
149
|
let jobId;
|
|
143
150
|
try {
|
|
144
151
|
jobId = await submitBulkJob(text, method, signal);
|
|
145
152
|
}
|
|
146
153
|
catch (submitError) {
|
|
147
|
-
showErrorToast(
|
|
154
|
+
showErrorToast(t("messagesBulkJobSubmitFailed", {
|
|
155
|
+
action: label,
|
|
156
|
+
error: submitError instanceof Error
|
|
157
|
+
? submitError.message
|
|
158
|
+
: t("unknownError"),
|
|
159
|
+
}));
|
|
148
160
|
return;
|
|
149
161
|
}
|
|
150
162
|
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
151
|
-
showInfoToast(
|
|
163
|
+
showInfoToast(t("messagesBulkProgress", { processed, total }));
|
|
152
164
|
});
|
|
153
165
|
if (signal.aborted)
|
|
154
166
|
return;
|
|
155
167
|
if (status.status === "completed") {
|
|
156
168
|
const r = status.results;
|
|
157
169
|
if (r && ((_e = r.errors) === null || _e === void 0 ? void 0 : _e.length) > 0) {
|
|
158
|
-
const summary = formatErrorSummary(r.errors);
|
|
159
|
-
showSuccessToast(
|
|
170
|
+
const summary = formatErrorSummary(t, r.errors);
|
|
171
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
172
|
+
created: r.created,
|
|
173
|
+
updated: r.updated,
|
|
174
|
+
skipped: r.skipped,
|
|
175
|
+
}) +
|
|
176
|
+
"\n" +
|
|
177
|
+
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(`${SECTION_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
@@ -189,17 +211,20 @@ export const SectionMoreActions = () => {
|
|
|
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 = [
|
|
@@ -34,7 +34,10 @@ export const StudentFeeFilter = () => {
|
|
|
34
34
|
info: t("filterByPaymentStatus"),
|
|
35
35
|
label: t("filterPaymentStatusLabel"),
|
|
36
36
|
onValueChange: (value) => handleChange("filterStatus", value),
|
|
37
|
-
options: PAYMENT_STATUS_OPTIONS.map((opt) => ({
|
|
37
|
+
options: PAYMENT_STATUS_OPTIONS.map((opt) => ({
|
|
38
|
+
value: opt.value,
|
|
39
|
+
label: paymentStatusLabelMap[opt.value] || opt.label,
|
|
40
|
+
})),
|
|
38
41
|
placeholder: t("filterAllStatusesLabel"),
|
|
39
42
|
searchEndpoint: STUDENT_FEE_API_ROUTES.UNIT,
|
|
40
43
|
searchPlaceholder: t("filterSearchStatusLabel"),
|
|
@@ -64,7 +64,10 @@ export const StudentFeeForm = () => {
|
|
|
64
64
|
info: t("formStudentInfo"),
|
|
65
65
|
label: t("formStudentLabel"),
|
|
66
66
|
onValueChange: (value) => handleChange("studentProfileId", value),
|
|
67
|
-
options: filteredStudentOptions
|
|
67
|
+
options: filteredStudentOptions.map((s) => ({
|
|
68
|
+
value: s.id,
|
|
69
|
+
label: s.name,
|
|
70
|
+
})),
|
|
68
71
|
placeholder: t("formStudentPlaceholder"),
|
|
69
72
|
required: true,
|
|
70
73
|
searchEndpoint: STUDENT_FEE_API_ROUTES.UNIT,
|
|
@@ -78,8 +81,8 @@ export const StudentFeeForm = () => {
|
|
|
78
81
|
label: t("formFeeStructureLabel"),
|
|
79
82
|
onValueChange: (value) => handleChange("feeStructureId", value),
|
|
80
83
|
options: feeStructures === null || feeStructures === void 0 ? void 0 : feeStructures.map((fs) => ({
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
value: fs.id,
|
|
85
|
+
label: fs.name || fs.id,
|
|
83
86
|
})),
|
|
84
87
|
placeholder: t("formFeeStructurePlaceholder"),
|
|
85
88
|
required: true,
|
|
@@ -94,8 +97,8 @@ export const StudentFeeForm = () => {
|
|
|
94
97
|
label: t("formDiscountCodeLabel"),
|
|
95
98
|
onValueChange: (value) => handleChange("discountCodeId", value),
|
|
96
99
|
options: (discountCodes === null || discountCodes === void 0 ? void 0 : discountCodes.map((code) => ({
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
value: code.id,
|
|
101
|
+
label: `${code.code} - ${code.discountValue}${code.discountType === DISCOUNT_TYPE.PERCENTAGE ? "%" : currency}`,
|
|
99
102
|
}))) || [],
|
|
100
103
|
placeholder: t("formDiscountCodePlaceholder"),
|
|
101
104
|
searchEndpoint: STUDENT_FEE_API_ROUTES.UNIT,
|
|
@@ -109,8 +112,8 @@ export const StudentFeeForm = () => {
|
|
|
109
112
|
label: t("formOptionStatus"),
|
|
110
113
|
onValueChange: (value) => handleChange("status", value),
|
|
111
114
|
options: PAYMENT_STATUS_OPTIONS.map((opt) => ({
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
value: opt.value,
|
|
116
|
+
label: paymentStatusLabelMap[opt.value] || opt.label,
|
|
114
117
|
})),
|
|
115
118
|
placeholder: t("formStatusPlaceholder"),
|
|
116
119
|
required: true,
|
|
@@ -8,7 +8,7 @@ import { STATUS_OPTIONS, STUDENT_PROFILE_API_ROUTES } from "./constants";
|
|
|
8
8
|
export const StudentProfileFilter = () => {
|
|
9
9
|
const t = useTranslations("studentProfile");
|
|
10
10
|
const context = useStudentProfileModule();
|
|
11
|
-
const {
|
|
11
|
+
const { filterEnabled } = context.state;
|
|
12
12
|
const { handleChange } = context;
|
|
13
13
|
const filterEnabledValue = filterEnabled === undefined
|
|
14
14
|
? "undefined"
|
|
@@ -27,8 +27,8 @@ export const StudentProfileFilter = () => {
|
|
|
27
27
|
label: t("filterOptionStatus"),
|
|
28
28
|
info: t("filterByStudentStatus"),
|
|
29
29
|
options: [...STATUS_OPTIONS].map((opt) => ({
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
value: opt.value,
|
|
31
|
+
label: statusLabelMap[opt.value] || opt.label,
|
|
32
32
|
})),
|
|
33
33
|
value: "filterStatus",
|
|
34
34
|
onValueChange: (value) => handleChange("filterStatus", value),
|
|
@@ -24,8 +24,8 @@ export const StudentProfileForm = () => {
|
|
|
24
24
|
label: t("formGenderLabel"),
|
|
25
25
|
onValueChange: (value) => handleChange("gender", value),
|
|
26
26
|
options: GENDER_OPTIONS.map((opt) => ({
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
value: opt.value,
|
|
28
|
+
label: genderLabelMap[opt.value] || opt.label,
|
|
29
29
|
})),
|
|
30
30
|
placeholder: "",
|
|
31
31
|
searchEndpoint: STUDENT_PROFILE_API_ROUTES.UNIT,
|
|
@@ -37,8 +37,8 @@ export const StudentProfileForm = () => {
|
|
|
37
37
|
label: t("formOptionStatus"),
|
|
38
38
|
onValueChange: (value) => handleChange("status", value),
|
|
39
39
|
options: STATUS_OPTIONS.map((opt) => ({
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
value: opt.value,
|
|
41
|
+
label: opt.label,
|
|
42
42
|
})),
|
|
43
43
|
placeholder: "",
|
|
44
44
|
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 SubjectMoreActions = () => {
|
|
@@ -106,7 +110,7 @@ export const SubjectMoreActions = () => {
|
|
|
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 SubjectMoreActions = () => {
|
|
|
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(`${SUBJECT_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
@@ -189,17 +211,20 @@ export const SubjectMoreActions = () => {
|
|
|
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 = [
|
|
@@ -49,8 +49,8 @@ export const TeacherForm = () => {
|
|
|
49
49
|
label: t("formGenderLabel"),
|
|
50
50
|
onValueChange: (value) => handleChange("gender", value || null),
|
|
51
51
|
options: GENDER_OPTIONS.map((opt) => ({
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
value: opt.value,
|
|
53
|
+
label: genderLabelMap[opt.value] || opt.label,
|
|
54
54
|
})),
|
|
55
55
|
placeholder: "",
|
|
56
56
|
searchEndpoint: TEACHER_API_ROUTES.UNIT,
|