import React from "react";
import { AppSidebar } from "./AppSidebar";
import { MobileNav } from "./MobileNav";
import { Outlet, useLocation } from "react-router-dom";
import { GlobalFunctions } from "@/GlobalFunctions";

export function AppLayout() {
  
  const { pathname } = useLocation();

  // ignora layout se for redirecionamento
  if (pathname.startsWith("/redir")) {
    return <></>;
  } 

  React.useEffect(() => {
    console.log('Aqui');
    if(!GlobalFunctions.isUsuarioLogado())window.location.replace(import.meta.env.VITE_BASE_URL_HGTX_CORE);
  },[]);

  return (
    <div className="flex h-screen w-full bg-background overflow-hidden">
      <MobileNav />
      <AppSidebar />
      <main className="flex-1 p-4 md:p-6 lg:p-8 overflow-y-auto pt-16 md:pt-6">
        <Outlet />
      </main>
    </div>
  );
}
