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 @@ ...@@ -2,7 +2,7 @@
<h1><br><br>Profilinnstillinger <br></h1> <h1><br><br>Profilinnstillinger <br></h1>
<div v-if="hasProfileImage" id = "profilepicture-container"> <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>
<div v-else id = "profilepicture-container"> <div v-else id = "profilepicture-container">
<Icon icon="material-symbols:person" :color=iconColor :style="{ fontSize: '500px'}" /> <Icon icon="material-symbols:person" :color=iconColor :style="{ fontSize: '500px'}" />
...@@ -71,6 +71,9 @@ export default { ...@@ -71,6 +71,9 @@ export default {
}, },
hasProfileImage() { hasProfileImage() {
return this.updatedProfile.upImage.length > 0; return this.updatedProfile.upImage.length > 0;
},
getProfileImage(){
return this.updatedProfile.upImage;
} }
}, },
methods: { methods: {
......
<script> <script>
import { useAuthStore } from "@/stores/authStore.js"; import { useAuthStore } from "@/stores/authStore.js";
import { mapState } from 'pinia' import { mapState } from 'pinia'
import router from "@/router";
export default { export default {
data() { data() {
return { return {
} }
}, },
computed: { computed: {
...mapState(useAuthStore, ['profile']) ...mapState(useAuthStore, ['profile'])
} }
} }
</script> </script>
......
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
</template> </template>
<script setup> <script setup>
import EditProfile from "../components/EditProfile.vue"; import EditProfile from "../components/EditProfile.vue";
import EditAccount from "../components/EditAccount.vue"; import EditAccount from "../components/EditAccount.vue";
</script> </script>
...@@ -25,89 +22,15 @@ export default { ...@@ -25,89 +22,15 @@ export default {
components: {Icon}, components: {Icon},
computed: { computed: {
...mapStores(useAuthStore), ...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() { iconColor() {
return "#000000" return "#000000"
}, },
hasProfileImage() {
return this.currentProfile.image.length > 0;
}
}, },
data() { beforeMount() {
return { if (!useAuthStore().isLoggedIn) {
currentUser: { router.push('/login')
newPassword: "",
},
currentProfile: {
name: "",
isRestricted: true,
image: "",
},
foodPreferences: [],
allergens: [],
deletionConfirmation: false,
} }
}, },
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> </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