From 18511b6546b7647b0b102d13308e5872b92595d8 Mon Sep 17 00:00:00 2001 From: JCEEE <0xjceee@proton.me> Date: Sun, 20 Sep 2026 17:49:14 +0100 Subject: [PATCH] payday tests --- frontend/src/lib/components/index.ts | 1 + .../[fam]/[username]/settings/+page.svelte | 69 +++++++++++++++---- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/frontend/src/lib/components/index.ts b/frontend/src/lib/components/index.ts index 9dd2e32..25d730f 100644 --- a/frontend/src/lib/components/index.ts +++ b/frontend/src/lib/components/index.ts @@ -6,6 +6,7 @@ export { default as ViewHeader } from './ViewHeader.svelte'; export { default as Card } from './Card.svelte'; export { default as CardGrid } from './CardGrid.svelte'; export { default as Button } from './Button.svelte'; +export { default as SaveButton } from './SaveButton.svelte'; export { default as Accordion } from './Accordion.svelte'; export { default as AccordionItem } from './AccordionItem.svelte'; export { default as Chat } from './Chat.svelte'; diff --git a/frontend/src/routes/[fam]/[username]/settings/+page.svelte b/frontend/src/routes/[fam]/[username]/settings/+page.svelte index ca626da..76969ab 100644 --- a/frontend/src/routes/[fam]/[username]/settings/+page.svelte +++ b/frontend/src/routes/[fam]/[username]/settings/+page.svelte @@ -9,6 +9,7 @@ CardGrid, Card, Button, + SaveButton, Accordion, AccordionItem, NoticeDialog @@ -89,6 +90,17 @@ }); let qrDataUrl = $state(''); let copied = $state(false); + + // Save-button success feedback: each save form holds a SaveButton ref and + // flashes it green for 4s from its use:enhance callback on success. + type Flasher = { flash: () => void } | null; + let renameBtn: Flasher = $state(null); + let paydayBtn: Flasher = $state(null); + let seasonBtn: Flasher = $state(null); + let lockBtn: Flasher = $state(null); + let addMemberBtn: Flasher = $state(null); + let inviteBtn: Flasher = $state(null); + let applyCodeBtn: Flasher = $state(null); let parentInviteName = $state(''); let parentInviteEmail = $state(''); @@ -153,6 +165,7 @@ if (result.type === 'success') { const d = result.data as { ok?: boolean; error?: string } | undefined; if (d?.ok) { + inviteBtn?.flash(); notices.success( 'Invite sent', `Email sent to ${parentInviteEmail} with a join link and code.` @@ -209,7 +222,16 @@ /{famSlug} even if you rename it — links you've shared keep working.

-
+ { + return async ({ result, update }) => { + await update(); + if (result.type === 'success') renameBtn?.flash(); + }; + }} + > - + {#if fam?.slug}

@@ -234,6 +256,7 @@ use:enhance={() => { return async ({ result }) => { if (result.type === 'error') alert(result.error || 'Failed to update payday'); + else if (result.type === 'success') paydayBtn?.flash(); }; }} class="payday-form" @@ -265,7 +288,7 @@ {/each} - +

Payday: the week starts on this day and weekly earnings are settled at this time. Pick @@ -278,7 +301,17 @@ Group chores into seasons. Tick a season on to make it available for assignment; untick to disable it.

-
+ { + return async ({ result, update }) => { + await update(); + if (result.type === 'success') seasonBtn?.flash(); + }; + }} + class="season-form" + >
@@ -297,7 +330,7 @@
- +
    @@ -385,8 +418,10 @@ return async ({ result }) => { if (result.type !== 'success') return; const d = result.data as any; - if (d?.ok) lockMins = String(d.lockMins); - else if (d?.error) alert(d.error); + if (d?.ok) { + lockMins = String(d.lockMins); + lockBtn?.flash(); + } else if (d?.error) alert(d.error); }; }} > @@ -395,7 +430,7 @@ - + @@ -405,7 +440,16 @@

    Add a child. They'll pick their own colour after joining.

    -
    + { + return async ({ result, update }) => { + await update(); + if (result.type === 'success') addMemberBtn?.flash(); + }; + }} + > - +
    @@ -631,7 +675,7 @@ placeholder="parent@example.com" required /> - +

    They'll receive a link with a code to set up their own password.

    @@ -704,6 +748,7 @@ const d = result.data as { error?: string; ok?: boolean }; accessMsg = d.error || 'Code applied — access enabled.'; accessCodeInput = ''; + if (d.ok && !d.error) applyCodeBtn?.flash(); } await update(); }; @@ -715,7 +760,7 @@ placeholder="Enter access code" autocomplete="off" /> - + {/if} {#if accessMsg}