diff --git a/src/components/EditProfile.vue b/src/components/EditProfile.vue index 7b9191ccc894d2e6d949cb98ae18b906a3dbb8a7..b04193f56b19b32e78b9b7524261887fae589c5d 100644 --- a/src/components/EditProfile.vue +++ b/src/components/EditProfile.vue @@ -2,10 +2,10 @@ <h2>Profilinnstillinger</h2> <div v-if="hasProfileImage" id = "profilepicture-container"> - <img width="100" :src="this.updatedProfile.upImage" alt="profile picture"> + <img width="100" :src="this.updatedProfile.upImage" alt="profile picture"> </div> - <div v-else id = "profilepicture-container"> - <Icon icon="material-symbols:person" :color=iconColor :style="{ fontSize: '500px'}" /> + <div v-else id="#placeholder"> + <Icon icon="material-symbols:person" :color=iconColor :style="{ fontSize: '500px'}" /> </div> <h3>{{this.profile.name}}</h3> @@ -13,7 +13,7 @@ <form @submit.prevent="submit"> <label for="brukernavn">Profilnavn</label><br> - <input type="text" required v-model="this.updatedProfile.upName"><br> + <input type="text" required id="brukernavn" v-model="this.updatedProfile.upName"><br> <br> <h3>Brukertype</h3> <input type="radio" id="normal" value="false" name="restrict" v-model="this.updatedProfile.upRestricted"> @@ -33,8 +33,8 @@ </div> <label for="chooseImageUrl">Bilde-URL:</label><br> - <input type="file" id="chooseImage" v-on:change="updateImage"> - <!--<input type="text" id="chooseImageUrl" v-model="this.updatedProfile.upImage">--> + <!--<input type="file" id="chooseImage" v-on:change="updateImage">--> + <input type="text" id="chooseImageUrl" v-model="this.updatedProfile.upImage"> </div> <br><br> @@ -115,17 +115,21 @@ export default { id,{ name:newName, profileImageUrl:this.updatedProfile.upImage, - restricted: newRestricted, + isRestricted: newRestricted, } ).then((savedProfile)=>{ useAuthStore().setProfile(savedProfile); this.alertMsg = "Profil oppdatert." }).catch(error=> { + console.log(error) if (error.message === '400') { - if(this.updatedProfile.name !== this.initialName){ - this.alertMsg = '‼ï¸Det oppsto en feil: Det finnes allerede en bruker med samme navn‼ï¸' - } else { + + if(newRestricted){ + this.alertMsg = '‼ï¸Det oppsto en feil: Sørg for at det finnes mist en standard profil pÃ¥ kontoenâ€¼ï¸ ' + } else if(this.updatedProfile.name !== this.initialName || this.updatedProfile.name) { + this.alertMsg = '‼ï¸Det oppsto en feil: Det finnes allerede en bruker med samme navn‼ï¸' + } }else{ this.alertMsg = "‼ï¸Det oppsto en feil.‼ï¸"