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

type UrlData = {
    id: string;
};

export default function ClientLayout({ 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 + "/templates/new/new");
    };

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