import PageContent from "./PageContent";
import LeftSidebar from "./LeftSidebar";
import { useSelector, useDispatch } from "react-redux";
import { useEffect, useState } from "react";
import { removeNotificationMessage } from "@/Components/features/common/headerSlice";
import { themeChange } from "theme-change";
import { usePage } from "@inertiajs/react";

function Layout({ children }) {
  const dispatch = useDispatch();
  const { url } = usePage(); // Gunakan usePage() dari Inertia
  const [showSidebar, setShowSidebar] = useState(true);

  useEffect(() => {
    console.log("Route berubah (Inertia):", url);
    setShowSidebar(!url.startsWith("/login")); // Sidebar disembunyikan di halaman login
  }, [url]);

  useEffect(() => {
    themeChange(false);
  }, []);

  return (
    <div className="drawer lg:drawer-open">
      <input id="left-sidebar-drawer" type="checkbox" className="drawer-toggle" />
      {showSidebar && <LeftSidebar />}
      <PageContent>{children}</PageContent>
    </div>
  );
}

export default Layout;

