diff --git a/SharpbinV3.Client/src/routes/user/[username]/+page.svelte b/SharpbinV3.Client/src/routes/user/[username]/+page.svelte index eed575c..d8b9089 100644 --- a/SharpbinV3.Client/src/routes/user/[username]/+page.svelte +++ b/SharpbinV3.Client/src/routes/user/[username]/+page.svelte @@ -15,7 +15,9 @@ Clock, Hash, Flag, - LoaderCircle + LoaderCircle, + Check, + X } from '@lucide/svelte'; import { extractDateFromUUIDv7, @@ -48,13 +50,17 @@ let totpEnabled = false; let now = new Date(); let interval: ReturnType | null = null; + let isEditingDisplayName = false; + let editDisplayNameValue = ''; $: isOwner = data.user && $user ? data.user?.uuid === $user.uuid : false; $: totpEnabled = Boolean($user?.totpEnabled); $: reportsSubmitted = data.reportsSubmitted; $: reportsTarget = data.reportsTarget; - let activeTab: 'pastes' | 'reportsSubmitted' | 'reportsTarget' = 'pastes'; + let activeTab: 'pastes' | 'reportsSubmitted' | 'reportsTarget' | 'settings' = isOwner + ? 'settings' + : 'pastes'; function updateTab(tab: typeof activeTab) { activeTab = tab; @@ -62,15 +68,24 @@ url.searchParams.set('tab', tab); goto(url, { replaceState: true, noScroll: true, keepFocus: true }); } - + $: { const tab = page.url.searchParams.get('tab'); - if (tab === 'reportsSubmitted' && reportsSubmitted) { - activeTab = 'reportsSubmitted'; - } else if (tab === 'reportsTarget' && reportsTarget) { - activeTab = 'reportsTarget'; - } else { - activeTab = 'pastes'; + switch (tab) { + case 'reportsSubmitted': + if (reportsSubmitted) activeTab = 'reportsSubmitted'; + else activeTab = 'pastes'; + break; + case 'reportsTarget': + if (reportsTarget) activeTab = 'reportsTarget'; + else activeTab = 'pastes'; + break; + case 'settings': + if (isOwner || $user?.roles?.some((r) => r === 255 || r === 1)) activeTab = 'settings'; + else activeTab = 'pastes'; + break; + default: + activeTab = 'pastes'; } } @@ -206,19 +221,21 @@ modalError = ''; } - async function openEditDisplayName() { - const value = String( - await openModal({ - mode: 'prompt', - title: 'Edit Display Name', - maxInputLength: 26, - placeholder: 'New Display Name', - error: modalError, - cancelValue: '' - }) - ).trim(); + async function saveDisplayName() { + const value = editDisplayNameValue.trim(); if (!value) return; await handleUserUpdate(value); + isEditingDisplayName = false; + } + + function startEditDisplayName() { + editDisplayNameValue = data.user?.displayName || data.user?.username || ''; + isEditingDisplayName = true; + } + + function cancelEditDisplayName() { + isEditingDisplayName = false; + editDisplayNameValue = ''; } async function openEditRoles() { @@ -376,45 +393,18 @@ {/if} - {#if isOwner || $user?.roles?.some((r) => r === 255 || r === 1)} -
- - {#if isOwner} - - {/if} - {#if $user?.roles?.some((r) => r === 255)} - - {/if} - {#if isOwner || $user?.roles?.some((r) => r === 255)} - - {/if} -
- {/if}
+ {#if isOwner || $user?.roles?.some((r) => r === 255 || r === 1)} + + {/if} + +
+ {:else} + {data.user?.displayName || data.user?.username} + + {/if} + + + + + {#if isOwner} +
+
+
+
+

Security

+

+ Manage your account security settings. +

+
+
+ +
+
+
+ Two-Factor Authentication + {totpEnabled ? 'Enabled' : 'Disabled'} +
+ +
+
+
+
+ {/if} + + {#if $user?.roles?.some((r) => r === 255)} +
+
+
+
+

Administration

+

Manage user roles and permissions.

+
+
+
+
+
+ User Roles + {data.user?.roles?.length ?? 0} roles assigned +
+ +
+
+
+
+ {/if} + + {#if isOwner || $user?.roles?.some((r) => r === 255)} +
+
+
+
+

Danger Zone

+

+ Irreversible actions related to this account. +

+
+
+ +
+
+

Delete Account

+

+ Permanently delete this account and all associated data. +

+
+ +
+
+
+ {/if} + + {:else if activeTab === 'pastes'}
{#if pastes && pastes.length > 0} {#each pastes