@nkhang1902/strapi-plugin-export-import-clsx 1.5.0 → 1.5.1

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.
@@ -79,7 +79,9 @@ const ExportButtonsEditView = (props) => {
79
79
  const a = document.createElement("a");
80
80
  a.href = url;
81
81
 
82
- const filename = `${contentType.replace("api::", "")}-participants-export.xlsx`;
82
+ const filename = response.headers
83
+ .get("Content-Disposition")
84
+ .split("filename=")[1];
83
85
 
84
86
  a.download = filename;
85
87
  document.body.appendChild(a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nkhang1902/strapi-plugin-export-import-clsx",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
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": {
@@ -15,9 +15,19 @@ module.exports = ({ strapi }) => ({
15
15
  );
16
16
 
17
17
  const filename = `${
18
- contentType?.replace("api::", "") || "strapi"
18
+ contentType?.split(".")[1]|| "strapi"
19
19
  }-export-${new Date().toISOString().split("T")[0]}.xlsx`;
20
20
 
21
+ if (mode === "participant") {
22
+ const expName = await strapi.documents(contentType).findOne({
23
+ select: ["name"],
24
+ filters: {
25
+ documentId: ctx.query[`filters[documentId][$eq]`],
26
+ },
27
+ })
28
+ filename = `${expName.name}-participant-export-${new Date().toISOString().split("T")[0]}.xlsx`;
29
+ }
30
+
21
31
  ctx.set(
22
32
  "Content-Type",
23
33
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
@@ -40,7 +50,10 @@ module.exports = ({ strapi }) => ({
40
50
  ctx.set("Content-Type", "application/json");
41
51
  ctx.set("Content-Disposition", `attachment; filename="${filename}"`);
42
52
 
43
- ctx.body = JSON.stringify(data, null, 2);
53
+ ctx.body = JSON.stringify({
54
+ filename: filename,
55
+ data: data,
56
+ }, null, 2);
44
57
  }
45
58
  } catch (error) {
46
59
  strapi.log.error("Export error:", error);
@@ -421,22 +421,24 @@ module.exports = ({ strapi }) => ({
421
421
  const participants = [
422
422
  ...tag(experienceData?.corporates, 'corporate'),
423
423
  ...tag(experienceData?.investors, 'investor'),
424
- ...tag(experienceData?.vipGuests, 'vip'),
424
+ ...tag(experienceData?.vipGuests, 'vipGuest'),
425
425
  ];
426
426
 
427
427
  const data = participants.map((p) => ({
428
428
  type: p.type,
429
- corporateName: p.corporateName ?? p.companyInformation?.companyName ?? '',
429
+ corporateName: p.corporateName ?? '',
430
430
  tickerCode: p.tickerCode ?? '',
431
431
  fullName:
432
432
  p.fullName ??
433
433
  [p.firstName, p.lastName].filter(Boolean).join(' ') ??
434
434
  '',
435
+ salutation: p.salutation ?? '',
435
436
  businessEmail: p.businessEmail ?? '',
437
+ businessTitle: p.businessTitle ?? '',
438
+ companyName: p.companyInformation?.companyName ?? '',
436
439
  mobile: p.mobile ?? '',
437
440
  }));
438
441
 
439
- console.log(data)
440
442
  const worksheet = XLSX.utils.json_to_sheet(data);
441
443
  XLSX.utils.book_append_sheet(
442
444
  workbook,