From 1cc227354ff7caf8f6c5ad61170636208bc1542b Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 27 May 2024 18:41:20 -0700 Subject: refactor(badges): move category toggle to script --- src/routes/user/[user]/+page.svelte | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/routes') 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 @@ -352,20 +365,7 @@ - + -- cgit v1.2.3