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

const { Option } = Select;

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

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

  return (
    <Select
      ref={ref}
      value={option}
      style={{
        width: 100
      }}
      onChange={setOption}
    >
      <Option value="courtesycars.status.in">{t("courtesycars.status.in")}</Option>
      <Option value="courtesycars.status.inservice">{t("courtesycars.status.inservice")}</Option>
      <Option value="courtesycars.status.out">{t("courtesycars.status.out")}</Option>
      <Option value="courtesycars.status.sold">{t("courtesycars.status.sold")}</Option>
      <Option value="courtesycars.status.leasereturn">{t("courtesycars.status.leasereturn")}</Option>
      <Option value="courtesycars.status.unavailable">{t("courtesycars.status.unavailable")}</Option>
    </Select>
  );
};
export default forwardRef(CourtesyCarStatusComponent);
