import { Select } from "antd";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

const CourtesyCarReadinessComponent = ({ value, onChange, ref }) => {
  const [option, setOption] = useState(value);
  const { t } = useTranslation();

  useEffect(() => {
    if (value !== option && onChange) {
      onChange(option);
    }
  }, [value, option, onChange]);

  return (
    <Select
      allowClear
      ref={ref}
      value={option}
      style={{
        width: 100
      }}
      onChange={setOption}
      options={[
        { value: "courtesycars.readiness.ready", label: t("courtesycars.readiness.ready") },
        { value: "courtesycars.readiness.notready", label: t("courtesycars.readiness.notready") }
      ]}
    />
  );
};
export default CourtesyCarReadinessComponent;
