import { useCallback, useEffect, useRef } from 'react';
import { useActionHandler } from '../../actions/useActionHandler';
import { useProductStore } from '../../../../store/simulation/useProductStore';

export function useTriggerHandler() {
    const { getActionByUuid } = useProductStore();
    const { handleAction } = useActionHandler();

    const handleTrigger = (trigger: TriggerSchema) => {

    }

    const triggerPointActions = useCallback((action: Action) => {
        if (!action) return;

        action.triggers.forEach(trigger => {
            switch (trigger.triggerType) {
                case 'onStart':
                    break;
                case 'onComplete':
                    handleTrigger(trigger);
                    break;
                case 'onStop':
                    break;
                case 'onError':
                    break;
                case 'delay':
                    break;
                default:
                    console.warn(`Unknown trigger type: ${trigger.triggerType}`);
            }
        });
    }, []);

    return {
        triggerPointActions
    };
}