"use client";

import type React from "react";
import { usePathname } from "next/navigation";
import Navbar from "@/components/navbar";

const NO_NAVBAR_PATHS = new Set(["/login", "/register"]);
const NO_NAVBAR_PREFIXES = ["/invite"];

type AppFrameProps = {
    children: React.ReactNode;
};

export default function AppFrame({ children }: AppFrameProps) {
    const pathname = usePathname();
    const hideNavbar = pathname
        ? NO_NAVBAR_PATHS.has(pathname) || NO_NAVBAR_PREFIXES.some(prefix => pathname.startsWith(prefix))
        : false;

    return (
        <>
            {hideNavbar ? null : <Navbar />}
            <main className="mx-auto max-w-5xl px-4 py-6">{children}</main>
        </>
    );
}
