|
1
|
import { Switch, Route } from "wouter"; |
|
2
|
import { queryClient } from "./lib/queryClient"; |
|
3
|
import { QueryClientProvider } from "@tanstack/react-query"; |
|
4
|
import { Toaster } from "@/components/ui/toaster"; |
|
5
|
import { TooltipProvider } from "@/components/ui/tooltip"; |
|
6
|
import { ThemeProvider } from "@/contexts/theme-context"; |
|
7
|
import { useAuth } from "@/hooks/useAuth"; |
|
8
|
import { lazy, Suspense } from "react"; |
|
9
|
import MainLayout from "@/components/layout/main-layout"; |
|
10
|
|
|
11
|
// Core pages loaded immediately |
|
12
|
import Home from "@/pages/home"; |
|
13
|
import Landing from "@/pages/landing"; |
|
14
|
import AuthPage from "@/pages/auth"; |
|
15
|
|
|
16
|
// Lazy load secondary pages |
|
17
|
const Favorites = lazy(() => import("@/pages/favorites")); |
|
18
|
const RepairGuide = lazy(() => import("@/pages/repair-guide")); |
|
19
|
const Troubleshooting = lazy(() => import("@/pages/troubleshooting")); |
|
20
|
const SoftwareTools = lazy(() => import("@/pages/software-tools")); |
|
21
|
const DeviceFinder = lazy(() => import("@/pages/device-finder")); |
|
22
|
const CreateGuide = lazy(() => import("@/pages/create-guide")); |
|
23
|
const OfflineSettings = lazy(() => import("@/pages/offline-settings")); |
|
24
|
const Downloads = lazy(() => import("@/pages/downloads")); |
|
25
|
const AdminDashboard = lazy(() => import("@/pages/admin-dashboard")); |
|
26
|
const NotFound = lazy(() => import("@/pages/not-found")); |
|
27
|
|
|
28
|
import { PageLoadingSpinner } from "@/components/ui/loading-spinner"; |
|
29
|
|
|
30
|
function Router() { |
|
31
|
const { isLoading } = useAuth(); |
|
32
|
|
|
33
|
if (isLoading) { |
|
34
|
return <PageLoadingSpinner />; |
|
35
|
} |
|
36
|
|
|
37
|
return ( |
|
38
|
<Suspense fallback={<PageLoadingSpinner />}> |
|
39
|
<Switch> |
|
40
|
{/* Standalone Landing and Auth pages */} |
|
41
|
<Route path="/landing" component={Landing} /> |
|
42
|
<Route path="/auth" component={AuthPage} /> |
|
43
|
|
|
44
|
{/* Core application routes rendered inside MainLayout */} |
|
45
|
<Route path="/"> |
|
46
|
{() => ( |
|
47
|
<MainLayout> |
|
48
|
<Home /> |
|
49
|
</MainLayout> |
|
50
|
)} |
|
51
|
</Route> |
|
52
|
<Route path="/favorites"> |
|
53
|
{() => ( |
|
54
|
<MainLayout> |
|
55
|
<Favorites /> |
|
56
|
</MainLayout> |
|
57
|
)} |
|
58
|
</Route> |
|
59
|
<Route path="/guide/:id"> |
|
60
|
{() => ( |
|
61
|
<MainLayout> |
|
62
|
<RepairGuide /> |
|
63
|
</MainLayout> |
|
64
|
)} |
|
65
|
</Route> |
|
66
|
<Route path="/troubleshooting"> |
|
67
|
{() => ( |
|
68
|
<MainLayout> |
|
69
|
<Troubleshooting /> |
|
70
|
</MainLayout> |
|
71
|
)} |
|
72
|
</Route> |
|
73
|
<Route path="/troubleshooting/:type"> |
|
74
|
{() => ( |
|
75
|
<MainLayout> |
|
76
|
<Troubleshooting /> |
|
77
|
</MainLayout> |
|
78
|
)} |
|
79
|
</Route> |
|
80
|
<Route path="/software-tools"> |
|
81
|
{() => ( |
|
82
|
<MainLayout> |
|
83
|
<SoftwareTools /> |
|
84
|
</MainLayout> |
|
85
|
)} |
|
86
|
</Route> |
|
87
|
<Route path="/device-finder"> |
|
88
|
{() => ( |
|
89
|
<MainLayout> |
|
90
|
<DeviceFinder /> |
|
91
|
</MainLayout> |
|
92
|
)} |
|
93
|
</Route> |
|
94
|
<Route path="/create-guide"> |
|
95
|
{() => ( |
|
96
|
<MainLayout> |
|
97
|
<CreateGuide /> |
|
98
|
</MainLayout> |
|
99
|
)} |
|
100
|
</Route> |
|
101
|
<Route path="/offline-settings"> |
|
102
|
{() => ( |
|
103
|
<MainLayout> |
|
104
|
<OfflineSettings /> |
|
105
|
</MainLayout> |
|
106
|
)} |
|
107
|
</Route> |
|
108
|
<Route path="/downloads"> |
|
109
|
{() => ( |
|
110
|
<MainLayout> |
|
111
|
<Downloads /> |
|
112
|
</MainLayout> |
|
113
|
)} |
|
114
|
</Route> |
|
115
|
<Route path="/admin"> |
|
116
|
{() => ( |
|
117
|
<MainLayout> |
|
118
|
<AdminDashboard /> |
|
119
|
</MainLayout> |
|
120
|
)} |
|
121
|
</Route> |
|
122
|
<Route component={NotFound} /> |
|
123
|
</Switch> |
|
124
|
</Suspense> |
|
125
|
); |
|
126
|
} |
|
127
|
|
|
128
|
function App() { |
|
129
|
return ( |
|
130
|
<ThemeProvider defaultTheme="dark" storageKey="jcr-guide-theme"> |
|
131
|
<QueryClientProvider client={queryClient}> |
|
132
|
<TooltipProvider> |
|
133
|
<Toaster /> |
|
134
|
<Router /> |
|
135
|
</TooltipProvider> |
|
136
|
</QueryClientProvider> |
|
137
|
</ThemeProvider> |
|
138
|
); |
|
139
|
} |
|
140
|
|
|
141
|
export default App; |