Adds PhotoAlbum, CreatorHome, AboutCreator.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="p-4 relative"
|
||||
<div class="p-4 relative"
|
||||
@mouseenter="showEditButtons = isLoggedIn && creatorProfileStore.creator?.id === brandingStore.value.id"
|
||||
@mouseleave="showEditButtons = false">
|
||||
|
||||
|
||||
<!-- Edit buttons with absolute positioning -->
|
||||
<div v-if="showEditButtons || isEditMode"
|
||||
class="absolute top-4 right-4 flex gap-2">
|
||||
@@ -12,7 +12,7 @@
|
||||
v-if="!isEditMode"
|
||||
class="w-12 h-12 bg-hutopyPrimary rounded-full flex items-center justify-center shadow-lg"
|
||||
@click="toggleEditMode()"
|
||||
:title="t('common.edit')"
|
||||
:title="t('edit')"
|
||||
>
|
||||
<v-icon large>mdi-pencil</v-icon>
|
||||
</button>
|
||||
@@ -22,7 +22,7 @@
|
||||
v-if="isEditMode"
|
||||
class="w-12 h-12 bg-hutopyPrimary rounded-full flex items-center justify-center shadow-lg"
|
||||
@click="saveChanges()"
|
||||
:title="t('common.save')"
|
||||
:title="t('save')"
|
||||
>
|
||||
<v-icon large>mdi-check</v-icon>
|
||||
</button>
|
||||
@@ -32,279 +32,87 @@
|
||||
v-if="isEditMode"
|
||||
class="w-12 h-12 bg-red-500 rounded-full flex items-center justify-center shadow-lg"
|
||||
@click="cancelEdit"
|
||||
:title="t('common.cancel')"
|
||||
:title="t('cancel')"
|
||||
>
|
||||
<v-icon large>mdi-close</v-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- MainPage -->
|
||||
<div class="flex flex-col mt-4">
|
||||
<div class="flex flex-col">
|
||||
|
||||
<h1 class="flex justify-start text-2xl font-bold text-center">{{ t('creator.sections.about.title') }}</h1>
|
||||
|
||||
<div>
|
||||
<!-- Main image Bloc D'information-->
|
||||
<div class="py-4">
|
||||
<h1 class="flex justify-start text-2xl font-bold text-center mb-4">
|
||||
{{ t('creator.sections.about.title') }}
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<!-- Description Section -->
|
||||
<div>
|
||||
<div v-if="!isEditMode">
|
||||
<p v-if="mainImageText" class="text-lg text-justify">
|
||||
{{ mainImageText }}
|
||||
<p v-if="description" class="text-lg text-justify mb-6">
|
||||
{{ description }}
|
||||
</p>
|
||||
</div>
|
||||
<v-textarea v-if="isEditMode" v-model="editableMainImageText" class="w-full p-2 py-6 " :label="t('creator.sections.about.description')"
|
||||
<v-textarea v-if="isEditMode"
|
||||
v-model="editableDescription"
|
||||
class="w-full p-2 py-6"
|
||||
:label="t('creator.sections.about.description')"
|
||||
variant="outlined"></v-textarea>
|
||||
|
||||
<div class="flex flex-row items-center space-x-4">
|
||||
<!-- image principale-->
|
||||
<div v-if="!isEditMode" class="flex justify-center items-center w-1/2">
|
||||
<img
|
||||
v-if="mainImageUrl"
|
||||
:src="mainImageUrl"
|
||||
:alt="t('creator.sections.about.mainImage')"
|
||||
class="max-w-full h-auto cursor-pointer"/>
|
||||
</div>
|
||||
<div v-if="isEditMode" class="relative flex justify-center">
|
||||
<label>
|
||||
<input class="hidden" type="file" @change="updateImage('mainImageUrl', $event)"/>
|
||||
<img :src="mainImageUrl || fallbackImage"
|
||||
:alt="t('creator.sections.about.mainImage')"
|
||||
class=" max-w-full h-auto cursor-pointer max-h-96"/>
|
||||
</label>
|
||||
<button v-if="isEditMode"
|
||||
class="absolute top-10 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600"
|
||||
@click="deleteImage('mainImageUrl')">
|
||||
{{ t('common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="w-1/2 flex flex-col justify-center">
|
||||
<h2 v-if="videoSubtitleMain" class="text-xl font-semibold text-center">
|
||||
{{ t('creator.sections.support.title') }}
|
||||
</h2>
|
||||
|
||||
<div v-if="!isEditMode">
|
||||
<p v-if="mainVideoText" class="text-lg text-justify">
|
||||
{{ mainVideoText }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="isEditMode">
|
||||
<v-textarea
|
||||
v-model="editableMainVideoText"
|
||||
class="p-2 rounded-md mt-4"
|
||||
:label="t('creator.sections.support.description')"
|
||||
rows="10"
|
||||
variant="outlined"
|
||||
></v-textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div v-if="!isEditMode" class="py-5 text-lg font-bold">
|
||||
{{ videoSubtitle }}
|
||||
</div>
|
||||
<div v-if="isEditMode">
|
||||
<v-text-field
|
||||
v-model="editableVideoSubtitle"
|
||||
class="w-full p-2"
|
||||
:label="t('creator.sections.support.subtitle')"
|
||||
variant="outlined"
|
||||
></v-text-field>
|
||||
</div>
|
||||
|
||||
<v-textarea v-if="isEditMode"
|
||||
v-model="editableVideoText"
|
||||
class="w-full p-2"
|
||||
:label="t('creator.sections.support.description')"
|
||||
variant="outlined"
|
||||
></v-textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- media-->
|
||||
<div v-if="!isEditMode">
|
||||
<div v-if="videoUrlMain" class="video-container">
|
||||
|
||||
<!-- Video Section -->
|
||||
<div v-if="videoUrl || isEditMode"
|
||||
:class="['content-section', {
|
||||
'rounded-t-xl': hasImages || isEditMode,
|
||||
'rounded-xl': !hasImages && !isEditMode
|
||||
}]">
|
||||
<div v-if="!isEditMode && videoUrl" class="video-container">
|
||||
<iframe
|
||||
:src="videoUrlMain"
|
||||
:src="youtubeEmbedUrl"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
class="video-frame"
|
||||
title="YouTube video player">
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isEditMode">
|
||||
<v-text-field
|
||||
v-model="editableVideoUrlMain"
|
||||
class="w-full p-2 rounded-md"
|
||||
:label="t('creator.fields.videoUrl')"
|
||||
type="text"
|
||||
variant="outlined"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Images -->
|
||||
|
||||
<div v-if="!isEditMode">
|
||||
<div v-if="imagesSubtitle || image1Url || image2Url || image3Url || image4Url || imagesText ">
|
||||
<!-- images-->
|
||||
<div class="py-2">
|
||||
<div>
|
||||
<!-- Affichage des images -->
|
||||
<div class="flex gap-2">
|
||||
<!-- Première image -->
|
||||
<div v-if="image1Url" class="relative w-full sm:flex-1 ">
|
||||
<img :src="image1Url"
|
||||
:alt="t('creator.sections.about.image1')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</div>
|
||||
|
||||
<!-- Deuxième image -->
|
||||
<div v-if="image2Url" class="relative w-full sm:flex-1 ">
|
||||
<img :src="image2Url"
|
||||
:alt="t('creator.sections.about.image2')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</div>
|
||||
|
||||
<!-- Troisième image -->
|
||||
<div v-if="image3Url" class="relative w-full sm:flex-1 ">
|
||||
<img :src="image3Url"
|
||||
:alt="t('creator.sections.about.image3')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</div>
|
||||
|
||||
<!-- Quatrième image -->
|
||||
<div v-if="image4Url" class="relative w-full sm:flex-1 ">
|
||||
<img :src="image4Url"
|
||||
:alt="t('creator.sections.about.image4')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isEditMode">
|
||||
<v-text-field
|
||||
v-model="editableVideoUrl"
|
||||
class="w-full p-2"
|
||||
:label="t('creator.fields.videoUrl')"
|
||||
type="text"
|
||||
variant="outlined"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isEditMode" class="rounded-2xl">
|
||||
<!--images-->
|
||||
<div class=" text-2xl pa-2">{{ t('creator.sections.about.images') }}</div>
|
||||
<div class="pa-2 grid grid-cols-1 gap-4 md:grid-cols-4">
|
||||
<!-- Première image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input class="hidden" type="file" @change="updateImage('image1Url', $event)"/>
|
||||
<img :src="image1Url || fallbackImage"
|
||||
:alt="t('creator.sections.about.image1')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</label>
|
||||
<button class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600"
|
||||
@click="deleteImage('image1Url')">
|
||||
{{ t('common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Deuxième image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input class="hidden" type="file" @change="updateImage('image2Url', $event)"/>
|
||||
<img :src="image2Url || fallbackImage"
|
||||
:alt="t('creator.sections.about.image2')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</label>
|
||||
<button class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600"
|
||||
@click="deleteImage('image2Url')">
|
||||
{{ t('common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Troisième image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input class="hidden" type="file" @change="updateImage('image3Url', $event)"/>
|
||||
<img :src="image3Url || fallbackImage"
|
||||
:alt="t('creator.sections.about.image3')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</label>
|
||||
<button class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600"
|
||||
@click="deleteImage('image3Url')">
|
||||
{{ t('common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Quatrième image -->
|
||||
<div class="relative">
|
||||
<label>
|
||||
<input class="hidden" type="file" @change="updateImage('image4Url', $event)"/>
|
||||
<img :src="image4Url || fallbackImage"
|
||||
:alt="t('creator.sections.about.image4')"
|
||||
class="rounded-md max-w-full h-auto cursor-pointer"/>
|
||||
</label>
|
||||
<button class="absolute top-2 right-2 px-2 py-1 bg-red-500 text-white hover:bg-red-600"
|
||||
@click="deleteImage('image4Url')">
|
||||
{{ t('common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Description-->
|
||||
<div class="text-2xl pa-2">{{ t('creator.sections.about.description') }}</div>
|
||||
</div>
|
||||
|
||||
<!--Edit-->
|
||||
<div v-if="isEditMode">
|
||||
<v-text-field
|
||||
v-model="editablePhoneNumber"
|
||||
class="w-full p-2"
|
||||
:label="t('creator.fields.phoneNumber')"
|
||||
variant="outlined"
|
||||
></v-text-field>
|
||||
|
||||
<v-text-field
|
||||
v-model="editableEmail"
|
||||
class="w-full p-2"
|
||||
:label="t('creator.fields.email')"
|
||||
variant="outlined"
|
||||
></v-text-field>
|
||||
</div>
|
||||
|
||||
<!-- Contact Info-->
|
||||
<div v-if="!isEditMode && phoneNumber || email">
|
||||
|
||||
<div class="my-10 flex flex-row">
|
||||
|
||||
<div v-if="phoneNumber" class="flex items-center space-x-2 w-1/2 justify-center">
|
||||
<i class="mdi mdi-phone-outline text-2xl"></i>
|
||||
<span>{{ phoneNumber }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Affichage de l'email -->
|
||||
<div v-if="email" class="flex items-center space-x-2 w-1/2 justify-center">
|
||||
<i class="mdi mdi-email-outline text-2xl"></i>
|
||||
<a :href="`mailto:${email}`" class="no-underline text-current">
|
||||
{{ email }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- Photos Section using CreatorAlbum component -->
|
||||
<CreatorAlbum
|
||||
v-if="hasImages || isEditMode"
|
||||
:is-edit-mode="isEditMode"
|
||||
:images="imageUrls"
|
||||
@update:images="updateImages"
|
||||
@update:isEditMode="isEditMode = $event"
|
||||
:class="['content-section', {
|
||||
'rounded-b-xl': videoUrl || isEditMode,
|
||||
'rounded-xl': !videoUrl && !isEditMode
|
||||
}]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {onMounted, ref} from "vue";
|
||||
import {onMounted, ref, computed} from "vue";
|
||||
import {useClient} from "@/plugins/api.js";
|
||||
import {useBrandingStore} from "@/stores/brandingStore.js";
|
||||
import {useCreatorProfileStore} from "@/stores/creatorProfileStore.js";
|
||||
import {useAuthStore} from "@/stores/authStore.js";
|
||||
import {useI18n} from 'vue-i18n';
|
||||
import CreatorAlbum from './CreatorAlbum.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const authStore = useAuthStore();
|
||||
const {t} = useI18n();
|
||||
const creatorProfileStore = useCreatorProfileStore();
|
||||
const brandingStore = useBrandingStore();
|
||||
const client = useClient();
|
||||
@@ -314,193 +122,169 @@ const isLoggedIn = true;
|
||||
const isEditMode = ref(false);
|
||||
const showEditButtons = ref(false);
|
||||
|
||||
const fallbackImage = "/medias/emptyimage.png";
|
||||
|
||||
// Variables réactives pour les données
|
||||
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 phoneNumber = ref("");
|
||||
const email = ref("");
|
||||
const description = ref("");
|
||||
const videoUrl = ref("");
|
||||
const imageUrls = ref([]);
|
||||
const albumId = ref(null);
|
||||
const originalPhotos = ref([]);
|
||||
|
||||
// Editable fields
|
||||
const editableMainTitle = ref("");
|
||||
const editableMainImageText = ref("");
|
||||
const editableMainVideoText = ref("");
|
||||
const editableImagesText = ref("");
|
||||
const editableVideoSubtitle = ref("");
|
||||
const editableVideoUrlMain = ref("");
|
||||
const editablePhoneNumber = ref("");
|
||||
const editableEmail = ref("");
|
||||
const editableDescription = ref("");
|
||||
const editableVideoUrl = ref("");
|
||||
|
||||
const editableImages = ref([null, null, null, null]);
|
||||
// Computed property to check if there are images
|
||||
const hasImages = computed(() => {
|
||||
// Only consider it has images if there are actual image URLs (not empty strings)
|
||||
return imageUrls.value.some(img => img && img.trim() !== "");
|
||||
});
|
||||
|
||||
// Computed property for YouTube embed URL
|
||||
const youtubeEmbedUrl = computed(() => {
|
||||
if (!videoUrl.value) return "";
|
||||
return `https://www.youtube.com/embed/${videoUrl.value}`;
|
||||
});
|
||||
|
||||
// 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;
|
||||
editableImagesText.value = imagesText.value;
|
||||
editableVideoSubtitle.value = videoSubtitle.value;
|
||||
editableVideoUrlMain.value = videoUrlMain.value;
|
||||
editablePhoneNumber.value = phoneNumber.value;
|
||||
editableEmail.value = email.value;
|
||||
} else {
|
||||
// Sauvegarder les modifications
|
||||
mainTitle.value = editableMainTitle.value;
|
||||
mainImageText.value = editableMainImageText.value;
|
||||
mainVideoText.value = editableMainVideoText.value;
|
||||
imagesText.value = editableImagesText.value;
|
||||
videoSubtitle.value = editableVideoSubtitle.value;
|
||||
videoUrlMain.value = editableVideoUrlMain.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 = "";
|
||||
editableDescription.value = description.value;
|
||||
editableVideoUrl.value = videoUrl.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) {
|
||||
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;
|
||||
// Fetch album data
|
||||
async function fetchAlbumData() {
|
||||
if (!creatorProfileStore.creator?.id) return;
|
||||
|
||||
albumId.value = creatorProfileStore.creator.id;
|
||||
|
||||
try {
|
||||
// Try to get the album
|
||||
const response = await client.get(`/api/albums/${albumId.value}`);
|
||||
|
||||
if (response.data && response.data.photos) {
|
||||
// Store original photos for comparison
|
||||
originalPhotos.value = response.data.photos;
|
||||
// Extract photo URLs from the album photos
|
||||
imageUrls.value = response.data.photos.map(photo => photo.photoUrl);
|
||||
} else {
|
||||
// Initialize with empty slots for adding new photos
|
||||
imageUrls.value = Array(6).fill("");
|
||||
originalPhotos.value = [];
|
||||
}
|
||||
} catch (error) {
|
||||
// Album might not exist yet, which is fine
|
||||
console.log("Album might not exist yet:", error);
|
||||
// Initialize with empty slots for adding new photos
|
||||
imageUrls.value = Array(6).fill("");
|
||||
originalPhotos.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Charger les données au montage
|
||||
onMounted(() => {
|
||||
if (brandingStore.presentationInfos === undefined) return;
|
||||
onMounted(async () => {
|
||||
if (!brandingStore.value?.presentation) return;
|
||||
|
||||
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;
|
||||
videoUrlMain.value = brandingStore.presentationInfos.videoUrlMain;
|
||||
phoneNumber.value = brandingStore.presentationInfos.phoneNumber;
|
||||
email.value = brandingStore.presentationInfos.email;
|
||||
description.value = brandingStore.value.presentation.description || "";
|
||||
videoUrl.value = brandingStore.value.presentation.videoUrl || "";
|
||||
|
||||
// Fetch album data
|
||||
await fetchAlbumData();
|
||||
});
|
||||
|
||||
// Update images from CreatorAlbum component
|
||||
function updateImages(newImages) {
|
||||
imageUrls.value = newImages;
|
||||
}
|
||||
|
||||
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("ImagesText", editableImagesText.value || "");
|
||||
formData.append("VideoSubtitle", editableVideoSubtitle.value || "");
|
||||
formData.append("VideoUrlMain", editableVideoUrlMain.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 {
|
||||
isLoading.value = true;
|
||||
|
||||
const response = await client.post(
|
||||
// Save presentation info
|
||||
const presentationResponse = await client.post(
|
||||
`/api/creators/${creatorProfileStore.creator.id}/presentation-infos`,
|
||||
formData,
|
||||
{headers: {"Content-Type": "multipart/form-data"}}
|
||||
{
|
||||
description: editableDescription.value || "",
|
||||
videoUrl: editableVideoUrl.value || ""
|
||||
}
|
||||
);
|
||||
|
||||
// Mettre à jour les valeurs locales pour refléter les changements
|
||||
mainTitle.value = editableMainTitle.value;
|
||||
mainImageText.value = editableMainImageText.value;
|
||||
mainVideoText.value = editableMainVideoText.value;
|
||||
imagesText.value = editableImagesText.value;
|
||||
videoSubtitle.value = editableVideoSubtitle.value;
|
||||
videoUrlMain.value = editableVideoUrlMain.value;
|
||||
phoneNumber.value = editablePhoneNumber.value;
|
||||
email.value = editableEmail.value;
|
||||
description.value = editableDescription.value;
|
||||
videoUrl.value = editableVideoUrl.value;
|
||||
|
||||
console.log("Données sauvegardées :", response.data);
|
||||
// Save album photos if they've changed
|
||||
if (imageUrls.value.length > 0) {
|
||||
// Create or update the album
|
||||
const albumId = creatorProfileStore.creator.id;
|
||||
|
||||
try {
|
||||
// Try to create the album first (it will fail if it already exists)
|
||||
await client.post('/api/albums', {
|
||||
albumId: albumId,
|
||||
title: `${creatorProfileStore.creator.name}'s Album`,
|
||||
description: "Photo album for the creator"
|
||||
});
|
||||
} catch (error) {
|
||||
// Album might already exist, which is fine
|
||||
console.log("Album might already exist:", error);
|
||||
}
|
||||
|
||||
// Check for deleted photos
|
||||
const deletedPhotos = originalPhotos.value.filter(originalPhoto => {
|
||||
// If the photo URL is not in the current images array, it was deleted
|
||||
return !imageUrls.value.includes(originalPhoto.photoUrl);
|
||||
});
|
||||
|
||||
// Delete removed photos
|
||||
for (const photo of deletedPhotos) {
|
||||
try {
|
||||
await client.delete(`/api/albums/${albumId}/photos/${photo.id}`);
|
||||
} catch (error) {
|
||||
console.error("Error deleting photo:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Now add or update photos
|
||||
for (let i = 0; i < imageUrls.value.length; i++) {
|
||||
const imageUrl = imageUrls.value[i];
|
||||
if (imageUrl && imageUrl.startsWith('data:')) {
|
||||
// This is a new image that needs to be uploaded
|
||||
const photoId = crypto.randomUUID();
|
||||
const formData = new FormData();
|
||||
|
||||
// Convert data URL to file
|
||||
const response = await fetch(imageUrl);
|
||||
const blob = await response.blob();
|
||||
const file = new File([blob], `photo-${i}.jpg`, { type: 'image/jpeg' });
|
||||
|
||||
formData.append('file', file);
|
||||
|
||||
await client.post(`/api/albums/${albumId}/photos`, formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
params: {
|
||||
photoId: photoId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh album data after changes
|
||||
await fetchAlbumData();
|
||||
}
|
||||
|
||||
console.log("Données sauvegardées :", presentationResponse.data);
|
||||
|
||||
isEditMode.value = false;
|
||||
|
||||
@@ -513,25 +297,25 @@ async function saveChanges() {
|
||||
|
||||
function cancelEdit() {
|
||||
// Restaurer les valeurs d'origine
|
||||
editableMainTitle.value = mainTitle.value;
|
||||
editableMainImageText.value = mainImageText.value;
|
||||
editableMainVideoText.value = mainVideoText.value;
|
||||
editableImagesText.value = imagesText.value;
|
||||
editableVideoSubtitle.value = videoSubtitle.value;
|
||||
editableVideoUrlMain.value = videoUrlMain.value;
|
||||
editablePhoneNumber.value = phoneNumber.value;
|
||||
editableEmail.value = email.value;
|
||||
editableDescription.value = description.value;
|
||||
editableVideoUrl.value = videoUrl.value;
|
||||
|
||||
// Désactiver le mode édition
|
||||
isEditMode.value = false;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.content-section {
|
||||
@apply w-full overflow-hidden;
|
||||
}
|
||||
|
||||
.video-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-top: 56.25%; /* Ratio 16:9 (9/16 = 0.5625) */
|
||||
padding-top: 31.25%; /* Reduced from 56.25% to make it shorter while maintaining aspect ratio */
|
||||
max-height: 40vh;
|
||||
}
|
||||
|
||||
.video-frame {
|
||||
@@ -540,106 +324,84 @@ function cancelEdit() {
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
border-radius: 0.5rem; /* Pour les bords arrondis */
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Add responsive breakpoints */
|
||||
@media (max-width: 640px) {
|
||||
.video-container {
|
||||
padding-top: 35%;
|
||||
max-height: 35vh;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.video-container {
|
||||
padding-top: 30%;
|
||||
max-height: 38vh;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<i18n>
|
||||
{
|
||||
"en": {
|
||||
"common": {
|
||||
"save": "Save",
|
||||
"edit": "Edit",
|
||||
"cancel": "Cancel",
|
||||
"delete": "Delete"
|
||||
},
|
||||
"edit": "Edit",
|
||||
"save": "Save",
|
||||
"cancel": "Cancel",
|
||||
"creator": {
|
||||
"sections": {
|
||||
"about": {
|
||||
"title": "About",
|
||||
"description": "Description",
|
||||
"mainImage": "Main image",
|
||||
"image1": "Image 1",
|
||||
"image2": "Image 2",
|
||||
"image3": "Image 3",
|
||||
"image4": "Image 4",
|
||||
"images": "Images"
|
||||
"description": "Description"
|
||||
},
|
||||
"support": {
|
||||
"title": "Support",
|
||||
"description": "Description",
|
||||
"subtitle": "Subtitle"
|
||||
"photos": {
|
||||
"title": "Photos",
|
||||
"image": "Image"
|
||||
}
|
||||
},
|
||||
"fields": {
|
||||
"videoUrl": "Video URL",
|
||||
"phoneNumber": "Phone Number",
|
||||
"email": "Email"
|
||||
"videoUrl": "Video URL"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fr": {
|
||||
"common": {
|
||||
"save": "Enregistrer",
|
||||
"edit": "Modifier",
|
||||
"cancel": "Annuler",
|
||||
"delete": "Supprimer"
|
||||
},
|
||||
"edit": "Modifier",
|
||||
"save": "Enregistrer",
|
||||
"cancel": "Annuler",
|
||||
"creator": {
|
||||
"sections": {
|
||||
"about": {
|
||||
"title": "À propos",
|
||||
"description": "Description",
|
||||
"mainImage": "Image principale",
|
||||
"image1": "Image 1",
|
||||
"image2": "Image 2",
|
||||
"image3": "Image 3",
|
||||
"image4": "Image 4",
|
||||
"images": "Images"
|
||||
"description": "Description"
|
||||
},
|
||||
"support": {
|
||||
"title": "Support",
|
||||
"description": "Description",
|
||||
"subtitle": "Sous-titre"
|
||||
"photos": {
|
||||
"title": "Photos",
|
||||
"image": "Image"
|
||||
}
|
||||
},
|
||||
"fields": {
|
||||
"videoUrl": "URL de la vidéo",
|
||||
"phoneNumber": "Numéro de téléphone",
|
||||
"email": "Email"
|
||||
"videoUrl": "URL de la vidéo"
|
||||
}
|
||||
}
|
||||
},
|
||||
"es": {
|
||||
"common": {
|
||||
"save": "Guardar",
|
||||
"edit": "Editar",
|
||||
"cancel": "Cancelar",
|
||||
"delete": "Eliminar"
|
||||
},
|
||||
"edit": "Editar",
|
||||
"save": "Guardar",
|
||||
"cancel": "Cancelar",
|
||||
"creator": {
|
||||
"sections": {
|
||||
"about": {
|
||||
"title": "Acerca de",
|
||||
"description": "Descripción",
|
||||
"mainImage": "Imagen principal",
|
||||
"image1": "Imagen 1",
|
||||
"image2": "Imagen 2",
|
||||
"image3": "Imagen 3",
|
||||
"image4": "Imagen 4",
|
||||
"images": "Imágenes"
|
||||
"description": "Descripción"
|
||||
},
|
||||
"support": {
|
||||
"title": "Soporte",
|
||||
"description": "Descripción",
|
||||
"subtitle": "Subtítulo"
|
||||
"photos": {
|
||||
"title": "Fotos",
|
||||
"image": "Imagen"
|
||||
}
|
||||
},
|
||||
"fields": {
|
||||
"videoUrl": "URL del video",
|
||||
"phoneNumber": "Número de teléfono",
|
||||
"email": "Correo electrónico"
|
||||
"videoUrl": "URL del video"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user