Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDATT2106 Scrum Team 02
Frontend
Commits
35b25960
Commit
35b25960
authored
2 years ago
by
Ingrid Martinsheimen Egge
Browse files
Options
Downloads
Patches
Plain Diff
api
parent
3b1f9f80
No related branches found
Branches containing commit
No related tags found
1 merge request
!21
Merge profilinnstillinger into main
Pipeline
#220720
failed
2 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/util/API.js
+24
-27
24 additions, 27 deletions
src/util/API.js
src/views/ProfileSettings.vue
+17
-13
17 additions, 13 deletions
src/views/ProfileSettings.vue
with
41 additions
and
40 deletions
src/util/API.js
+
24
−
27
View file @
35b25960
...
...
@@ -105,15 +105,22 @@ export const API = {
},
/**
* Fetches all available foodpreference options
* Deletes account from the
* @param id
* @param token
* @returns {Promise<*>}
*/
getFoodpreferences
:
async
()
=>
{
return
axios
.
get
(
`
${
import
.
meta
.
env
.
VITE_BACKEND_URL
}
/foodpreferences`
)
deleteAccount
:
async
(
id
,
token
)
=>
{
return
axios
.
delete
(
`
${
import
.
meta
.
env
.
VITE_BACKEND_URL
}
/account/{id}`
,
{
headers
:
{
Authorization
:
`Bearer
${
token
}
`
},
})
.
then
((
response
)
=>
{
return
response
.
data
;
}).
catch
(()
=>
{
throw
new
Error
();
})
.
catch
(()
=>
{
throw
new
Error
(
"
Account not found or not accessible
"
);
});
},
/**
...
...
@@ -128,38 +135,28 @@ export const API = {
});
},
/**
* Deletes account from the
* @param id
* @param token
* @returns {Promise<*>}
*/
deleteAccount
:
async
(
id
,
token
)
=>
{
return
axios
.
delete
(
`
${
import
.
meta
.
env
.
VITE_BACKEND_URL
}
/account/{id}`
,
{
headers
:
{
Authorization
:
`Bearer
${
token
}
`
},
})
.
then
((
response
)
=>
{
return
response
.
data
;
})
.
catch
(()
=>
{
throw
new
Error
(
"
Account not found or not accessible
"
);
});
updateProfile
:
async
(
id
,
request
)
=>
{
const
authStore
=
useAuthStore
();
if
(
!
authStore
.
isLoggedIn
)
{
throw
new
Error
();
}
},
return
axios
.
put
(
`
${
import
.
meta
.
env
.
VITE_BACKEND_URL
}
/profile/
${
id
}
`
,
request
,
{
headers
:
{
Authorization
:
`Bearer
${
authStore
.
token
}
`
},
updateProfile
:
async
(
id
,
token
)
=>
{
return
axios
.
delete
(
`
${
import
.
meta
.
env
.
VITE_BACKEND_URL
}
/profile/{id}`
,
{
headers
:
{
Authorization
:
`Bearer
${
token
}
`
},
})
.
then
((
response
)
=>
{
//authStore.setProfile(response.data)
return
response
.
data
;
})
.
catch
(()
=>
{
throw
new
Error
(
"
Account not found or not accessible
"
);
.
catch
((
error
)
=>
{
throw
new
Error
(
"
Error when updating profile:
"
+
error
);
});
},
}
This diff is collapsed.
Click to expand it.
src/views/ProfileSettings.vue
+
17
−
13
View file @
35b25960
...
...
@@ -118,7 +118,7 @@ export default {
computed
:
{
...
mapStores
(
useAuthStore
),
profile
()
{
cons
t
store
=
useAuthStore
();
le
t
store
=
useAuthStore
();
this
.
currentProfile
.
name
=
store
.
profile
.
name
;
this
.
currentProfile
.
isRestricted
=
store
.
profile
.
restricted
;
this
.
currentProfile
.
image
=
store
.
profile
.
profileImageUrl
;
...
...
@@ -152,14 +152,23 @@ export default {
},
methods
:
{
saveUserSettings
(){
//profilnavn, profilbilde, profilrestriksjoner
console
.
log
(
this
.
currentProfile
.
image
)
alert
(
"
(Denne knappen gjør ingen ting) brukerinnstillinger lagret!
"
)
const
namee
=
this
.
currentProfile
.
name
;
const
isRestrictede
=
this
.
currentProfile
.
isRestricted
;
const
profileImageUrle
=
this
.
currentProfile
.
image
;
API
.
updateProfile
(
this
.
user
.
id
,
this
.
profile
.
name
,
this
.
profile
.
isRestricted
,
this
.
profile
.
image
,
);
this
.
profile
.
id
,{
name
:
namee
,
profileImageUrl
:
profileImageUrle
,
restricted
:
isRestrictede
,
}
).
then
((
savedProfile
)
=>
{
useAuthStore
().
setProfile
(
savedProfile
);
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
})
},
chooseProfilePicture
(){
alert
(
"
velgBilde
"
)
...
...
@@ -171,11 +180,6 @@ export default {
alert
(
"
(Denne knappen gjør ingen ting) konto oppdatert
"
)
}
/*API.updateAccount(
this.user.id,
this.user.password,
token);*/
},
deleteAccount
(){
if
(
this
.
deletionConfirmation
===
false
){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment