"use client";
import { useRouter } from "next/navigation";
import { EVENT_TYPES, useEventHandlerStore } from "@store/EventHandler.Store";
import Secure from "@components/Secure/Secure";
import SectionContainer from "@components/SectionContainer/SectionContainer";
import Addable from "@components/Addable/Addable";
import CenteredContent from "@components/CenteredContent/CenteredContent";
import Content from "@components/Content/Content";
import { Suspense } from "react";
import SuspenseLoading from "@core/app/components/SuspendeLoading/SuspenseLoading";

export default function OrgLayout({ children }: { children: React.ReactNode }) {
    const router = useRouter();
    //const SessionInfo = useSessionStore();
    //const alert = useAlert();
    const eventHandler = useEventHandlerStore();

    const handleAdd = () => {
        eventHandler.setEventType(EVENT_TYPES.SLEEP);
        router.push("/admin/org/create");
    };

    return (
        <>
            <Content>
                <Suspense fallback={<SuspenseLoading />}>
                    <Secure>
                        <SectionContainer borders="none" style={{ top: "0px" }}>
                            <CenteredContent>
                                <Addable onClick={handleAdd}>{children}</Addable>
                            </CenteredContent>
                        </SectionContainer>
                    </Secure>
                </Suspense>
            </Content>
        </>
    );
}
