EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
ClientLayout.tsx
Go to the documentation of this file.
1"use client";
2import { usePathname } from "next/navigation";
3import Navigation from "@/components/Navigation";
4import Breadcrumbs from "@/components/Breadcrumbs";
5import { StoreProvider } from "@/contexts/StoreContext";
6import { ThemeProvider } from "@/contexts/ThemeContext";
7import { IconProvider } from "@/contexts/IconContext";
8import ThemeIndicator from "@/components/ThemeIndicator";
9
10export default function ClientLayout({
11 children,
12}: {
13 children: React.ReactNode;
14}) {
15 const pathname = usePathname();
16
17 // Pages that should be full-screen without navigation
18 const fullScreenPages = ["/", "/login", "/pages/landing", "/pages/login", "/pages/sales/display"];
19 const isFullScreen = pathname ? (fullScreenPages.includes(pathname) || pathname.startsWith("/pages/login") || pathname.startsWith("/pages/landing") || pathname.startsWith("/pages/sales/display")) : false;
20
21 // Pages that don't need authentication/session (login pages)
22 const isLoginPage = pathname === "/login" || pathname === "/pages/login" || pathname?.startsWith("/pages/login");
23
24 if (isFullScreen) {
25 // Login pages don't need StoreProvider (no session required)
26 if (isLoginPage) {
27 return (
28 <ThemeProvider>
29 <IconProvider>
30 {children}
31 <ThemeIndicator />
32 </IconProvider>
33 </ThemeProvider>
34 );
35 }
36
37 // Other full-screen pages (like customer display) need StoreProvider
38 return (
39 <ThemeProvider>
40 <IconProvider>
41 <StoreProvider>
42 {children}
43 <ThemeIndicator />
44 </StoreProvider>
45 </IconProvider>
46 </ThemeProvider>
47 );
48 }
49
50 return (
51 <ThemeProvider>
52 <IconProvider>
53 <StoreProvider>
54 <div className="flex h-screen" style={{ background: 'var(--bg)' }}>
55 <Navigation />
56 <div className="flex-1 overflow-y-auto flex flex-col">
57 <Breadcrumbs />
58 <div className="flex-1">
59 {children}
60 </div>
61 </div>
62 </div>
63 <ThemeIndicator />
64 </StoreProvider>
65 </IconProvider>
66 </ThemeProvider>
67 );
68}