import React from "react";
import { useStore, isValidCameraView } from "../store/store.ts";

export const CameraSelector: React.FC = () => {
  const cameraView = useStore((state) => state.cameraView);
  const setCameraView = useStore((state) => state.setCameraView);

  const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
    const value = event.target.value;
    if (isValidCameraView(value)) {
      setCameraView(value);
    }
  };

  return (
    <div className="camera-selector-wrapper">
      <select
        className="camera-selector"
        value={cameraView}
        onChange={handleChange}
      >
        <option value="perspective">Perspective</option>
        <option value="ortho-top">Top (Ortho)</option>
        <option value="ortho-front">Front (Ortho)</option>
        <option value="ortho-side">Side (Ortho)</option>
      </select>
    </div>
  );
};
