@nkhang1902/strapi-plugin-export-import-clsx 1.4.1 → 1.4.2

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.
@@ -6,7 +6,6 @@ import { Download, Upload } from "@strapi/icons";
6
6
  import { useNotification } from "@strapi/strapi/admin";
7
7
 
8
8
  const ExportImportButtons = (props) => {
9
- const { isExpParticipantsExporting } = props;
10
9
  const [isExporting, setIsExporting] = useState(false);
11
10
  const [isImporting, setIsImporting] = useState(false);
12
11
  const { toggleNotification } = useNotification();
@@ -42,32 +42,6 @@ const ExportButtonsEditView = (props) => {
42
42
  return null;
43
43
  };
44
44
 
45
- // Get event filter for event manager - simplified with exclude list
46
- const getEventFilter = () => {
47
- const path = window.location.pathname;
48
- const eventManagerMatch = path.match(
49
- /\/admin\/plugins\/event-manager\/([^\/]+)\/([^\/]+)/
50
- );
51
-
52
- if (eventManagerMatch) {
53
- const eventId = eventManagerMatch[1];
54
- const collectionType = eventManagerMatch[2];
55
-
56
- if (
57
- eventId &&
58
- eventId !== "events" &&
59
- allowedContentTypes.includes(collectionType)
60
- ) {
61
- return {
62
- eventId,
63
- relationField: "event",
64
- };
65
- }
66
- }
67
-
68
- return null;
69
- };
70
-
71
45
  const currentContentType = getContentType();
72
46
 
73
47
  const handleExport = async () => {
@@ -82,22 +56,23 @@ const ExportButtonsEditView = (props) => {
82
56
 
83
57
  setIsExporting(true);
84
58
  try {
85
- const eventFilter = getEventFilter();
86
-
59
+ const parts = window.location.pathname.split('/').filter(Boolean);
60
+ const documentId = parts[parts.indexOf('event-manager') + 3];
61
+ console.log(documentId)
87
62
  const queryParams = new URLSearchParams({
88
63
  format: "excel",
89
64
  contentType: contentType,
90
65
  });
91
66
 
92
67
  // Add event filter if we're in event manager
93
- if (eventFilter) {
68
+ if (documentId) {
94
69
  queryParams.set(
95
- `filters[${eventFilter.relationField}][documentId][$eq]`,
96
- eventFilter.eventId
70
+ `filters[documentId][$eq]`,
71
+ documentId
97
72
  );
98
73
  }
99
74
 
100
- const response = await fetch(`/export-import-clsx/export?${queryParams}&mode=participantList`);
75
+ const response = await fetch(`/export-import-clsx/export?${queryParams}&mode=participant`);
101
76
 
102
77
  if (response.ok) {
103
78
  const blob = await response.blob();
@@ -142,7 +117,7 @@ const ExportButtonsEditView = (props) => {
142
117
  loading={isExporting}
143
118
  startIcon={<Download />}
144
119
  variant="secondary"
145
- size="S"
120
+ fullWidth
146
121
  >
147
122
  Export Participants
148
123
  </Button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nkhang1902/strapi-plugin-export-import-clsx",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
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": {
@@ -1,7 +1,7 @@
1
1
  module.exports = ({ strapi }) => ({
2
2
  async export(ctx) {
3
3
  try {
4
- const { format = "excel", contentType, ...filters } = ctx.query;
4
+ const { format = "excel", contentType, mode, ...filters } = ctx.query;
5
5
  const exportService = strapi
6
6
  .plugin("export-import-clsx")
7
7
  .service("export-service");
@@ -28,7 +28,8 @@ module.exports = ({ strapi }) => ({
28
28
  const data = await exportService.exportData(
29
29
  "json",
30
30
  contentType,
31
- filters
31
+ filters,
32
+ mode
32
33
  );
33
34
 
34
35
  const filename = `${
@@ -1,7 +1,7 @@
1
1
  const XLSX = require("xlsx");
2
2
 
3
3
  module.exports = ({ strapi }) => ({
4
- async exportData(format = "json", contentType = null, rawFilters = {}) {
4
+ async exportData(format = "json", contentType = null, rawFilters = {}, mode) {
5
5
  // Normalize content type - handle both content-manager and event-manager formats
6
6
  if (contentType && !contentType.startsWith("api::")) {
7
7
  // If it's already in api:: format from event-manager, use as is
@@ -102,6 +102,7 @@ module.exports = ({ strapi }) => ({
102
102
  } catch (error) {
103
103
  strapi.log.error(`Failed to query entries:`, error);
104
104
  }
105
+ console.log({entries})
105
106
 
106
107
  strapi.log.info(
107
108
  `Final result: ${