-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
88 lines (83 loc) · 2.98 KB
/
App.tsx
File metadata and controls
88 lines (83 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { Toaster } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import NotFound from "@/pages/NotFound";
import { Route, Switch } from "wouter";
import ErrorBoundary from "./components/ErrorBoundary";
import { ThemeProvider } from "./contexts/ThemeContext";
import Home from "./pages/ComponentShowcase";
import NailSimulator from "./pages/NailSimulator";
import TechBooking from "./pages/TechBooking";
import BookAppointment from "./pages/BookAppointment";
import Calendar from "./pages/Calendar";
import About from "./pages/About";
import Contact from "./pages/Contact";
import Admin from "./pages/Admin";
import Profile from "./pages/Profile";
import { AdPopup } from "./components/AdComponents";
import { AIChatPanel } from "./components/AIChatPanel";
import { usePWAInstall } from "./hooks/usePWAInstall";
import { Button } from "./components/ui/button";
import { Download } from "lucide-react";
import { toast } from "sonner";
function Router() {
const { deferredPrompt, isAppInstalled, promptInstall } = usePWAInstall();
useEffect(() => {
if (deferredPrompt && !isAppInstalled) {
toast.info(
<div className="flex items-center justify-between w-full">
<span>Install NaildBySteph as an app!</span>
<Button
onClick={promptInstall}
size="sm"
className="ml-4 bg-pink-600 hover:bg-pink-700"
>
<Download className="w-4 h-4 mr-2" /> Install
</Button>
</div>,
{
duration: 10000,
id: 'pwa-install-prompt',
}
);
}
}, [deferredPrompt, isAppInstalled, promptInstall]);
// make sure to consider if you need authentication for certain routes
return (
<Switch>
<Route path="/" component={Home} />
<Route path="/book" component={BookAppointment} />
<Route path="/calendar" component={Calendar} />
<Route path="/about" component={About} />
<Route path="/contact" component={Contact} />
<Route path="/admin" component={Admin} />
<Route path="/profile" component={Profile} />
<Route path="/simulator" component={NailSimulator} />
<Route path="/tech-booking" component={TechBooking} />
<Route path="/404" component={NotFound} />
{/* Final fallback route */}
<Route component={NotFound} />
</Switch>
);
}
// NOTE: About Theme
// - First choose a default theme according to your design style (dark or light bg), than change color palette in index.css
// to keep consistent foreground/background color across components
// - If you want to make theme switchable, pass `switchable` ThemeProvider and use `useTheme` hook
function App() {
return (
<ErrorBoundary>
<ThemeProvider
defaultTheme="light"
// switchable
>
<TooltipProvider>
<Toaster />
<Router />
<AdPopup />
<AIChatPanel />
</TooltipProvider>
</ThemeProvider>
</ErrorBoundary>
);
}
export default App;