Merged PR 87: UpdateCurrentUser into Main
This commit is contained in:
18
src/App.vue
18
src/App.vue
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-app>
|
<v-app v-if="isUserLoaded">
|
||||||
<div class="m-0 flex flex-column h-screen">
|
<div class="m-0 flex flex-column h-screen">
|
||||||
<Header @toggle-sidebar="toggleSidebar" class="fixed w-full z-50 top-0 p-2"></Header>
|
<Header @toggle-sidebar="toggleSidebar" class="fixed w-full z-50 top-0 p-2"></Header>
|
||||||
<div class="flex flex-row relative">
|
<div class="flex flex-row relative">
|
||||||
@@ -27,20 +27,30 @@
|
|||||||
</v-app>
|
</v-app>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script async setup>
|
||||||
import Header from "@/views/main/Header.vue";
|
import Header from "@/views/main/Header.vue";
|
||||||
import Footer from "@/views/main/Footer.vue";
|
import Footer from "@/views/main/Footer.vue";
|
||||||
import SideBar from "@/views/main/SideBar.vue";
|
import SideBar from "@/views/main/SideBar.vue";
|
||||||
import {ref, onMounted, onUnmounted} from 'vue';
|
import {ref, onMounted, onUnmounted, onBeforeMount} from 'vue';
|
||||||
import StripePayment from "@/views/StripePayment.vue";
|
|
||||||
import {eventBus} from '@/eventBus.js';
|
import {eventBus} from '@/eventBus.js';
|
||||||
|
import {useUserStore} from "@/stores/user.js";
|
||||||
|
import {useClient} from "@/plugins/api.js";
|
||||||
|
|
||||||
const hideSideBar = ref(false);
|
const hideSideBar = ref(false);
|
||||||
|
const isUserLoaded = ref(false);
|
||||||
const showPopup = ref(false);
|
const showPopup = ref(false);
|
||||||
const popup = ref(null);
|
const popup = ref(null);
|
||||||
const popupButton = ref(null);
|
const popupButton = ref(null);
|
||||||
let closeSidebarTimer = null;
|
let closeSidebarTimer = null;
|
||||||
|
|
||||||
|
let client = useClient();
|
||||||
|
let userStore = useUserStore();
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
await userStore.setCurrentUser(client);
|
||||||
|
isUserLoaded.value = true;
|
||||||
|
});
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
hideSideBar.value = !hideSideBar.value;
|
hideSideBar.value = !hideSideBar.value;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import UserTransactionsModel from "@/models/userTransactionsModel.js";
|
import UserTransactionsModel from "@/models/userTransactionsModel.js";
|
||||||
|
import SocialNetworksModel from "@/models/socialNetworksModel.js";
|
||||||
|
import ProfileColorsModel from "@/models/profileColorsModel.js";
|
||||||
|
import StoredDataUrlsModel from "@/models/storedDataUrlsModel.js";
|
||||||
|
|
||||||
export default class MyUserModel
|
export default class MyUserModel
|
||||||
{
|
{
|
||||||
@@ -6,6 +9,18 @@ export default class MyUserModel
|
|||||||
firstName = "";
|
firstName = "";
|
||||||
lastName = "";
|
lastName = "";
|
||||||
userName = "";
|
userName = "";
|
||||||
|
occupation = "";
|
||||||
|
email = "";
|
||||||
|
phoneNumber = "";
|
||||||
|
birthDate = "";
|
||||||
|
country = "";
|
||||||
|
city = "";
|
||||||
|
address = "";
|
||||||
|
about = "";
|
||||||
|
description = "";
|
||||||
|
socialNetworks = new SocialNetworksModel();
|
||||||
|
profileColors = new ProfileColorsModel();
|
||||||
|
storedDataUrlsModel = new StoredDataUrlsModel();
|
||||||
totalBalance = "";
|
totalBalance = "";
|
||||||
userTransactions = [];
|
userTransactions = [];
|
||||||
|
|
||||||
@@ -21,4 +36,11 @@ export default class MyUserModel
|
|||||||
|
|
||||||
return userModel;
|
return userModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getDefaultUser(){
|
||||||
|
const defaultUser = new MyUserModel();
|
||||||
|
defaultUser.userName = "Anonymous"
|
||||||
|
|
||||||
|
return defaultUser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
11
src/models/profileColorsModel.js
Normal file
11
src/models/profileColorsModel.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export default class ProfileColorsModel
|
||||||
|
{
|
||||||
|
bannerTop = "";
|
||||||
|
bannerBottom = "";
|
||||||
|
accent = "";
|
||||||
|
menu = "";
|
||||||
|
|
||||||
|
static createFromApiResult(apiResult){
|
||||||
|
return Object.assign(new ProfileColorsModel(), apiResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/models/socialNetworksModel.js
Normal file
15
src/models/socialNetworksModel.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export default class SocialNetworksModel
|
||||||
|
{
|
||||||
|
facebookUrl = "";
|
||||||
|
instagramUrl = "";
|
||||||
|
xUrl = "";
|
||||||
|
linkedInUrl = "";
|
||||||
|
tikTokUrl = "";
|
||||||
|
youtubeUrl = "";
|
||||||
|
redditUrl = "";
|
||||||
|
yourWebsiteUrl = "";
|
||||||
|
|
||||||
|
static createFromApiResult(apiResult){
|
||||||
|
return Object.assign(new SocialNetworksModel(), apiResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/models/storedDataUrlsModel.js
Normal file
10
src/models/storedDataUrlsModel.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export default class StoredDataUrlsModel
|
||||||
|
{
|
||||||
|
bannerPictureUrl = "";
|
||||||
|
profilePictureUrl = "";
|
||||||
|
websiteIconUrl = "";
|
||||||
|
|
||||||
|
static createFromApiResult(apiResult){
|
||||||
|
return Object.assign(new StoredDataUrlsModel(), apiResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
27
src/stores/user.js
Normal file
27
src/stores/user.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import MyUserModel from "@/models/myUserModel.js";
|
||||||
|
|
||||||
|
export const useUserStore = defineStore('user', () => {
|
||||||
|
const user = ref({});
|
||||||
|
|
||||||
|
function getCurrentUser() {
|
||||||
|
return this.user.value;
|
||||||
|
}
|
||||||
|
async function setCurrentUser(client) {
|
||||||
|
try {
|
||||||
|
const myUser = await client.get("/api/GetMyUser");
|
||||||
|
this.user.value = MyUserModel.createFromApiResult(myUser.data);
|
||||||
|
} catch (e){
|
||||||
|
this.user.value = MyUserModel.getDefaultUser();
|
||||||
|
console.log("User not logged.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateCurrentUser(client, myUserModel) {
|
||||||
|
this.user.value = myUserModel;
|
||||||
|
await client.patch("/api/UpdateMyUser/profile", myUserModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
return { user, getCurrentUser, setCurrentUser, updateCurrentUser }
|
||||||
|
})
|
||||||
@@ -7,42 +7,42 @@
|
|||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Prénom</label>
|
<label class="text-lg">Prénom</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="firstName" label="Prénom" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.firstName" label="Prénom" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Nom</label>
|
<label class="text-lg">Nom</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="lastName" label="Nom" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.lastName" label="Nom" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Occupation</label>
|
<label class="text-lg">Occupation</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="occupation" label="Occupation" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.occupation" label="Occupation" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Courriel</label>
|
<label class="text-lg">Courriel</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="email" label="Courriel" variant="outlined"></v-text-field>
|
<v-text-field disabled v-model="user.email" label="Courriel" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Téléphone</label>
|
<label class="text-lg">Téléphone</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="phone" label="Téléphone" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.phoneNumber" label="Téléphone" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Date de naissance (JJ/MM/AAAA)</label>
|
<label class="text-lg">Date de naissance (JJ/MM/AAAA)</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="birthDate" label="Date de naissance" variant="outlined"
|
<v-text-field v-model="user.birthDate" label="Date de naissance" variant="outlined"
|
||||||
:rules="[dateRule]"></v-text-field>
|
:rules="[dateRule]"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -50,35 +50,35 @@
|
|||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Pays</label>
|
<label class="text-lg">Pays</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="country" label="Pays" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.country" label="Pays" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Ville</label>
|
<label class="text-lg">Ville</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="city" label="Ville" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.city" label="Ville" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Adresse</label>
|
<label class="text-lg">Adresse</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="address" label="Adresse" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.address" label="Adresse" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Titre A propos</label>
|
<label class="text-lg">Titre A propos</label>
|
||||||
</div>
|
</div>
|
||||||
<v-text-field v-model="titre" label="Titre A propos" variant="outlined"></v-text-field>
|
<v-text-field v-model="user.about" label="Titre A propos" variant="outlined"></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
<label class="text-lg">Description</label>
|
<label class="text-lg">Description</label>
|
||||||
</div>
|
</div>
|
||||||
<v-textarea v-model="description" label="Description" variant="outlined"></v-textarea>
|
<v-textarea v-model="user.description" label="Description" variant="outlined"></v-textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,19 +86,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref, defineProps } from 'vue';
|
||||||
|
import MyUserModel from "@/models/myUserModel.js";
|
||||||
|
|
||||||
const firstName = ref('');
|
const props = defineProps({
|
||||||
const lastName = ref('');
|
user: { type: MyUserModel },
|
||||||
const occupation = ref('');
|
});
|
||||||
const email = ref('');
|
|
||||||
const phone = ref('');
|
|
||||||
const birthDate = ref('');
|
|
||||||
const country = ref('');
|
|
||||||
const city = ref('');
|
|
||||||
const address = ref('');
|
|
||||||
const titre = ref('');
|
|
||||||
const description = ref('');
|
|
||||||
|
|
||||||
const dateRule = value => {
|
const dateRule = value => {
|
||||||
const datePattern = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/(19|20)\d{2}$/;
|
const datePattern = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/(19|20)\d{2}$/;
|
||||||
|
|||||||
@@ -101,18 +101,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import MyUserModel from "@/models/myUserModel.js";
|
|
||||||
import {useClient} from "@/plugins/api.js";
|
|
||||||
import {ref, onMounted, onBeforeUnmount} from "vue";
|
import {ref, onMounted, onBeforeUnmount} from "vue";
|
||||||
import {eventBus} from '@/eventBus.js';
|
import {eventBus} from '@/eventBus.js';
|
||||||
import {useRouter} from 'vue-router';
|
import {useRouter} from 'vue-router';
|
||||||
|
import {useUserStore} from "@/stores/user.js";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const currentUserName = ref("Anonyme");
|
const currentUserName = ref("Anonyme");
|
||||||
const searchQuery = ref("");
|
const searchQuery = ref("");
|
||||||
const showSearch = ref(false);
|
const showSearch = ref(false);
|
||||||
let currentUser = null;
|
let currentUser = null;
|
||||||
const client = useClient();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
eventBus.value.toggleSidebar();
|
eventBus.value.toggleSidebar();
|
||||||
@@ -151,15 +150,10 @@ const logout = () => {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted( () => {
|
||||||
try {
|
currentUser = userStore.getCurrentUser();
|
||||||
const myUser = await client.get("/api/GetMyUser");
|
currentUserName.value = currentUser.userName;
|
||||||
const currentUserModel = MyUserModel.createFromApiResult(myUser.data);
|
|
||||||
currentUser = currentUserModel;
|
|
||||||
currentUserName.value = currentUserModel.userName;
|
|
||||||
} catch (error) {
|
|
||||||
console.log("User not logged");
|
|
||||||
}
|
|
||||||
document.addEventListener('click', handleClickOutside);
|
document.addEventListener('click', handleClickOutside);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,32 +2,66 @@
|
|||||||
<div class="px-2">
|
<div class="px-2">
|
||||||
<div class="flex flex-col max-w-2xl mx-auto rounded-3xl shadow-2xl mt-2 mb-16">
|
<div class="flex flex-col max-w-2xl mx-auto rounded-3xl shadow-2xl mt-2 mb-16">
|
||||||
|
|
||||||
<H1 class="text-center text-4xl bg-fuchsia-900 p-3 w-full rounded-t-3xl border-b-4 border-b-gray-200 font-sans text-white">
|
<h1 class="text-center text-4xl bg-fuchsia-900 p-3 w-full rounded-t-3xl border-b-4 border-b-gray-200 font-sans text-white">
|
||||||
Personnaliser votre profil
|
Personnaliser votre profil
|
||||||
</H1>
|
</h1>
|
||||||
|
|
||||||
<ProfileBanner></ProfileBanner>
|
<ProfileBanner :user="currentUser"></ProfileBanner>
|
||||||
<Aboutyou></Aboutyou>
|
<AboutYou :user="currentUser"></AboutYou>
|
||||||
<SocialLinks></SocialLinks>
|
<SocialLinks :social-networks="currentUser.socialNetworks"></SocialLinks>
|
||||||
|
|
||||||
<div class="sticky inset-x-0 bottom-0 flex justify-center px-4 pb-4">
|
<div class="sticky inset-x-0 bottom-0 flex justify-center px-4 pb-4">
|
||||||
<div class="flex space-x-2">
|
<div class="flex space-x-2">
|
||||||
<v-btn class="save-btn" @click="saveAll">Enregistrer</v-btn>
|
<v-btn class="save-btn" @click="saveForm">Enregistrer</v-btn>
|
||||||
<router-link :to="`/${currentUserName}`">
|
<router-link :to="`/${currentUser.userName}`">
|
||||||
<v-btn class="save-btn">Retour</v-btn>
|
<v-btn class="save-btn">Retour</v-btn>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<v-snackbar v-model="snackbar" :timeout="1000">
|
||||||
|
Sauvegarde
|
||||||
|
|
||||||
|
<template v-slot:actions>
|
||||||
|
<v-btn color="green" variant="text" @click="snackbar = false">
|
||||||
|
Fermer
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-snackbar>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script async setup>
|
<script async setup>
|
||||||
import Aboutyou from "@/views/main/Aboutyou.vue";
|
import AboutYou from "@/views/main/Aboutyou.vue";
|
||||||
import SocialLinks from "@/views/main/SocialLinks.vue";
|
import SocialLinks from "@/views/main/SocialLinks.vue";
|
||||||
import ProfileBanner from "@/views/main/ProfileBanner.vue";
|
import ProfileBanner from "@/views/main/ProfileBanner.vue";
|
||||||
import DonationPopup from "@/views/main/DonationPopup.vue";
|
import {onBeforeMount, ref} from "vue";
|
||||||
|
import {useUserStore} from "@/stores/user.js";
|
||||||
|
import MyUserModel from "@/models/myUserModel.js";
|
||||||
|
import {useClient} from "@/plugins/api.js";
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const client = useClient();
|
||||||
|
|
||||||
|
const currentUser = ref(MyUserModel)
|
||||||
|
const snackbar = ref(false);
|
||||||
|
|
||||||
|
onBeforeMount( () => {
|
||||||
|
try {
|
||||||
|
currentUser.value = userStore.getCurrentUser();
|
||||||
|
} catch(error) {
|
||||||
|
console.log("User not logged")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
async function saveForm(){
|
||||||
|
snackbar.value = true;
|
||||||
|
await userStore.updateCurrentUser(client, currentUser.value);
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<div class="px-5 py-2 bg-fuchsia-800 text-white" :style="{ backgroundColor: accent2Color }" >
|
<div class="px-5 py-2 bg-fuchsia-800 text-white" :style="{ backgroundColor: user.profileColors.menu }" >
|
||||||
<div class="flex justify-center text-2xl">Photo de couverture</div>
|
<div class="flex justify-center text-2xl">Photo de couverture</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div :style="{ backgroundColor: topColor }" class="flex h-4"></div>
|
<div :style="{ backgroundColor: user.profileColors.bannerTop }" class="flex h-4"></div>
|
||||||
<img :src="bannerImageUrl" alt="Banner Image" class="w-full object-cover">
|
<img :src="bannerImageUrl" alt="Banner Image" class="w-full object-cover">
|
||||||
<div :style="{ backgroundColor: bottomColor }" class="h-4">
|
<div :style="{ backgroundColor: user.profileColors.bannerBottom }" class="h-4">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="space-x-4 flex justify-center py-2">
|
<div class="space-x-4 flex justify-center py-2">
|
||||||
<v-btn @click="openColorPicker('top')"
|
<v-btn @click="openColorPicker('top')"
|
||||||
:style="{ backgroundColor: topColor, color: getTextColor(topColor) }">Haut
|
:style="{ backgroundColor: user.profileColors.bannerTop, color: getTextColor(user.profileColors.bannerTop) }">Haut
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn @click="openColorPicker('bottom')"
|
<v-btn @click="openColorPicker('bottom')"
|
||||||
:style="{ backgroundColor: bottomColor, color: getTextColor(bottomColor) }">Bas
|
:style="{ backgroundColor: user.profileColors.bannerBottom, color: getTextColor(user.profileColors.bannerBottom) }">Bas
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn @click="openColorPicker('accent')"
|
<v-btn @click="openColorPicker('accent')"
|
||||||
:style="{ backgroundColor: accentColor, color: getTextColor(accentColor) }">Accent1
|
:style="{ backgroundColor: user.profileColors.accent, color: getTextColor(user.profileColors.accent) }">Accent1
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn @click="openColorPicker('accent2')"
|
<v-btn @click="openColorPicker('menu')"
|
||||||
:style="{ backgroundColor: accent2Color, color: getTextColor(accent2Color) }">Menu
|
:style="{ backgroundColor: user.profileColors.menu, color: getTextColor(user.profileColors.menu) }">Menu
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex justify-center py-4">
|
<div class="flex justify-center py-4">
|
||||||
<img :src="profilePictureUrl"
|
<img :src="profilePictureUrl"
|
||||||
:style="{ borderColor: accentColor, borderWidth: '3px', borderStyle: 'solid' }"
|
:style="{ borderColor: user.profileColors.accent, borderWidth: '3px', borderStyle: 'solid' }"
|
||||||
class="rounded-full max-w-48 max-w-48"
|
class="rounded-full max-w-48 max-w-48"
|
||||||
alt="Profile Image">
|
alt="Profile Image">
|
||||||
</div>
|
</div>
|
||||||
@@ -67,105 +67,73 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import {ref} from 'vue';
|
import { ref, defineProps } from 'vue';
|
||||||
|
import MyUserModel from "@/models/myUserModel.js";
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
props: {
|
initialBannerImageUrl: { type: String, default: '/images/usersmedia/HutopyProfile/banners/banner01.png' },
|
||||||
initialTopColor: {type: String, default: '#6B0065'},
|
initialProfilePictureUrl: { type: String, default: '/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png' },
|
||||||
initialBottomColor: {type: String, default: '#A30E79'},
|
user: { type: MyUserModel },
|
||||||
initialAccentColor: {type: String, default: '#282286'},
|
});
|
||||||
initialAccent2Color: {type: String, default: '#A526B6'},
|
|
||||||
initialBannerImageUrl: {type: String, default: '/images/usersmedia/HutopyProfile/banners/banner01.png'},
|
|
||||||
initialProfilePictureUrl: {
|
|
||||||
type: String,
|
|
||||||
default: '/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup(props) {
|
|
||||||
const topColor = ref(props.initialTopColor);
|
|
||||||
const bottomColor = ref(props.initialBottomColor);
|
|
||||||
const accentColor = ref(props.initialAccentColor);
|
|
||||||
const accent2Color = ref(props.initialAccent2Color);
|
|
||||||
|
|
||||||
const bannerImageUrl = ref(props.initialBannerImageUrl);
|
const bannerImageUrl = ref(props.initialBannerImageUrl);
|
||||||
const profilePictureUrl = ref(props.initialProfilePictureUrl);
|
const profilePictureUrl = ref(props.initialProfilePictureUrl);
|
||||||
|
|
||||||
const bannerImage = ref(null);
|
const bannerImage = ref(null);
|
||||||
const profilePicture = ref(null);
|
const profilePicture = ref(null);
|
||||||
|
|
||||||
const showColorPicker = ref(false);
|
const showColorPicker = ref(false);
|
||||||
const selectedColor = ref('#F4F4F4');
|
const selectedColor = ref('#F4F4F4');
|
||||||
const colorTarget = ref('');
|
const colorTarget = ref('');
|
||||||
|
|
||||||
const onBannerFileChange = (event) => {
|
const onBannerFileChange = (event) => {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
bannerImageUrl.value = e.target.result;
|
bannerImageUrl.value = e.target.result;
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onProfileFileChange = (event) => {
|
const onProfileFileChange = (event) => {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
profilePictureUrl.value = e.target.result;
|
profilePictureUrl.value = e.target.result;
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const openColorPicker = (target) => {
|
const openColorPicker = (target) => {
|
||||||
colorTarget.value = target;
|
colorTarget.value = target;
|
||||||
showColorPicker.value = true;
|
showColorPicker.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyColor = () => {
|
const applyColor = () => {
|
||||||
if (colorTarget.value === 'top') {
|
if (colorTarget.value === 'top') {
|
||||||
topColor.value = selectedColor.value;
|
props.user.profileColors.bannerTop = selectedColor.value;
|
||||||
} else if (colorTarget.value === 'bottom') {
|
} else if (colorTarget.value === 'bottom') {
|
||||||
bottomColor.value = selectedColor.value;
|
props.user.profileColors.bannerBottom = selectedColor.value;
|
||||||
} else if (colorTarget.value === 'accent') {
|
} else if (colorTarget.value === 'accent') {
|
||||||
accentColor.value = selectedColor.value;
|
props.user.profileColors.accent = selectedColor.value;
|
||||||
} else if (colorTarget.value === 'accent2') {
|
} else if (colorTarget.value === 'menu') {
|
||||||
accent2Color.value = selectedColor.value; // Appliquer la nouvelle couleur
|
props.user.profileColors.menu = selectedColor.value;
|
||||||
}
|
}
|
||||||
showColorPicker.value = false;
|
showColorPicker.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTextColor = (bgColor) => {
|
const getTextColor = (bgColor) => {
|
||||||
// Simple function to determine if the text should be white or black based on the background color
|
// Simple function to determine if the text should be white or black based on the background color
|
||||||
const color = bgColor.replace('#', '');
|
const color = bgColor.replace('#', '');
|
||||||
const r = parseInt(color.substr(0, 2), 16);
|
const r = parseInt(color.substr(0, 2), 16);
|
||||||
const g = parseInt(color.substr(2, 2), 16);
|
const g = parseInt(color.substr(2, 2), 16);
|
||||||
const b = parseInt(color.substr(4, 2), 16);
|
const b = parseInt(color.substr(4, 2), 16);
|
||||||
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
||||||
return brightness > 155 ? '#000' : '#fff';
|
return brightness > 155 ? '#000' : '#fff';
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
topColor,
|
|
||||||
bottomColor,
|
|
||||||
accentColor,
|
|
||||||
accent2Color,
|
|
||||||
bannerImageUrl,
|
|
||||||
profilePictureUrl,
|
|
||||||
bannerImage,
|
|
||||||
profilePicture,
|
|
||||||
showColorPicker,
|
|
||||||
selectedColor,
|
|
||||||
colorTarget,
|
|
||||||
onBannerFileChange,
|
|
||||||
onProfileFileChange,
|
|
||||||
openColorPicker,
|
|
||||||
applyColor,
|
|
||||||
getTextColor,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -22,15 +22,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import {defineProps, ref} from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
socialNetworks: { type: Object },
|
||||||
|
});
|
||||||
|
|
||||||
const socialNetworks = ref([
|
const socialNetworks = ref([
|
||||||
{ label: 'Instagram', field: 'instagram', value: '' },
|
{ label: 'Instagram', field: 'instagram', value: props.socialNetworks.instagramUrl },
|
||||||
{ label: 'TikTok', field: 'tiktok', value: '' },
|
{ label: 'TikTok', field: 'tiktok', value: props.socialNetworks.tikTokUrl },
|
||||||
{ label: 'Facebook', field: 'facebook', value: '' },
|
{ label: 'Facebook', field: 'facebook', value: props.socialNetworks.facebookUrl },
|
||||||
{ label: 'X', field: 'X', value: '' },
|
{ label: 'X', field: 'X', value: props.socialNetworks.xUrl },
|
||||||
{ label: 'LinkedIn', field: 'linkedin', value: '' },
|
{ label: 'LinkedIn', field: 'linkedin', value: props.socialNetworks.linkedInUrl },
|
||||||
{ label: 'Site Web', field: 'website', value: '' }
|
{ label: 'Site Web', field: 'website', value: props.socialNetworks.yourWebsiteUrl }
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const iconUrl = ref('');
|
const iconUrl = ref('');
|
||||||
|
|||||||
@@ -44,16 +44,16 @@
|
|||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script async setup>
|
||||||
import { onBeforeMount, ref, computed } from 'vue';
|
import { onBeforeMount, ref, computed } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useClient } from "@/plugins/api.js";
|
import {useUserStore} from "@/stores/user.js";
|
||||||
|
|
||||||
const client = useClient();
|
const userStore = useUserStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const userTransactions = ref([]);
|
const userTransactions = ref([]);
|
||||||
const totalBalance = ref(0);
|
const totalBalance = ref("");
|
||||||
const isModalOpen = ref(false);
|
const isModalOpen = ref(false);
|
||||||
|
|
||||||
const formattedTransactions = computed(() => {
|
const formattedTransactions = computed(() => {
|
||||||
@@ -72,11 +72,17 @@ const formattedBalance = computed(() => {
|
|||||||
|
|
||||||
const transactionCount = computed(() => userTransactions.value.length);
|
const transactionCount = computed(() => userTransactions.value.length);
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount( () => {
|
||||||
try {
|
try {
|
||||||
const myUser = await client.get("/api/GetMyUser");
|
const myUser = userStore.getCurrentUser();
|
||||||
userTransactions.value = myUser.data.userTransactions;
|
|
||||||
totalBalance.value = myUser.data.totalBalance;
|
userTransactions.value = myUser.userTransactions;
|
||||||
|
totalBalance.value = myUser.totalBalance;
|
||||||
|
|
||||||
|
console.log(userTransactions.value);
|
||||||
|
console.log(totalBalance.value);
|
||||||
|
console.log(formattedTransactions);
|
||||||
|
console.log(formattedBalance);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
navigateToHome();
|
navigateToHome();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user