@appcorp/fusion-storybook 0.2.23 → 0.2.24
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.
|
@@ -43,8 +43,9 @@ async function submitBulkJob(csvData, method, signal) {
|
|
|
43
43
|
const data = (await res.json());
|
|
44
44
|
return data.jobId;
|
|
45
45
|
}
|
|
46
|
-
async function pollBulkJob(jobId, signal) {
|
|
46
|
+
async function pollBulkJob(jobId, signal, onProgress) {
|
|
47
47
|
const startTime = Date.now();
|
|
48
|
+
let lastProgressToast = 0;
|
|
48
49
|
while (true) {
|
|
49
50
|
if (signal.aborted)
|
|
50
51
|
throw new Error("Polling cancelled");
|
|
@@ -66,6 +67,12 @@ async function pollBulkJob(jobId, signal) {
|
|
|
66
67
|
if (data.status === "completed" || data.status === "failed") {
|
|
67
68
|
return data;
|
|
68
69
|
}
|
|
70
|
+
// Show progress toast every 10 seconds while running
|
|
71
|
+
if (data.status === "running" &&
|
|
72
|
+
Date.now() - lastProgressToast > 10000) {
|
|
73
|
+
lastProgressToast = Date.now();
|
|
74
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(data.processed, data.total);
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
function formatErrorSummary(errors) {
|
|
@@ -133,7 +140,9 @@ export const TeacherMoreActions = () => {
|
|
|
133
140
|
try {
|
|
134
141
|
showInfoToast(`Bulk ${label} job queued (${records.length} records). Processing...`);
|
|
135
142
|
const jobId = await submitBulkJob(text, method, signal);
|
|
136
|
-
const status = await pollBulkJob(jobId, signal)
|
|
143
|
+
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
144
|
+
showInfoToast(`Processing ${processed}/${total} teachers...`);
|
|
145
|
+
});
|
|
137
146
|
if (signal.aborted)
|
|
138
147
|
return;
|
|
139
148
|
if (status.status === "completed") {
|