W n8n attention vm
This commit is contained in:
parent
9e57d512e5
commit
e6dd911309
@ -427,13 +427,38 @@ export function MissionsAdminPanel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle file uploads after mission creation if needed
|
// Handle file uploads after mission creation if needed
|
||||||
if (selectedLogoFile || selectedAttachments.length > 0) {
|
if (data?.mission?.id && (selectedLogoFile || selectedAttachments.length > 0)) {
|
||||||
// TODO: Implement file upload handling
|
// Upload logo
|
||||||
console.log('Files to be uploaded:', {
|
if (selectedLogoFile) {
|
||||||
logo: selectedLogoFile,
|
const result = await import('@/lib/s3').then(mod => mod.uploadMissionFile({
|
||||||
attachments: selectedAttachments
|
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({
|
toast({
|
||||||
title: "Mission créée avec succès",
|
title: "Mission créée avec succès",
|
||||||
|
|||||||
27
lib/s3.ts
Normal file
27
lib/s3.ts
Normal file
@ -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 };
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user