diff options
Diffstat (limited to 'ui/routes')
| -rw-r--r-- | ui/routes/(app)/+layout.svelte | 2 | ||||
| -rw-r--r-- | ui/routes/(app)/me/+page.svelte | 84 | ||||
| -rw-r--r-- | ui/routes/+layout.svelte | 2 |
3 files changed, 13 insertions, 75 deletions
diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte index f876338..86bc330 100644 --- a/ui/routes/(app)/+layout.svelte +++ b/ui/routes/(app)/+layout.svelte @@ -71,7 +71,7 @@ <CreateChannelForm /> </div> </nav> - <main> + <main class="pl-4"> {@render children?.()} </main> </div> diff --git a/ui/routes/(app)/me/+page.svelte b/ui/routes/(app)/me/+page.svelte index 8d24a61..aded292 100644 --- a/ui/routes/(app)/me/+page.svelte +++ b/ui/routes/(app)/me/+page.svelte @@ -1,79 +1,17 @@ <script> - import { goto } from '$app/navigation'; - import { changePassword, logOut } from '$lib/apiServer.js'; - import { currentUser } from '$lib/store'; - + import LogOut from '$lib/components/LogOut.svelte'; import Invites from '$lib/components/Invites.svelte'; - - let currentPassword = $state(''), - newPassword = $state(''), - confirmPassword = $state(''), - passwordForm; - let pending = $state(false); - let valid = $derived(newPassword === confirmPassword && newPassword !== currentPassword); - let disabled = $derived(pending || !valid); - - async function onLogOut(event) { - event.preventDefault(); - const response = await logOut(); - if (200 <= response.status && response.status < 300) { - currentUser.update(() => null); - goto('/login'); - } - } - - async function onPasswordChange(event) { - event.preventDefault(); - pending = true; - let response = await changePassword(currentPassword, newPassword); - switch (response.status) { - case 200: - passwordForm.reset(); - break; - } - pending = false; - } + import ChangePassword from '$lib/components/ChangePassword.svelte'; </script> -<form onsubmit={onLogOut}> - <button class="btn variant-filled" type="submit">log out</button> -</form> - -<form onsubmit={onPasswordChange} bind:this={passwordForm}> - <label - >current password - <input - class="input" - name="currentPassword" - type="password" - placeholder="password" - bind:value={currentPassword} - /> - </label> - - <label - >new password - <input - class="input" - name="newPassword" - type="password" - placeholder="password" - bind:value={newPassword} - /> - </label> - - <label - >confirm new password - <input - class="input" - name="confirmPassword" - type="password" - placeholder="password" - bind:value={confirmPassword} - /> - </label> +<div class="mb-4"> + <ChangePassword /> +</div> - <button class="btn variant-filled" type="submit" {disabled}> change password </button> -</form> +<div class="mb-4"> + <Invites /> +</div> -<Invites /> +<div> + <LogOut /> +</div> diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index dbf109f..8940659 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -33,7 +33,7 @@ <a href="/">pilcrow</a> <svelte:fragment slot="trail"> {#if $currentUser} - <div class="rounded-full bg-secondary-400 px-2 py-1"> + <div class="rounded-full bg-secondary-400 px-3 py-1"> <a href="/me">@{$currentUser.username}</a> </div> {/if} |
