@@ -2,7 +2,7 @@ import { Toaster } from "@/components/ui/toaster";
22import { Toaster as Sonner } from "@/components/ui/sonner" ;
33import { TooltipProvider } from "@/components/ui/tooltip" ;
44import { QueryClient , QueryClientProvider } from "@tanstack/react-query" ;
5- import { BrowserRouter , Routes , Route , Navigate } from "react-router-dom" ;
5+ import { BrowserRouter , HashRouter , Routes , Route , Navigate } from "react-router-dom" ;
66import { AuthProvider , useAuth } from "@/contexts/AuthContext" ;
77import Index from "./pages/Index" ;
88import NotFound from "./pages/NotFound" ;
@@ -12,6 +12,7 @@ import Dashboard from "./pages/admin/Dashboard";
1212import Products from "./pages/admin/Products" ;
1313import ProductEditor from "./pages/admin/ProductEditor" ;
1414import Orders from "./pages/admin/Orders" ;
15+ import OrderStats from "./pages/admin/OrderStats" ;
1516import Customers from "./pages/admin/Customers" ;
1617import MediaPage from "./pages/admin/Media" ;
1718import Posts from "./pages/admin/Posts" ;
@@ -29,6 +30,7 @@ import Comments from "./pages/admin/Comments";
2930import Coupons from "./pages/admin/Coupons" ;
3031
3132const queryClient = new QueryClient ( ) ;
33+ const useHashRouter = import . meta. env . VITE_ROUTER_MODE === "hash" ;
3234
3335const ProtectedRoute = ( { children } : { children : React . ReactNode } ) => {
3436 const { admin, loading } = useAuth ( ) ;
@@ -55,45 +57,87 @@ const App = () => (
5557 < TooltipProvider >
5658 < Toaster />
5759 < Sonner />
58- < BrowserRouter
59- future = { { v7_startTransition : true , v7_relativeSplatPath : true } }
60- >
61- < Routes >
62- < Route path = "/" element = { < Index /> } />
63- < Route path = "/login" element = { < Login /> } />
64- < Route
65- path = "/admin"
66- element = {
67- < ProtectedRoute >
68- < AdminLayout />
69- </ ProtectedRoute >
70- }
60+ { useHashRouter ? (
61+ < HashRouter >
62+ < Routes >
63+ < Route path = "/" element = { < Index /> } />
64+ < Route path = "/login" element = { < Login /> } />
65+ < Route
66+ path = "/admin"
67+ element = {
68+ < ProtectedRoute >
69+ < AdminLayout />
70+ </ ProtectedRoute >
71+ }
72+ >
73+ < Route index element = { < Dashboard /> } />
74+ < Route path = "products" element = { < Products /> } />
75+ < Route path = "products/new" element = { < ProductEditor /> } />
76+ < Route path = "products/:id/edit" element = { < ProductEditor /> } />
77+ < Route path = "categories" element = { < Categories /> } />
78+ < Route path = "tags" element = { < Tags /> } />
79+ < Route path = "orders" element = { < Orders /> } />
80+ < Route path = "orders/stats" element = { < OrderStats /> } />
81+ < Route path = "shipments" element = { < Shipments /> } />
82+ < Route path = "customers" element = { < Customers /> } />
83+ < Route path = "media" element = { < MediaPage /> } />
84+ < Route path = "posts" element = { < Posts /> } />
85+ < Route path = "pages" element = { < Pages /> } />
86+ < Route path = "roles" element = { < Roles /> } />
87+ < Route path = "permissions" element = { < Permissions /> } />
88+ < Route path = "attributes" element = { < Attributes /> } />
89+ < Route path = "payment-gateways" element = { < PaymentGateways /> } />
90+ < Route path = "shipping-methods" element = { < ShippingMethods /> } />
91+ < Route path = "comments" element = { < Comments /> } />
92+ < Route path = "coupons" element = { < Coupons /> } />
93+ < Route path = "settings" element = { < Settings /> } />
94+ </ Route >
95+ { /* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */ }
96+ < Route path = "*" element = { < NotFound /> } />
97+ </ Routes >
98+ </ HashRouter >
99+ ) : (
100+ < BrowserRouter
101+ future = { { v7_startTransition : true , v7_relativeSplatPath : true } }
71102 >
72- < Route index element = { < Dashboard /> } />
73- < Route path = "products" element = { < Products /> } />
74- < Route path = "products/new" element = { < ProductEditor /> } />
75- < Route path = "products/:id/edit" element = { < ProductEditor /> } />
76- < Route path = "categories" element = { < Categories /> } />
77- < Route path = "tags" element = { < Tags /> } />
78- < Route path = "orders" element = { < Orders /> } />
79- < Route path = "shipments" element = { < Shipments /> } />
80- < Route path = "customers" element = { < Customers /> } />
81- < Route path = "media" element = { < MediaPage /> } />
82- < Route path = "posts" element = { < Posts /> } />
83- < Route path = "pages" element = { < Pages /> } />
84- < Route path = "roles" element = { < Roles /> } />
85- < Route path = "permissions" element = { < Permissions /> } />
86- < Route path = "attributes" element = { < Attributes /> } />
87- < Route path = "payment-gateways" element = { < PaymentGateways /> } />
88- < Route path = "shipping-methods" element = { < ShippingMethods /> } />
89- < Route path = "comments" element = { < Comments /> } />
90- < Route path = "coupons" element = { < Coupons /> } />
91- < Route path = "settings" element = { < Settings /> } />
92- </ Route >
93- { /* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */ }
94- < Route path = "*" element = { < NotFound /> } />
95- </ Routes >
96- </ BrowserRouter >
103+ < Routes >
104+ < Route path = "/" element = { < Index /> } />
105+ < Route path = "/login" element = { < Login /> } />
106+ < Route
107+ path = "/admin"
108+ element = {
109+ < ProtectedRoute >
110+ < AdminLayout />
111+ </ ProtectedRoute >
112+ }
113+ >
114+ < Route index element = { < Dashboard /> } />
115+ < Route path = "products" element = { < Products /> } />
116+ < Route path = "products/new" element = { < ProductEditor /> } />
117+ < Route path = "products/:id/edit" element = { < ProductEditor /> } />
118+ < Route path = "categories" element = { < Categories /> } />
119+ < Route path = "tags" element = { < Tags /> } />
120+ < Route path = "orders" element = { < Orders /> } />
121+ < Route path = "orders/stats" element = { < OrderStats /> } />
122+ < Route path = "shipments" element = { < Shipments /> } />
123+ < Route path = "customers" element = { < Customers /> } />
124+ < Route path = "media" element = { < MediaPage /> } />
125+ < Route path = "posts" element = { < Posts /> } />
126+ < Route path = "pages" element = { < Pages /> } />
127+ < Route path = "roles" element = { < Roles /> } />
128+ < Route path = "permissions" element = { < Permissions /> } />
129+ < Route path = "attributes" element = { < Attributes /> } />
130+ < Route path = "payment-gateways" element = { < PaymentGateways /> } />
131+ < Route path = "shipping-methods" element = { < ShippingMethods /> } />
132+ < Route path = "comments" element = { < Comments /> } />
133+ < Route path = "coupons" element = { < Coupons /> } />
134+ < Route path = "settings" element = { < Settings /> } />
135+ </ Route >
136+ { /* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */ }
137+ < Route path = "*" element = { < NotFound /> } />
138+ </ Routes >
139+ </ BrowserRouter >
140+ ) }
97141 </ TooltipProvider >
98142 </ AuthProvider >
99143 </ QueryClientProvider >
0 commit comments