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

type UrlData = {
    id: string;
};

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

    const handleAdd = () => {
        eventHandler.setEventType(EVENT_TYPES.SLEEP);
        router.push("/admin/org/profile/" + id + "/services/new");
    };

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