import { useEffect } from 'react';
import { useProductStore } from '../../../store/simulation/useProductStore';
import { useActionHandler } from '../actions/useActionHandler';
import { usePlayButtonStore, useResetButtonStore } from '../../../store/usePlayButtonStore';
import { determineExecutionOrder } from './functions/determineExecutionOrder';

function Simulator() {
    const { products } = useProductStore();
    const { handleAction } = useActionHandler();
    const { isPlaying } = usePlayButtonStore();
    const { isReset } = useResetButtonStore();

    useEffect(() => {
        if (!isPlaying || isReset) return;

        const executionOrder = determineExecutionOrder(products);
        executionOrder.map(point => {
            const action = 'actions' in point ? point.actions[0] : point.action;
            handleAction(action);
        });
    }, [products, isPlaying, isReset]);

    return (

        <>

        </>

    );
}

export default Simulator;