import { useFetchCameraConfig } from "../../hooks/useCameraConfig";
import Card from "../UI/Card";
import CardHeader from "../UI/CardHeader";
import CameraSettingFields from "./CameraSettingFields";
import { faWrench } from "@fortawesome/free-solid-svg-icons";

const CameraSettings = ({
  title,
  side,
  zoomLevel,
  onZoomLevelChange,
}: {
  title: string;
  side: string;
  zoomLevel?: number;
  onZoomLevelChange?: (level: number | undefined) => void;
}) => {
  const { data, updateCameraConfig, updateCameraConfigError } = useFetchCameraConfig(side);

  return (
    <Card className="overflow-x-visible min-h-[40vh] md:min-h-[60vh] lg:w-[40%] p-4">
      <div className="relative flex flex-col space-y-3">
        <CardHeader title={title} icon={faWrench} />
        {
          <CameraSettingFields
            initialData={data}
            updateCameraConfig={updateCameraConfig}
            zoomLevel={zoomLevel}
            onZoomLevelChange={onZoomLevelChange}
            updateCameraConfigError={updateCameraConfigError}
          />
        }
      </div>
    </Card>
  );
};

export default CameraSettings;
