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

const ContractStatusComponent = ({ 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}
      options={[
        { value: "contracts.status.new", label: t("contracts.status.new") },
        { value: "contracts.status.out", label: t("contracts.status.out") },
        { value: "contracts.status.returned", label: t("contracts.status.out") }
      ]}
    />
  );
};

ContractStatusComponent.displayName = "ContractStatusComponent";

export default ContractStatusComponent;
