|
@@ -582,20 +582,21 @@ const handleAttachFiles = async (orderId: number, files: FileList | File | null)
|
|
|
const id = orderId;
|
|
const id = orderId;
|
|
|
const fileArray = files instanceof FileList ? Array.from(files) : [files];
|
|
const fileArray = files instanceof FileList ? Array.from(files) : [files];
|
|
|
|
|
|
|
|
- const toastId = toast.loading(`Attaching ${fileArray.length} file(s)...`);
|
|
|
|
|
|
|
+ const toastId = toast.loading(`Uploading ${fileArray.length} file(s)...`);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- for (const file of fileArray) {
|
|
|
|
|
- console.log(`DEBUG: Uploading file: ${file.name} to order: ${id}`);
|
|
|
|
|
|
|
+ // Perform parallel uploads for speed
|
|
|
|
|
+ await Promise.all(fileArray.map(async (file) => {
|
|
|
|
|
+ console.log(`DEBUG: Starting upload for: ${file.name} to order: ${id}`);
|
|
|
const fd = new FormData();
|
|
const fd = new FormData();
|
|
|
fd.append("file", file);
|
|
fd.append("file", file);
|
|
|
- await adminAttachFile(id, fd);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return adminAttachFile(id, fd);
|
|
|
|
|
+ }));
|
|
|
|
|
|
|
|
toast.success(`${fileArray.length} file(s) attached successfully`, { id: toastId });
|
|
toast.success(`${fileArray.length} file(s) attached successfully`, { id: toastId });
|
|
|
await fetchData();
|
|
await fetchData();
|
|
|
|
|
|
|
|
- // Re-sync editingOrder if open
|
|
|
|
|
|
|
+ // Re-sync editingOrder if open to show new files immediately
|
|
|
if (editingOrder.value?.id === id) {
|
|
if (editingOrder.value?.id === id) {
|
|
|
const updatedOrder = orders.value.find(o => o.id === id);
|
|
const updatedOrder = orders.value.find(o => o.id === id);
|
|
|
if (updatedOrder) editingOrder.value = updatedOrder;
|
|
if (updatedOrder) editingOrder.value = updatedOrder;
|