@appcorp/fusion-storybook 0.2.28 → 0.2.30
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.
|
@@ -8,9 +8,9 @@ import { Timeline } from "../../components/timeline";
|
|
|
8
8
|
import { useTranslations } from "next-intl";
|
|
9
9
|
import { CSVS } from "../../constants";
|
|
10
10
|
import { teacherFormValidation } from "./validate";
|
|
11
|
-
import { TEACHER_API_ROUTES } from "./constants";
|
|
11
|
+
import { TEACHER_API_ROUTES, pageLimit } from "./constants";
|
|
12
12
|
import { invalidateTeachersCache } from "./cache";
|
|
13
|
-
import { TEACHER_ACTION_TYPES,
|
|
13
|
+
import { TEACHER_ACTION_TYPES, useTeacherContext } from "./context";
|
|
14
14
|
import { useRef, useEffect, useCallback } from "react";
|
|
15
15
|
const workspace = getCachedWorkspaceSync();
|
|
16
16
|
const POLL_INTERVAL_MS = 2000;
|
|
@@ -93,7 +93,7 @@ function formatErrorSummary(errors) {
|
|
|
93
93
|
}
|
|
94
94
|
export const TeacherMoreActions = () => {
|
|
95
95
|
const t = useTranslations("teacher");
|
|
96
|
-
const { dispatch
|
|
96
|
+
const { dispatch } = useTeacherContext();
|
|
97
97
|
const abortRef = useRef(null);
|
|
98
98
|
// Abort any in-flight polling on unmount
|
|
99
99
|
useEffect(() => {
|
|
@@ -103,7 +103,7 @@ export const TeacherMoreActions = () => {
|
|
|
103
103
|
};
|
|
104
104
|
}, []);
|
|
105
105
|
const handleBulkFlow = useCallback(async (files, method) => {
|
|
106
|
-
var _a, _b, _c;
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
107
|
const closeDrawer = () => {
|
|
108
108
|
dispatch({
|
|
109
109
|
type: TEACHER_ACTION_TYPES.SET_DRAWER,
|
|
@@ -172,12 +172,32 @@ export const TeacherMoreActions = () => {
|
|
|
172
172
|
showSuccessToast("Bulk operation completed successfully");
|
|
173
173
|
}
|
|
174
174
|
invalidateTeachersCache();
|
|
175
|
-
|
|
175
|
+
const schoolId = ((_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id) || "";
|
|
176
|
+
fetch(`${TEACHER_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
177
|
+
headers: {
|
|
178
|
+
"Content-Type": "application/json",
|
|
179
|
+
"x-api-token": process.env.NEXT_PUBLIC_API_KEY,
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
.then(async (res) => {
|
|
183
|
+
var _a, _b;
|
|
184
|
+
if (!res.ok)
|
|
185
|
+
return;
|
|
186
|
+
const data = await res.json();
|
|
187
|
+
dispatch({
|
|
188
|
+
type: TEACHER_ACTION_TYPES.SET_ITEMS,
|
|
189
|
+
payload: {
|
|
190
|
+
items: (_a = data.items) !== null && _a !== void 0 ? _a : [],
|
|
191
|
+
count: (_b = data.count) !== null && _b !== void 0 ? _b : 0,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
})
|
|
195
|
+
.catch(() => { });
|
|
176
196
|
closeDrawer();
|
|
177
197
|
}
|
|
178
198
|
else {
|
|
179
199
|
const r = status.results;
|
|
180
|
-
const detail = ((
|
|
200
|
+
const detail = ((_d = r === null || r === void 0 ? void 0 : r.errors) === null || _d === void 0 ? void 0 : _d.length)
|
|
181
201
|
? formatErrorSummary(r.errors)
|
|
182
202
|
: "Unknown error";
|
|
183
203
|
showErrorToast(`Bulk ${label} failed.\n${detail}`);
|
|
@@ -188,7 +208,7 @@ export const TeacherMoreActions = () => {
|
|
|
188
208
|
return;
|
|
189
209
|
showErrorToast(`Bulk ${label} failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
190
210
|
}
|
|
191
|
-
}, [dispatch
|
|
211
|
+
}, [dispatch]);
|
|
192
212
|
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
193
213
|
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
194
214
|
const create = [
|