import { useLocation, useNavigate } from "react-router-dom";
import { Footer } from "./Footer";
import { Navbar } from "./Navbar";
import ROUTE_CONSTANTS from "@/constants/route.constants";

export default function LandingLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const location = useLocation();
  const navigate = useNavigate();
  const isHome = location.pathname === ROUTE_CONSTANTS.Landing;

  return (
    <div>
      <Navbar
        currentView={isHome ? "HOME" : "OTHER"}
        onNavigate={(view) => {
          if (view === "HOME") {
            navigate(ROUTE_CONSTANTS.Landing);
          }
        }}
      />
      {children}
      <Footer />
    </div>
  );
}
