mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
fix: improve error handling and update user display name modal
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
Hash,
|
Hash,
|
||||||
Flag
|
Flag
|
||||||
} from '@lucide/svelte';
|
} from '@lucide/svelte';
|
||||||
import { extractDateFromUUIDv7, tooltip, dateToRelativeString } from '$lib/utils/misc';
|
import { extractDateFromUUIDv7, tooltip, dateToRelativeString, extractError } from '$lib/utils/misc';
|
||||||
import { roles } from '$lib/consts';
|
import { roles } from '$lib/consts';
|
||||||
import { getToken } from '$lib/utils/auth';
|
import { getToken } from '$lib/utils/auth';
|
||||||
import { needsAdminTotp } from '$lib/utils/totp';
|
import { needsAdminTotp } from '$lib/utils/totp';
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
loading = false;
|
loading = false;
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const err = await res.json();
|
const err = await res.json();
|
||||||
modalError = err.message || 'Failed to update display name';
|
modalError = extractError(err) || 'Failed to update user';
|
||||||
await openModal({
|
await openModal({
|
||||||
mode: 'confirm',
|
mode: 'confirm',
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
loading = false;
|
loading = false;
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const err = await res.json();
|
const err = await res.json();
|
||||||
modalError = err.message || 'Failed to delete account';
|
modalError = extractError(err) || 'Failed to delete account';
|
||||||
await openModal({
|
await openModal({
|
||||||
mode: 'confirm',
|
mode: 'confirm',
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
@@ -185,6 +185,7 @@
|
|||||||
await openModal<string>({
|
await openModal<string>({
|
||||||
mode: 'prompt',
|
mode: 'prompt',
|
||||||
title: 'Edit Display Name',
|
title: 'Edit Display Name',
|
||||||
|
maxInputLength: 26,
|
||||||
placeholder: 'New Display Name',
|
placeholder: 'New Display Name',
|
||||||
error: modalError,
|
error: modalError,
|
||||||
cancelValue: ''
|
cancelValue: ''
|
||||||
@@ -268,7 +269,7 @@
|
|||||||
class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
|
class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
|
||||||
>
|
>
|
||||||
<div class="relative w-[95%] max-w-5xl rounded border-2 border-neutral-800 bg-neutral-900 p-6">
|
<div class="relative w-[95%] max-w-5xl rounded border-2 border-neutral-800 bg-neutral-900 p-6">
|
||||||
<h1 class="flex items-center justify-center gap-4 text-center text-4xl font-bold">
|
<h1 class="flex flex-wrap items-center justify-center gap-4 text-center text-4xl font-bold">
|
||||||
{#if data.user?.roles?.includes(403)}
|
{#if data.user?.roles?.includes(403)}
|
||||||
<span
|
<span
|
||||||
class="relative flex h-7 w-7 items-center justify-center overflow-hidden rounded-full"
|
class="relative flex h-7 w-7 items-center justify-center overflow-hidden rounded-full"
|
||||||
@@ -288,7 +289,7 @@
|
|||||||
<User class="h-8 w-8 text-neutral-400" />
|
<User class="h-8 w-8 text-neutral-400" />
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
<span use:tooltip={data.user?.uuid || 'Unknown UUID'}>
|
<span use:tooltip={data.user?.uuid || 'Unknown UUID'} class="wrap-break-word whitespace-normal max-w-full">
|
||||||
{data.user?.displayName || data.user?.username}
|
{data.user?.displayName || data.user?.username}
|
||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user