W n8n attention vm

This commit is contained in:
alma 2025-05-24 20:34:58 +02:00
parent 486a8db3a8
commit 6ba5c2dd6d

View File

@ -399,7 +399,36 @@ export function MissionsAdminPanel() {
setIsSubmitting(true);
try {
// Prepare the mission data with logo
// First, upload the logo if it exists
let logoPath = null;
if (missionData.logo) {
try {
const formData = new FormData();
formData.append('type', 'logo');
formData.append('file', missionData.logo);
const uploadResponse = await fetch('/api/missions/upload', {
method: 'POST',
body: formData
});
if (!uploadResponse.ok) {
throw new Error('Failed to upload logo');
}
const uploadData = await uploadResponse.json();
logoPath = uploadData.filePath;
} catch (error) {
console.error('Error uploading logo:', error);
toast({
title: "Warning",
description: "Failed to upload logo. Mission will be created without logo.",
variant: "destructive",
});
}
}
// Prepare the mission data with logo path
const formattedData = {
name: missionData.name || '',
oddScope: (Array.isArray(missionData.oddScope) ? missionData.oddScope : [missionData.oddScope]).filter(Boolean) as string[],
@ -417,11 +446,7 @@ export function MissionsAdminPanel() {
'gardien-memoire': gardienDeLaMemoire || ''
},
volunteers: (volontaires || []).filter(Boolean) as string[],
logo: missionData.logo ? {
data: missionData.logo,
name: 'logo.png',
type: 'image/png'
} : null
logo: logoPath
};
// Send to API