@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.
@@ -76,13 +76,15 @@ async function pollBulkJob(jobId, signal, onProgress) {
76
76
  }
77
77
  }
78
78
  }
79
- function formatErrorSummary(errors) {
79
+ function formatErrorSummary(t, errors) {
80
80
  if (!(errors === null || errors === void 0 ? void 0 : errors.length))
81
81
  return "";
82
- const lines = errors.slice(0, 5).map((e) => `Row ${e.row}: ${e.error}`);
82
+ const lines = errors
83
+ .slice(0, 5)
84
+ .map((e) => t("messagesBulkRowError", { row: e.row, error: e.error }));
83
85
  const remaining = errors.length - 5;
84
86
  if (remaining > 0)
85
- lines.push(`...and ${remaining} more`);
87
+ lines.push(t("messagesBulkMoreRows", { count: remaining }));
86
88
  return lines.join("\n");
87
89
  }
88
90
  export const TeacherMoreActions = () => {
@@ -115,7 +117,7 @@ export const TeacherMoreActions = () => {
115
117
  const text = await file.text();
116
118
  const records = converter.csv2json(text);
117
119
  if (!Array.isArray(records) || records.length === 0) {
118
- showErrorToast("CSV file is empty or invalid");
120
+ showErrorToast(t("messagesBulkCsvEmpty"));
119
121
  return;
120
122
  }
121
123
  // Client-side validation — fast feedback, saves worker round-trip
@@ -131,7 +133,7 @@ export const TeacherMoreActions = () => {
131
133
  }
132
134
  else {
133
135
  if (!((_b = row.id) === null || _b === void 0 ? void 0 : _b.trim()))
134
- msgs.push("id is required for update");
136
+ msgs.push(t("validationRequiredIdForUpdate"));
135
137
  }
136
138
  if (msgs.length > 0) {
137
139
  validationErrors.push({ row: i + 1, messages: msgs });
@@ -140,38 +142,58 @@ export const TeacherMoreActions = () => {
140
142
  if (validationErrors.length > 0) {
141
143
  const summary = validationErrors
142
144
  .slice(0, 5)
143
- .map((e) => `Row ${e.row}: ${e.messages.join("; ")}`)
145
+ .map((e) => t("messagesBulkRowError", {
146
+ row: e.row,
147
+ error: e.messages.join("; "),
148
+ }))
144
149
  .join("\n");
145
- const remaining = validationErrors.length - 5;
146
- showErrorToast(`Validation failed for ${validationErrors.length} row(s).\n${summary}${remaining > 0 ? `\n...and ${remaining} more` : ""}`);
150
+ showErrorToast(t("messagesBulkValidationFailed", {
151
+ count: validationErrors.length,
152
+ errors: summary,
153
+ }));
147
154
  return;
148
155
  }
149
156
  try {
150
- showInfoToast(`Bulk ${label} job queued (${records.length} records). Processing...`);
157
+ showInfoToast(t("messagesBulkJobQueued", { action: label, count: records.length }));
151
158
  let jobId;
152
159
  try {
153
160
  jobId = await submitBulkJob(text, method, signal);
154
161
  }
155
162
  catch (submitError) {
156
- showErrorToast(`Failed to submit ${label} job: ${submitError instanceof Error ? submitError.message : "Unknown error"}`);
163
+ showErrorToast(t("messagesBulkJobSubmitFailed", {
164
+ action: label,
165
+ error: submitError instanceof Error
166
+ ? submitError.message
167
+ : t("unknownError"),
168
+ }));
157
169
  return;
158
170
  }
159
171
  const status = await pollBulkJob(jobId, signal, (processed, total) => {
160
- showInfoToast(`Processing ${processed}/${total} teachers...`);
172
+ showInfoToast(t("messagesBulkProgress", { processed, total }));
161
173
  });
162
174
  if (signal.aborted)
163
175
  return;
164
176
  if (status.status === "completed") {
165
177
  const r = status.results;
166
178
  if (r && ((_c = r.errors) === null || _c === void 0 ? void 0 : _c.length) > 0) {
167
- const summary = formatErrorSummary(r.errors);
168
- showSuccessToast(`Created ${r.created} | Updated ${r.updated} | Skipped ${r.skipped}\n${summary}`);
179
+ const summary = formatErrorSummary(t, r.errors);
180
+ showSuccessToast(t("messagesBulkResults", {
181
+ created: r.created,
182
+ updated: r.updated,
183
+ skipped: r.skipped,
184
+ }) +
185
+ "\n" +
186
+ summary);
169
187
  }
170
188
  else if (r) {
171
- showSuccessToast(`Created ${r.created} | Updated ${r.updated} | Skipped ${r.skipped}`);
189
+ showSuccessToast(t("messagesBulkResults", {
190
+ created: r.created,
191
+ updated: r.updated,
192
+ skipped: r.skipped,
193
+ }));
172
194
  }
173
195
  else {
174
- showSuccessToast("Bulk operation completed successfully");
196
+ showSuccessToast(t("messagesBulkSuccess"));
175
197
  }
176
198
  const schoolId = ((_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id) || "";
177
199
  fetch(`${TEACHER_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
@@ -199,17 +221,20 @@ export const TeacherMoreActions = () => {
199
221
  else {
200
222
  const r = status.results;
201
223
  const detail = ((_e = r === null || r === void 0 ? void 0 : r.errors) === null || _e === void 0 ? void 0 : _e.length)
202
- ? formatErrorSummary(r.errors)
203
- : "Unknown error";
204
- showErrorToast(`Bulk ${label} failed.\n${detail}`);
224
+ ? formatErrorSummary(t, r.errors)
225
+ : t("unknownError");
226
+ showErrorToast(t("messagesBulkFailed", { action: label }) + "\n" + detail);
205
227
  }
206
228
  }
207
229
  catch (error) {
208
230
  if (error.message === "Polling cancelled")
209
231
  return;
210
- showErrorToast(`Bulk ${label} failed: ${error instanceof Error ? error.message : "Unknown error"}`);
232
+ showErrorToast(t("messagesBulkFailedDetail", {
233
+ action: label,
234
+ error: error instanceof Error ? error.message : t("unknownError"),
235
+ }));
211
236
  }
212
- }, [dispatch]);
237
+ }, [dispatch, t]);
213
238
  const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
214
239
  const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
215
240
  const create = [
@@ -36,8 +36,8 @@ export const UserForm = () => {
36
36
  label: t("formRoleIdLabel"),
37
37
  onValueChange: (value) => handleChange("userRole", value),
38
38
  options: roleOptions.map((opt) => ({
39
- id: opt.id,
40
- name: opt.name,
39
+ value: opt.id,
40
+ label: opt.name,
41
41
  })),
42
42
  placeholder: t("formRoleIdPlaceholder"),
43
43
  required: true,
@@ -39,8 +39,8 @@ export const WorkspaceForm = () => {
39
39
  options: plans
40
40
  .filter(({ name }) => name.match("PKR"))
41
41
  .map((plan) => ({
42
- id: plan.id,
43
- name: plan.name,
42
+ value: plan.id,
43
+ label: plan.name,
44
44
  })),
45
45
  placeholder: t("formPlanPlaceholder"),
46
46
  info: t("formPlanInfo"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.2.42",
3
+ "version": "0.2.45",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@appcorp/app-corp-vista": "^1.0.0",
41
- "@appcorp/shadcn": "^1.1.92",
41
+ "@appcorp/shadcn": "^1.1.97",
42
42
  "@chromatic-com/storybook": "^5.1.2",
43
43
  "@commitlint/cli": "^20.5.0",
44
44
  "@commitlint/config-conventional": "^20.5.0",