"use strict";

var _react = _interopRequireDefault(require("react"));
var _react2 = require("@storybook/react");
var _storybookState = require("@sambego/storybook-state");
var _i18n = require("../../../../../Framework/i18n");
var _index = _interopRequireDefault(require("./index"));
var _PriceList = _interopRequireDefault(require("../../../../Shared/Components/PriceList"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var mockedDesignAreas = [{
  name: 'Auf Schaft',
  identifier: 'auf_schaft'
}, {
  name: 'Auf Clip',
  identifier: 'auf_clip'
}, {
  name: 'Auf Schaft Rückseite',
  identifier: 'auf_schaft_rueckseite'
}, {
  name: 'Druckknopf',
  identifier: 'druckknopf'
}];
var mockedCalculationData = [{
  key: '100 x ' + (0, _i18n.t)('mockedData.demoPen'),
  identifier: 'costs',
  label: (0, _i18n.t)('mockedData.demoPen'),
  selectable: false,
  price: '50,00 €'
}, {
  key: 'Grundkosten',
  identifier: 'basiccosts',
  label: (0, _i18n.t)('mockedData.basicCosts'),
  selectable: false,
  price: '29,00 €'
}, {
  key: 'Druckkosten',
  identifier: 'printcosts',
  label: (0, _i18n.t)('mockedData.printingCosts'),
  selectable: false,
  price: '44,00 €'
}, {
  key: 'Profi-Datencheck',
  identifier: 'datacheck',
  label: (0, _i18n.t)('mockedData.professionalCheck'),
  selectable: true,
  selectet: false,
  price: '10,00 €'
}];
var designProductionList = [{
  name: (0, _i18n.t)('mockedData.print'),
  identifier: 'Druck'
}, {
  name: (0, _i18n.t)('mockedData.embossing'),
  identifier: 'Prägung'
}, {
  name: (0, _i18n.t)('mockedData.engraving'),
  identifier: 'Gravur'
}];
var selectedColorAmountList = [{
  name: '1 ' + (0, _i18n.t)('mockedData.color'),
  identifier: '1 farbig'
}, {
  name: '2 ' + (0, _i18n.t)('mockedData.colors'),
  identifier: '2 farbig'
}, {
  name: '3 ' + (0, _i18n.t)('mockedData.colors'),
  identifier: '3 farbig'
}];
var store = new _storybookState.Store({
  amount: '100',
  priceData: 'mockedCalculationData',
  mockedCalculationData: mockedCalculationData,
  designProductionList: designProductionList,
  selectedColorAmountList: selectedColorAmountList,
  selectedColorAmount: '1 farbig',
  designProduction: 'Druck'
});
function handleChangeAmount(event) {
  store.set({
    amount: event.target.value
  });
}
var onSelectableChanged = function onSelectableChanged(mockedCalculationData) {
  return function (key, newSelected) {
    var nextData = mockedCalculationData.map(function (currentElement) {
      if (currentElement.key === key) {
        return _objectSpread(_objectSpread({}, currentElement), {}, {
          selected: newSelected,
          price: newSelected ? '10,00 €' : '0,00 €'
        });
      }
      return currentElement;
    });
    store.set({
      mockedCalculationData: nextData
    });
  };
};
function handleChangeDesignProductionMethod(event) {
  store.set({
    designProduction: event.target.value
  });
}
function handleChangeSelectedColorAmount(event) {
  store.set({
    selectedColorAmount: event.target.value
  });
}
(0, _react2.storiesOf)('CalculationWidget', module).add('designCalculationScreen', function () {
  return /*#__PURE__*/_react["default"].createElement(_storybookState.State, {
    store: store
  }, function (state) {
    return /*#__PURE__*/_react["default"].createElement(_index["default"], {
      colorAmountList: state.selectedColorAmountList,
      currentSelectedColorAmount: state.selectedColorAmount,
      designProductionMethods: state.designProductionList,
      currentDesignProductionMethod: state.designProduction,
      handleChangeDesignProductionMethod: handleChangeDesignProductionMethod,
      handleChangeSelectedColorAmount: handleChangeSelectedColorAmount,
      designAreas: mockedDesignAreas,
      amountValue: state.amount,
      onChangeAmount: handleChangeAmount,
      calculationData: state.mockedCalculationData,
      onSelectableChanged: onSelectableChanged(state.mockedCalculationData),
      totalPrice: '123,00 €',
      priceListComponent: /*#__PURE__*/_react["default"].createElement(_PriceList["default"], {
        amount: state.amount,
        list: state.mockedCalculationData,
        totalPrice: '123,00€',
        taxNote: (0, _i18n.t)('amountPrice.vatNotice'),
        onSelectableChanged: onSelectableChanged(state.mockedCalculationData)
      })
    });
  });
});