From 7741dd806724ab17a400034b571b877e2f6f2eb9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 18:39:20 +0000 Subject: [PATCH] Fix frontend build TypeScript errors Fixed multiple TypeScript type errors that were preventing the build from working properly: 1. Fixed infinite query type issue in forecasting.ts by excluding 'select' from options 2. Fixed Card variant type errors by changing contentPadding="default" to contentPadding="md" 3. Fixed router export issues by removing non-existent exports (ROUTE_CONFIGS, getRoutesForRole, etc.) 4. Fixed router readonly array type issues by updating RouteConfig interface 5. Fixed ProtectedRoute requiredRoles prop issue by removing invalid prop usage 6. Fixed auth store User type compatibility by allowing null for tenant_id 7. Fixed missing useToasts export from ui.store by removing from exports 8. Fixed permissions utility boolean type issues by wrapping expressions in Boolean() The frontend build now completes successfully. --- frontend/src/api/hooks/forecasting.ts | 2 +- frontend/src/pages/public/AboutPage.tsx | 2 +- frontend/src/pages/public/BlogPage.tsx | 2 +- frontend/src/pages/public/CareersPage.tsx | 2 +- frontend/src/pages/public/ContactPage.tsx | 2 +- frontend/src/pages/public/DocumentationPage.tsx | 2 +- frontend/src/pages/public/FeedbackPage.tsx | 2 +- frontend/src/pages/public/HelpCenterPage.tsx | 2 +- frontend/src/router/AppRouter.tsx | 2 +- frontend/src/router/index.ts | 16 ++++++---------- frontend/src/router/routes.config.ts | 4 ++-- frontend/src/stores/auth.store.ts | 2 +- frontend/src/stores/index.ts | 2 +- frontend/src/utils/permissions.ts | 6 +++--- 14 files changed, 22 insertions(+), 26 deletions(-) diff --git a/frontend/src/api/hooks/forecasting.ts b/frontend/src/api/hooks/forecasting.ts index 026fc6e2..a7b79e29 100644 --- a/frontend/src/api/hooks/forecasting.ts +++ b/frontend/src/api/hooks/forecasting.ts @@ -116,7 +116,7 @@ export const useForecastingHealth = ( export const useInfiniteTenantForecasts = ( tenantId: string, baseParams?: Omit, - options?: Omit, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> + options?: Omit, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam' | 'select'> ) => { const limit = 20; diff --git a/frontend/src/pages/public/AboutPage.tsx b/frontend/src/pages/public/AboutPage.tsx index 9fdfdceb..67b8688a 100644 --- a/frontend/src/pages/public/AboutPage.tsx +++ b/frontend/src/pages/public/AboutPage.tsx @@ -91,7 +91,7 @@ const AboutPage: React.FC = () => { return ( { return ( { return ( { return ( { return ( { return ( { + diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index e6013cd2..7ff50e2d 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -1,15 +1,11 @@ export { AppRouter, default as Router } from './AppRouter'; export { ProtectedRoute } from './ProtectedRoute'; -export { - ROUTES, - ROUTE_CONFIGS, - canAccessRoute, - getRouteByPath, - getRoutesForRole, - getRoutesWithPermission, - isPublicRoute, - isProtectedRoute, - type RouteConfig +export { + ROUTES, + routesConfig, + canAccessRoute, + getRouteByPath, + type RouteConfig } from './routes.config'; // Additional utility exports for route components diff --git a/frontend/src/router/routes.config.ts b/frontend/src/router/routes.config.ts index f85b2089..4b723d41 100644 --- a/frontend/src/router/routes.config.ts +++ b/frontend/src/router/routes.config.ts @@ -12,8 +12,8 @@ export interface RouteConfig { description?: string; icon?: string; requiresAuth: boolean; - requiredRoles?: string[]; - requiredPermissions?: string[]; + requiredRoles?: readonly string[]; + requiredPermissions?: readonly string[]; requiredSubscriptionFeature?: string; requiredAnalyticsLevel?: 'basic' | 'advanced' | 'predictive'; showInNavigation?: boolean; diff --git a/frontend/src/stores/auth.store.ts b/frontend/src/stores/auth.store.ts index 139fb8b1..532ff260 100644 --- a/frontend/src/stores/auth.store.ts +++ b/frontend/src/stores/auth.store.ts @@ -14,7 +14,7 @@ export interface User { language?: string; timezone?: string; avatar?: string; // User avatar image URL - tenant_id?: string; + tenant_id?: string | null; role?: GlobalUserRole; } diff --git a/frontend/src/stores/index.ts b/frontend/src/stores/index.ts index 744993ef..a6e4c7b2 100644 --- a/frontend/src/stores/index.ts +++ b/frontend/src/stores/index.ts @@ -2,7 +2,7 @@ export { useAuthStore, useAuthUser, useIsAuthenticated, useAuthLoading, useAuthError, usePermissions, useAuthActions } from './auth.store'; export type { User, AuthState } from './auth.store'; -export { useUIStore, useLanguage, useSidebar, useCompactMode, useViewMode, useLoading, useToasts, useModals, useBreadcrumbs, usePreferences, useUIActions } from './ui.store'; +export { useUIStore, useLanguage, useSidebar, useCompactMode, useViewMode, useLoading, useModals, useBreadcrumbs, usePreferences, useUIActions } from './ui.store'; export type { Theme, Language, ViewMode, SidebarState, Toast, Modal, UIState } from './ui.store'; diff --git a/frontend/src/utils/permissions.ts b/frontend/src/utils/permissions.ts index 400cb0ff..c5397c4f 100644 --- a/frontend/src/utils/permissions.ts +++ b/frontend/src/utils/permissions.ts @@ -210,19 +210,19 @@ export function checkCombinedPermission( } = options; // Check global roles - const hasGlobalAccess = globalRoles.length === 0 || ( + const hasGlobalAccess = globalRoles.length === 0 || Boolean( user?.is_active && globalRoles.some(role => hasGlobalRole(user.role, role)) ); // Check tenant roles - const hasTenantRoleAccess = tenantRoles.length === 0 || ( + const hasTenantRoleAccess = tenantRoles.length === 0 || Boolean( tenantAccess?.has_access && tenantRoles.some(role => hasTenantRole(tenantAccess.role, role)) ); // Check tenant permissions - const hasTenantPermissionAccess = tenantPermissions.length === 0 || ( + const hasTenantPermissionAccess = tenantPermissions.length === 0 || Boolean( tenantAccess?.has_access && tenantPermissions.some(perm => tenantAccess.permissions?.includes(perm)) );