- useMediaQuery hook extracted from CalendarPage inline pattern - h-screen → h-dvh for mobile address bar viewport fix - px-6 → px-4 md:px-6 on all page containers/toolbars (14 files) - Input/Select text-base on mobile to prevent iOS auto-zoom - Sheet full-width on mobile, max-w-[540px] on sm+ - Button icon size touch-friendly (44px mobile, 40px desktop) - Tailwind hoverOnlyWhenSupported: true (fixes 157 hover interactions) - PWA meta tags (apple-mobile-web-app-capable, theme-color) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
94 lines
3.1 KiB
TypeScript
94 lines
3.1 KiB
TypeScript
import { lazy, Suspense } from 'react';
|
|
import { Routes, Route, Navigate } from 'react-router-dom';
|
|
import { useAuth } from '@/hooks/useAuth';
|
|
import LockScreen from '@/components/auth/LockScreen';
|
|
import AppLayout from '@/components/layout/AppLayout';
|
|
import DashboardPage from '@/components/dashboard/DashboardPage';
|
|
import TodosPage from '@/components/todos/TodosPage';
|
|
import CalendarPage from '@/components/calendar/CalendarPage';
|
|
import RemindersPage from '@/components/reminders/RemindersPage';
|
|
import ProjectsPage from '@/components/projects/ProjectsPage';
|
|
import ProjectDetail from '@/components/projects/ProjectDetail';
|
|
import PeoplePage from '@/components/people/PeoplePage';
|
|
import LocationsPage from '@/components/locations/LocationsPage';
|
|
import SettingsPage from '@/components/settings/SettingsPage';
|
|
import NotificationsPage from '@/components/notifications/NotificationsPage';
|
|
|
|
const AdminPortal = lazy(() => import('@/components/admin/AdminPortal'));
|
|
|
|
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
const { authStatus, isLoading } = useAuth();
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="flex h-dvh items-center justify-center">
|
|
<div className="text-muted-foreground">Loading...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!authStatus?.authenticated) {
|
|
return <Navigate to="/login" replace />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}
|
|
|
|
function AdminRoute({ children }: { children: React.ReactNode }) {
|
|
const { authStatus, isLoading } = useAuth();
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="flex h-dvh items-center justify-center">
|
|
<div className="text-muted-foreground">Loading...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!authStatus?.authenticated || authStatus?.role !== 'admin') {
|
|
return <Navigate to="/dashboard" replace />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}
|
|
|
|
function App() {
|
|
return (
|
|
<Routes>
|
|
<Route path="/login" element={<LockScreen />} />
|
|
<Route
|
|
path="/"
|
|
element={
|
|
<ProtectedRoute>
|
|
<AppLayout />
|
|
</ProtectedRoute>
|
|
}
|
|
>
|
|
<Route index element={<Navigate to="/dashboard" replace />} />
|
|
<Route path="dashboard" element={<DashboardPage />} />
|
|
<Route path="todos" element={<TodosPage />} />
|
|
<Route path="calendar" element={<CalendarPage />} />
|
|
<Route path="reminders" element={<RemindersPage />} />
|
|
<Route path="projects" element={<ProjectsPage />} />
|
|
<Route path="projects/:id" element={<ProjectDetail />} />
|
|
<Route path="people" element={<PeoplePage />} />
|
|
<Route path="locations" element={<LocationsPage />} />
|
|
<Route path="notifications" element={<NotificationsPage />} />
|
|
<Route path="settings" element={<SettingsPage />} />
|
|
<Route
|
|
path="admin/*"
|
|
element={
|
|
<AdminRoute>
|
|
<Suspense fallback={<div className="flex h-full items-center justify-center text-muted-foreground">Loading...</div>}>
|
|
<AdminPortal />
|
|
</Suspense>
|
|
</AdminRoute>
|
|
}
|
|
/>
|
|
</Route>
|
|
</Routes>
|
|
);
|
|
}
|
|
|
|
export default App;
|