"use client";

import { usePathname } from "next/navigation";
import type { ReactNode } from "react";

import { DashboardShell, type DashboardUser } from "@/components/dashboard-shell";
import { ThemeHydrator } from "@/components/theme-toggle";

const publicPaths = new Set(["/", "/pricing", "/access", "/contact", "/signin"]);

export function AppShellRouter({
  children,
  signedIn,
  user,
}: {
  children: ReactNode;
  signedIn: boolean;
  user: DashboardUser;
}) {
  const pathname = usePathname();
  const showDashboardShell = signedIn && !publicPaths.has(pathname);

  return (
    <>
      <ThemeHydrator />
      {showDashboardShell ? (
        <DashboardShell user={user}>{children}</DashboardShell>
      ) : (
        children
      )}
    </>
  );
}
