Wip upload d'image présentation
This commit is contained in:
@@ -420,24 +420,37 @@ function deleteImage(field) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mettre à jour une image
|
// Mettre à jour une image
|
||||||
function updateImage(index, event) {
|
function updateImage(field, event) {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
// Stocker le fichier pour l'enregistrement
|
// Stocker le fichier dans editableImages pour l'envoi
|
||||||
editableImages.value[index] = file;
|
switch (field) {
|
||||||
|
case "mainImageUrl":
|
||||||
// Générer une URL temporaire pour la prévisualisation
|
editableImages.value[0] = file;
|
||||||
const previewUrl = URL.createObjectURL(file);
|
mainImageUrl.value = URL.createObjectURL(file);
|
||||||
|
break;
|
||||||
// Mettre à jour la prévisualisation (remplacer dans l'interface utilisateur)
|
case "image1Url":
|
||||||
if (index === 0) image1Url.value = previewUrl;
|
editableImages.value[1] = file;
|
||||||
else if (index === 1) image2Url.value = previewUrl;
|
image1Url.value = URL.createObjectURL(file);
|
||||||
else if (index === 2) image3Url.value = previewUrl;
|
break;
|
||||||
else if (index === 3) image4Url.value = previewUrl;
|
case "image2Url":
|
||||||
|
editableImages.value[2] = file;
|
||||||
|
image2Url.value = URL.createObjectURL(file);
|
||||||
|
break;
|
||||||
|
case "image3Url":
|
||||||
|
editableImages.value[3] = file;
|
||||||
|
image3Url.value = URL.createObjectURL(file);
|
||||||
|
break;
|
||||||
|
case "image4Url":
|
||||||
|
editableImages.value[4] = file;
|
||||||
|
image4Url.value = URL.createObjectURL(file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Charger les données au montage
|
// Charger les données au montage
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
mainTitle.value = brandingStore.presentationInfos.title;
|
mainTitle.value = brandingStore.presentationInfos.title;
|
||||||
@@ -467,31 +480,34 @@ async function saveChanges() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = {
|
const formData = new FormData();
|
||||||
PhoneNumber: editablePhoneNumber.value,
|
|
||||||
Email: editableEmail.value,
|
|
||||||
Title: editableMainTitle.value,
|
|
||||||
MainImageText: editableMainImageText.value,
|
|
||||||
MainVideoText: editableMainVideoText.value,
|
|
||||||
ImagesSubtitle: editableImagesSubtitle.value,
|
|
||||||
ImagesText: editableImagesText.value,
|
|
||||||
VideoSubtitle: editableVideoSubtitle.value,
|
|
||||||
VideoSubtitleMain: editableVideoSubtitleMain.value,
|
|
||||||
VideoUrlMain: editableVideoUrlMain.value,
|
|
||||||
VideoUrl: editableVideoUrl.value,
|
|
||||||
VideoText: editableVideoText.value
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Ajout des champs textuels au payload
|
||||||
|
formData.append("PhoneNumber", editablePhoneNumber.value || "");
|
||||||
|
formData.append("Email", editableEmail.value || "");
|
||||||
|
formData.append("Title", editableMainTitle.value || "");
|
||||||
|
formData.append("MainImageText", editableMainImageText.value || "");
|
||||||
|
formData.append("MainVideoText", editableMainVideoText.value || "");
|
||||||
|
formData.append("ImagesSubtitle", editableImagesSubtitle.value || "");
|
||||||
|
formData.append("ImagesText", editableImagesText.value || "");
|
||||||
|
formData.append("VideoSubtitle", editableVideoSubtitle.value || "");
|
||||||
|
formData.append("VideoSubtitleMain", editableVideoSubtitleMain.value || "");
|
||||||
|
formData.append("VideoUrlMain", editableVideoUrlMain.value || "");
|
||||||
|
formData.append("VideoUrl", editableVideoUrl.value || "");
|
||||||
|
formData.append("VideoText", editableVideoText.value || "");
|
||||||
|
|
||||||
|
// Ajout des fichiers au payload
|
||||||
|
if (editableImages.value[0]) formData.append("MainImage", editableImages.value[0]);
|
||||||
console.log("Payload envoyé :", payload);
|
if (editableImages.value[1]) formData.append("Image1", editableImages.value[1]);
|
||||||
|
if (editableImages.value[2]) formData.append("Image2", editableImages.value[2]);
|
||||||
|
if (editableImages.value[3]) formData.append("Image3", editableImages.value[3]);
|
||||||
|
if (editableImages.value[4]) formData.append("Image4", editableImages.value[4]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await client.post(
|
const response = await client.post(
|
||||||
`/api/creators/${creatorProfileStore.creator.id}/presentation-infos`,
|
`/api/creators/${creatorProfileStore.creator.id}/presentation-infos`,
|
||||||
payload,
|
formData,
|
||||||
{ headers: { "Content-Type": "application/json" } }
|
{ headers: { "Content-Type": "multipart/form-data" } }
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("Données sauvegardées :", response.data);
|
console.log("Données sauvegardées :", response.data);
|
||||||
@@ -503,6 +519,7 @@ async function saveChanges() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cancelEdit() {
|
function cancelEdit() {
|
||||||
// Restaurer les valeurs d'origine
|
// Restaurer les valeurs d'origine
|
||||||
editableMainTitle.value = mainTitle.value;
|
editableMainTitle.value = mainTitle.value;
|
||||||
|
|||||||
Reference in New Issue
Block a user