import React, { Component } from 'react';
import translateLabel from "../translation";
import { withNamespaces } from 'react-i18next';
import Img from '../assets/images/document.svg';
import Config from '../config/appConstants';
import { store } from "../redux";

class DocumentList extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  handleSectionEditClick() {
    this.props.onSectionActionClick(this.props.storeData.WizardStep);
  }

  render() {
    var uploadedFiles;
    uploadedFiles = JSON.parse(store.getState().appInfo.selectedFiles);
    let removeDuplicateData = Object.values(uploadedFiles.reduce((acc, cur) => Object.assign(acc, {
      [cur.DocumentTypeID]: cur
    }), {}));
    uploadedFiles = removeDuplicateData;

    if (uploadedFiles !== null && uploadedFiles !== undefined && uploadedFiles.length > 0) {
      return /*#__PURE__*/React.createElement("div", {
        style: {
          marginLeft: "-11px"
        }
      }, /*#__PURE__*/React.createElement("div", {
        className: "container"
      }, /*#__PURE__*/React.createElement("div", {
        className: "row"
      }, /*#__PURE__*/React.createElement("div", {
        className: "header-align-left col-lg-12 col-md-6"
      }, /*#__PURE__*/React.createElement("h4", {
        className: "selectDocumentHead"
      }, translateLabel('REQURIED_DOC_LIST'))), /*#__PURE__*/React.createElement("div", {
        className: "col col-lg-12 col-md-12"
      }, /*#__PURE__*/React.createElement("div", {
        className: "row",
        style: {
          width: '105%'
        }
      }, (() => {
        if (this.props.storeData.hasOwnProperty('WizardStep') && this.props.storeData.WizardStep !== "") {
          return /*#__PURE__*/React.createElement("div", {
            className: "col-lg-12 col-md-12 col-sm-12 col-12"
          }, /*#__PURE__*/React.createElement("div", {
            className: this.props.i18n.language === Config.LANG.AR ? "text-left" : "text-right"
          }, /*#__PURE__*/React.createElement("button", {
            onClick: () => {
              this.handleSectionEditClick();
            },
            className: "btn-primary"
          }, " ", translateLabel("EDITBTN"))));
        } else {
          return "";
        }
      })(), /*#__PURE__*/React.createElement("div", {
        className: "col col-lg-12 col-md-12"
      }, /*#__PURE__*/React.createElement("div", {
        className: "table-responsive-lg"
      }, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("table", {
        className: "table"
      }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
        className: this.props.i18n.language === Config.LANG.AR ? "text-right" : "text-left"
      }, translateLabel("FILE_NAME")))), /*#__PURE__*/React.createElement("tbody", null, uploadedFiles.map(function (object, i) {
        return /*#__PURE__*/React.createElement("tr", {
          key: i + "-tr"
        }, /*#__PURE__*/React.createElement("td", {
          key: i + "-fname",
          className: this.props.i18n.language === Config.LANG.AR ? "text-right" : "text-left"
        }, /*#__PURE__*/React.createElement("img", {
          src: Img,
          alt: "doc",
          style: {
            width: "50px"
          },
          disabled: true
        }), "\xA0\xA0", this.props.i18n.language === Config.LANG.AR ? object.DocumentTypeArabic : object.DocumentTypeEnglish));
      }.bind(this)))))))))));
    }
  }

}

export default withNamespaces()(DocumentList);