Expand shared profile and about dialogs
Lint / Lint (Go) (push) Successful in 17s
Lint / Lint (Python) (push) Successful in 9s
Tests / Test (Node/Svelte) (push) Successful in 13s
Tests / Test (Go) (push) Successful in 17s
Tests / Test (Python) (push) Successful in 9s
Lint / Lint (Node/Svelte) (push) Successful in 14s
Lint / Lint (Go) (push) Successful in 17s
Lint / Lint (Python) (push) Successful in 9s
Tests / Test (Node/Svelte) (push) Successful in 13s
Tests / Test (Go) (push) Successful in 17s
Tests / Test (Python) (push) Successful in 9s
Lint / Lint (Node/Svelte) (push) Successful in 14s
This commit is contained in:
1 parent
d134d6626a
commit
c95865dbe2
3 files changed
+44
-1
No files matched your search
@@ -1,15 +1,18 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { AboutLink } from '../types';
|
||||
import Dialog from './Dialog.svelte';
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
children,
|
||||
description = '',
|
||||
links = [],
|
||||
open = $bindable(false),
|
||||
version = ''
|
||||
}: {
|
||||
brand?: string;
|
||||
children?: Snippet;
|
||||
description?: string;
|
||||
links?: AboutLink[];
|
||||
open?: boolean;
|
||||
@@ -31,6 +34,10 @@
|
||||
<p class="sc-muted">{description}</p>
|
||||
{/if}
|
||||
|
||||
{#if children}
|
||||
{@render children()}
|
||||
{/if}
|
||||
|
||||
{#if links.length > 0}
|
||||
<div class="sc-about-links">
|
||||
{#each links as link}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
let username = $state('');
|
||||
let email = $state('');
|
||||
let password = $state('');
|
||||
let confirmPassword = $state('');
|
||||
let error = $state('');
|
||||
let saving = $state(false);
|
||||
|
||||
@@ -24,6 +26,8 @@
|
||||
if (open) {
|
||||
username = currentUsername;
|
||||
email = currentEmail;
|
||||
password = '';
|
||||
confirmPassword = '';
|
||||
error = '';
|
||||
}
|
||||
});
|
||||
@@ -32,6 +36,11 @@
|
||||
event.preventDefault();
|
||||
error = '';
|
||||
|
||||
if (password && password !== confirmPassword) {
|
||||
error = 'Passwords do not match.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!onSave) {
|
||||
error = 'The application has not configured its profile update handler.';
|
||||
return;
|
||||
@@ -39,7 +48,7 @@
|
||||
|
||||
saving = true;
|
||||
try {
|
||||
await onSave({ username, email });
|
||||
await onSave({ username, email, password: password || undefined });
|
||||
open = false;
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Profile update failed.';
|
||||
@@ -68,6 +77,32 @@
|
||||
<input autocomplete="email" class="sc-input" required type="email" bind:value={email} />
|
||||
</label>
|
||||
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">New password</span>
|
||||
<input
|
||||
autocomplete="new-password"
|
||||
class="sc-input"
|
||||
minlength="8"
|
||||
placeholder="Leave blank to keep the current password"
|
||||
type="password"
|
||||
bind:value={password}
|
||||
/>
|
||||
</label>
|
||||
|
||||
{#if password}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Confirm new password</span>
|
||||
<input
|
||||
autocomplete="new-password"
|
||||
class="sc-input"
|
||||
minlength="8"
|
||||
required
|
||||
type="password"
|
||||
bind:value={confirmPassword}
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
{#if error}
|
||||
<p aria-live="polite" class="sc-error">{error}</p>
|
||||
{/if}
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface AuthLoginInput {
|
||||
export interface ProfileUpdateInput {
|
||||
username: string;
|
||||
email: string;
|
||||
password?: string;
|
||||
}
|
||||
|
||||
export interface AboutLink {
|
||||
|
||||
Reference in new issue
Block a user