"use strict";

var _react = _interopRequireDefault(require("react"));
var _react2 = require("@storybook/react");
var _index = _interopRequireDefault(require("./index"));
var _storybookState = require("@sambego/storybook-state");
var _i18n = require("../../../../Framework/i18n");
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 mockedPriceData = [{
  key: 'Damen Polo Organic, JAMES & NICHOLSON',
  identifier: 'precosts',
  label: 'Damen Polo Organic, JAMES & NICHOLSON',
  selectable: false,
  price: '98,00 €'
}, {
  key: 'Vorkosten',
  identifier: 'precosts',
  label: 'Vorkosten',
  selectable: false,
  price: '29,00 €'
}, {
  key: 'Werbedruck',
  identifier: 'advertisePrinting',
  label: 'Werbedruck',
  selectable: false,
  price: '42,00 €'
}, {
  key: 'Logokosten',
  identifier: 'logisticsCosts',
  label: 'Logokosten',
  selectable: false,
  price: '0,00 €'
}, {
  key: 'Korrekturabzug',
  identifier: 'proof',
  label: 'Korrekturabzug',
  selectable: true,
  selected: false,
  price: '0,00 €'
}, {
  key: 'Korrekturmuster',
  identifier: 'correctionDraft',
  label: 'Korrekturmuster',
  selectable: true,
  selected: false,
  price: '0,00 €'
}];
var mockedPriceDataWithoutSelectable = [{
  key: 'Damen Polo Organic, JAMES & NICHOLSON',
  identifier: 'precosts',
  label: 'Damen Polo Organic, JAMES & NICHOLSON',
  selectable: false,
  price: '98,00 €'
}, {
  key: 'Korrekturmuster',
  identifier: 'correctionDraft',
  label: 'Korrekturmuster',
  selectable: false,
  price: '0,00 €'
}];
var store = new _storybookState.Store({
  priceData: mockedPriceData
});
var onSelectableChanged = function onSelectableChanged(priceData) {
  return function (key, newSelected) {
    var nextData = priceData.map(function (currentElement) {
      if (currentElement.key === key) {
        return _objectSpread(_objectSpread({}, currentElement), {}, {
          selected: newSelected,
          price: newSelected ? '10,00 €' : '0,00 €'
        });
      }
      return currentElement;
    });
    store.set({
      priceData: nextData
    });
  };
};
(0, _react2.storiesOf)('PriceList', module).add('with checkboxes', function () {
  return /*#__PURE__*/_react["default"].createElement(_storybookState.State, {
    store: store
  }, function (state) {
    return /*#__PURE__*/_react["default"].createElement(_index["default"], {
      amount: "100",
      list: state.priceData,
      currentTotalPrice: "500,00 \u20AC",
      taxNote: (0, _i18n.t)('amountPrice.vatNotice'),
      onSelectableChanged: onSelectableChanged(state.priceData)
    });
  });
}).add('without checkboxes', function () {
  return /*#__PURE__*/_react["default"].createElement(_index["default"], {
    list: mockedPriceDataWithoutSelectable,
    amount: "100",
    currentTotalPrice: "500,00 \u20AC",
    taxNote: (0, _i18n.t)('amountPrice.vatNotice')
  });
});