From e6dd9113099addf3cf4ad9d5070ea6ccac068d34 Mon Sep 17 00:00:00 2001 From: alma Date: Sat, 24 May 2025 19:34:35 +0200 Subject: [PATCH] W n8n attention vm --- .DS_Store | Bin 10244 -> 10244 bytes components/missions/missions-admin-panel.tsx | 37 ++++++++++++++++--- lib/s3.ts | 27 ++++++++++++++ logo.png | Bin 0 -> 68 bytes 4 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 lib/s3.ts create mode 100644 logo.png diff --git a/.DS_Store b/.DS_Store index 340fe96d8ea6c46e3048925e4b9dc746bd287c6c..60b378a632a6b0b93887564a9d098a73c66c9bdc 100644 GIT binary patch delta 46 zcmV+}0MY-1P=rvBPXQ;fP`eKSCzA{ig|pib^a7Kq6zsF{6&4DyfPewB2O#Sc8pWJp%*Nxy@|? z|Cv<98GIQk8R8kr8S)v57_u4Cfa>#sym$sf1|tSNh9scg?8$ZllDe`WP5;4w0R)8c z=>+PK(1X}RlolffL!cJT$*sa~Y~>jIfKJF`Pyjj}M5i%i0-cu2@DeCu26U7KgE4~v sgE`P~$w2WGuygak&Q4@Vnd~7TzqwFEjB7Ky!Y`J|cZH`=#XMmq08gD#v;Y7A diff --git a/components/missions/missions-admin-panel.tsx b/components/missions/missions-admin-panel.tsx index b63ba8cd..56a55ece 100644 --- a/components/missions/missions-admin-panel.tsx +++ b/components/missions/missions-admin-panel.tsx @@ -427,12 +427,37 @@ export function MissionsAdminPanel() { } // Handle file uploads after mission creation if needed - if (selectedLogoFile || selectedAttachments.length > 0) { - // TODO: Implement file upload handling - console.log('Files to be uploaded:', { - logo: selectedLogoFile, - attachments: selectedAttachments - }); + if (data?.mission?.id && (selectedLogoFile || selectedAttachments.length > 0)) { + // Upload logo + if (selectedLogoFile) { + const result = await import('@/lib/s3').then(mod => mod.uploadMissionFile({ + missionId: data.mission.id, + file: selectedLogoFile, + type: 'logo', + })); + if (!result.success) { + toast({ + title: "Erreur", + description: result.error || "Erreur lors de l'upload du logo", + variant: "destructive", + }); + } + } + // Upload attachments + for (const file of selectedAttachments) { + const result = await import('@/lib/s3').then(mod => mod.uploadMissionFile({ + missionId: data.mission.id, + file, + type: 'attachment', + })); + if (!result.success) { + toast({ + title: "Erreur", + description: result.error || `Erreur lors de l'upload du fichier ${file.name}`, + variant: "destructive", + }); + } + } } toast({ diff --git a/lib/s3.ts b/lib/s3.ts new file mode 100644 index 00000000..28261fda --- /dev/null +++ b/lib/s3.ts @@ -0,0 +1,27 @@ +export async function uploadMissionFile({ + missionId, + file, + type, // 'logo' or 'attachment' +}: { + missionId: string; + file: File; + type: 'logo' | 'attachment'; +}): Promise<{ success: boolean; data?: any; error?: string }> { + const formData = new FormData(); + formData.append('missionId', missionId); + formData.append('type', type); + formData.append('file', file); + + const res = await fetch('/api/missions/upload', { + method: 'POST', + body: formData, + }); + + if (!res.ok) { + const err = await res.json().catch(() => ({})); + return { success: false, error: err.error || 'Upload failed' }; + } + + const data = await res.json(); + return { success: true, data }; +} \ No newline at end of file diff --git a/logo.png b/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..26a8c68efad2a094e8fe6d850426b651d353c568 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcwN$DL?ob7+Dz^)g>OM Q0fiYnUHx3vIVCg!0A@T4ng9R* literal 0 HcmV?d00001