Fixes some issues during edits of user profile
This commit is contained in:
@@ -107,7 +107,7 @@ export const useUserStore = defineStore(
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeBirthday(birthdate) {
|
async function changeBirthday(birthdate) {
|
||||||
try {
|
try {
|
||||||
await client.post(
|
await client.post(
|
||||||
@@ -120,7 +120,7 @@ export const useUserStore = defineStore(
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changePhone(phoneNumber) {
|
async function changePhone(phoneNumber) {
|
||||||
try {
|
try {
|
||||||
await client.post(
|
await client.post(
|
||||||
@@ -133,7 +133,7 @@ export const useUserStore = defineStore(
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeEmail(email) {
|
async function changeEmail(email) {
|
||||||
try {
|
try {
|
||||||
await client.post(
|
await client.post(
|
||||||
@@ -159,6 +159,21 @@ export const useUserStore = defineStore(
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function changePortrait(selectedFile) {
|
||||||
|
try {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', selectedFile)
|
||||||
|
|
||||||
|
const response = await client.post(
|
||||||
|
`/api/users/portrait`,
|
||||||
|
formData)
|
||||||
|
|
||||||
|
user.value.portraitUrl = `${response.data.blobUrl}?${Date.now()}` // the Date.now() is for cache-busting
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user,
|
user,
|
||||||
@@ -173,6 +188,7 @@ export const useUserStore = defineStore(
|
|||||||
changePhone,
|
changePhone,
|
||||||
changeEmail,
|
changeEmail,
|
||||||
changeAddress,
|
changeAddress,
|
||||||
|
changePortrait,
|
||||||
fetchCurrentUserProfile,
|
fetchCurrentUserProfile,
|
||||||
fetchCurrentCreatorProfile
|
fetchCurrentCreatorProfile
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
<span class="value">Un portrait vous permet de personnaliser votre profil</span>
|
<span class="value">Un portrait vous permet de personnaliser votre profil</span>
|
||||||
<span>
|
<span>
|
||||||
<img
|
<img
|
||||||
:src="userStore.portraitUrl"
|
:src="userStore.user.portraitUrl"
|
||||||
alt="Profile Image"
|
alt="Profile Image"
|
||||||
class="rounded-full"
|
class="rounded-full"
|
||||||
width="48px"
|
width="48px"
|
||||||
height="48px">
|
height="48px"/>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
<span class="value">{{ userStore.user.alias }}</span>
|
<span class="value">{{ userStore.user.alias }}</span>
|
||||||
<span><v-icon>mdi-chevron-right</v-icon></span>
|
<span><v-icon>mdi-chevron-right</v-icon></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="editableValue"
|
class="editableValue"
|
||||||
@click="openEditBirthday">
|
@click="openEditBirthday">
|
||||||
@@ -94,27 +94,32 @@
|
|||||||
<!-- Modal -->
|
<!-- Modal -->
|
||||||
<v-dialog v-model="dialogEditPortraitShown" max-width="600px">
|
<v-dialog v-model="dialogEditPortraitShown" max-width="600px">
|
||||||
<portrait-dialog
|
<portrait-dialog
|
||||||
|
:portrait-url="userStore.user.portraitUrl"
|
||||||
@close="handleCloseEditPortrait"
|
@close="handleCloseEditPortrait"
|
||||||
@save="handleSaveEditPortrait"
|
@save="handleSaveEditPortrait"
|
||||||
></portrait-dialog>
|
></portrait-dialog>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<v-dialog v-model="dialogEditFullnameShown" max-width="600px">
|
<v-dialog v-model="dialogEditFullnameShown" max-width="600px">
|
||||||
<fullname-dialog
|
<fullname-dialog
|
||||||
|
:firstname="userStore.user.firstname"
|
||||||
|
:lastname="userStore.user.lastname"
|
||||||
@close="handleCloseEditFullname"
|
@close="handleCloseEditFullname"
|
||||||
@save="handleSaveEditFullname"
|
@save="handleSaveEditFullname"
|
||||||
></fullname-dialog>
|
></fullname-dialog>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<v-dialog v-model="dialogEditAliasShown" max-width="600px">
|
<v-dialog v-model="dialogEditAliasShown" max-width="600px">
|
||||||
<alias-dialog
|
<alias-dialog
|
||||||
|
:alias="userStore.user.alias"
|
||||||
@close="handleCloseEditAlias"
|
@close="handleCloseEditAlias"
|
||||||
@save="handleSaveEditAlias"
|
@save="handleSaveEditAlias"
|
||||||
></alias-dialog>
|
></alias-dialog>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<v-dialog v-model="dialogEditBirthdayShown" max-width="600px">
|
<v-dialog v-model="dialogEditBirthdayShown" max-width="600px">
|
||||||
<birthday-dialog
|
<birthday-dialog
|
||||||
|
:birth-date="userStore.user.birthDate"
|
||||||
@close="handleCloseEditBirthday"
|
@close="handleCloseEditBirthday"
|
||||||
@save="handleSaveEditBirthday"
|
@save="handleSaveEditBirthday"
|
||||||
></birthday-dialog>
|
></birthday-dialog>
|
||||||
@@ -122,6 +127,7 @@
|
|||||||
|
|
||||||
<v-dialog v-model="dialogEditPhoneShown" max-width="600px">
|
<v-dialog v-model="dialogEditPhoneShown" max-width="600px">
|
||||||
<phone-dialog
|
<phone-dialog
|
||||||
|
:phone="userStore.user.phoneNumber"
|
||||||
@close="handleCloseEditPhone"
|
@close="handleCloseEditPhone"
|
||||||
@save="handleSaveEditPhone"
|
@save="handleSaveEditPhone"
|
||||||
></phone-dialog>
|
></phone-dialog>
|
||||||
@@ -129,6 +135,7 @@
|
|||||||
|
|
||||||
<v-dialog v-model="dialogEditEmailShown" max-width="600px">
|
<v-dialog v-model="dialogEditEmailShown" max-width="600px">
|
||||||
<email-dialog
|
<email-dialog
|
||||||
|
:email="userStore.user.email"
|
||||||
@close="handleCloseEditEmail"
|
@close="handleCloseEditEmail"
|
||||||
@save="handleSaveEditEmail"
|
@save="handleSaveEditEmail"
|
||||||
></email-dialog>
|
></email-dialog>
|
||||||
@@ -136,11 +143,11 @@
|
|||||||
|
|
||||||
<v-dialog v-model="dialogEditAddressShown" max-width="600px">
|
<v-dialog v-model="dialogEditAddressShown" max-width="600px">
|
||||||
<address-dialog
|
<address-dialog
|
||||||
|
:address="userStore.user.address"
|
||||||
@close="handleCloseEditAddress"
|
@close="handleCloseEditAddress"
|
||||||
@save="handleSaveEditAddress"
|
@save="handleSaveEditAddress"
|
||||||
></address-dialog>
|
></address-dialog>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -168,8 +175,8 @@ function handleCloseEditPortrait() {
|
|||||||
dialogEditPortraitShown.value = false
|
dialogEditPortraitShown.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSaveEditPortrait(portraitUrl) {
|
function handleSaveEditPortrait(portraitData) {
|
||||||
console.log(`going to save portrait: ${portraitUrl}`)
|
userStore.changePortrait(portraitData)
|
||||||
dialogEditPortraitShown.value = false
|
dialogEditPortraitShown.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,11 +280,9 @@ function handleSaveEditAddress(address) {
|
|||||||
userStore.changeAddress(address)
|
userStore.changeAddress(address)
|
||||||
dialogEditAddressShown.value = false
|
dialogEditAddressShown.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.editableValue {
|
.editableValue {
|
||||||
@apply py-2 px-4 border-gray-400 shadow flex items-center transition duration-200 ease-in-out w-full;
|
@apply py-2 px-4 border-gray-400 shadow flex items-center transition duration-200 ease-in-out w-full;
|
||||||
@apply hover:bg-[#A6147D] hover:text-white hover:opacity-90;
|
@apply hover:bg-[#A6147D] hover:text-white hover:opacity-90;
|
||||||
@@ -290,5 +295,4 @@ function handleSaveEditAddress(address) {
|
|||||||
.value {
|
.value {
|
||||||
@apply flex-auto pr-6 text-left;
|
@apply flex-auto pr-6 text-left;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -29,14 +29,8 @@ import {ref} from 'vue';
|
|||||||
const props = defineProps(['address'])
|
const props = defineProps(['address'])
|
||||||
const emit = defineEmits(['close', 'save'])
|
const emit = defineEmits(['close', 'save'])
|
||||||
|
|
||||||
const title = ref(props.title);
|
|
||||||
const address = ref(props.address);
|
const address = ref(props.address);
|
||||||
|
|
||||||
const requestClose = () => emit('close')
|
const requestClose = () => emit('close')
|
||||||
const requestSave = () => emit('save', address.value)
|
const requestSave = () => emit('save', address.value)
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref} from 'vue';
|
import {ref} from 'vue';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
Numéro de téléphone
|
Numéro de téléphone
|
||||||
@@ -23,7 +22,6 @@
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -32,7 +30,7 @@ import {ref} from 'vue';
|
|||||||
const props = defineProps(['phone'])
|
const props = defineProps(['phone'])
|
||||||
const emit = defineEmits(['close', 'save'])
|
const emit = defineEmits(['close', 'save'])
|
||||||
|
|
||||||
const phone = ref(props.email)
|
const phone = ref(props.phone)
|
||||||
|
|
||||||
const requestClose = () => emit('close')
|
const requestClose = () => emit('close')
|
||||||
const requestSave = () => emit('save', phone.value)
|
const requestSave = () => emit('save', phone.value)
|
||||||
|
|||||||
@@ -5,10 +5,19 @@
|
|||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
||||||
<div class="m-4">
|
<div class="m-4">
|
||||||
<v-text-field
|
<img
|
||||||
|
:src="portraitData"
|
||||||
|
class="mb-5 w-full transition duration-200 ease-in-out transform"
|
||||||
|
alt="Aperçu de la bannière"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<v-file-input
|
||||||
|
@change="onSelectedFileChanged"
|
||||||
|
v-model="selectedFile"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
v-model="portraitUrl"
|
accept="image/*"
|
||||||
></v-text-field>
|
label="Votre bannière"
|
||||||
|
></v-file-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
@@ -29,8 +38,21 @@ import {ref} from 'vue';
|
|||||||
const props = defineProps(['portraitUrl'])
|
const props = defineProps(['portraitUrl'])
|
||||||
const emit = defineEmits(['close', 'save'])
|
const emit = defineEmits(['close', 'save'])
|
||||||
|
|
||||||
const portraitUrl = ref(props.portraitUrl)
|
const portraitData = ref(props.portraitUrl)
|
||||||
|
|
||||||
|
const selectedFile = ref({})
|
||||||
|
const onSelectedFileChanged = () => {
|
||||||
|
if (selectedFile.value) {
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.onload = (event) => {
|
||||||
|
portraitData.value = event.target.result
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(selectedFile.value)
|
||||||
|
} else {
|
||||||
|
portraitData.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const requestClose = () => emit('close')
|
const requestClose = () => emit('close')
|
||||||
const requestSave = () => emit('save', portraitUrl.value)
|
const requestSave = () => emit('save', selectedFile.value)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emits = defineEmits(['closeRequested'])
|
const emits = defineEmits(['closeRequested'])
|
||||||
|
|
||||||
const selectedFile = ref("")
|
const selectedFile = ref({})
|
||||||
const fileUrl = ref(props.creator.images.banner)
|
const fileUrl = ref(props.creator.images.banner)
|
||||||
|
|
||||||
const onFileSelected = () => {
|
const onFileSelected = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user