@haus-tech/product-import-export-plugin 3.3.10-next.1 → 3.3.10-next.3
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.
- package/CHANGELOG.md +2 -24
- package/README.mdx +30 -56
- package/package.json +5 -5
- package/src/dashboard/bulk-export.tsx +0 -1
- package/src/dashboard/export-dialog.tsx +252 -22
- package/src/dashboard/export.tsx +17 -52
- package/src/dashboard/exported-list.tsx +103 -167
- package/src/dashboard/import.tsx +148 -258
- package/src/dashboard/index.tsx +28 -27
- package/src/providers/import-providers/asset-importer.js +8 -27
- package/src/providers/import-providers/asset-importer.js.map +1 -1
- package/src/providers/import-providers/import-parser.d.ts +0 -1
- package/src/providers/import-providers/import-parser.js +2 -18
- package/src/providers/import-providers/import-parser.js.map +1 -1
- package/src/providers/import-providers/product-importer.d.ts +1 -10
- package/src/providers/import-providers/product-importer.js +38 -125
- package/src/providers/import-providers/product-importer.js.map +1 -1
- package/src/services/extended-fast-importer.service.js +8 -1
- package/src/services/extended-fast-importer.service.js.map +1 -1
- package/src/services/product-export.service.d.ts +0 -1
- package/src/services/product-export.service.js +3 -12
- package/src/services/product-export.service.js.map +1 -1
- package/src/dashboard/export-configuration-panel.tsx +0 -418
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Button,
|
|
3
|
-
Card,
|
|
4
|
-
CardContent,
|
|
5
|
-
CardDescription,
|
|
6
|
-
CardHeader,
|
|
7
|
-
CardTitle,
|
|
8
3
|
Dialog,
|
|
9
4
|
DialogContent,
|
|
10
5
|
DialogDescription,
|
|
11
6
|
DialogFooter,
|
|
12
7
|
DialogHeader,
|
|
13
8
|
DialogTitle,
|
|
14
|
-
Input,
|
|
15
|
-
Table,
|
|
16
|
-
TableBody,
|
|
17
|
-
TableCell,
|
|
18
|
-
TableHead,
|
|
19
|
-
TableHeader,
|
|
20
|
-
TableRow,
|
|
21
|
-
toast,
|
|
22
9
|
} from '@vendure/dashboard'
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
SearchIcon,
|
|
28
|
-
TrashIcon,
|
|
29
|
-
} from 'lucide-react'
|
|
30
|
-
import { useEffect, useMemo, useState } from 'react'
|
|
31
|
-
import { getChannelHeader, getServerLocation } from './utils'
|
|
10
|
+
import { getServerLocation, getChannelHeader } from './utils'
|
|
11
|
+
import { useState, useEffect, useMemo } from 'react'
|
|
12
|
+
import { DownloadIcon, ChevronLeftIcon, ChevronRightIcon, TrashIcon } from 'lucide-react'
|
|
13
|
+
import { toast } from 'sonner'
|
|
32
14
|
|
|
33
15
|
interface ExportedFile {
|
|
34
16
|
fileName: string
|
|
@@ -36,12 +18,12 @@ interface ExportedFile {
|
|
|
36
18
|
created: string
|
|
37
19
|
}
|
|
38
20
|
|
|
39
|
-
const
|
|
21
|
+
const itemsPerPage = 10
|
|
22
|
+
const POLL_INTERVAL_MS = 10_000
|
|
40
23
|
|
|
41
24
|
export function ExportedList() {
|
|
42
25
|
const [exportedFiles, setExportedFiles] = useState<ExportedFile[]>([])
|
|
43
26
|
const [error, setError] = useState<string | null>(null)
|
|
44
|
-
const [search, setSearch] = useState('')
|
|
45
27
|
const [currentPage, setCurrentPage] = useState(1)
|
|
46
28
|
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
|
|
47
29
|
const [fileToDelete, setFileToDelete] = useState<string | null>(null)
|
|
@@ -71,29 +53,27 @@ export function ExportedList() {
|
|
|
71
53
|
}
|
|
72
54
|
|
|
73
55
|
useEffect(() => {
|
|
74
|
-
getExportFiles()
|
|
56
|
+
void getExportFiles()
|
|
75
57
|
}, [])
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, [exportedFiles, search])
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const intervalId = setInterval(() => {
|
|
61
|
+
void getExportFiles()
|
|
62
|
+
}, POLL_INTERVAL_MS)
|
|
63
|
+
|
|
64
|
+
return () => clearInterval(intervalId)
|
|
65
|
+
}, [])
|
|
85
66
|
|
|
86
|
-
|
|
67
|
+
// Pagination calculations
|
|
87
68
|
const paginatedFiles = useMemo(() => {
|
|
88
|
-
const startIndex = (currentPage - 1) *
|
|
89
|
-
|
|
90
|
-
|
|
69
|
+
const startIndex = (currentPage - 1) * itemsPerPage
|
|
70
|
+
const endIndex = startIndex + itemsPerPage
|
|
71
|
+
return exportedFiles.slice(startIndex, endIndex)
|
|
72
|
+
}, [exportedFiles, currentPage])
|
|
91
73
|
|
|
92
|
-
|
|
93
|
-
if (currentPage > totalPages) setCurrentPage(1)
|
|
94
|
-
}, [totalPages, currentPage])
|
|
74
|
+
const totalPages = Math.ceil(exportedFiles.length / itemsPerPage)
|
|
95
75
|
|
|
96
|
-
const
|
|
76
|
+
const downLoadFile = async (fileName: string) => {
|
|
97
77
|
const serverPath = getServerLocation()
|
|
98
78
|
const res = await fetch(`${serverPath}/product-export/download/${fileName}`, {
|
|
99
79
|
method: 'GET',
|
|
@@ -150,138 +130,94 @@ export function ExportedList() {
|
|
|
150
130
|
|
|
151
131
|
const formatFileSize = (bytes: number): string => {
|
|
152
132
|
if (bytes < 1024) return bytes + ' B'
|
|
153
|
-
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(
|
|
154
|
-
return (bytes / (1024 * 1024)).toFixed(
|
|
133
|
+
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB'
|
|
134
|
+
return (bytes / (1024 * 1024)).toFixed(2) + ' MB'
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (error) {
|
|
138
|
+
return (
|
|
139
|
+
<div className="text-center text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed">
|
|
140
|
+
<p className="text-red-500">{error}</p>
|
|
141
|
+
</div>
|
|
142
|
+
)
|
|
155
143
|
}
|
|
156
144
|
|
|
157
145
|
return (
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
<div className="
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
146
|
+
<div>
|
|
147
|
+
{exportedFiles.length > 0 && (
|
|
148
|
+
<div className="space-y-2">
|
|
149
|
+
<div className="border rounded-md divide-y">
|
|
150
|
+
{paginatedFiles.map((file) => (
|
|
151
|
+
<div key={file.fileName} className="p-4 hover:bg-muted/50 transition-colors">
|
|
152
|
+
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
|
153
|
+
<div className="flex-1">
|
|
154
|
+
<p className="font-medium">{file.fileName}</p>
|
|
155
|
+
<div className="flex flex-col sm:flex-row gap-2 sm:gap-4 text-sm text-muted-foreground mt-1">
|
|
156
|
+
<span>Size: {formatFileSize(file.size)}</span>
|
|
157
|
+
<span>
|
|
158
|
+
Created:{' '}
|
|
159
|
+
{new Date(file.created).toLocaleString(navigator.language || undefined)}
|
|
160
|
+
</span>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
<div className="flex items-center gap-2">
|
|
164
|
+
<Button variant="outline" size="sm" onClick={() => downLoadFile(file.fileName)}>
|
|
165
|
+
<DownloadIcon className="mr-2 h-4 w-4" />
|
|
166
|
+
Download
|
|
167
|
+
</Button>
|
|
168
|
+
<Button
|
|
169
|
+
variant="outline"
|
|
170
|
+
size="sm"
|
|
171
|
+
onClick={() => handleDeleteClick(file.fileName)}
|
|
172
|
+
className="text-destructive hover:text-destructive"
|
|
173
|
+
>
|
|
174
|
+
<TrashIcon className="h-4 w-4" /> Delete
|
|
175
|
+
</Button>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
))}
|
|
184
180
|
</div>
|
|
185
|
-
) : (
|
|
186
|
-
<>
|
|
187
|
-
<div className="rounded-md border overflow-hidden">
|
|
188
|
-
<Table>
|
|
189
|
-
<TableHeader>
|
|
190
|
-
<TableRow>
|
|
191
|
-
<TableHead className="w-[140px]">Type</TableHead>
|
|
192
|
-
<TableHead>File</TableHead>
|
|
193
|
-
<TableHead>Created</TableHead>
|
|
194
|
-
<TableHead className="text-right">Actions</TableHead>
|
|
195
|
-
</TableRow>
|
|
196
|
-
</TableHeader>
|
|
197
|
-
<TableBody>
|
|
198
|
-
{paginatedFiles.length === 0 ? (
|
|
199
|
-
<TableRow>
|
|
200
|
-
<TableCell colSpan={4} className="text-center text-muted-foreground py-8">
|
|
201
|
-
No results match your filters.
|
|
202
|
-
</TableCell>
|
|
203
|
-
</TableRow>
|
|
204
|
-
) : (
|
|
205
|
-
paginatedFiles.map((file) => (
|
|
206
|
-
<TableRow key={file.fileName}>
|
|
207
|
-
<TableCell>
|
|
208
|
-
<div className="flex items-center gap-2">
|
|
209
|
-
<span className="bg-primary/10 text-primary flex h-8 w-8 shrink-0 items-center justify-center rounded-md">
|
|
210
|
-
<DownloadIcon className="h-4 w-4" aria-hidden />
|
|
211
|
-
</span>
|
|
212
|
-
<span className="text-sm font-medium">Export</span>
|
|
213
|
-
</div>
|
|
214
|
-
</TableCell>
|
|
215
|
-
<TableCell>
|
|
216
|
-
<div className="font-medium truncate max-w-xs">{file.fileName}</div>
|
|
217
|
-
<div className="text-xs text-muted-foreground">
|
|
218
|
-
{formatFileSize(file.size)}
|
|
219
|
-
</div>
|
|
220
|
-
</TableCell>
|
|
221
|
-
<TableCell>
|
|
222
|
-
<span className="text-sm">
|
|
223
|
-
{new Date(file.created).toLocaleString(navigator.language || undefined)}
|
|
224
|
-
</span>
|
|
225
|
-
</TableCell>
|
|
226
|
-
<TableCell className="text-right">
|
|
227
|
-
<div className="inline-flex gap-2">
|
|
228
|
-
<Button
|
|
229
|
-
variant="outline"
|
|
230
|
-
size="sm"
|
|
231
|
-
onClick={() => downloadFile(file.fileName)}
|
|
232
|
-
>
|
|
233
|
-
<DownloadIcon className="mr-1 h-3.5 w-3.5" /> Download
|
|
234
|
-
</Button>
|
|
235
|
-
<Button
|
|
236
|
-
variant="ghost"
|
|
237
|
-
size="sm"
|
|
238
|
-
onClick={() => handleDeleteClick(file.fileName)}
|
|
239
|
-
className="text-muted-foreground hover:text-destructive"
|
|
240
|
-
>
|
|
241
|
-
<TrashIcon className="h-3.5 w-3.5" />
|
|
242
|
-
</Button>
|
|
243
|
-
</div>
|
|
244
|
-
</TableCell>
|
|
245
|
-
</TableRow>
|
|
246
|
-
))
|
|
247
|
-
)}
|
|
248
|
-
</TableBody>
|
|
249
|
-
</Table>
|
|
250
|
-
</div>
|
|
251
181
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
<Button
|
|
272
|
-
variant="outline"
|
|
273
|
-
size="sm"
|
|
274
|
-
onClick={() => setCurrentPage((prev) => Math.min(totalPages, prev + 1))}
|
|
275
|
-
disabled={currentPage === totalPages}
|
|
276
|
-
>
|
|
277
|
-
<ChevronRightIcon className="h-4 w-4" />
|
|
278
|
-
</Button>
|
|
182
|
+
{/* Pagination controls */}
|
|
183
|
+
{totalPages > 1 && (
|
|
184
|
+
<div className="flex items-center justify-between py-2 border-t">
|
|
185
|
+
<div className="text-sm text-muted-foreground">
|
|
186
|
+
Showing {(currentPage - 1) * itemsPerPage + 1} to{' '}
|
|
187
|
+
{Math.min(currentPage * itemsPerPage, exportedFiles.length)} of{' '}
|
|
188
|
+
{exportedFiles.length}
|
|
189
|
+
</div>
|
|
190
|
+
<div className="flex items-center gap-1">
|
|
191
|
+
<Button
|
|
192
|
+
variant="outline"
|
|
193
|
+
size="sm"
|
|
194
|
+
onClick={() => setCurrentPage((prev) => Math.max(1, prev - 1))}
|
|
195
|
+
disabled={currentPage === 1}
|
|
196
|
+
>
|
|
197
|
+
<ChevronLeftIcon className="h-4 w-4" />
|
|
198
|
+
</Button>
|
|
199
|
+
<div className="text-sm text-muted-foreground px-2">
|
|
200
|
+
{currentPage} / {totalPages}
|
|
279
201
|
</div>
|
|
202
|
+
<Button
|
|
203
|
+
variant="outline"
|
|
204
|
+
size="sm"
|
|
205
|
+
onClick={() => setCurrentPage((prev) => Math.min(totalPages, prev + 1))}
|
|
206
|
+
disabled={currentPage === totalPages}
|
|
207
|
+
>
|
|
208
|
+
<ChevronRightIcon className="h-4 w-4" />
|
|
209
|
+
</Button>
|
|
280
210
|
</div>
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
211
|
+
</div>
|
|
212
|
+
)}
|
|
213
|
+
</div>
|
|
214
|
+
)}
|
|
215
|
+
|
|
216
|
+
{exportedFiles.length === 0 && (
|
|
217
|
+
<div className="text-center py-8 text-muted-foreground text-sm">
|
|
218
|
+
<p>You have no exported files</p>
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
285
221
|
|
|
286
222
|
<Dialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
|
|
287
223
|
<DialogContent>
|
|
@@ -301,7 +237,7 @@ export function ExportedList() {
|
|
|
301
237
|
</DialogFooter>
|
|
302
238
|
</DialogContent>
|
|
303
239
|
</Dialog>
|
|
304
|
-
</
|
|
240
|
+
</div>
|
|
305
241
|
)
|
|
306
242
|
}
|
|
307
243
|
|