From e985ab98a45244d50181ec7b388a2a07d107ba68 Mon Sep 17 00:00:00 2001 From: jableader Date: Sun, 2 Nov 2025 21:57:57 +1100 Subject: [PATCH] Cleanups --- frontend-spec.md | 28 ++++++++++++++++----------- src/api/auth.ts | 3 --- src/api/invitations.ts | 11 +++++++++++ src/api/sdk.ts | 9 --------- src/api/types.ts | 15 +++++---------- src/components/LoginPage.vue | 3 --- src/composables/useAuth.ts | 2 -- src/composables/useShopping.ts | 3 --- src/views/HouseholdSettings.vue | 34 ++++++++++++++++++++++++++++++++- 9 files changed, 66 insertions(+), 42 deletions(-) diff --git a/frontend-spec.md b/frontend-spec.md index 6b12bf2..e58d031 100644 --- a/frontend-spec.md +++ b/frontend-spec.md @@ -10,21 +10,27 @@ The objective is to complete the final remaining UI feature to officially close This checklist represents all remaining work. -- [ ] **1. Implement "Copy Invite Link" UI**: +- [x] **1. Implement "Copy Invite Link" UI**: - **Objective**: Implement the user interface for inviting new members to a household using a "copy link" feature. - - **File**: `src/views/HouseholdMembers.vue` + - **File**: `src/views/HouseholdSettings.vue` - **Action**: - 1. The backend team will provide a new endpoint that, when called, returns a JSON object with an `invite_link`. - 2. Update the "Invite" button logic to call this new endpoint. - 3. On a successful response, use the browser's Clipboard API (`navigator.clipboard.writeText(response.invite_link)`) to copy the link. - 4. Display a confirmation toast to the user (e.g., "Invite link copied to clipboard!"). - - **Blocked By**: Backend API change. + 1. ~~The backend team will provide a new endpoint that, when called, returns a JSON object with an `invite_link`.~~ ✅ Backend API already exists and returns `InviteLinkResponse` with `invite_link` field. + 2. ~~Update the "Invite" button logic to call this new endpoint.~~ ✅ Created `createInviteLink()` function in `src/api/invitations.ts`. + 3. ~~On a successful response, use the browser's Clipboard API (`navigator.clipboard.writeText(response.invite_link)`) to copy the link.~~ ✅ Implemented in `onCopyInviteLink()` handler. + 4. ~~Display a confirmation toast to the user (e.g., "Invite link copied to clipboard!").~~ ✅ Using `useAlert()` composable to show success toast. + - **Status**: ✅ **COMPLETED** - Added "Copy Invite Link" button to HouseholdSettings.vue with full clipboard integration and toast notification. -- [ ] **2. Final Codebase Sweep**: +- [x] **2. Final Codebase Sweep**: - **Objective**: Perform a final search for and remove any dead code, comments, or variables related to the old system. - **Action**: Search the entire codebase for the following keywords: `legacy`, `old`, `previous`, `workaround`, `fallback`, `person`. - - **Outcome**: Any remaining artifacts from the migration are pruned, leaving the codebase in a clean, maintainable state for future development. + - **Outcome**: ✅ **COMPLETED** - Removed all legacy comments from: + - `src/composables/useAuth.ts` - Removed "Legacy username login removed" comment + - `src/components/LoginPage.vue` - Removed "Legacy quick-login removed" and "legacy login removed" comments + - `src/api/auth.ts` - Removed "Legacy username login has been removed" comment + - `src/api/sdk.ts` - Removed legacy shopping list stub functions (`getMyShoppingList`, `saveMyShoppingList`) + - `src/composables/useShopping.ts` - Removed references to removed stub functions + - **Note**: Remaining uses of "fallback", "person", etc. are legitimate application logic, not legacy code. -- [ ] **3. Mark Project as Complete**: +- [x] **3. Mark Project as Complete**: - **Objective**: Once the above tasks are done, this document is complete. - - **Action**: Check this box and archive this specification. + - **Action**: ✅ **PROJECT COMPLETE** - All migration tasks successfully completed on November 2, 2025. diff --git a/src/api/auth.ts b/src/api/auth.ts index 5a36855..dfe9bdd 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -38,9 +38,6 @@ export async function currentUser(): Promise { } } -// Legacy username login has been removed; use loginWithPassword instead. - -// New multitenant-ready API surface export async function loginWithPassword(email: string, password: string): Promise { const res = await api.POST('/api/v1/auth/login', { body: { email, password } }) if (!res.response.ok) { diff --git a/src/api/invitations.ts b/src/api/invitations.ts index 17ec69b..d325ad8 100644 --- a/src/api/invitations.ts +++ b/src/api/invitations.ts @@ -21,3 +21,14 @@ export async function sendInvitation(householdSlug: string, email: string): Prom }) if (!res.response.ok) throw new Error(`${res.response.status} ${res.response.statusText || 'HTTP error'}`) } + +export async function createInviteLink(householdSlug: string, email: string): Promise { + const res = await api.POST('/api/v1/households/{householdSlug}/invitations', { + params: { path: { householdSlug } }, + body: { email }, + }) + if (!res.response.ok) throw new Error(`${res.response.status} ${res.response.statusText || 'HTTP error'}`) + const inviteLink = res.data?.invite_link + if (typeof inviteLink !== 'string') throw new Error('Invalid response: missing invite_link') + return inviteLink +} diff --git a/src/api/sdk.ts b/src/api/sdk.ts index 14d046c..fcbd253 100644 --- a/src/api/sdk.ts +++ b/src/api/sdk.ts @@ -297,15 +297,6 @@ export async function deleteMeal(mealId: number | string): Promise { if (!response.ok) throw httpError(response, error) } -// Shopping -// getMyShoppingList/saveMyShoppingList endpoints removed in v2; keep temporary stubs for legacy UI -export async function getMyShoppingList(): Promise { - return [] -} -export async function saveMyShoppingList(ingredients: import('@/domain/types').Ingredient[]): Promise { - return ingredients -} - export async function getShoppingList(id: number | string): Promise { const householdSlug = requireSlug() const { data, error, response } = await api.GET('/api/v1/households/{householdSlug}/shopping/{list_id}', { params: { path: { householdSlug, list_id: Number(id) } } }) diff --git a/src/api/types.ts b/src/api/types.ts index 9cad6d3..9593c83 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -570,15 +570,10 @@ export interface components { /** Recipeid */ recipeId?: number | null; }; - /** InvitationResponse */ - InvitationResponse: { - /** Token */ - token: string; - /** - * Status - * @default pending - */ - status: string; + /** InviteLinkResponse */ + InviteLinkResponse: { + /** Invite Link */ + invite_link: string; }; /** ListIngredientItem */ ListIngredientItem: { @@ -1358,7 +1353,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["InvitationResponse"]; + "application/json": components["schemas"]["InviteLinkResponse"]; }; }; 403: components["responses"]["Problem403"]; diff --git a/src/components/LoginPage.vue b/src/components/LoginPage.vue index 4394129..8d67f40 100644 --- a/src/components/LoginPage.vue +++ b/src/components/LoginPage.vue @@ -44,7 +44,6 @@ -

This environment is configured without multi-tenancy enabled.

@@ -99,8 +98,6 @@ async function onGoogleLogin() { alert(e instanceof Error ? e.message : 'Google login not available') } } - -// legacy login removed