Add 'frontend/' from commit 'c070c0315d66a44154ab7d9f9ea6c211a15f4dba'
git-subtree-dir: frontend git-subtree-mainline:205a3bd14bgit-subtree-split:c070c0315d
This commit is contained in:
634
frontend/src/views/creators/CreatorHome.vue
Normal file
634
frontend/src/views/creators/CreatorHome.vue
Normal file
@@ -0,0 +1,634 @@
|
||||
<template>
|
||||
<div v-if="creatorProfileStore.creator.id === brandingStore.value.id" class="flex justify-end space-x-2 mb-5 pa-1">
|
||||
<!-- Bouton principal : Éditer ou Enregistrer -->
|
||||
<button
|
||||
v-if="isLoggedIn"
|
||||
@click="isEditMode ? saveChanges() : toggleEditMode()"
|
||||
class="px-4 py-2 rounded-md hover:opacity-90"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"
|
||||
>
|
||||
{{ isEditMode ? 'Enregistrer' : 'Éditer' }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="isEditMode && isLoggedIn"
|
||||
@click="cancelEdit"
|
||||
class="px-4 py-2 rounded-md hover:opacity-90 bg-red-500 text-white"
|
||||
>
|
||||
Annuler
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col space-y-8 px-6 rounded-2xl py-8 shadow-2xl"
|
||||
:style="{ backgroundColor: brandingStore.colors.primary, color: brandingStore.colors.onPrimary }">
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Titre principal -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2"> Titre</div>
|
||||
<textarea v-model="editableMainTitle" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<h1 v-else-if="mainTitle" class="text-4xl font-bold text-center ">{{ mainTitle }}</h1>
|
||||
|
||||
<!-- Image principale -->
|
||||
<div class="relative flex justify-center">
|
||||
<label v-if="isEditMode">
|
||||
<input type="file" @change="updateImage('mainImageUrl', $event)" class="hidden"/>
|
||||
<img :src="mainImageUrl || fallbackImage"
|
||||
alt="Image principale"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</label>
|
||||
<img v-else-if="mainImageUrl" :src="mainImageUrl"
|
||||
alt="Image principale"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"
|
||||
@click="openFullscreen(mainImageUrl)"/>
|
||||
|
||||
<button v-if="isEditMode" @click="deleteImage('mainImageUrl')"
|
||||
class="absolute top-10 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600">
|
||||
X
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Texte sous l'image principale -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2"> Description</div>
|
||||
<textarea v-model="editableMainImageText" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<p v-else-if="mainImageText" class="text-lg text-justify">
|
||||
{{ mainImageText }}
|
||||
</p>
|
||||
|
||||
<!-- Titre video principale -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2"> Titre Vidéo Princpiale</div>
|
||||
<textarea v-model="editableVideoSubtitleMain" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<h2 v-else-if="videoSubtitleMain" class="text-2xl font-semibold text-center" >
|
||||
{{ videoSubtitleMain }}
|
||||
</h2>
|
||||
|
||||
<!-- Vidéo YouTube principale -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2">URL vidéo</div>
|
||||
<input
|
||||
v-if="isEditMode"
|
||||
type="text"
|
||||
v-model="editableVideoUrlMain"
|
||||
class="w-full p-2 border rounded-md"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-center">
|
||||
<div v-if="isEditMode"></div>
|
||||
<div v-else-if="videoUrlMain" class="video-container">
|
||||
<iframe
|
||||
:src="videoUrlMain"
|
||||
title="YouTube video player"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
class="video-frame">
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Texte sous video principale -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2"> Description</div>
|
||||
<textarea v-model="editableMainVideoText" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<p v-else-if="mainVideoText" class="text-lg text-justify">
|
||||
{{ mainVideoText }}
|
||||
</p>
|
||||
|
||||
|
||||
<!-- Sous-titre avant les deux images -->
|
||||
<div v-if="isEditMode">
|
||||
<div v-if="isEditMode" class="text-2xl py-2"> Sous-titre</div>
|
||||
<textarea v-model="editableImagesSubtitle" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<h2 v-else-if="imagesSubtitle" class="text-2xl font-semibold text-center">
|
||||
{{ imagesSubtitle }}
|
||||
</h2>
|
||||
|
||||
<!-- 4 images côte à côte -->
|
||||
<FullscreenImage ref="fullscreenImage" :image-url="currentImage" />
|
||||
<div>
|
||||
<!-- Mode édition -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2">Images</div>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-4">
|
||||
<!-- Première image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input type="file" @change="updateImage('image1Url', $event)" class="hidden" />
|
||||
<img :src="image1Url || fallbackImage"
|
||||
alt="Image 1"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</label>
|
||||
<button @click="deleteImage('image1Url')"
|
||||
class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600">
|
||||
X
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Deuxième image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input type="file" @change="updateImage('image2Url', $event)" class="hidden" />
|
||||
<img :src="image2Url || fallbackImage"
|
||||
alt="Image 2"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</label>
|
||||
<button @click="deleteImage('image2Url')"
|
||||
class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600">
|
||||
X
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Troisième image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input type="file" @change="updateImage('image3Url', $event)" class="hidden" />
|
||||
<img :src="image3Url || fallbackImage"
|
||||
alt="Image 3"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</label>
|
||||
<button @click="deleteImage('image3Url')"
|
||||
class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600">
|
||||
X
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Quatrième image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input type="file" @change="updateImage('image4Url', $event)" class="hidden" />
|
||||
<img :src="image4Url || fallbackImage"
|
||||
alt="Image 4"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</label>
|
||||
<button @click="deleteImage('image4Url')"
|
||||
class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600">
|
||||
X
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mode normal -->
|
||||
<div v-else>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<!-- Première image -->
|
||||
<div class="relative w-full sm:flex-1 sm:min-w-[calc(25%-1rem)]" v-if="image1Url" @click="openFullscreen(image1Url)">
|
||||
<img :src="image1Url" alt="Image 1" class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</div>
|
||||
|
||||
<!-- Deuxième image -->
|
||||
<div class="relative w-full sm:flex-1 sm:min-w-[calc(25%-1rem)]" v-if="image2Url" @click="openFullscreen(image2Url)">
|
||||
<img :src="image2Url" alt="Image 2" class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</div>
|
||||
|
||||
<!-- Troisième image -->
|
||||
<div class="relative w-full sm:flex-1 sm:min-w-[calc(25%-1rem)]" v-if="image3Url" @click="openFullscreen(image3Url)">
|
||||
<img :src="image3Url" alt="Image 3" class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</div>
|
||||
|
||||
<!-- Quatrième image -->
|
||||
<div class="relative w-full sm:flex-1 sm:min-w-[calc(25%-1rem)]" v-if="image4Url" @click="openFullscreen(image4Url)">
|
||||
<img :src="image4Url" alt="Image 4" class="rounded-md max-w-full h-auto cursor-pointer" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Texte sous les deux images -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2"> Images</div>
|
||||
<textarea v-model="editableImagesText" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<p v-else-if="imagesText" class="text-lg text-justify">
|
||||
{{ imagesText }}
|
||||
</p>
|
||||
|
||||
<!-- Sous-titre avant la vidéo -->
|
||||
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2"> Titre Video</div>
|
||||
<textarea v-model="editableVideoSubtitle" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<h2 v-else-if="videoSubtitle" class="text-2xl font-semibold text-center">
|
||||
{{ videoSubtitle }}
|
||||
</h2>
|
||||
|
||||
<!-- Vidéo YouTube -->
|
||||
<div v-if="isEditMode">
|
||||
<div class="text-2xl py-2">URL vidéo</div>
|
||||
<input
|
||||
v-if="isEditMode"
|
||||
type="text"
|
||||
v-model="editableVideoUrl"
|
||||
class="w-full p-2 border rounded-md"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-center">
|
||||
<div v-if="isEditMode"></div>
|
||||
<iframe
|
||||
v-else-if="videoUrl"
|
||||
:src="videoUrl"
|
||||
title="YouTube video player"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
class="rounded-md"
|
||||
style="width: 600px; height: 337px;"
|
||||
></iframe>
|
||||
</div>
|
||||
|
||||
<!-- Texte sous la vidéo -->
|
||||
<div v-if="isEditMode" class="text-2xl"> Description</div>
|
||||
<div v-if="isEditMode">
|
||||
<textarea v-model="editableVideoText" class="w-full p-2 border rounded-md h-24"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"></textarea>
|
||||
</div>
|
||||
<p v-else-if="videoText" class="text-lg text-justify">
|
||||
{{ videoText }}
|
||||
</p>
|
||||
|
||||
<!-- Informations de contact -->
|
||||
<div class="flex flex-col space-y-6 mt-8">
|
||||
<div v-if="isEditMode" class="flex flex-col space-y-2">
|
||||
<!-- Édition du téléphone -->
|
||||
<div>
|
||||
<label class="text-lg">Numéro de téléphone</label>
|
||||
<input
|
||||
v-model="editablePhoneNumber"
|
||||
type="text"
|
||||
class="w-full p-2 border rounded-md"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"
|
||||
/>
|
||||
</div>
|
||||
<!-- Édition de l'email -->
|
||||
<div>
|
||||
<label class="text-lg">Adresse email</label>
|
||||
<input
|
||||
v-model="editableEmail"
|
||||
type="text"
|
||||
class="w-full p-2 border rounded-md"
|
||||
:style="{ backgroundColor: brandingStore.colors.secondary, color: brandingStore.colors.onSecondary }"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="flex flex-col sm:flex-row sm:space-x-64 space-y-4 sm:space-y-0 justify-center items-center"
|
||||
>
|
||||
<!-- Affichage du téléphone -->
|
||||
<div v-if="editablePhoneNumber" class="flex items-center space-x-2">
|
||||
<i class="mdi mdi-phone-outline text-2xl"></i>
|
||||
<span>{{ editablePhoneNumber }}</span>
|
||||
</div>
|
||||
<!-- Affichage de l'email -->
|
||||
<div v-if="editableEmail" class="flex items-center space-x-2">
|
||||
<i class="mdi mdi-email-outline text-2xl"></i>
|
||||
<a
|
||||
:href="`mailto:${editableEmail}`"
|
||||
class="no-underline text-current"
|
||||
>
|
||||
{{ editableEmail }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref, onMounted} from "vue";
|
||||
import { useClient } from "@/plugins/api.js";
|
||||
import {useBrandingStore} from "@/stores/brandingStore.js";
|
||||
import { useCreatorProfileStore } from "@/stores/creatorProfileStore.js";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { watch} from "vue";
|
||||
import FullscreenImage from "@/views/creators/FullscreenImage.vue";
|
||||
|
||||
const { smAndDown } = useDisplay();
|
||||
const isMobileView = ref(smAndDown.value);
|
||||
|
||||
|
||||
const creatorProfileStore = useCreatorProfileStore();
|
||||
const brandingStore = useBrandingStore();
|
||||
const client = useClient();
|
||||
|
||||
const isLoading = ref(true);
|
||||
const isLoggedIn = true;
|
||||
const isEditMode = ref(false);
|
||||
|
||||
|
||||
|
||||
const currentImage = ref("");
|
||||
const fullscreenImage = ref(null);
|
||||
|
||||
function openFullscreen(imageUrl) {
|
||||
currentImage.value = imageUrl;
|
||||
fullscreenImage.value.open();
|
||||
}
|
||||
|
||||
watch(smAndDown, (newVal) => {
|
||||
isMobileView.value = newVal;
|
||||
});
|
||||
|
||||
// Image de fallback pour l'éditeur
|
||||
const fallbackImage = "https://via.placeholder.com/300?text=Image+non+disponible";
|
||||
|
||||
// Variables réactives pour les données
|
||||
const editablePhoneNumber = ref("");
|
||||
const editableEmail = ref("");
|
||||
const mainTitle = ref("");
|
||||
const mainImageUrl = ref("");
|
||||
const mainImageText = ref("");
|
||||
const mainVideoText = ref("");
|
||||
const imagesSubtitle = ref("");
|
||||
const image1Url = ref("");
|
||||
const image2Url = ref("");
|
||||
const image3Url = ref("");
|
||||
const image4Url = ref("");
|
||||
const imagesText = ref("");
|
||||
const videoSubtitle = ref("");
|
||||
const videoSubtitleMain = ref("");
|
||||
const videoUrlMain = ref("");
|
||||
const videoUrl = ref("");
|
||||
const videoText = ref("");
|
||||
const phoneNumber = ref("");
|
||||
const email = ref("");
|
||||
|
||||
|
||||
const editableImages = ref([null, null, null, null]);
|
||||
|
||||
|
||||
// Editable fields
|
||||
const editableMainTitle = ref("");
|
||||
const editableMainImageText = ref("");
|
||||
const editableMainVideoText = ref("");
|
||||
const editableImagesSubtitle = ref("");
|
||||
const editableImagesText = ref("");
|
||||
const editableVideoSubtitle = ref("");
|
||||
const editableVideoSubtitleMain = ref("");
|
||||
const editableVideoText = ref("");
|
||||
const editableVideoUrlMain = ref("");
|
||||
const editableVideoUrl = ref("");
|
||||
|
||||
// Activer/désactiver le mode édition
|
||||
function toggleEditMode() {
|
||||
isEditMode.value = !isEditMode.value;
|
||||
if (isEditMode.value) {
|
||||
// Charger les valeurs pour l'édition
|
||||
editableMainTitle.value = mainTitle.value;
|
||||
editableMainImageText.value = mainImageText.value;
|
||||
editableMainVideoText.value = mainVideoText.value;
|
||||
editableImagesSubtitle.value = imagesSubtitle.value;
|
||||
editableImagesText.value = imagesText.value;
|
||||
editableVideoSubtitle.value = videoSubtitle.value;
|
||||
editableVideoSubtitleMain.value = videoSubtitleMain.value;
|
||||
editableVideoText.value = videoText.value;
|
||||
editableVideoUrlMain.value = videoUrlMain.value;
|
||||
editableVideoUrl.value = videoUrl.value;
|
||||
editablePhoneNumber.value = phoneNumber.value;
|
||||
editableEmail.value = email.value;
|
||||
} else {
|
||||
// Sauvegarder les modifications ou réinitialiser les URLs des images supprimées
|
||||
mainTitle.value = editableMainTitle.value;
|
||||
mainImageText.value = editableMainImageText.value;
|
||||
mainVideoText.value = editableMainVideoText.value;
|
||||
imagesSubtitle.value = editableImagesSubtitle.value;
|
||||
imagesText.value = editableImagesText.value;
|
||||
videoSubtitle.value = editableVideoSubtitle.value;
|
||||
videoSubtitleMain.value = editableVideoSubtitleMain.value;
|
||||
videoText.value = editableVideoText.value;
|
||||
videoUrlMain.value = editableVideoUrlMain.value;
|
||||
videoUrl.value = editableVideoUrl.value;
|
||||
phoneNumber.value = editablePhoneNumber.value;
|
||||
email.value = editableEmail.value;
|
||||
|
||||
// Réinitialisation des images supprimées à des strings vides si nécessaire
|
||||
if (mainImageUrl.value === null) mainImageUrl.value = "";
|
||||
if (image1Url.value === null) image1Url.value = "";
|
||||
if (image2Url.value === null) image2Url.value = "";
|
||||
if (image3Url.value === null) image3Url.value = "";
|
||||
if (image4Url.value === null) image4Url.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Supprimer une image
|
||||
function deleteImage(field) {
|
||||
switch (field) {
|
||||
case "mainImageUrl":
|
||||
mainImageUrl.value = ""; // Remplace par un string vide
|
||||
break;
|
||||
case "image1Url":
|
||||
image1Url.value = ""; // Remplace par un string vide
|
||||
break;
|
||||
case "image2Url":
|
||||
image2Url.value = ""; // Remplace par un string vide
|
||||
break;
|
||||
case "image3Url":
|
||||
image3Url.value = ""; // Remplace par un string vide
|
||||
break;
|
||||
case "image4Url":
|
||||
image4Url.value = ""; // Remplace par un string vide
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mettre à jour une image
|
||||
function updateImage(field, event) {
|
||||
const file = event.target.files[0];
|
||||
if (file) {
|
||||
// Stocker le fichier dans editableImages pour l'envoi
|
||||
switch (field) {
|
||||
case "mainImageUrl":
|
||||
editableImages.value[0] = file;
|
||||
mainImageUrl.value = URL.createObjectURL(file);
|
||||
break;
|
||||
case "image1Url":
|
||||
editableImages.value[1] = file;
|
||||
image1Url.value = URL.createObjectURL(file);
|
||||
break;
|
||||
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
|
||||
onMounted(() => {
|
||||
mainTitle.value = brandingStore.presentationInfos.title;
|
||||
mainImageUrl.value = brandingStore.presentationInfos.mainImageUrl;
|
||||
mainImageText.value = brandingStore.presentationInfos.mainImageText;
|
||||
mainVideoText.value = brandingStore.presentationInfos.mainVideoText;
|
||||
imagesSubtitle.value = brandingStore.presentationInfos.imagesSubtitle;
|
||||
image1Url.value = brandingStore.presentationInfos.image1Url;
|
||||
image2Url.value = brandingStore.presentationInfos.image2Url;
|
||||
image3Url.value = brandingStore.presentationInfos.image3Url;
|
||||
image4Url.value = brandingStore.presentationInfos.image4Url;
|
||||
imagesText.value = brandingStore.presentationInfos.imagesText;
|
||||
videoSubtitle.value = brandingStore.presentationInfos.videoSubtitle;
|
||||
videoSubtitleMain.value = brandingStore.presentationInfos.videoSubtitleMain;
|
||||
videoUrl.value = brandingStore.presentationInfos.videoUrl;
|
||||
videoUrlMain.value = brandingStore.presentationInfos.videoUrlMain;
|
||||
videoText.value = brandingStore.presentationInfos.videoText;
|
||||
editablePhoneNumber.value = brandingStore.presentationInfos.phoneNumber;
|
||||
editableEmail.value= brandingStore.presentationInfos.email;
|
||||
phoneNumber.value = brandingStore.presentationInfos.phoneNumber;
|
||||
email.value = brandingStore.presentationInfos.email;
|
||||
});
|
||||
|
||||
async function saveChanges() {
|
||||
if (!creatorProfileStore.creator.id) {
|
||||
console.error("L'ID du créateur est manquant !");
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
// Ajout des champs textuels
|
||||
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 URLs d'images supprimées
|
||||
formData.append("MainImageUrl", mainImageUrl.value || ""); // Peut contenir un string vide
|
||||
formData.append("Image1Url", image1Url.value || "");
|
||||
formData.append("Image2Url", image2Url.value || "");
|
||||
formData.append("Image3Url", image3Url.value || "");
|
||||
formData.append("Image4Url", image4Url.value || "");
|
||||
|
||||
// Ajout des fichiers d'images téléversées
|
||||
if (editableImages.value[0]) formData.append("MainImage", editableImages.value[0]);
|
||||
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 {
|
||||
// Désactiver le bouton de sauvegarde pour éviter les clics multiples
|
||||
isLoading.value = true;
|
||||
|
||||
// Envoyer les données au backend
|
||||
const response = await client.post(
|
||||
`/api/creators/${creatorProfileStore.creator.id}/presentation-infos`,
|
||||
formData,
|
||||
{ headers: { "Content-Type": "multipart/form-data" } }
|
||||
);
|
||||
|
||||
// Mettre à jour les valeurs locales pour refléter les changements
|
||||
mainTitle.value = editableMainTitle.value;
|
||||
mainImageText.value = editableMainImageText.value;
|
||||
mainVideoText.value = editableMainVideoText.value;
|
||||
imagesSubtitle.value = editableImagesSubtitle.value;
|
||||
imagesText.value = editableImagesText.value;
|
||||
videoSubtitle.value = editableVideoSubtitle.value;
|
||||
videoSubtitleMain.value = editableVideoSubtitleMain.value;
|
||||
videoText.value = editableVideoText.value;
|
||||
videoUrlMain.value = editableVideoUrlMain.value;
|
||||
videoUrl.value = editableVideoUrl.value;
|
||||
phoneNumber.value = editablePhoneNumber.value;
|
||||
email.value = editableEmail.value;
|
||||
|
||||
console.log("Données sauvegardées :", response.data);
|
||||
|
||||
// Réinitialiser le mode édition
|
||||
isEditMode.value = false;
|
||||
|
||||
// Rafraîchir après une légère pause pour s'assurer des mises à jour visuelles
|
||||
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la sauvegarde :", error);
|
||||
} finally {
|
||||
// Réactiver les interactions
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function cancelEdit() {
|
||||
// Restaurer les valeurs d'origine
|
||||
editableMainTitle.value = mainTitle.value;
|
||||
editableMainImageText.value = mainImageText.value;
|
||||
editableMainVideoText.value = mainVideoText.value;
|
||||
editableImagesSubtitle.value = imagesSubtitle.value;
|
||||
editableImagesText.value = imagesText.value;
|
||||
editableVideoSubtitle.value = videoSubtitle.value;
|
||||
editableVideoSubtitleMain.value = videoSubtitleMain.value;
|
||||
editableVideoText.value = videoText.value;
|
||||
editableVideoUrlMain.value = videoUrlMain.value;
|
||||
editableVideoUrl.value = videoUrl.value;
|
||||
editablePhoneNumber.value = phoneNumber.value;
|
||||
editableEmail.value = email.value;
|
||||
|
||||
// Désactiver le mode édition
|
||||
isEditMode.value = false;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.video-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-top: 56.25%; /* Ratio 16:9 (9/16 = 0.5625) */
|
||||
}
|
||||
|
||||
.video-frame {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
border-radius: 0.5rem; /* Pour les bords arrondis */
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user