Skip to content
Snippets Groups Projects
Commit 3ec77a69 authored by Ingrid Martinsheimen Egge's avatar Ingrid Martinsheimen Egge :cow2:
Browse files

profilbildet kan oppdateres

parent 2ee1fd44
No related branches found
No related tags found
1 merge request!21Merge profilinnstillinger into main
......@@ -2,7 +2,7 @@
<h1><br><br>Profilinnstillinger <br></h1>
<div v-if="hasProfileImage" id = "profilepicture-container">
<img width="100" :src="this.updatedProfile.upImage" alt="profile picture">
<img width="100" :src="getProfileImage" alt="profile picture">
</div>
<div v-else id = "profilepicture-container">
<Icon icon="material-symbols:person" :color=iconColor :style="{ fontSize: '500px'}" />
......@@ -71,6 +71,9 @@ export default {
},
hasProfileImage() {
return this.updatedProfile.upImage.length > 0;
},
getProfileImage(){
return this.updatedProfile.upImage;
}
},
methods: {
......
<script>
import { useAuthStore } from "@/stores/authStore.js";
import { mapState } from 'pinia'
import router from "@/router";
export default {
data() {
return {
}
},
computed: {
...mapState(useAuthStore, ['profile'])
}
}
</script>
......
......@@ -6,9 +6,6 @@
</template>
<script setup>
import EditProfile from "../components/EditProfile.vue";
import EditAccount from "../components/EditAccount.vue";
</script>
......@@ -25,89 +22,15 @@ export default {
components: {Icon},
computed: {
...mapStores(useAuthStore),
profile() {
let store = useAuthStore();
this.currentProfile.name = store.profile.name;
this.currentProfile.isRestricted = store.profile.restricted;
this.currentProfile.image = store.profile.profileImageUrl;
return store.profile
},
user() {
const store = useAuthStore();
return store.user
},
iconColor() {
return "#000000"
},
hasProfileImage() {
return this.currentProfile.image.length > 0;
}
},
data() {
return {
currentUser: {
newPassword: "",
},
currentProfile: {
name: "",
isRestricted: true,
image: "",
},
foodPreferences: [],
allergens: [],
deletionConfirmation: false,
beforeMount() {
if (!useAuthStore().isLoggedIn) {
router.push('/login')
}
},
methods: {
saveUserSettings(){ //profilnavn, profilbilde, profilrestriksjoner
const namee = this.currentProfile.name;
const isRestrictede = this.currentProfile.isRestricted;
const profileImageUrle = this.currentProfile.image;
API.updateProfile(
this.profile.id,{
name:namee,
profileImageUrl: profileImageUrle,
restricted: isRestrictede,
}
).then((savedProfile)=>{
useAuthStore().setProfile(savedProfile);
}).catch((error)=> {
console.log(error)
})
},
chooseProfilePicture(){
alert("velgBilde")
},
saveAccountSettings(){ //passord
if(this.currentUser.newPassword.length===0){
alert("Det er ikke gjort endringer, og passordet vil ikke bli oppdatert")
} else {
alert("(Denne knappen gjør ingen ting) konto oppdatert")
}
},
deleteAccount(){
if(this.deletionConfirmation===false){
alert("Du må bekrefte at du vil slette konto ved å huke av boksen")
}
else {
alert("(Denne knappen gjør ingen ting) men account deleted")
//API.deleteAccount(this.user.id, token);
}
},
deleteUser(){
alert("(Denne knappen gjør ingen ting) bruker slettet")
//API.deleteAccount(this.user.id, token).then
},
changeProfile(){
router.push("/selectProfile");
}
}
}
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment