aboutsummaryrefslogtreecommitdiff
path: root/src/routes/user
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/user')
-rw-r--r--src/routes/user/[user]/+page.svelte69
1 files changed, 64 insertions, 5 deletions
diff --git a/src/routes/user/[user]/+page.svelte b/src/routes/user/[user]/+page.svelte
index 2dd8dc2b..097007f0 100644
--- a/src/routes/user/[user]/+page.svelte
+++ b/src/routes/user/[user]/+page.svelte
@@ -68,6 +68,11 @@
const getBiography = () =>
(document.getElementById('biography') as HTMLTextAreaElement).value.slice(0, 3000);
+ const refreshPreferences = () =>
+ fetch(root(`/api/preferences?id=${userData?.id}`))
+ .then((rawPreferences) => rawPreferences.json())
+ .then((JSONpreferences) => (preferences = JSONpreferences));
+
// 8.5827814569536423841e0
</script>
@@ -239,6 +244,49 @@
<p />
+ Pinned Categories
+
+ <div class="pinned-categories">
+ {#each preferences.pinned_badge_wall_categories.split(',') as category}
+ <span class="card card-small pinned-category">
+ <span class="pinned-category-name">
+ {category}
+ </span>
+ <button
+ on:click={() => {
+ if (userData)
+ fetch(root(`/api/preferences?id=${userData.id}&toggleCategory=${category}`), {
+ method: 'PUT'
+ }).then(refreshPreferences);
+ }}>Remove</button
+ >
+ </span>
+ {/each}
+
+ <span class="card card-small pinned-category">
+ <span class="pinned-category-name">
+ <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
+ >
+ </span>
+ </div>
+
+ <p />
+
Biography
<button
@@ -247,11 +295,7 @@
fetch(root(`/api/preferences?id=${userData.id}&biography`), {
method: 'PUT',
body: getBiography()
- }).then(() =>
- fetch(root(`/api/preferences?id=${userData?.id}`))
- .then((rawPreferences) => rawPreferences.json())
- .then((JSONpreferences) => (preferences = JSONpreferences))
- );
+ }).then(refreshPreferences);
}}>Save</button
>
<textarea
@@ -355,4 +399,19 @@
.user-grid-rest {
flex: 1;
}
+
+ .pinned-categories {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1rem;
+ }
+
+ .pinned-category {
+ display: flex;
+ align-items: center;
+ }
+
+ .pinned-category-name {
+ margin-right: 0.5em;
+ }
</style>