From 6d95764516b57d90d4ad4d213cc16e691c2240db Mon Sep 17 00:00:00 2001 From: jableader Date: Sat, 1 Nov 2025 14:49:57 +1100 Subject: [PATCH] =?UTF-8?q?HouseholdSettings.vue=20=E2=80=94=20fixed=20tem?= =?UTF-8?q?plate,=20added=20proper=20imports,=20typed=20members,=20and=20r?= =?UTF-8?q?endered=20current=20members=20list.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend-spec.md | 1 + src/api/households.ts | 18 ++++++++++++++ src/views/HouseholdSettings.vue | 25 +++++++++++++++++-- tests/households.members.api.test.ts | 37 ++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 src/api/households.ts create mode 100644 tests/households.members.api.test.ts diff --git a/frontend-spec.md b/frontend-spec.md index 46d719d..ef93967 100644 --- a/frontend-spec.md +++ b/frontend-spec.md @@ -165,6 +165,7 @@ Progress Log (Nov 1, 2025) - Added `useAuth.createAccount` with state update and tests for it; implemented `CreateAccount.vue` with form and navigation. - Implemented Invitation Accept flow: added `src/api/invitations.ts` with `acceptInvitation` (temporary raw fetch), `InvitationAccept.vue` reads token and redirects to household; added `tests/invitations.api.test.ts`. - Next: Implement Household Settings (invite members form), then remove legacy Person UI. + - Added a Settings link to `HouseholdSwitcher.vue` to surface the `household-settings` route for easier discovery. --- diff --git a/src/api/households.ts b/src/api/households.ts new file mode 100644 index 0000000..8ba1412 --- /dev/null +++ b/src/api/households.ts @@ -0,0 +1,18 @@ +import { api, fetchApi } from '@/api/client' +import type { components, paths } from '@/api/types' + +export type Member = components['schemas']['User'] + +// Prefer typed endpoint if exists, fallback to raw fetch for now +export async function listMembers(): Promise { + // Try typed path if openapi exposes it + const hasTyped: boolean = Boolean((api as unknown as { GET?: unknown }).GET) + if (hasTyped) { + // Our OpenAPI file doesn't specify this route yet, so default to raw fetch + } + const resp = await fetchApi('/api/v1/households/members', { method: 'GET' }) + if (!resp.ok) throw new Error(`${resp.status} ${resp.statusText || 'HTTP error'}`) + const data = await resp.json().catch(() => null) + const arr = Array.isArray(data) ? data : [] + return arr.filter((m): m is Member => typeof m === 'object' && m !== null && typeof (m as { id: unknown }).id === 'number') +} diff --git a/src/views/HouseholdSettings.vue b/src/views/HouseholdSettings.vue index 5448d39..81cbc68 100644 --- a/src/views/HouseholdSettings.vue +++ b/src/views/HouseholdSettings.vue @@ -35,7 +35,18 @@

Current members

-

+

    +
  • + {{ m.displayName }} ({{ m.email }}) +
  • +
+

Listing members will be added once the backend endpoint is available.

@@ -43,13 +54,23 @@