File size: 1,179 Bytes
65d68f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"use client";

import { useTheme } from "next-themes";
import { usePathname } from "next/navigation";
import { useHydrated } from "@/hooks/useHydrated";
import { AppShellDark } from "@/components/dark/layout/AppShellDark";
import { CleanAppLayout } from "@/components/clean/layout/CleanAppLayout";

export function ThemeLayoutWrapper({ children }: { children: React.ReactNode }) {
  const { resolvedTheme } = useTheme();
  const mounted = useHydrated();
  const pathname = usePathname();
  const isTuitionWorkspace = pathname === "/tuition" || pathname?.startsWith("/tuition/");

  // Tuition is intentionally light-only so the class never changes visual
  // systems when the student's device theme changes.
  if (isTuitionWorkspace) {
    return <CleanAppLayout>{children}</CleanAppLayout>;
  }

  // During SSR and initial hydration, default to AppShellDark to prevent flash if dark was default,
  // or return a simpler loading skeleton if you prefer.
  if (!mounted) {
    return <AppShellDark>{children}</AppShellDark>;
  }

  if (resolvedTheme === "light") {
    return <CleanAppLayout>{children}</CleanAppLayout>;
  }

  return <AppShellDark>{children}</AppShellDark>;
}