@nkhang1902/strapi-plugin-export-import-clsx 1.1.14 → 1.1.151
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.
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { useState, useRef } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
Typography,
|
|
5
|
+
Box,
|
|
6
|
+
Button,
|
|
7
|
+
} from "@strapi/design-system";
|
|
3
8
|
import { Download, Upload } from "@strapi/icons";
|
|
4
9
|
import { useNotification } from "@strapi/strapi/admin";
|
|
5
10
|
|
|
6
11
|
const ExportImportButtons = (props) => {
|
|
7
12
|
const [isExporting, setIsExporting] = useState(false);
|
|
8
13
|
const [isImporting, setIsImporting] = useState(false);
|
|
14
|
+
const [showErrorModal, setShowErrorModal] = useState(false);
|
|
15
|
+
const [importErrors, setImportErrors] = useState([]);
|
|
16
|
+
|
|
9
17
|
const { toggleNotification } = useNotification();
|
|
10
18
|
|
|
11
19
|
// Get current content type from props or URL
|
|
@@ -184,33 +192,21 @@ const ExportImportButtons = (props) => {
|
|
|
184
192
|
|
|
185
193
|
if (response.ok) {
|
|
186
194
|
const result = await response.json();
|
|
195
|
+
const created = result.summary?.created || result.result.created || 0;
|
|
196
|
+
const updated = result.summary?.updated || result.result.updated || 0;
|
|
187
197
|
|
|
188
|
-
|
|
189
|
-
const created = result.summary?.created || result.result.created;
|
|
190
|
-
const updated = result.summary?.updated || result.result.updated;
|
|
191
|
-
const errors = result.result.errors?.length || 0;
|
|
192
|
-
|
|
193
|
-
const total = created + updated;
|
|
198
|
+
const errorList = result.result?.errors || [];
|
|
194
199
|
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
message: `Import completed with ${errors} error(s). Processed ${total} entries (${created} created, ${updated} updated)`,
|
|
199
|
-
});
|
|
200
|
+
if (errorList.length > 0) {
|
|
201
|
+
setImportErrors(errorList);
|
|
202
|
+
setShowErrorModal(true);
|
|
200
203
|
} else if (total > 0) {
|
|
201
204
|
toggleNotification({
|
|
202
205
|
type: "success",
|
|
203
206
|
message: `Import completed successfully! Processed ${total} entries (${created} created, ${updated} updated)`,
|
|
204
207
|
});
|
|
205
|
-
|
|
206
|
-
toggleNotification({
|
|
207
|
-
type: "info",
|
|
208
|
-
message: "Import completed - no changes were made",
|
|
209
|
-
});
|
|
208
|
+
window.location.reload();
|
|
210
209
|
}
|
|
211
|
-
|
|
212
|
-
// Reload the page to show new data
|
|
213
|
-
window.location.reload();
|
|
214
210
|
} else {
|
|
215
211
|
const error = await response.json();
|
|
216
212
|
throw new Error(error.error || "Import failed");
|
|
@@ -239,6 +235,7 @@ const ExportImportButtons = (props) => {
|
|
|
239
235
|
const fileInputRef = useRef(null);
|
|
240
236
|
|
|
241
237
|
return (
|
|
238
|
+
<>
|
|
242
239
|
<div
|
|
243
240
|
style={{
|
|
244
241
|
display: "flex",
|
|
@@ -276,6 +273,41 @@ const ExportImportButtons = (props) => {
|
|
|
276
273
|
Import
|
|
277
274
|
</Button>
|
|
278
275
|
</div>
|
|
276
|
+
{showErrorModal && (
|
|
277
|
+
<Modal.Root
|
|
278
|
+
onClose={() => setShowErrorModal(false)}
|
|
279
|
+
labelledBy="import-errors-title"
|
|
280
|
+
>
|
|
281
|
+
<Modal.Content>
|
|
282
|
+
<Modal.Header>
|
|
283
|
+
<Typography id="import-errors-title" fontWeight="bold">
|
|
284
|
+
Import Errors ({importErrors.length})
|
|
285
|
+
</Typography>
|
|
286
|
+
</Modal.Header>
|
|
287
|
+
|
|
288
|
+
<Modal.Body>
|
|
289
|
+
<Box padding={4}>
|
|
290
|
+
{importErrors.map((err, index) => (
|
|
291
|
+
<Box key={index} paddingBottom={2}>
|
|
292
|
+
<Typography textColor="danger600">
|
|
293
|
+
{index + 1}. {err}
|
|
294
|
+
</Typography>
|
|
295
|
+
</Box>
|
|
296
|
+
))}
|
|
297
|
+
</Box>
|
|
298
|
+
</Modal.Body>
|
|
299
|
+
|
|
300
|
+
<Modal.Footer
|
|
301
|
+
endActions={
|
|
302
|
+
<Button onClick={() => setShowErrorModal(false)}>
|
|
303
|
+
Close
|
|
304
|
+
</Button>
|
|
305
|
+
}
|
|
306
|
+
/>
|
|
307
|
+
</Modal.Content>
|
|
308
|
+
</Modal.Root>
|
|
309
|
+
)}
|
|
310
|
+
</>
|
|
279
311
|
);
|
|
280
312
|
};
|
|
281
313
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nkhang1902/strapi-plugin-export-import-clsx",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.151",
|
|
4
4
|
"description": "A powerful Strapi plugin for exporting and importing data with Excel support and advanced filtering",
|
|
5
5
|
"main": "./strapi-server.js",
|
|
6
6
|
"scripts": {
|
|
@@ -352,13 +352,6 @@ module.exports = ({ strapi }) => ({
|
|
|
352
352
|
}
|
|
353
353
|
return result;
|
|
354
354
|
}
|
|
355
|
-
|
|
356
|
-
if (["corporate", "investor", "vip-guest"].includes(contentType.split(".")[1])) {
|
|
357
|
-
cleanedEntries.forEach((entry) => {
|
|
358
|
-
entry["liveLink"] = `${process.env.PREVIEW_URL}/download/live-link?participantId=${entry["documentId"]}`;
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
|
|
362
355
|
const cleanedFlat = cleanedEntries.map((entry) =>
|
|
363
356
|
flattenForXLSX(entry)
|
|
364
357
|
);
|