import React, { useEffect } from 'react'
import MachineInstances from './instances/machineInstances'
import { useMachineStore } from '../../../store/simulation/useMachineStore'
import { useSelectedProduct } from '../../../store/simulation/useSimulationStore';

function Machine() {
    const { addMachine, addCurrentAction, removeMachine, machines } = useMachineStore();
    const { selectedProduct } = useSelectedProduct();

    const machineSample: MachineEventSchema[] = [
        {
            modelUuid: "machine-1234-5678-9012",
            modelName: "CNC Milling Machine",
            position: [10, 0, 5],
            rotation: [0, 0, 0],
            state: "idle",
            type: "machine",
            point: {
                uuid: "machine-point-9876-5432-1098",
                position: [10, 0.5, 5.2],
                rotation: [0, 0, 0],
                action: {
                    actionUuid: "machine-action-2468-1357-8024",
                    actionName: "Metal Processing",
                    actionType: "process",
                    processTime: 10,
                    swapMaterial: "steel",
                    triggers: []
                }
            }
        }
    ];

    useEffect(() => {
        removeMachine(machineSample[0].modelUuid);
        addMachine(selectedProduct.productId, machineSample[0]);

        // addCurrentAction(machineSample[0].modelUuid, machineSample[0].point.action.actionUuid);
    }, [])


    useEffect(() => {

        // console.log('machines: ', machines);
    }, [machines])

    return (
        <>

            <MachineInstances />

        </>
    )
}

export default Machine