'use client';

import { usePathname } from 'next/navigation';
import { DataNav } from '@/components/admin/data-nav';

type SalesLayoutShellProps = {
  children: React.ReactNode;
  title: string;
  links: { title: string; href: string; subLinks?: { title: string; href: string }[] }[];
  hideChrome?: boolean;
};

export default function SalesLayoutShell({ children, title, links, hideChrome = false }: SalesLayoutShellProps) {
  const pathname = usePathname();
  const isPosPage = pathname?.startsWith('/admin/sales/pos');

  if (hideChrome || isPosPage) {
    return (
      <div className="min-h-[calc(100vh-4rem)] w-[calc(100%+2rem)] -mx-4 overflow-hidden bg-background sm:w-[calc(100%+3rem)] sm:-mx-6">
        {children}
      </div>
    );
  }

  return (
    <div className="me-auto ms-0 grid w-full max-w-[1700px] gap-2 px-2 xl:px-4">
      <h1 className="text-3xl font-semibold">{title}</h1>
      <div className="mt-4 w-full border-b">
        <DataNav links={links} />
      </div>
      <div className="mt-6">
        {children}
      </div>
    </div>
  );
}
