From 92a3dc4c628fb16a8109eee7a0dc4f2083decc76 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Sat, 27 Sep 2025 08:16:59 -0400 Subject: [PATCH] Made login auto-redirect to first profile. Fixes #31 --- web-app/src/api/profile.ts | 18 ++++ web-app/src/components/AccountCard.vue | 22 +++-- .../components/common/form/FormControl.vue | 14 ++-- web-app/src/pages/AccountPage.vue | 58 ++++++++++--- web-app/src/pages/LoginPage.vue | 12 ++- web-app/src/pages/forms/EditAccountPage.vue | 51 ++++++++++-- .../src/pages/forms/EditTransactionPage.vue | 82 +++++++++++++++---- web-app/src/router/index.ts | 7 +- 8 files changed, 215 insertions(+), 49 deletions(-) diff --git a/web-app/src/api/profile.ts b/web-app/src/api/profile.ts index ef2e171..240e03e 100644 --- a/web-app/src/api/profile.ts +++ b/web-app/src/api/profile.ts @@ -48,3 +48,21 @@ export function getSelectedProfile(route: RouteLocation): string { } return name } + +const LAST_PROFILE_USED_KEY = 'last-profile-used' + +export function saveLastProfileUsed(route: RouteLocation) { + try { + const profileName = getSelectedProfile(route) + const existing = localStorage.getItem(LAST_PROFILE_USED_KEY) + if (existing === null || existing !== profileName) { + localStorage.setItem(LAST_PROFILE_USED_KEY, profileName) + } + } catch { + localStorage.removeItem(LAST_PROFILE_USED_KEY) + } +} + +export function getLastProfileUsed(): string | null { + return localStorage.getItem(LAST_PROFILE_USED_KEY) +} diff --git a/web-app/src/components/AccountCard.vue b/web-app/src/components/AccountCard.vue index c8a21d1..1c1a030 100644 --- a/web-app/src/components/AccountCard.vue +++ b/web-app/src/components/AccountCard.vue @@ -34,18 +34,28 @@ function goToAccount() { }