import React from 'react';
import { Form } from 'react-bootstrap';
import { ValidatorComponent } from 'react-form-validator-core';
import translateLabel from "../../../../shared/translation";
import Config from "../../../../../config/appConstants";

class Select extends ValidatorComponent {
  // constructor(props) {
  //   super(props);
  // }
  render() {
    // const { errorMessages, validators, requiredError, validatorListener, id, name, label, value, type, asterisk, lang, readonly, placeholder, required, onChange } = this.props;
    return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form.Group, null, /*#__PURE__*/React.createElement(Form.Label, {
      dir: this.props.lang === Config.LANG.AR ? "rtl" : "ltr"
    }, this.props.label, this.props.asterisk ? /*#__PURE__*/React.createElement("span", {
      className: "asterisk"
    }, "*") : ""), /*#__PURE__*/React.createElement("select", {
      className: "form-control",
      name: this.props.name,
      id: this.props.id,
      value: this.props.value !== null ? this.props.value : "",
      onChange: this.props.onChange,
      ref: r => {
        this.input = r;
      }
    }, /*#__PURE__*/React.createElement("option", {
      key: "0",
      value: ""
    }, translateLabel("SELECT") + " " + this.props.label), this.props.options.map((data, index) => /*#__PURE__*/React.createElement("option", {
      key: index + 1,
      value: data.value
    }, data.text))), this.errorText()));
  }

  errorText() {
    const {
      isValid
    } = this.state;

    if (isValid) {
      return null;
    }

    return /*#__PURE__*/React.createElement("div", {
      className: "errorStr"
    }, translateLabel(this.getErrorMessage()));
  }

}

export default Select;