import { useEffect, useCallback, useRef, useState } from 'react';

export function useMachineActions() {

    const handleProcessAction = useCallback((action: MachineAction) => {
        if (!action || action.actionType !== 'process') return;
        console.log(`Machine processing for ${action.processTime}ms`);
    }, []);

    const handleMachineAction = useCallback((action: MachineAction) => {
        if (!action) return;

        switch (action.actionType) {
            case 'process':
                handleProcessAction(action);
                break;
            default:
                console.warn(`Unknown machine action type: ${action.actionType}`);
        }
    }, [handleProcessAction]);

    const cleanup = useCallback(() => {
    }, []);

    useEffect(() => {
        return () => {
            cleanup();
        };
    }, [cleanup]);

    return {
        handleMachineAction,
        cleanup,
    };
}