diff options
Diffstat (limited to 'fe/src/lib/PreferencesForm.svelte')
-rw-r--r-- | fe/src/lib/PreferencesForm.svelte | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fe/src/lib/PreferencesForm.svelte b/fe/src/lib/PreferencesForm.svelte index 875393c..74b8a63 100644 --- a/fe/src/lib/PreferencesForm.svelte +++ b/fe/src/lib/PreferencesForm.svelte | |||
@@ -2,6 +2,7 @@ | |||
2 | import { user, preferences, token } from "../stores/auth"; | 2 | import { user, preferences, token } from "../stores/auth"; |
3 | import { createEventDispatcher, onDestroy, onMount } from "svelte"; | 3 | import { createEventDispatcher, onDestroy, onMount } from "svelte"; |
4 | import type { User } from "../types"; | 4 | import type { User } from "../types"; |
5 | import { apiURL } from "../utils"; | ||
5 | 6 | ||
6 | export let open: boolean; | 7 | export let open: boolean; |
7 | 8 | ||
@@ -13,9 +14,10 @@ | |||
13 | 14 | ||
14 | const unsubscribe = preferences.subscribe( | 15 | const unsubscribe = preferences.subscribe( |
15 | (value: any) => { | 16 | (value: any) => { |
16 | console.log('update value: ', value); | 17 | if (value) { |
17 | color = value.color; | 18 | color = value.color; |
18 | selectedSize = value.size_id; | 19 | selectedSize = value.size_id; |
20 | } | ||
19 | }, | 21 | }, |
20 | ); | 22 | ); |
21 | 23 | ||
@@ -24,7 +26,7 @@ | |||
24 | } | 26 | } |
25 | 27 | ||
26 | async function updateUserPreferences() { | 28 | async function updateUserPreferences() { |
27 | const res = await fetch("http://localhost:8080/api/v1/user/preferences", { | 29 | const res = await fetch(apiURL("user/preferences"), { |
28 | method: "PATCH", | 30 | method: "PATCH", |
29 | headers: { | 31 | headers: { |
30 | Authorization: `Bearer ${$token}`, | 32 | Authorization: `Bearer ${$token}`, |
@@ -34,8 +36,7 @@ | |||
34 | } | 36 | } |
35 | 37 | ||
36 | async function getUserPreferences() { | 38 | async function getUserPreferences() { |
37 | const res = await fetch( | 39 | const res = await fetch(apiURL(`user/${($user as User)!.id}/preferences`), |
38 | `http://localhost:8080/api/v1/user/${($user as User)!.id}/preferences`, | ||
39 | { | 40 | { |
40 | method: "GET", | 41 | method: "GET", |
41 | headers: { | 42 | headers: { |
@@ -61,7 +62,7 @@ | |||
61 | } | 62 | } |
62 | 63 | ||
63 | onMount(() => { | 64 | onMount(() => { |
64 | fetch("http://localhost:8080/api/v1/sizes", { | 65 | fetch(apiURL("sizes"), { |
65 | method: "GET", | 66 | method: "GET", |
66 | headers: { | 67 | headers: { |
67 | Authorization: `Bearer ${$token}`, | 68 | Authorization: `Bearer ${$token}`, |