"use client";
import { useParams } from "next/navigation";
import { EVENT_TYPES, useEventHandlerStore } from "@store/EventHandler.Store";
import Addable from "@components/Addable/Addable";
import { useNavigation } from "@hooks/goto";

type UrlData = {
    id: string;
};

export default function OrgLayout({ children }: { children: React.ReactNode }) {
    const urlData = useParams<UrlData>();
    const id = urlData.id;
    const eventHandler = useEventHandlerStore();
    const { goTo } = useNavigation();

    const handleAdd = () => {
        eventHandler.setEventType(EVENT_TYPES.SLEEP);
        goTo("/admin/org/profile/" + id + "/collaborators/add");
    };

    return (
        <>
            <Addable onClick={handleAdd}>{children}</Addable>
        </>
    );
}
