aboutsummaryrefslogtreecommitdiff
path: root/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/user/[user]/+page.svelte28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/routes/user/[user]/+page.svelte b/src/routes/user/[user]/+page.svelte
index 4152c9f4..5cff3ca8 100644
--- a/src/routes/user/[user]/+page.svelte
+++ b/src/routes/user/[user]/+page.svelte
@@ -146,6 +146,19 @@
.then((rawPreferences) => rawPreferences.json())
.then((JSONpreferences) => (preferences = JSONpreferences));
+ const toggleCategory = () => {
+ if (!userData) return;
+
+ const categoryElement = document.getElementById('category') as HTMLInputElement;
+ const category = categoryElement.value;
+
+ fetch(root(`/api/preferences?id=${userData.id}&toggleCategory=${category}`), {
+ method: 'PUT'
+ }).then(refreshPreferences);
+
+ categoryElement.value = '';
+ };
+
// 8.5827814569536423841e0
</script>
@@ -352,20 +365,7 @@
<input type="text" id="category" placeholder="Category" style="width: 10em;" />
</span>
- <button
- class="button-lined"
- on:click={() => {
- if (userData) {
- const category = document.getElementById('category').value;
-
- fetch(root(`/api/preferences?id=${userData.id}&toggleCategory=${category}`), {
- method: 'PUT'
- }).then(refreshPreferences);
-
- document.getElementById('category').value = '';
- }
- }}>Add</button
- >
+ <button class="button-lined" on:click={toggleCategory}>Add</button>
</span>
</div>