Revert "Fix NameEditor reservations handling of errors"

This reverts commit 78185151e7.
This commit is contained in:
2025-04-16 17:58:07 -04:00
parent 78185151e7
commit b927d3abc8

View File

@@ -4,30 +4,21 @@
Logo Logo
</div> </div>
<div class="card-content"> <div class="card-content flex flex-col items-center">
<div class="image-preview-container">
<img <img
:src="fileUrl || fallbackUrl" :src="fileUrl || fallbackUrl"
alt="Aperçu du logo" alt="Aperçu du logo"
class="preview-image" class="mb-5 transition duration-200 ease-in-out transform w-[200px] h-[200px]"
/> />
</div>
<div class="file-input-container"> <v-file-input
<input v-model="selectedFile"
type="file"
ref="fileInput"
accept="image/*" accept="image/*"
class="hidden" class="w-full"
label="Votre logo"
variant="outlined"
@change="onFileSelected" @change="onFileSelected"
/> ></v-file-input>
<button
class="choose-file-button"
@click="triggerFileInput"
>
Choisir une image...
</button>
</div>
</div> </div>
<div class="card-actions"> <div class="card-actions">
@@ -41,8 +32,10 @@
</button> </button>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import {ref} from 'vue' import {ref} from 'vue'
import {useClient} from '@/plugins/api.js' import {useClient} from '@/plugins/api.js'
@@ -55,26 +48,18 @@ const props = defineProps({
const emits = defineEmits(['closeRequested']) const emits = defineEmits(['closeRequested'])
const fileInput = ref(null) const selectedFile = ref("")
const selectedFile = ref(null)
const fileUrl = ref(props.creator.images.logo) const fileUrl = ref(props.creator.images.logo)
const fallbackUrl = '/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png' const fallbackUrl = '/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png' // Chemin de votre image de secours
const triggerFileInput = () => { const onFileSelected = () => {
fileInput.value.click() if (selectedFile.value) {
}
const onFileSelected = (event) => {
const file = event.target.files[0]
if (file) {
selectedFile.value = file
const reader = new FileReader() const reader = new FileReader()
reader.onload = (e) => { reader.onload = (event) => {
fileUrl.value = e.target.result fileUrl.value = event.target.result
} }
reader.readAsDataURL(file) reader.readAsDataURL(selectedFile.value)
} else { } else {
selectedFile.value = null
fileUrl.value = null fileUrl.value = null
} }
} }
@@ -82,16 +67,15 @@ const onFileSelected = (event) => {
const client = useClient() const client = useClient()
const publish = async () => { const publish = async () => {
try { try {
const formData = new FormData() const formData = new FormData();
formData.append('file', selectedFile.value) formData.append('file', selectedFile.value)
const response = await client.post( const response = await client.post(
`/api/creators/${props.creator.id}/logo`, `/api/creators/${props.creator.id}/logo`,
formData formData)
)
props.creator.images.logo = `${response.data.blobUrl}?t=${Date.now()}` props.creator.images.logo = `${response.data.blobUrl}?t=${Date.now()}`;
emits('closeRequested') emits('closeRequested');
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }
@@ -102,38 +86,3 @@ const cancel = () => {
} }
</script> </script>
<style scoped>
.image-preview-container {
@apply mb-5;
@apply w-full;
@apply flex;
@apply justify-center;
@apply items-center;
@apply overflow-hidden;
@apply rounded-lg;
@apply bg-gray-100;
}
.preview-image {
@apply w-[200px];
@apply h-[200px];
@apply object-cover;
@apply rounded-full;
}
.file-input-container {
@apply flex;
@apply justify-center;
@apply items-center;
@apply w-full;
}
.choose-file-button {
@apply px-4;
@apply py-2;
@apply primary;
@apply rounded-lg;
@apply cursor-pointer;
}
</style>