diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index d32919b..f7914c0 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -4,7 +4,7 @@
import React, { useState, useEffect, useTransition, useCallback, lazy } from 'react';
import { useQueryClient } from '@tanstack/react-query';
-import { Routes, Route, Navigate } from 'react-router-dom';
+import { Routes, Route, Navigate, useLocation } from 'react-router-dom';
import { useAuth0 } from '@auth0/auth0-react';
import { useIsAuthInitialized } from './core/auth/auth-gate';
import { motion, AnimatePresence } from 'framer-motion';
@@ -238,6 +238,7 @@ const AddVehicleScreen: React.FC = ({ onBack, onAdded })
function App() {
const { isLoading, isAuthenticated, user } = useAuth0();
+ const location = useLocation();
const isAuthGateReady = useIsAuthInitialized();
const [_isPending, startTransition] = useTransition();
console.log('[DEBUG App] Render check - isLoading:', isLoading, 'isAuthenticated:', isAuthenticated, 'isAuthGateReady:', isAuthGateReady);
@@ -363,6 +364,10 @@ function App() {
console.log('MotoVaultPro status:', { isLoading, isAuthenticated, mobileMode, activeScreen, vehicleSubScreen, userAgent: navigator.userAgent });
+ const isGarageRoute = location.pathname === '/garage' || location.pathname.startsWith('/garage/');
+ const isCallbackRoute = location.pathname === '/callback';
+ const shouldShowHomePage = !isGarageRoute && !isCallbackRoute;
+
// Enhanced navigation handlers for mobile
const handleVehicleSelect = useCallback((vehicle: Vehicle) => {
setSelectedVehicle(vehicle);
@@ -416,7 +421,18 @@ function App() {
);
}
- if (!isAuthenticated) {
+ if (isCallbackRoute) {
+ return (
+
+
+
+
+ );
+ }
+
+ if (shouldShowHomePage) {
return (
@@ -426,6 +442,10 @@ function App() {
);
}
+ if (!isAuthenticated) {
+ return ;
+ }
+
// Wait for auth gate to be ready before rendering protected routes
// This prevents a race condition where the page renders before the auth token is ready
if (!isAuthGateReady) {
@@ -615,17 +635,16 @@ function App() {
- } />
- Processing login...} />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx
index b7bac6a..cba5356 100644
--- a/frontend/src/components/Layout.tsx
+++ b/frontend/src/components/Layout.tsx
@@ -37,12 +37,12 @@ export const Layout: React.FC = ({ children, mobileMode = false })
}, [mobileMode, setSidebarOpen]); // Removed sidebarOpen from dependencies
const navigation = [
- { name: 'Vehicles', href: '/vehicles', icon: },
- { name: 'Fuel Logs', href: '/fuel-logs', icon: },
- { name: 'Maintenance', href: '/maintenance', icon: },
- { name: 'Gas Stations', href: '/stations', icon: },
- { name: 'Documents', href: '/documents', icon: },
- { name: 'Settings', href: '/settings', icon: },
+ { name: 'Vehicles', href: '/garage/vehicles', icon: },
+ { name: 'Fuel Logs', href: '/garage/fuel-logs', icon: },
+ { name: 'Maintenance', href: '/garage/maintenance', icon: },
+ { name: 'Gas Stations', href: '/garage/stations', icon: },
+ { name: 'Documents', href: '/garage/documents', icon: },
+ { name: 'Settings', href: '/garage/settings', icon: },
];
// Mobile layout
diff --git a/frontend/src/core/auth/Auth0Provider.tsx b/frontend/src/core/auth/Auth0Provider.tsx
index 1dd427d..7657762 100644
--- a/frontend/src/core/auth/Auth0Provider.tsx
+++ b/frontend/src/core/auth/Auth0Provider.tsx
@@ -26,7 +26,8 @@ export const Auth0Provider: React.FC = ({ children }) => {
const onRedirectCallback = (appState?: { returnTo?: string }) => {
console.log('[Auth0Provider] Redirect callback triggered', { appState, returnTo: appState?.returnTo });
- navigate(appState?.returnTo || '/dashboard');
+ const target = appState?.returnTo || '/garage';
+ navigate(target, { replace: true });
};
return (
diff --git a/frontend/src/features/documents/mobile/DocumentsMobileScreen.test.tsx b/frontend/src/features/documents/mobile/DocumentsMobileScreen.test.tsx
index c35c693..a3f790d 100644
--- a/frontend/src/features/documents/mobile/DocumentsMobileScreen.test.tsx
+++ b/frontend/src/features/documents/mobile/DocumentsMobileScreen.test.tsx
@@ -187,7 +187,7 @@ describe('DocumentsMobileScreen', () => {
const openButtons = screen.getAllByText('Open');
await user.click(openButtons[0]);
- expect(mockNavigate).toHaveBeenCalledWith('/documents/doc-1');
+ expect(mockNavigate).toHaveBeenCalledWith('/garage/documents/doc-1');
});
it('should navigate to correct document for each Open button', async () => {
@@ -197,10 +197,10 @@ describe('DocumentsMobileScreen', () => {
const openButtons = screen.getAllByText('Open');
await user.click(openButtons[0]);
- expect(mockNavigate).toHaveBeenCalledWith('/documents/doc-1');
+ expect(mockNavigate).toHaveBeenCalledWith('/garage/documents/doc-1');
await user.click(openButtons[1]);
- expect(mockNavigate).toHaveBeenCalledWith('/documents/doc-2');
+ expect(mockNavigate).toHaveBeenCalledWith('/garage/documents/doc-2');
});
});
@@ -406,4 +406,4 @@ describe('DocumentsMobileScreen', () => {
expect(uploadButtons).toHaveLength(mockDocuments.length);
});
});
-});
\ No newline at end of file
+});
diff --git a/frontend/src/features/documents/mobile/DocumentsMobileScreen.tsx b/frontend/src/features/documents/mobile/DocumentsMobileScreen.tsx
index cd96e6d..c9208e1 100644
--- a/frontend/src/features/documents/mobile/DocumentsMobileScreen.tsx
+++ b/frontend/src/features/documents/mobile/DocumentsMobileScreen.tsx
@@ -185,7 +185,7 @@ export const DocumentsMobileScreen: React.FC = () => {
{doc.document_type} • {vehicleLabel}
-
+
{upload.isPending && currentId === doc.id && (
{upload.progress}%
diff --git a/frontend/src/features/documents/pages/DocumentDetailPage.tsx b/frontend/src/features/documents/pages/DocumentDetailPage.tsx
index e9fd364..593c1b0 100644
--- a/frontend/src/features/documents/pages/DocumentDetailPage.tsx
+++ b/frontend/src/features/documents/pages/DocumentDetailPage.tsx
@@ -64,7 +64,7 @@ export const DocumentDetailPage: React.FC = () => {
Please log in to view this document
-
+
@@ -88,7 +88,7 @@ export const DocumentDetailPage: React.FC = () => {
Your session has expired. Please log in again to continue.
-
+
@@ -112,7 +112,7 @@ export const DocumentDetailPage: React.FC = () => {
The document you're looking for could not be found.
-
+
@@ -127,7 +127,7 @@ export const DocumentDetailPage: React.FC = () => {
Document Not Found
The document you're looking for does not exist.
-
+
diff --git a/frontend/src/features/documents/pages/DocumentsPage.tsx b/frontend/src/features/documents/pages/DocumentsPage.tsx
index 4f957d4..54b0daa 100644
--- a/frontend/src/features/documents/pages/DocumentsPage.tsx
+++ b/frontend/src/features/documents/pages/DocumentsPage.tsx
@@ -115,7 +115,7 @@ export const DocumentsPage: React.FC = () => {
No Documents Yet
You haven't added any documents yet. Documents will appear here once you create them.
-
Get Started
@@ -200,7 +207,7 @@ export const HomePage = () => {
We are a cloud-based platform accessible anywhere, anytime.
Get Started