From f9125e744b75c8b6ea1e1a739311a14fbb955308 Mon Sep 17 00:00:00 2001 From: Bastian Masanek Date: Wed, 5 Nov 2025 01:04:26 +0100 Subject: [PATCH] Implement Role Management Features and UI Enhancements - Introduced a new composable `useActiveRole` for managing user roles, including fetching role status and switching roles with server validation. - Updated `RoleSwitcher.vue` to utilize the new composable, enhancing role selection with improved error handling and UI feedback. - Added new API endpoints for role management, including fetching user role status and switching active roles. - Enhanced product visibility logic to filter based on the user's active role, ensuring a tailored experience. - Updated database schema to support last active role tracking for users, improving session management. - Refined UI components across the application to reflect role-based changes and improve user experience. --- .claude/settings.local.json | 7 +- app/components/UserMenu.vue | 1 - app/components/navigation/RoleSwitcher.vue | 148 ++- app/composables/useActiveRole.ts | 142 +++ app/pages/checkout.vue | 6 +- server/api/auth/login.post.ts | 18 +- server/api/products/index.get.ts | 16 +- server/api/user/active-role.patch.ts | 64 + server/api/user/role-status.get.ts | 69 ++ .../migrations/0003_charming_zzzax.sql | 1 + .../migrations/meta/0003_snapshot.json | 1030 +++++++++++++++++ server/database/migrations/meta/_journal.json | 7 + server/database/schema.ts | 3 + server/database/seed.ts | 2 +- server/utils/role-session.ts | 111 ++ server/utils/roles.ts | 42 + 16 files changed, 1576 insertions(+), 91 deletions(-) create mode 100644 app/composables/useActiveRole.ts create mode 100644 server/api/user/active-role.patch.ts create mode 100644 server/api/user/role-status.get.ts create mode 100644 server/database/migrations/0003_charming_zzzax.sql create mode 100644 server/database/migrations/meta/0003_snapshot.json create mode 100644 server/utils/role-session.ts diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 2695a35..90c513f 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -80,7 +80,12 @@ "Bash(pnpm remove:*)", "Bash(pnpm db:generate:*)", "Bash(pnpm tsx:*)", - "Bash(node test-roleswitcher-keyboard.mjs:*)" + "Bash(node test-roleswitcher-keyboard.mjs:*)", + "Bash(tmux capture-pane:*)", + "Bash(tmux list-sessions:*)", + "Bash(tmux send-keys:*)", + "Bash(tmux new-session:*)", + "Bash(tmux kill-session:*)" ], "deny": [], "ask": [] diff --git a/app/components/UserMenu.vue b/app/components/UserMenu.vue index ab9b23f..847d944 100644 --- a/app/components/UserMenu.vue +++ b/app/components/UserMenu.vue @@ -74,7 +74,6 @@ async function handleLogout() { - {{ userInitials }} diff --git a/app/components/navigation/RoleSwitcher.vue b/app/components/navigation/RoleSwitcher.vue index e288d6f..264c1b2 100644 --- a/app/components/navigation/RoleSwitcher.vue +++ b/app/components/navigation/RoleSwitcher.vue @@ -1,6 +1,7 @@