"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.CheckoutCompanyForm = void 0;

var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));

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

var _Common = require("../../../../../Common");

var _UI = require("../../../UI");

var _lib = require("@sentecacommerce-theme/lib");

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _templateObject;

var CheckoutCompanyForm = function CheckoutCompanyForm() {
  var _data$company, _data$company2, _data$company3, _data$company4;

  var _useCheckoutFormBilli = (0, _lib.useCheckoutFormBillingState)(),
      data = _useCheckoutFormBilli.data,
      errors = _useCheckoutFormBilli.errors,
      onInputChange = _useCheckoutFormBilli.onInputChange;

  var _useCheckoutErrorFiel = (0, _lib.useCheckoutErrorFields)(),
      errorRef = _useCheckoutErrorFiel.errorRef;

  var onChange = function onChange(e) {
    if (!data) return;
    onInputChange == null ? void 0 : onInputChange(e.target.name, e.target.value);
  };

  var labels = (0, _lib.useLocalLabels)();
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "col-12 mt-0"
  }, /*#__PURE__*/_react["default"].createElement(_UI.CheckoutTitle, {
    data: labels.companyDetails
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "row g-4"
  }, /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.vatNumberLabel,
    value: data == null ? void 0 : (_data$company = data.company) == null ? void 0 : _data$company.vatId,
    onChange: onChange,
    id: "company.vatId",
    type: "text",
    name: "company.vatId",
    isRequired: false
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "vatId",
    errors: errors,
    absolute: true
  })), /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.uicLabel,
    value: data == null ? void 0 : (_data$company2 = data.company) == null ? void 0 : _data$company2.companyId,
    onChange: onChange,
    id: "company.companyId",
    type: "text",
    isRequired: true,
    name: "company.companyId"
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "companyId",
    errors: errors,
    absolute: true
  })))), /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.recipientLabel,
    value: data == null ? void 0 : (_data$company3 = data.company) == null ? void 0 : _data$company3.companyPerson,
    onChange: onChange,
    id: "company.companyPerson",
    type: "text",
    isRequired: true,
    name: "company.companyPerson"
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "companyPerson",
    errors: errors,
    absolute: true
  })), /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.companyNameLabel,
    value: data == null ? void 0 : (_data$company4 = data.company) == null ? void 0 : _data$company4.companyName,
    onChange: onChange,
    id: "company.companyName",
    type: "text",
    isRequired: true,
    name: "company.companyName"
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "companyName",
    errors: errors,
    absolute: true
  })), /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.companyCityLabel,
    value: data == null ? void 0 : data.additionalAddressInfo,
    onChange: onChange,
    id: "city",
    type: "text",
    isRequired: true,
    name: "city"
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "city",
    errors: errors,
    absolute: true
  })), /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.companyZipLabel,
    value: data == null ? void 0 : data.additionalAddressInfo,
    onChange: onChange,
    id: "postalCode",
    type: "text",
    isRequired: true,
    name: "postalCode"
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "postalCode",
    errors: errors,
    absolute: true
  })), /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.companyStreetLabel,
    value: data == null ? void 0 : data.additionalAddressInfo,
    onChange: onChange,
    id: "streetName",
    type: "text",
    isRequired: true,
    name: "streetName"
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "streetName",
    errors: errors,
    absolute: true
  })), /*#__PURE__*/_react["default"].createElement(DesktopHalf, null, /*#__PURE__*/_react["default"].createElement(_Common.TextInput, {
    inputSize: "normal",
    label: labels.companyStreetNumberLabel,
    value: data == null ? void 0 : data.additionalAddressInfo,
    onChange: onChange,
    id: "streetNumber",
    type: "text",
    name: "streetNumber"
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errorRef: errorRef,
    fieldName: "streetNumber",
    errors: errors,
    absolute: true
  })));
};

exports.CheckoutCompanyForm = CheckoutCompanyForm;

var DesktopHalf = _styledComponents["default"].div.attrs({
  className: 'col-12 col-sm-6'
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])([""])));
//# sourceMappingURL=index.js.map