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.
This commit is contained in:
1
server/database/migrations/0003_charming_zzzax.sql
Normal file
1
server/database/migrations/0003_charming_zzzax.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "users" ADD COLUMN "last_active_role_code" "role_code";
|
||||
1030
server/database/migrations/meta/0003_snapshot.json
Normal file
1030
server/database/migrations/meta/0003_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,13 @@
|
||||
"when": 1762176703220,
|
||||
"tag": "0002_heavy_namora",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "7",
|
||||
"when": 1762266703780,
|
||||
"tag": "0003_charming_zzzax",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -127,6 +127,9 @@ export const users = pgTable('users', {
|
||||
city: text('city'),
|
||||
countryCode: text('country_code'), // ISO 3166-1 alpha-2 (e.g., 'DE', 'AT')
|
||||
|
||||
// Role preference (last selected role, used as default after login)
|
||||
lastActiveRoleCode: roleCodeEnum('last_active_role_code'),
|
||||
|
||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
||||
})
|
||||
|
||||
@@ -88,7 +88,7 @@ const mockProducts: Array<{
|
||||
stockQuantity: 99999,
|
||||
category: 'educator-annual-pass',
|
||||
active: true,
|
||||
roles: ['private', 'educator'],
|
||||
roles: ['educator'],
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user