Imporve the role based forntend protected roles

This commit is contained in:
Urtzi Alfaro
2025-09-09 07:32:59 +02:00
parent ddb75f8e55
commit 5269a083b6
15 changed files with 286 additions and 91 deletions

View File

@@ -54,6 +54,12 @@ export class TenantService {
return apiClient.get<TenantAccessResponse>(`${this.baseUrl}/${tenantId}/access/${userId}`);
}
async getCurrentUserTenantAccess(tenantId: string): Promise<TenantAccessResponse> {
// This will use the current user from the auth token
// The backend endpoint handles extracting user_id from the token
return apiClient.get<TenantAccessResponse>(`${this.baseUrl}/${tenantId}/my-access`);
}
// Search & Discovery
async searchTenants(params: TenantSearchParams): Promise<TenantResponse[]> {
const queryParams = new URLSearchParams();

View File

@@ -2,6 +2,8 @@
* Auth API Types - Mirror backend schemas
*/
import type { GlobalUserRole } from '../../types/roles';
export interface User {
id: string;
email: string;
@@ -14,7 +16,7 @@ export interface User {
language?: string;
timezone?: string;
tenant_id?: string;
role?: string;
role?: GlobalUserRole;
}
export interface UserRegistration {
@@ -65,7 +67,7 @@ export interface UserResponse {
language?: string;
timezone?: string;
tenant_id?: string;
role?: string;
role?: GlobalUserRole;
}
export interface UserUpdate {
@@ -79,7 +81,7 @@ export interface TokenVerificationResponse {
valid: boolean;
user_id?: string;
email?: string;
role?: string;
role?: GlobalUserRole;
exp?: number;
message?: string;
}

View File

@@ -2,6 +2,8 @@
* Tenant API Types - Mirror backend schemas
*/
import type { TenantRole } from '../../types/roles';
export interface BakeryRegistration {
name: string;
address: string;
@@ -38,8 +40,10 @@ export interface TenantResponse {
export interface TenantAccessResponse {
has_access: boolean;
role?: string;
role?: TenantRole;
permissions?: string[];
membership_id?: string;
joined_at?: string;
}
export interface TenantUpdate {
@@ -62,7 +66,7 @@ export interface TenantMemberResponse {
id: string;
tenant_id: string;
user_id: string;
role: string;
role: TenantRole;
is_active: boolean;
joined_at: string;
user_email?: string;