"use client";

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

type UrlData = {
    oid: string;
    clientId: string;
};

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

    const handleAdd = () => {
        eventHandler.setEventType(EVENT_TYPES.SLEEP);
        goTo("/admin/org/" + urlData.oid + "/client/" + clientId + "/repeats/create");
    };

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