import { useCallback } from "react";
import { useSceneContext } from "../../../../scene/sceneContext";

export function useDefaultHandler() {
    const { materialStore } = useSceneContext();
    const { getMaterialById } = materialStore();

    const defaultLogStatus = (materialUuid: string, status: string) => {
        echo.info(`${materialUuid}, ${status}`);
    }

    const handleDefault = useCallback((action: ConveyorAction, materialId?: string) => {
        if (!action || action.actionType !== 'default' || !materialId) return;

        const material = getMaterialById(materialId);
        if (!material) return;

        defaultLogStatus(material.materialName, `performed Default action`);

    }, [getMaterialById]);

    return {
        handleDefault,
    };
}