import { Form, Input } from "antd";
import { useTranslation } from "react-i18next";
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react";

const mapStateToProps = createStructuredSelector({
  bodyshop: selectBodyshop
});
const mapDispatchToProps = () => ({
  //setUserLanguage: language => dispatch(setUserLanguage(language))
});
export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoOrderStatusComponent);

export function ShopInfoOrderStatusComponent({ bodyshop }) {
  const { t } = useTranslation();

  const {
    treatments: { OEConnection }
  } = useTreatmentsWithConfig({
    attributes: {},
    names: ["OEConnection"],
    splitKey: bodyshop.imexshopid
  });

  return (
    <LayoutFormRow header={t("bodyshop.labels.orderstatuses")}>
      <Form.Item
        label={t("bodyshop.fields.statuses.default_bo")}
        rules={[
          {
            required: true
            //message: t("general.validation.required"),
          }
        ]}
        name={["md_order_statuses", "default_bo"]}
      >
        <Input />
      </Form.Item>
      <Form.Item
        label={t("bodyshop.fields.statuses.default_ordered")}
        rules={[
          {
            required: true
            //message: t("general.validation.required"),
          }
        ]}
        name={["md_order_statuses", "default_ordered"]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label={t("bodyshop.fields.statuses.default_received")}
        rules={[
          {
            required: true
            //message: t("general.validation.required"),
          }
        ]}
        name={["md_order_statuses", "default_received"]}
      >
        <Input />
      </Form.Item>
      <Form.Item
        label={t("bodyshop.fields.statuses.default_returned")}
        rules={[
          {
            required: true
            //message: t("general.validation.required"),
          }
        ]}
        name={["md_order_statuses", "default_returned"]}
      >
        <Input />
      </Form.Item>
      {OEConnection.treatment === "on" && (
        <Form.Item
          label={t("bodyshop.fields.statuses.default_quote")}
          rules={[
            {
              required: true
              //message: t("general.validation.required"),
            }
          ]}
          name={["md_order_statuses", "default_quote"]}
        >
          <Input />
        </Form.Item>
      )}
    </LayoutFormRow>
  );
}
