"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _modularityFront = _interopRequireDefault(require("modularity-front"));

var _reactMaterialize = require("react-materialize");

var _GoogleMap = _interopRequireDefault(require("../../Modules/GoogleMap"));

var _Form = _interopRequireDefault(require("../../Modules/Form"));

var _Toast = _interopRequireDefault(require("../../helpers/Toast"));

var _DictionaryService = _interopRequireDefault(require("../../Services/DictionaryService"));

require("./ContactPackage.css");

var _TonersalesInfo = _interopRequireDefault(require("../../Inputs/TonersalesInfo"));

var _ContactInputs = _interopRequireDefault(require("../../Inputs/ContactInputs"));

var _API = _interopRequireDefault(require("../../Services/API"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var Module = _modularityFront.default.Module;

var ContactPackage =
/*#__PURE__*/
function (_Modularity$Module) {
  _inherits(ContactPackage, _Modularity$Module);

  function ContactPackage(props) {
    var _this;

    _classCallCheck(this, ContactPackage);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(ContactPackage).call(this, props));
    _this.API = new _API.default();
    _this.state = {
      formKey: 1
    };
    console.log("Info", _TonersalesInfo.default);
    return _this;
  }

  _createClass(ContactPackage, [{
    key: "contact",
    value: function contact(data) {
      var _this2 = this;

      if (data.email) {
        this.API.post('/contact', data).then(function (res) {
          _Toast.default.success(_DictionaryService.default.get("Email was sent"));

          _this2.setState({
            formKey: Math.random()
          });
        });
      }
    }
  }, {
    key: "render",
    value: function render() {
      var _this3 = this;

      var info = Object.keys(_TonersalesInfo.default).map(function (key, index) {
        return _react.default.createElement(_reactMaterialize.CollectionItem, null, _react.default.createElement("div", {
          className: "title"
        }, key), _react.default.createElement("div", {
          className: "items"
        }, _TonersalesInfo.default[key]));
      });
      return _react.default.createElement("div", {
        className: "contact"
      }, _react.default.createElement(_reactMaterialize.Row, null, _react.default.createElement(_reactMaterialize.Col, {
        s: 8
      }, _react.default.createElement(_reactMaterialize.Collection, {
        header: _react.default.createElement("div", {
          className: "cont_title"
        }, "\u03A4\u03BF\u03C0\u03BF\u03B8\u03B5\u03C3\u03AF\u03B1 \u039A\u03B1\u03C4\u03B1\u03C3\u03C4\u03AE\u03BC\u03B1\u03C4\u03BF\u03C2")
      }, _react.default.createElement(_reactMaterialize.CollectionItem, {
        className: 'no-padding'
      }, _react.default.createElement(_GoogleMap.default, null)))), _react.default.createElement(_reactMaterialize.Col, {
        s: 4
      }, _react.default.createElement(_reactMaterialize.Collection, {
        header: _react.default.createElement("div", {
          className: "cont_title"
        }, "\u03A3\u03C4\u03BF\u03B9\u03C7\u03B5\u03B9\u03B1 \u039A\u03B1\u03C4\u03B1\u03C3\u03C4\u03AE\u03BC\u03B1\u03C4\u03BF\u03C2")
      }, info))), _react.default.createElement(_reactMaterialize.Row, null, _react.default.createElement(_reactMaterialize.Col, {
        s: 12
      }, _react.default.createElement("div", {
        className: "form_container"
      }, _react.default.createElement(_reactMaterialize.Row, {
        className: "center cont_title"
      }, "\u0395\u03C0\u03B9\u03BA\u03BF\u03B9\u03BD\u03C9\u03BD\u03AE\u03C3\u03C4\u03B5 \u039C\u03B1\u03B6\u03AF \u03BC\u03B1\u03C2"), _react.default.createElement(_Form.default, {
        key: this.state.formKey,
        onSubmit: function onSubmit(data) {
          return _this3.contact(data);
        },
        FormInputs: _ContactInputs.default,
        activeButton: true,
        button: 'Αποστολή',
        withCaptcha: true,
        CaptchaKey: '6LcaRqcUAAAAAJRvSwHNtyRDwUiGYcuAfIQVaA1W'
      })))));
    }
  }]);

  return ContactPackage;
}(_modularityFront.default.Module);

ContactPackage.Inputs = {};
ContactPackage.Category = "Sxoinas Packages";
var _default = ContactPackage;
exports.default = _default;