import React, { useEffect, useState } from "react";
import VehicleInstances from "./instances/vehicleInstances";
import { useVehicleStore } from "../../../store/simulation/useVehicleStore";
import { useFloorItems } from "../../../store/store";
import { useSelectedEventSphere } from "../../../store/simulation/useSimulationStore";
import VehicleUI from "../ui/vehicle/vehicleUI";
function Vehicles() {
  const { vehicles, addVehicle } = useVehicleStore();
  const { selectedEventSphere } = useSelectedEventSphere();

  const { floorItems } = useFloorItems();

  const [vehicleStatusSample, setVehicleStatusSample] = useState<
    VehicleEventSchema[]
  >([
    
    {
      modelUuid: "68f8dc55-7802-47fe-aa1c-eade54b4320a",
      modelName: "AGV",
      position: [89.61609306554463, 0, 33.634136622267356],
      rotation: [0, 0, 0],
      state: "idle",
      type: "vehicle",
      speed: 2.5,
      point: {
        uuid: "point-789",
        position: [0, 1, 0],
        rotation: [0, 0, 0],
        action: {
          actionUuid: "action-456",
          actionName: "Deliver to Zone A",
          actionType: "travel",
          unLoadDuration: 10,
          loadCapacity: 2,
          pickUpPoint: null,
          unLoadPoint: null,
          triggers: [
            {
              triggerUuid: "trig-001",
              triggerName: "Start Travel",
              triggerType: "onStart",
              delay: 0,
              triggeredAsset: {
                triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" },
                triggeredPoint: {
                  pointName: "Pickup Arm Point",
                  pointUuid: "arm-point-01",
                },
                triggeredAction: {
                  actionName: "Grab Widget",
                  actionUuid: "grab-001",
                },
              },
            },
            {
              triggerUuid: "trig-002",
              triggerName: "Complete Travel",
              triggerType: "onComplete",
              delay: 2,
              triggeredAsset: null,
            },
          ],
        },
      },
    },
    {
      modelUuid: "3a8f6da6-da57-4ef5-91e3-b8daf89e5753",
      modelName: "forklift",
      position: [98.85729337188162, 0, 38.36616546567653],
      rotation: [0, 0, 0],
      state: "idle",
      type: "vehicle",
      speed: 2.5,
      point: {
        uuid: "point-789",
        position: [0, 1, 0],
        rotation: [0, 0, 0],
        action: {
          actionUuid: "action-456",
          actionName: "Deliver to Zone A",
          actionType: "travel",
          unLoadDuration: 15,
          loadCapacity: 5,
          pickUpPoint: null,
          unLoadPoint: null,
          triggers: [
            {
              triggerUuid: "trig-001",
              triggerName: "Start Travel",
              triggerType: "onStart",
              delay: 0,
              triggeredAsset: {
                triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" },
                triggeredPoint: {
                  pointName: "Pickup Arm Point",
                  pointUuid: "arm-point-01",
                },
                triggeredAction: {
                  actionName: "Grab Widget",
                  actionUuid: "grab-001",
                },
              },
            },
            {
              triggerUuid: "trig-002",
              triggerName: "Complete Travel",
              triggerType: "onComplete",
              delay: 2,
              triggeredAsset: null,
            },
          ],
        },
      },
    },
  ]);
  // useEffect(())
  console.log("vehicleStatusSample", vehicleStatusSample);
  useEffect(() => {
    addVehicle("123", vehicleStatusSample[0]);
    // addVehicle('123', vehicleStatusSample[1]);
    // addVehicle('123', vehicleStatusSample[2]);
  }, []);

  useEffect(() => {}, [vehicles]);

  return (
    <>
      <VehicleInstances />
      <VehicleUI
        setVehicleStatusSample={setVehicleStatusSample}
        vehicleStatusSample={vehicleStatusSample}
      />
    </>
  );
}

export default Vehicles;



