@nkhang1902/strapi-plugin-export-import-clsx 1.1.13 → 1.1.15

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,22 @@
1
1
  import { useState, useRef } from "react";
2
- import { Button } from "@strapi/design-system";
2
+ import {
3
+ ModalLayout,
4
+ ModalHeader,
5
+ ModalBody,
6
+ ModalFooter,
7
+ Typography,
8
+ Box,
9
+ Button,
10
+ } from "@strapi/design-system";
3
11
  import { Download, Upload } from "@strapi/icons";
4
12
  import { useNotification } from "@strapi/strapi/admin";
5
13
 
6
14
  const ExportImportButtons = (props) => {
7
15
  const [isExporting, setIsExporting] = useState(false);
8
16
  const [isImporting, setIsImporting] = useState(false);
17
+ const [showErrorModal, setShowErrorModal] = useState(false);
18
+ const [importErrors, setImportErrors] = useState([]);
19
+
9
20
  const { toggleNotification } = useNotification();
10
21
 
11
22
  // Get current content type from props or URL
@@ -184,33 +195,21 @@ const ExportImportButtons = (props) => {
184
195
 
185
196
  if (response.ok) {
186
197
  const result = await response.json();
198
+ const created = result.summary?.created || result.result.created || 0;
199
+ const updated = result.summary?.updated || result.result.updated || 0;
187
200
 
188
- // Create appropriate notification based on results
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;
201
+ const errorList = result.result?.errors || [];
194
202
 
195
- if (errors > 0) {
196
- toggleNotification({
197
- type: "warning",
198
- message: `Import completed with ${errors} error(s). Processed ${total} entries (${created} created, ${updated} updated)`,
199
- });
203
+ if (errorList.length > 0) {
204
+ setImportErrors(errorList);
205
+ setShowErrorModal(true);
200
206
  } else if (total > 0) {
201
207
  toggleNotification({
202
208
  type: "success",
203
209
  message: `Import completed successfully! Processed ${total} entries (${created} created, ${updated} updated)`,
204
210
  });
205
- } else {
206
- toggleNotification({
207
- type: "info",
208
- message: "Import completed - no changes were made",
209
- });
211
+ window.location.reload();
210
212
  }
211
-
212
- // Reload the page to show new data
213
- window.location.reload();
214
213
  } else {
215
214
  const error = await response.json();
216
215
  throw new Error(error.error || "Import failed");
@@ -239,6 +238,7 @@ const ExportImportButtons = (props) => {
239
238
  const fileInputRef = useRef(null);
240
239
 
241
240
  return (
241
+ <>
242
242
  <div
243
243
  style={{
244
244
  display: "flex",
@@ -276,6 +276,39 @@ const ExportImportButtons = (props) => {
276
276
  Import
277
277
  </Button>
278
278
  </div>
279
+ {showErrorModal && (
280
+ <ModalLayout
281
+ onClose={() => setShowErrorModal(false)}
282
+ labelledBy="import-errors-title"
283
+ >
284
+ <ModalHeader>
285
+ <Typography id="import-errors-title" fontWeight="bold">
286
+ Import Errors ({importErrors.length})
287
+ </Typography>
288
+ </ModalHeader>
289
+
290
+ <ModalBody>
291
+ <Box padding={4}>
292
+ {importErrors.map((err, index) => (
293
+ <Box key={index} paddingBottom={2}>
294
+ <Typography textColor="danger600">
295
+ {index + 1}. {err}
296
+ </Typography>
297
+ </Box>
298
+ ))}
299
+ </Box>
300
+ </ModalBody>
301
+
302
+ <ModalFooter
303
+ endActions={
304
+ <Button onClick={() => setShowErrorModal(false)}>
305
+ Close
306
+ </Button>
307
+ }
308
+ />
309
+ </ModalLayout>
310
+ )}
311
+ </>
279
312
  );
280
313
  };
281
314
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nkhang1902/strapi-plugin-export-import-clsx",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
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": {
@@ -287,7 +287,10 @@ module.exports = ({ strapi }) => ({
287
287
  for (const key in obj) {
288
288
  const value = obj[key];
289
289
 
290
- // Skip system keys
290
+ if (key === "documentId" && ["corporate", "investor", "vip-guest"].includes(contentType.split(".")[1])) {
291
+ result["liveLink"] = `${process.env.PREVIEW_URL}/download/live-link?participantId=${value}`;
292
+ continue
293
+ }
291
294
  if (SYSTEM_KEYS.includes(key)) continue;
292
295
  if (customFields.includes(key)) continue;
293
296
  if ([...skipFields, "wishlist", "availableSlot"].includes(key))
@@ -295,7 +298,7 @@ module.exports = ({ strapi }) => ({
295
298
 
296
299
  if (componentFields.includes(key)) {
297
300
  for (const subKey in value) {
298
- if (subKey === "id") continue;
301
+ if (["id", "createdAt", "updatedAt", "lastUpdate", "passcode"]) continue;
299
302
  result[`${key}_${subKey}`] = value[subKey];
300
303
  }
301
304
  continue;
@@ -349,13 +352,6 @@ module.exports = ({ strapi }) => ({
349
352
  }
350
353
  return result;
351
354
  }
352
-
353
- if (["corporate", "investor", "vip-guest"].includes(contentType.split(".")[1])) {
354
- cleanedEntries.forEach((entry) => {
355
- entry["liveLink"] = `${process.env.PREVIEW_URL}/download/live-link?participantId=${entry["documentId"]}`;
356
- });
357
- }
358
-
359
355
  const cleanedFlat = cleanedEntries.map((entry) =>
360
356
  flattenForXLSX(entry)
361
357
  );