@crystaldesign/diva-seller 25.10.0-beta.16 → 25.10.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/build/esm/index.js +593 -267
  2. package/build/types/seller/src/components/Basket/Step3Checkout.d.ts +1 -1
  3. package/build/types/seller/src/components/Basket/Step3Checkout.d.ts.map +1 -1
  4. package/build/types/seller/src/components/Basket/defaultSchema/step3.d.ts +86 -66
  5. package/build/types/seller/src/components/Basket/defaultSchema/step3.d.ts.map +1 -1
  6. package/build/types/seller/src/components/Basket/index.d.ts.map +1 -1
  7. package/build/types/seller/src/components/Basket/types.d.ts +11 -0
  8. package/build/types/seller/src/components/Basket/types.d.ts.map +1 -1
  9. package/build/types/seller/src/provider/context.d.ts +1 -0
  10. package/build/types/seller/src/provider/context.d.ts.map +1 -1
  11. package/build/types/seller/src/provider/hooks/useSellerStateData/index.d.ts +1 -0
  12. package/build/types/seller/src/provider/hooks/useSellerStateData/index.d.ts.map +1 -1
  13. package/build/types/seller/src/types.d.ts +1 -0
  14. package/build/types/seller/src/types.d.ts.map +1 -1
  15. package/build/types/seller/src/ui/Basket/CheckOut/SaveButtonsGroup.d.ts +2 -2
  16. package/build/types/seller/src/ui/Basket/CheckOut/SaveButtonsGroup.d.ts.map +1 -1
  17. package/build/types/seller/src/ui/Basket/CheckOut/index.d.ts +1 -1
  18. package/build/types/seller/src/ui/Basket/CheckOut/index.d.ts.map +1 -1
  19. package/build/types/seller/src/ui/Basket/CheckOut/statusMenu.d.ts.map +1 -1
  20. package/build/types/seller/src/ui/Basket/CheckOut/useCheckoutStep3.d.ts +18 -0
  21. package/build/types/seller/src/ui/Basket/CheckOut/useCheckoutStep3.d.ts.map +1 -0
  22. package/package.json +5 -5
@@ -45,6 +45,7 @@ import Divider from '@mui/material/Divider';
45
45
  import Alert from '@mui/material/Alert';
46
46
  import AlertTitle from '@mui/material/AlertTitle/AlertTitle';
47
47
  import Form from '@crystaldesign/forms';
48
+ import classnames from 'classnames';
48
49
  import _typeof from '@babel/runtime/helpers/typeof';
49
50
  import InputLabel from '@mui/material/InputLabel';
50
51
  import Checkbox from '@mui/material/Checkbox';
@@ -60,8 +61,8 @@ import _toArray from '@babel/runtime/helpers/toArray';
60
61
  import Box from '@mui/material/Box';
61
62
  import StarBorderIcon from '@mui/icons-material/StarBorder';
62
63
  import EditIcon from '@mui/icons-material/Edit';
64
+ import { useSellerState as useSellerState$1 } from '@crystaldesign/diva-seller/provider/SellerStateProvider';
63
65
  import OrderEntry, { apiSaveRenderJobs, VariantSelector } from '@crystaldesign/order-entry';
64
- import classnames from 'classnames';
65
66
  import { InfoRounded, Remove, Add, Delete } from '@mui/icons-material';
66
67
  import { Swiper, SwiperSlide } from 'swiper/react';
67
68
  import { Autoplay, Thumbs, Pagination, FreeMode, Mousewheel } from 'swiper/modules';
@@ -195,7 +196,10 @@ var SellerContext = /*#__PURE__*/createContext({
195
196
  loadAnalyticScore: function loadAnalyticScore() {
196
197
  return Promise.resolve({});
197
198
  },
198
- loadManualCustomDataFields: function loadManualCustomDataFields() {}
199
+ loadManualCustomDataFields: function loadManualCustomDataFields() {},
200
+ setOrdered: function setOrdered() {
201
+ return Promise.resolve({});
202
+ }
199
203
  }
200
204
  });
201
205
 
@@ -1434,9 +1438,9 @@ function _apiGetAffiliates() {
1434
1438
  return _apiGetAffiliates.apply(this, arguments);
1435
1439
  }
1436
1440
 
1437
- function _createForOfIteratorHelper$3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
1438
- function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
1439
- function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1441
+ function _createForOfIteratorHelper$4(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$4(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
1442
+ function _unsupportedIterableToArray$4(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$4(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$4(r, a) : void 0; } }
1443
+ function _arrayLikeToArray$4(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1440
1444
  function processData(_ref) {
1441
1445
  var top = _ref.top,
1442
1446
  skip = _ref.skip,
@@ -1502,7 +1506,7 @@ function isGlobalFiltered(d, filter) {
1502
1506
  });
1503
1507
  }
1504
1508
  function orderFn(a, b, orderBy) {
1505
- var _iterator = _createForOfIteratorHelper$3(orderBy),
1509
+ var _iterator = _createForOfIteratorHelper$4(orderBy),
1506
1510
  _step;
1507
1511
  try {
1508
1512
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -1536,9 +1540,9 @@ function orderFn(a, b, orderBy) {
1536
1540
  var _excluded$a = ["collectionId"],
1537
1541
  _excluded2$2 = ["basetId"],
1538
1542
  _excluded3$1 = ["catalogCodex", "accountId", "collectionId"];
1539
- function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
1540
- function _unsupportedIterableToArray$2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0; } }
1541
- function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1543
+ function _createForOfIteratorHelper$3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
1544
+ function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
1545
+ function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1542
1546
  function ownKeys$D(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; }
1543
1547
  function _objectSpread$D(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$D(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$D(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1544
1548
  var LOG$9 = getLogger('Seller', 'SellerStateData');
@@ -1562,7 +1566,8 @@ function useSellerStateData(_ref) {
1562
1566
  toggleLoading = _useDivaCore$actions.toggleLoading,
1563
1567
  getSessionGuid = _useDivaCore$actions.getSessionGuid,
1564
1568
  updateCustomLogo = _useDivaCore$actions.updateCustomLogo,
1565
- openModal = _useDivaCore$actions.openModal;
1569
+ openModal = _useDivaCore$actions.openModal,
1570
+ sendEmail = _useDivaCore$actions.sendEmail;
1566
1571
  var _useTranslation = useTranslation(),
1567
1572
  i18n = _useTranslation.i18n,
1568
1573
  t = _useTranslation.t;
@@ -1900,7 +1905,7 @@ function useSellerStateData(_ref) {
1900
1905
  break;
1901
1906
  }
1902
1907
  catalogData = [];
1903
- _iterator = _createForOfIteratorHelper$2(catalog);
1908
+ _iterator = _createForOfIteratorHelper$3(catalog);
1904
1909
  _context5.prev = 12;
1905
1910
  _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
1906
1911
  var _collection$enricherS3;
@@ -2745,6 +2750,102 @@ function useSellerStateData(_ref) {
2745
2750
  });
2746
2751
  }
2747
2752
  };
2753
+ var setOrdered = /*#__PURE__*/function () {
2754
+ var _ref19 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(basket, sendOrderEmail) {
2755
+ var to, emails, _iterator2, _step2, mail, _basket$Client;
2756
+ return _regeneratorRuntime.wrap(function _callee10$(_context11) {
2757
+ while (1) switch (_context11.prev = _context11.next) {
2758
+ case 0:
2759
+ if (!jwt) {
2760
+ _context11.next = 8;
2761
+ break;
2762
+ }
2763
+ if (!(sendOrderEmail && organization.settings.sendOrdersEmail)) {
2764
+ _context11.next = 6;
2765
+ break;
2766
+ }
2767
+ to = [organization.settings.sendOrdersEmail];
2768
+ if (configData !== null && configData !== void 0 && configData.sendOrderEmails) {
2769
+ emails = configData.sendOrderEmails.split(',');
2770
+ _iterator2 = _createForOfIteratorHelper$3(emails);
2771
+ try {
2772
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2773
+ mail = _step2.value;
2774
+ if (mail == 'CLIENT') {
2775
+ if ((_basket$Client = basket.Client) !== null && _basket$Client !== void 0 && _basket$Client.email) to.push(basket.Client.email);
2776
+ } else if (mail == 'SELLER') {
2777
+ if (basket.SalespersonEmail) to.push(basket.SalespersonEmail);
2778
+ } else if (mail == 'ORGANIZATION') {
2779
+ if (organization !== null && organization !== void 0 && organization.email) to.push(organization.email);
2780
+ } else if (mail == 'USER') {
2781
+ if (currentUser !== null && currentUser !== void 0 && currentUser.mainEmail) to.push(currentUser.mainEmail);
2782
+ }
2783
+ }
2784
+ } catch (err) {
2785
+ _iterator2.e(err);
2786
+ } finally {
2787
+ _iterator2.f();
2788
+ }
2789
+ }
2790
+ try {
2791
+ toggleLoading('setOrdered');
2792
+ sendEmail({
2793
+ //dialogText: t('basket.checkout.modals.ordered'),
2794
+ showDialog: false,
2795
+ callback: function callback(success) {
2796
+ if (success) {
2797
+ basketHandler.setOrdered({
2798
+ serviceUrl: apiConfig.basketService,
2799
+ organizationId: currentOrganization === null || currentOrganization === void 0 ? void 0 : currentOrganization._id,
2800
+ jwt: jwt,
2801
+ divaNr: basket.DivaNr,
2802
+ documentVersion: basket.DocumentVersion
2803
+ });
2804
+ toggleLoading('setOrdered');
2805
+ openModal({
2806
+ title: t('basket.checkout.modals.ordered'),
2807
+ accept: true
2808
+ });
2809
+ toggleLoading('setOrdered');
2810
+ } else {
2811
+ openModal({
2812
+ title: t('basket.checkout.modals.orderederror'),
2813
+ accept: true
2814
+ });
2815
+ toggleLoading('setOrdered');
2816
+ }
2817
+ },
2818
+ content: {
2819
+ to: to.join(','),
2820
+ type: 'basket',
2821
+ variant: 'SEND',
2822
+ divaNr: basket.DivaNr,
2823
+ version: basket.DocumentVersion
2824
+ }
2825
+ });
2826
+ } catch (e) {
2827
+ console.error(e);
2828
+ }
2829
+ return _context11.abrupt("return");
2830
+ case 6:
2831
+ _context11.next = 8;
2832
+ return basketHandler.setOrdered({
2833
+ serviceUrl: apiConfig.basketService,
2834
+ organizationId: currentOrganization === null || currentOrganization === void 0 ? void 0 : currentOrganization._id,
2835
+ jwt: jwt,
2836
+ divaNr: basket.DivaNr,
2837
+ documentVersion: basket.DocumentVersion
2838
+ });
2839
+ case 8:
2840
+ case "end":
2841
+ return _context11.stop();
2842
+ }
2843
+ }, _callee10);
2844
+ }));
2845
+ return function setOrdered(_x17, _x18) {
2846
+ return _ref19.apply(this, arguments);
2847
+ };
2848
+ }();
2748
2849
  return {
2749
2850
  state: state,
2750
2851
  setFirstLoginApiUrl: setFirstLoginApiUrl,
@@ -2770,7 +2871,8 @@ function useSellerStateData(_ref) {
2770
2871
  resetForCache: resetForCache,
2771
2872
  loadAnalyticScore: loadAnalyticScore,
2772
2873
  setManualCustomDataFields: setManualCustomDataFields,
2773
- setCloseOnSave: setCloseOnSave
2874
+ setCloseOnSave: setCloseOnSave,
2875
+ setOrdered: setOrdered
2774
2876
  };
2775
2877
  }
2776
2878
 
@@ -6028,8 +6130,8 @@ function styleInject(css, ref) {
6028
6130
 
6029
6131
  var infocontainer$1 = "infocontainer-ir9gv";
6030
6132
  var stepsContent = "steps-content-jDbLc";
6031
- var css_248z$c = ".infocontainer-ir9gv {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.steps-content-jDbLc {\n margin-left: 10px;\n padding-top: 10px;\n padding-right: 10px;\n height: 100%;\n overflow-y: auto;\n}\n\n.steps-content-jDbLc #diva-order-entry-footer > span > div {\n width: 500px;\n}\n\n.steps-content-jDbLc #diva-order-entry-footer > span > div > span {\n margin-left: 110px;\n}\n";
6032
- styleInject(css_248z$c);
6133
+ var css_248z$d = ".infocontainer-ir9gv {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.steps-content-jDbLc {\n margin-left: 10px;\n padding-top: 10px;\n padding-right: 10px;\n height: 100%;\n overflow-y: auto;\n}\n\n.steps-content-jDbLc #diva-order-entry-footer > span > div {\n width: 500px;\n}\n\n.steps-content-jDbLc #diva-order-entry-footer > span > div > span {\n margin-left: 110px;\n}\n";
6134
+ styleInject(css_248z$d);
6033
6135
 
6034
6136
  function Step2ClientData(_ref) {
6035
6137
  var _config$clientData, _config$clientData2;
@@ -6058,6 +6160,17 @@ function Step2ClientData(_ref) {
6058
6160
  });
6059
6161
  }
6060
6162
 
6163
+ var saveButton = "saveButton-vFkgp";
6164
+ var newPlanningButton = "newPlanningButton-rpBS2";
6165
+ var saveButtonGroup = "saveButtonGroup-r-Uwi";
6166
+ var checkout3Container = "checkout3Container-efdnR";
6167
+ var checkout3Header = "checkout3Header-Kph7T";
6168
+ var checkoutHeaderButtonGroup = "checkoutHeaderButtonGroup-ao8TM";
6169
+ var gdprCheckbox = "gdprCheckbox-jqVEK";
6170
+ var checkoutForm = "checkoutForm-wZEGN";
6171
+ var css_248z$c = ".saveButton-vFkgp {\n width: 25%;\n}\n\n.newPlanningButton-rpBS2 {\n width: 20%;\n}\n.saveButtonGroup-r-Uwi {\n text-align: right !important;\n}\n\n.checkout3Container-efdnR {\n display: flex;\n flex-direction: column;\n width: 95%;\n margin: 1rem;\n}\n\n.checkout3Header-Kph7T {\n display: flex;\n flex-direction: row;\n width: 50%;\n}\n\n.checkoutHeaderButtonGroup-ao8TM {\n margin-top: 0.4rem;\n margin-bottom: 1rem;\n margin-left: 1rem;\n width: 100%;\n}\n.gdprCheckbox-jqVEK {\n margin-left: 40px;\n}\n\n.checkoutForm-wZEGN {\n width: 100%;\n}\n";
6172
+ styleInject(css_248z$c);
6173
+
6061
6174
  function StatusMenu(_ref) {
6062
6175
  var visibleStatus = _ref.visibleStatus,
6063
6176
  status = _ref.status,
@@ -6069,14 +6182,11 @@ function StatusMenu(_ref) {
6069
6182
  var _useTranslation = useTranslation(),
6070
6183
  t = _useTranslation.t;
6071
6184
  return /*#__PURE__*/jsx("div", {
6072
- style: {
6073
- "float": 'left',
6074
- marginTop: '0.4rem',
6075
- marginLeft: '1rem'
6076
- },
6185
+ className: checkoutHeaderButtonGroup,
6077
6186
  children: /*#__PURE__*/jsx(ButtonGroup$1, {
6078
6187
  color: "primary",
6079
6188
  "aria-label": "outlined primary button group",
6189
+ fullWidth: true,
6080
6190
  children: visibleStatus.filter(function (item) {
6081
6191
  return typeof item == 'string';
6082
6192
  }) //filter out old configuration,where it was an object
@@ -6111,80 +6221,57 @@ function SaveButtonsGroup(_ref) {
6111
6221
  orderEmpty = _ref.orderEmpty,
6112
6222
  status = _ref.status,
6113
6223
  configSaveButtons = _ref.configSaveButtons,
6114
- userInfoPresent = _ref.userInfoPresent;
6224
+ validData = _ref.validData;
6115
6225
  var _useTranslation = useTranslation(),
6116
6226
  t = _useTranslation.t;
6117
6227
  var classes = useStyles$1();
6118
6228
  return /*#__PURE__*/jsxs("div", {
6119
6229
  style: {
6120
- marginTop: '0.4rem',
6121
- marginLeft: '2.5rem'
6230
+ marginTop: '0.4rem'
6122
6231
  },
6123
6232
  children: [(configSaveButtons === null || configSaveButtons === void 0 ? void 0 : configSaveButtons.includes('SAVE')) && /*#__PURE__*/jsx(Button$1, {
6124
6233
  variant: "contained",
6125
6234
  size: "medium",
6126
6235
  color: "primary",
6127
- disabled: orderEmpty,
6236
+ disabled: orderEmpty || !validData,
6128
6237
  onClick: function onClick() {
6129
6238
  onClickSave();
6130
6239
  },
6131
- className: classes.margin,
6240
+ className: classnames(classes.margin, saveButton),
6132
6241
  children: t('basket.checkout.actions.save')
6133
- }), (configSaveButtons === null || configSaveButtons === void 0 ? void 0 : configSaveButtons.includes('SAVE_AND_SEND')) && status !== 'BASE_CONFIGURATION' && /*#__PURE__*/jsx(Button$1, {
6134
- variant: "outlined",
6135
- size: "medium",
6136
- color: "primary",
6137
- disabled: orderEmpty || !userInfoPresent,
6138
- onClick: function onClick() {
6139
- onClickSave('generate', true);
6140
- },
6141
- className: classes.margin,
6142
- children: t('basket.checkout.actions.saveAndSendMail', {
6143
- type: t('data.' + status)
6144
- })
6145
- }), (configSaveButtons === null || configSaveButtons === void 0 ? void 0 : configSaveButtons.includes('SAVE_AND_OPEN')) && status !== 'BASE_CONFIGURATION' && /*#__PURE__*/jsx(Button$1, {
6146
- variant: "outlined",
6147
- size: "medium",
6148
- color: "primary",
6149
- disabled: orderEmpty,
6150
- onClick: function onClick() {
6151
- onClickSave('open');
6152
- },
6153
- className: classes.margin,
6154
- children: t('basket.checkout.actions.saveAndOpenNote', {
6155
- type: t('data.' + status)
6156
- })
6157
- }), status == 'BASE_CONFIGURATION' && /*#__PURE__*/jsx(Tooltip, {
6158
- title: t('checkout.product.asfavbuttontooltip'),
6159
- placement: "bottom",
6160
- arrow: true,
6161
- children: /*#__PURE__*/jsx(Button$1, {
6242
+ }), status == 'BASE_CONFIGURATION' && /*#__PURE__*/jsxs(Fragment, {
6243
+ children: [/*#__PURE__*/jsx(Tooltip, {
6244
+ title: t('checkout.product.asfavbuttontooltip'),
6245
+ placement: "bottom",
6246
+ arrow: true,
6247
+ children: /*#__PURE__*/jsx(Button$1, {
6248
+ variant: "outlined",
6249
+ size: "medium",
6250
+ color: "primary",
6251
+ disabled: orderEmpty,
6252
+ onClick: function onClick() {
6253
+ onClickSave(undefined, false, true);
6254
+ },
6255
+ className: classes.margin,
6256
+ children: t('basket.checkout.actions.saveAsFavorite')
6257
+ })
6258
+ }), /*#__PURE__*/jsx(Button$1, {
6162
6259
  variant: "outlined",
6163
6260
  size: "medium",
6164
6261
  color: "primary",
6165
6262
  disabled: orderEmpty,
6166
6263
  onClick: function onClick() {
6167
- onClickSave(undefined, false, true);
6264
+ onClickSave(undefined, false, true, true);
6168
6265
  },
6169
6266
  className: classes.margin,
6170
- children: t('basket.checkout.actions.saveAsFavorite')
6171
- })
6172
- }), status == 'BASE_CONFIGURATION' && /*#__PURE__*/jsx(Button$1, {
6173
- variant: "outlined",
6174
- size: "medium",
6175
- color: "primary",
6176
- disabled: orderEmpty,
6177
- onClick: function onClick() {
6178
- onClickSave(undefined, false, true, true);
6179
- },
6180
- className: classes.margin,
6181
- children: t('basket.checkout.actions.saveAndOrderMedia')
6267
+ children: t('basket.checkout.actions.saveAndOrderMedia')
6268
+ })]
6182
6269
  }), (configSaveButtons === null || configSaveButtons === void 0 ? void 0 : configSaveButtons.includes('NEW')) && /*#__PURE__*/jsx(Button$1, {
6183
6270
  variant: "outlined",
6184
6271
  size: "medium",
6185
6272
  color: "primary",
6186
6273
  onClick: startWithEmptyBasket,
6187
- className: classes.margin,
6274
+ className: classnames(classes.margin, newPlanningButton),
6188
6275
  children: t('basket.checkout.actions.newOrder')
6189
6276
  })]
6190
6277
  });
@@ -6736,10 +6823,107 @@ function InfoAlert(_ref2) {
6736
6823
  });
6737
6824
  }
6738
6825
 
6826
+ function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
6827
+ function _unsupportedIterableToArray$2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0; } }
6828
+ function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
6829
+ var useCheckoutStep3 = function useCheckoutStep3(schema) {
6830
+ var _useState = useState(false),
6831
+ _useState2 = _slicedToArray(_useState, 2),
6832
+ basket3DExportChecked = _useState2[0],
6833
+ setBasket3DExportChecked = _useState2[1];
6834
+ var _useState3 = useState(false),
6835
+ _useState4 = _slicedToArray(_useState3, 2),
6836
+ basketSendMailChecked = _useState4[0],
6837
+ setBasketSendMailChecked = _useState4[1];
6838
+ var _useState5 = useState(false),
6839
+ _useState6 = _slicedToArray(_useState5, 2),
6840
+ basketSendOrderChecked = _useState6[0],
6841
+ setBasketSendOrderChecked = _useState6[1];
6842
+ var setVirtualFields = useCallback(function (key, value) {
6843
+ switch (key) {
6844
+ case 'Order3DExport':
6845
+ setBasket3DExportChecked(value);
6846
+ break;
6847
+ case 'SendMail':
6848
+ setBasketSendMailChecked(value);
6849
+ break;
6850
+ case 'SendOrder':
6851
+ setBasketSendOrderChecked(value);
6852
+ break;
6853
+ }
6854
+ }, []);
6855
+ var getVirtualFields = useCallback(function (key) {
6856
+ switch (key) {
6857
+ case 'Order3DExport':
6858
+ return basket3DExportChecked;
6859
+ case 'SendMail':
6860
+ return basketSendMailChecked;
6861
+ case 'SendOrder':
6862
+ return basketSendOrderChecked;
6863
+ default:
6864
+ return undefined;
6865
+ }
6866
+ }, [basket3DExportChecked, basketSendMailChecked, basketSendOrderChecked]);
6867
+ var getVirtualFieldsObject = useCallback(function () {
6868
+ var virtualFields = {};
6869
+ for (var key in schema.properties) {
6870
+ var _schema$properties;
6871
+ if ((_schema$properties = schema.properties) !== null && _schema$properties !== void 0 && (_schema$properties = _schema$properties[key]) !== null && _schema$properties !== void 0 && (_schema$properties = _schema$properties.properties) !== null && _schema$properties !== void 0 && _schema$properties.virtual) {
6872
+ virtualFields[key] = getVirtualFields(key);
6873
+ }
6874
+ }
6875
+ return virtualFields;
6876
+ }, [getVirtualFields, schema]);
6877
+ function validateRequiredFieldsFromSchema(schema, data) {
6878
+ var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
6879
+ try {
6880
+ var requiredFields = schema.required || [];
6881
+ var _iterator = _createForOfIteratorHelper$2(requiredFields),
6882
+ _step;
6883
+ try {
6884
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
6885
+ var field = _step.value;
6886
+ var value = data === null || data === void 0 ? void 0 : data[field];
6887
+ if (value === undefined || value === null || typeof value === 'string' && value.trim() === '') {
6888
+ return false;
6889
+ }
6890
+ }
6891
+ // Recursive through nested objects
6892
+ } catch (err) {
6893
+ _iterator.e(err);
6894
+ } finally {
6895
+ _iterator.f();
6896
+ }
6897
+ for (var _i = 0, _Object$entries = Object.entries(schema.properties || {}); _i < _Object$entries.length; _i++) {
6898
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
6899
+ key = _Object$entries$_i[0],
6900
+ propSchema = _Object$entries$_i[1];
6901
+ if (propSchema.type === 'object' && data !== null && data !== void 0 && data[key]) {
6902
+ var isValid = validateRequiredFieldsFromSchema(propSchema, data[key], path ? "".concat(path, ".").concat(key) : key);
6903
+ if (!isValid) {
6904
+ return false;
6905
+ }
6906
+ }
6907
+ }
6908
+ return true;
6909
+ } catch (error) {
6910
+ return false;
6911
+ }
6912
+ }
6913
+ return {
6914
+ setVirtualFields: setVirtualFields,
6915
+ getVirtualFields: getVirtualFields,
6916
+ getVirtualFieldsObject: getVirtualFieldsObject,
6917
+ basket3DExportChecked: basket3DExportChecked,
6918
+ basketSendMailChecked: basketSendMailChecked,
6919
+ basketSendOrderChecked: basketSendOrderChecked,
6920
+ validateRequiredFieldsFromSchema: validateRequiredFieldsFromSchema
6921
+ };
6922
+ };
6923
+
6739
6924
  function ownKeys$v(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; }
6740
6925
  function _objectSpread$v(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$v(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$v(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6741
6926
  function CheckOut(_ref) {
6742
- var _basket$Client;
6743
6927
  var schema = _ref.schema,
6744
6928
  uiSchema = _ref.uiSchema,
6745
6929
  renderService = _ref.renderService,
@@ -6756,18 +6940,25 @@ function CheckOut(_ref) {
6756
6940
  saveProduct = _ref.saveProduct,
6757
6941
  updateProductData = _ref.updateProductData,
6758
6942
  gdpr = _ref.gdpr;
6943
+ var _useCheckoutStep = useCheckoutStep3(schema),
6944
+ setVirtualFields = _useCheckoutStep.setVirtualFields,
6945
+ getVirtualFieldsObject = _useCheckoutStep.getVirtualFieldsObject,
6946
+ basket3DExportChecked = _useCheckoutStep.basket3DExportChecked,
6947
+ basketSendMailChecked = _useCheckoutStep.basketSendMailChecked,
6948
+ basketSendOrderChecked = _useCheckoutStep.basketSendOrderChecked,
6949
+ validateRequiredFieldsFromSchema = _useCheckoutStep.validateRequiredFieldsFromSchema;
6759
6950
  var _useState = useState(false),
6760
6951
  _useState2 = _slicedToArray(_useState, 2),
6761
6952
  isSaving = _useState2[0],
6762
6953
  setIsSaving = _useState2[1];
6763
6954
  var _useState3 = useState(false),
6764
6955
  _useState4 = _slicedToArray(_useState3, 2),
6765
- basket3DExportChecked = _useState4[0],
6766
- setBasket3DExportChecked = _useState4[1];
6767
- var _useState5 = useState(false),
6956
+ productSaved = _useState4[0],
6957
+ setProductSaved = _useState4[1];
6958
+ var _useState5 = useState(true),
6768
6959
  _useState6 = _slicedToArray(_useState5, 2),
6769
- productSaved = _useState6[0],
6770
- setProductSaved = _useState6[1];
6960
+ validData = _useState6[0],
6961
+ setValidData = _useState6[1];
6771
6962
  var _useTranslation = useTranslation(),
6772
6963
  t = _useTranslation.t;
6773
6964
  var _useSellerState = useSellerState(),
@@ -6776,8 +6967,7 @@ function CheckOut(_ref) {
6776
6967
  _useDivaCore$actions = _useDivaCore.actions,
6777
6968
  userHasPermission = _useDivaCore$actions.userHasPermission,
6778
6969
  toggleLoading = _useDivaCore$actions.toggleLoading,
6779
- openModal = _useDivaCore$actions.openModal,
6780
- organization = _useDivaCore.state.organization;
6970
+ openModal = _useDivaCore$actions.openModal;
6781
6971
  var handleSave = useCallback(/*#__PURE__*/function () {
6782
6972
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(openPDF, sendMail, isFav) {
6783
6973
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -6815,8 +7005,12 @@ function CheckOut(_ref) {
6815
7005
  return _context.abrupt("return");
6816
7006
  case 17:
6817
7007
  if (!isSaving) {
7008
+ openPDF = 'open';
6818
7009
  setIsSaving(true);
6819
- onClickSave(openPDF, sendMail, basket3DExportChecked)["finally"](function () {
7010
+ if (basketSendMailChecked) {
7011
+ sendMail = true;
7012
+ }
7013
+ onClickSave(openPDF, sendMail, basket3DExportChecked, basketSendOrderChecked)["finally"](function () {
6820
7014
  return setIsSaving(false);
6821
7015
  });
6822
7016
  }
@@ -6829,12 +7023,18 @@ function CheckOut(_ref) {
6829
7023
  return function (_x, _x2, _x3) {
6830
7024
  return _ref2.apply(this, arguments);
6831
7025
  };
6832
- }(), [isSaving, onClickSave, basket3DExportChecked]);
7026
+ }(), [isSaving, onClickSave, basket3DExportChecked, basketSendMailChecked, basketSendOrderChecked, toggleLoading, saveProduct, status, openModal, t]);
6833
7027
  var onChangeForm = function onChangeForm(_ref3) {
6834
7028
  var data = _ref3.data;
6835
7029
  for (var key in data) {
7030
+ var _schema$properties;
7031
+ if ((_schema$properties = schema.properties) !== null && _schema$properties !== void 0 && (_schema$properties = _schema$properties[key]) !== null && _schema$properties !== void 0 && (_schema$properties = _schema$properties.properties) !== null && _schema$properties !== void 0 && _schema$properties.virtual) {
7032
+ setVirtualFields(key, data[key]);
7033
+ continue;
7034
+ }
6836
7035
  basket[key] = data[key];
6837
7036
  }
7037
+ setValidData(validateRequiredFieldsFromSchema(schema, data));
6838
7038
  };
6839
7039
 
6840
7040
  // for LEAFLET don't show printOptions, if there are any configured.
@@ -6849,22 +7049,27 @@ function CheckOut(_ref) {
6849
7049
  finalSchema.elements.splice(index, 1);
6850
7050
  }
6851
7051
  }
7052
+ if (status !== 'ORDER') {
7053
+ var additionalOptions = finalSchema.elements.find(function (e) {
7054
+ return e.key == 'AdditionalOptions';
7055
+ });
7056
+ if (additionalOptions) {
7057
+ var _index = additionalOptions.elements.findIndex(function (e) {
7058
+ return e.key == 'SendOrder';
7059
+ });
7060
+ if (_index >= 0) {
7061
+ additionalOptions.elements.splice(_index, 1);
7062
+ }
7063
+ }
7064
+ }
6852
7065
  var permissionAnyHqRenderBox = userHasPermission('anyhqrenderbox');
6853
- var handleCheckBoxChange = function handleCheckBoxChange(event) {
6854
- setBasket3DExportChecked(event.target.checked);
6855
- };
6856
7066
  return /*#__PURE__*/jsxs("div", {
6857
- style: {
6858
- display: 'flex',
6859
- flexDirection: 'column'
6860
- },
7067
+ id: "checkout3Container",
7068
+ className: checkout3Container,
6861
7069
  children: [/*#__PURE__*/jsxs("div", {
7070
+ id: "checkout3Header",
7071
+ className: checkout3Header,
6862
7072
  children: [/*#__PURE__*/jsx(Typography, {
6863
- style: {
6864
- "float": 'left',
6865
- marginLeft: '50px',
6866
- width: 'fit-content'
6867
- },
6868
7073
  variant: "h4",
6869
7074
  children: "Checkout"
6870
7075
  }), /*#__PURE__*/jsx(StatusMenu, {
@@ -6881,45 +7086,19 @@ function CheckOut(_ref) {
6881
7086
  handleSave: handleSave,
6882
7087
  updateProductData: updateProductData,
6883
7088
  disabled: basket.OrderSets.length > 1
6884
- }), status !== 'BASE_CONFIGURATION' && /*#__PURE__*/jsxs(Fragment, {
6885
- children: [/*#__PURE__*/jsx("div", {
6886
- style: {
6887
- margin: '1rem',
6888
- marginLeft: '50px',
6889
- width: '700px'
6890
- },
6891
- children: /*#__PURE__*/jsx(Form, {
6892
- data: basket,
6893
- onChange: onChangeForm,
6894
- schema: schema,
6895
- uischema: finalSchema,
6896
- renderer: "material"
6897
- })
7089
+ }), status !== 'BASE_CONFIGURATION' && /*#__PURE__*/jsxs("div", {
7090
+ className: checkoutForm,
7091
+ children: [/*#__PURE__*/jsx(Form, {
7092
+ data: _objectSpread$v(_objectSpread$v({}, basket), getVirtualFieldsObject()),
7093
+ onChange: onChangeForm,
7094
+ schema: schema,
7095
+ uischema: finalSchema,
7096
+ renderer: "material"
6898
7097
  }), !!renderService && permissionAnyHqRenderBox && (catalogData === null || catalogData === void 0 ? void 0 : catalogData[0].has3D) && /*#__PURE__*/jsx(HqRenderBox, {
6899
7098
  basket: basket,
6900
7099
  config: renderService
6901
- }), (catalogData === null || catalogData === void 0 ? void 0 : catalogData.find(function (c) {
6902
- return !c.disable3DExport;
6903
- })) && (catalogData === null || catalogData === void 0 ? void 0 : catalogData.find(function (c) {
6904
- return c.has3D;
6905
- })) && organization.settings.enable3DExport && /*#__PURE__*/jsxs("div", {
6906
- style: {
6907
- marginLeft: '50px',
6908
- width: '700px'
6909
- },
6910
- children: [/*#__PURE__*/jsx(FormControlLabel$1, {
6911
- control: /*#__PURE__*/jsx(Checkbox$1, {
6912
- onChange: handleCheckBoxChange
6913
- }),
6914
- label: t('basket.checkout.order3dexport')
6915
- }), /*#__PURE__*/jsxs(Typography, {
6916
- variant: "caption",
6917
- children: ["(", t('basket.checkout.3dexport'), ")"]
6918
- })]
6919
- }), gdpr && !isEmpty(basket === null || basket === void 0 ? void 0 : basket.Client) && /*#__PURE__*/jsx(FormControlLabel$1, {
6920
- style: {
6921
- marginLeft: '40px'
6922
- },
7100
+ }), gdpr && !isEmpty$1(basket === null || basket === void 0 ? void 0 : basket.Client) && /*#__PURE__*/jsx(FormControlLabel$1, {
7101
+ className: gdprCheckbox,
6923
7102
  label: t('basket.checkout.gdpr'),
6924
7103
  control: /*#__PURE__*/jsx(Checkbox$1, {
6925
7104
  checked: basket === null || basket === void 0 ? void 0 : basket.Gdpr,
@@ -6930,17 +7109,20 @@ function CheckOut(_ref) {
6930
7109
  })
6931
7110
  })]
6932
7111
  })]
6933
- }), status !== 'BASE_CONFIGURATION' && /*#__PURE__*/jsx(SaveButtonsGroup, {
6934
- orderEmpty: !basket.OrderSets || basket.OrderSets.length == 0 || gdpr && !isEmpty(basket === null || basket === void 0 ? void 0 : basket.Client) && !basket.Gdpr,
6935
- onClickSave: handleSave,
6936
- startWithEmptyBasket: startWithEmptyBasket,
6937
- status: status,
6938
- configSaveButtons: configSaveButtons,
6939
- userInfoPresent: !!((_basket$Client = basket.Client) !== null && _basket$Client !== void 0 && _basket$Client.email)
7112
+ }), status !== 'BASE_CONFIGURATION' && /*#__PURE__*/jsx("div", {
7113
+ className: saveButtonGroup,
7114
+ children: /*#__PURE__*/jsx(SaveButtonsGroup, {
7115
+ orderEmpty: !basket.OrderSets || basket.OrderSets.length == 0 || gdpr && !isEmpty$1(basket === null || basket === void 0 ? void 0 : basket.Client) && !basket.Gdpr,
7116
+ onClickSave: handleSave,
7117
+ startWithEmptyBasket: startWithEmptyBasket,
7118
+ status: status,
7119
+ configSaveButtons: configSaveButtons,
7120
+ validData: validData
7121
+ })
6940
7122
  })]
6941
7123
  });
6942
7124
  }
6943
- function isEmpty(data) {
7125
+ function isEmpty$1(data) {
6944
7126
  if (!data) {
6945
7127
  return true;
6946
7128
  }
@@ -6950,16 +7132,17 @@ function isEmpty(data) {
6950
7132
  return false;
6951
7133
  }
6952
7134
  return Object.keys(data).every(function (k) {
6953
- return isEmpty(data[k]);
7135
+ return isEmpty$1(data[k]);
6954
7136
  });
6955
7137
  }
6956
7138
 
6957
7139
  function ownKeys$u(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; }
6958
7140
  function _objectSpread$u(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$u(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$u(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6959
- var schema = function schema(hideWWSButton) {
7141
+ var schema = function schema(settings) {
7142
+ var _settings$sendMail, _settings$sendMail2;
6960
7143
  return {
6961
7144
  type: 'object',
6962
- properties: _objectSpread$u(_objectSpread$u({
7145
+ properties: _objectSpread$u(_objectSpread$u(_objectSpread$u(_objectSpread$u(_objectSpread$u({
6963
7146
  Salesperson: {
6964
7147
  type: 'string',
6965
7148
  title: 'basket.checkout.form.seller'
@@ -6988,11 +7171,37 @@ var schema = function schema(hideWWSButton) {
6988
7171
  type: ['string', 'null'],
6989
7172
  title: 'basket.checkout.form.sellerNr'
6990
7173
  }
6991
- }, !hideWWSButton ? {
7174
+ }, !settings.hideWWSButton ? {
6992
7175
  SendIWOBasket: {
6993
7176
  type: 'boolean',
6994
7177
  title: 'basket.checkout.form.sendIwoBasket'
6995
7178
  }
7179
+ } : {}), settings.show3dExport ? {
7180
+ Order3DExport: {
7181
+ type: 'boolean',
7182
+ title: 'basket.checkout.order3dexport',
7183
+ description: 'basket.checkout.3dexport',
7184
+ properties: {
7185
+ virtual: true
7186
+ }
7187
+ }
7188
+ } : {}), (_settings$sendMail = settings.sendMail) !== null && _settings$sendMail !== void 0 && _settings$sendMail.show ? {
7189
+ SendMail: {
7190
+ type: 'boolean',
7191
+ title: 'basket.checkout.form.sendMail',
7192
+ readOnly: (_settings$sendMail2 = settings.sendMail) === null || _settings$sendMail2 === void 0 ? void 0 : _settings$sendMail2.disabled,
7193
+ properties: {
7194
+ virtual: true
7195
+ }
7196
+ }
7197
+ } : {}), settings.showSendOrder ? {
7198
+ SendOrder: {
7199
+ type: 'boolean',
7200
+ title: 'basket.checkout.form.sendOrder',
7201
+ properties: {
7202
+ virtual: true
7203
+ }
7204
+ }
6996
7205
  } : {}), {}, {
6997
7206
  PrintOptions: {
6998
7207
  type: 'object',
@@ -7046,154 +7255,222 @@ var schema = function schema(hideWWSButton) {
7046
7255
  })
7047
7256
  };
7048
7257
  };
7049
- var uiSchema = function uiSchema(hideWWSButton, enableSellerInfos) {
7258
+ var uiSchema = function uiSchema(settings) {
7050
7259
  return {
7051
7260
  type: 'VerticalLayout',
7052
7261
  elements: [{
7053
- type: 'HorizontalLayout',
7262
+ key: 'BasicData',
7263
+ type: 'Group',
7264
+ label: 'basket.checkout.form.basicData',
7054
7265
  elements: [{
7055
- type: 'Control',
7056
- scope: '#/properties/RetailerOfferNum'
7057
- }, {
7058
- type: 'Control',
7059
- scope: '#/properties/RetailerName',
7060
- rule: {
7061
- effect: 'ENABLE',
7062
- condition: {
7063
- scope: '#/properties/RetailerName',
7064
- schema: {
7065
- "const": '----'
7066
- }
7067
- }
7068
- }
7069
- }, {
7070
- type: 'Control',
7071
- scope: '#/properties/RetailerNr',
7072
- rule: {
7073
- effect: 'ENABLE',
7074
- condition: {
7075
- scope: '#/properties/RetailerName',
7076
- schema: {
7077
- "const": '----'
7266
+ type: 'HorizontalLayout',
7267
+ elements: [{
7268
+ type: 'Control',
7269
+ scope: '#/properties/RetailerOfferNum'
7270
+ }, {
7271
+ type: 'Control',
7272
+ scope: '#/properties/RetailerName',
7273
+ rule: {
7274
+ effect: 'ENABLE',
7275
+ condition: {
7276
+ scope: '#/properties/RetailerName',
7277
+ schema: {
7278
+ "const": '----'
7279
+ }
7078
7280
  }
7079
7281
  }
7080
- }
7081
- }]
7082
- }, {
7083
- type: 'HorizontalLayout',
7084
- elements: [{
7085
- type: 'Control',
7086
- scope: '#/properties/Salesperson',
7087
- rule: !enableSellerInfos ? {
7088
- effect: 'ENABLE',
7089
- condition: {
7090
- scope: '#/properties/RetailerName',
7091
- schema: {
7092
- "const": '----'
7282
+ }, {
7283
+ type: 'Control',
7284
+ scope: '#/properties/RetailerNr',
7285
+ rule: {
7286
+ effect: 'ENABLE',
7287
+ condition: {
7288
+ scope: '#/properties/RetailerName',
7289
+ schema: {
7290
+ "const": '----'
7291
+ }
7093
7292
  }
7094
7293
  }
7095
- } : undefined
7294
+ }]
7096
7295
  }, {
7097
- type: 'Control',
7098
- scope: '#/properties/SalespersonEmail',
7099
- rule: !enableSellerInfos ? {
7100
- effect: 'ENABLE',
7101
- condition: {
7102
- scope: '#/properties/RetailerName',
7103
- schema: {
7104
- "const": '----'
7296
+ type: 'HorizontalLayout',
7297
+ elements: [{
7298
+ type: 'Control',
7299
+ scope: '#/properties/Salesperson',
7300
+ rule: !settings.enableSellerInfos ? {
7301
+ effect: 'ENABLE',
7302
+ condition: {
7303
+ scope: '#/properties/RetailerName',
7304
+ schema: {
7305
+ "const": '----'
7306
+ }
7105
7307
  }
7106
- }
7107
- } : undefined
7308
+ } : undefined
7309
+ }, {
7310
+ type: 'Control',
7311
+ scope: '#/properties/SalespersonEmail',
7312
+ rule: !settings.enableSellerInfos ? {
7313
+ effect: 'ENABLE',
7314
+ condition: {
7315
+ scope: '#/properties/RetailerName',
7316
+ schema: {
7317
+ "const": '----'
7318
+ }
7319
+ }
7320
+ } : undefined
7321
+ }, {
7322
+ type: 'Control',
7323
+ scope: '#/properties/SalespersonNr',
7324
+ rule: !settings.enableSellerInfos ? {
7325
+ effect: 'ENABLE',
7326
+ condition: {
7327
+ scope: '#/properties/RetailerName',
7328
+ schema: {
7329
+ "const": '----'
7330
+ }
7331
+ }
7332
+ } : undefined
7333
+ }]
7108
7334
  }, {
7109
7335
  type: 'Control',
7110
- scope: '#/properties/SalespersonNr',
7111
- rule: !enableSellerInfos ? {
7112
- effect: 'ENABLE',
7113
- condition: {
7114
- scope: '#/properties/RetailerName',
7115
- schema: {
7116
- "const": '----'
7117
- }
7118
- }
7119
- } : undefined
7336
+ scope: '#/properties/ClientRemark',
7337
+ options: {
7338
+ multi: true
7339
+ }
7120
7340
  }]
7121
7341
  }, {
7122
- type: 'Control',
7123
- scope: '#/properties/ClientRemark',
7124
- options: {
7125
- multi: true
7126
- }
7127
- }, {
7128
- key: 'PrintOptions',
7129
- type: 'Group',
7130
- label: 'basket.checkout.form.printOptions',
7342
+ type: 'HorizontalLayout',
7131
7343
  elements: [{
7132
- type: 'HorizontalLayout',
7344
+ key: 'PrintOptions',
7345
+ type: 'Group',
7346
+ label: 'basket.checkout.form.printOptions',
7133
7347
  elements: [{
7134
- type: 'VerticalLayout',
7348
+ type: 'HorizontalLayout',
7135
7349
  elements: [{
7136
- type: 'Control',
7137
- scope: '#/properties/PrintOptions/properties/PlanningSketch'
7138
- }, {
7139
- type: 'Control',
7140
- scope: '#/properties/PrintOptions/properties/Remark'
7350
+ type: 'VerticalLayout',
7351
+ elements: [{
7352
+ type: 'Control',
7353
+ scope: '#/properties/PrintOptions/properties/PlanningSketch'
7354
+ }]
7141
7355
  }, {
7142
- type: 'Control',
7143
- scope: '#/properties/PrintOptions/properties/Signature'
7144
- }, {
7145
- type: 'Control',
7146
- scope: '#/properties/PrintOptions/properties/SalespersonData'
7356
+ type: 'VerticalLayout',
7357
+ elements: [{
7358
+ type: 'Control',
7359
+ scope: '#/properties/PrintOptions/properties/ModelName'
7360
+ }]
7147
7361
  }]
7148
7362
  }, {
7149
- type: 'VerticalLayout',
7363
+ type: 'HorizontalLayout',
7150
7364
  elements: [{
7151
- type: 'Control',
7152
- scope: '#/properties/PrintOptions/properties/ModelName'
7153
- }, {
7154
- type: 'Control',
7155
- scope: '#/properties/PrintOptions/properties/Gdpr'
7365
+ type: 'VerticalLayout',
7366
+ elements: [{
7367
+ type: 'Control',
7368
+ scope: '#/properties/PrintOptions/properties/CollectionLogo'
7369
+ }]
7156
7370
  }, {
7157
- type: 'Control',
7158
- scope: '#/properties/PrintOptions/properties/Prices'
7371
+ type: 'VerticalLayout',
7372
+ elements: [{
7373
+ type: 'Control',
7374
+ scope: '#/properties/PrintOptions/properties/Remark'
7375
+ }]
7376
+ }]
7377
+ }, {
7378
+ type: 'HorizontalLayout',
7379
+ elements: [{
7380
+ type: 'VerticalLayout',
7381
+ elements: [{
7382
+ type: 'Control',
7383
+ scope: '#/properties/PrintOptions/properties/ClientpersonData'
7384
+ }]
7159
7385
  }, {
7160
- type: 'Control',
7161
- scope: '#/properties/PrintOptions/properties/OpvCodices'
7386
+ type: 'VerticalLayout',
7387
+ elements: [{
7388
+ type: 'Control',
7389
+ scope: '#/properties/PrintOptions/properties/Signature'
7390
+ }]
7162
7391
  }]
7163
7392
  }, {
7164
- type: 'VerticalLayout',
7393
+ type: 'HorizontalLayout',
7165
7394
  elements: [{
7166
- type: 'Control',
7167
- scope: '#/properties/PrintOptions/properties/CollectionLogo'
7395
+ type: 'VerticalLayout',
7396
+ elements: [{
7397
+ type: 'Control',
7398
+ scope: '#/properties/PrintOptions/properties/Gdpr'
7399
+ }]
7168
7400
  }, {
7169
- type: 'Control',
7170
- scope: '#/properties/PrintOptions/properties/ClientpersonData'
7401
+ type: 'VerticalLayout',
7402
+ elements: []
7403
+ }]
7404
+ }, {
7405
+ type: 'HorizontalLayout',
7406
+ elements: [{
7407
+ type: 'VerticalLayout',
7408
+ elements: [{
7409
+ type: 'Control',
7410
+ scope: '#/properties/PrintOptions/properties/Prices'
7411
+ }]
7171
7412
  }, {
7172
- type: 'Control',
7173
- scope: '#/properties/PrintOptions/properties/AllPrices',
7174
- rule: {
7175
- effect: 'HIDE',
7176
- condition: {
7177
- scope: '#/properties/PrintOptions/properties/Prices',
7178
- schema: {
7179
- not: {
7180
- "const": true
7413
+ type: 'VerticalLayout',
7414
+ elements: [{
7415
+ type: 'Control',
7416
+ scope: '#/properties/PrintOptions/properties/AllPrices',
7417
+ rule: {
7418
+ effect: 'HIDE',
7419
+ condition: {
7420
+ scope: '#/properties/PrintOptions/properties/Prices',
7421
+ schema: {
7422
+ not: {
7423
+ "const": true
7424
+ }
7181
7425
  }
7182
7426
  }
7183
7427
  }
7184
- }
7428
+ }]
7429
+ }]
7430
+ }, {
7431
+ type: 'HorizontalLayout',
7432
+ elements: [{
7433
+ type: 'VerticalLayout',
7434
+ elements: [{
7435
+ type: 'Control',
7436
+ scope: '#/properties/PrintOptions/properties/SalespersonData'
7437
+ }]
7438
+ }, {
7439
+ type: 'VerticalLayout',
7440
+ elements: [{
7441
+ type: 'Control',
7442
+ scope: '#/properties/PrintOptions/properties/OpvCodices'
7443
+ }]
7185
7444
  }]
7186
7445
  }]
7446
+ }, {
7447
+ key: 'AdditionalOptions',
7448
+ type: 'Group',
7449
+ label: 'basket.checkout.form.additionalOptions',
7450
+ elements: [].concat(_toConsumableArray(!settings.hideWWSButton ? [{
7451
+ type: 'Control',
7452
+ scope: '#/properties/SendIWOBasket'
7453
+ }] : []), _toConsumableArray(settings.showSendOrder ? [{
7454
+ key: 'SendOrder',
7455
+ type: 'Control',
7456
+ scope: '#/properties/SendOrder'
7457
+ }] : []), _toConsumableArray(settings.show3dExport ? [{
7458
+ type: 'Control',
7459
+ scope: '#/properties/Order3DExport',
7460
+ options: {
7461
+ showUnfocusedDescription: true
7462
+ }
7463
+ }] : []), [{
7464
+ type: 'Control',
7465
+ scope: '#/properties/SendMail'
7466
+ }])
7187
7467
  }]
7188
- }].concat(_toConsumableArray(!hideWWSButton ? [{
7189
- type: 'Control',
7190
- scope: '#/properties/SendIWOBasket'
7191
- }] : []))
7468
+ }]
7192
7469
  };
7193
7470
  };
7194
7471
 
7195
7472
  function Step3Checkout(_ref) {
7196
- var _config$checkout, _config$checkout2, _config$checkout3, _config$checkout4, _config$checkout5;
7473
+ var _config$checkout, _config$checkout2, _basket$Client, _config$checkout3, _config$checkout4, _config$checkout5, _config$checkout6;
7197
7474
  var updateBasket = _ref.updateBasket,
7198
7475
  startWithEmptyBasket = _ref.startWithEmptyBasket,
7199
7476
  onClickSave = _ref.onClickSave,
@@ -7208,6 +7485,25 @@ function Step3Checkout(_ref) {
7208
7485
  updateProductData = _ref.updateProductData;
7209
7486
  var _useDivaCore = useDivaCore(),
7210
7487
  organization = _useDivaCore.state.organization;
7488
+ var _useSellerState = useSellerState$1(),
7489
+ catalogData = _useSellerState.state.catalogData;
7490
+ var configSaveButtons = (config === null || config === void 0 || (_config$checkout = config.checkout) === null || _config$checkout === void 0 ? void 0 : _config$checkout.saveButtons) || ['SAVE', 'SAVE_AND_SEND', 'NEW'];
7491
+ var orderEmpty = !basket.OrderSets || basket.OrderSets.length == 0 || (config === null || config === void 0 || (_config$checkout2 = config.checkout) === null || _config$checkout2 === void 0 ? void 0 : _config$checkout2.checkGdpr) && !isEmpty(basket === null || basket === void 0 ? void 0 : basket.Client) && !basket.Gdpr;
7492
+ var userInfoPresent = !!((_basket$Client = basket.Client) !== null && _basket$Client !== void 0 && _basket$Client.email);
7493
+ var schemaSettings = {
7494
+ hideWWSButton: !organization.hasIwoFurn,
7495
+ enableSellerInfos: config === null || config === void 0 ? void 0 : config.enableSellerInfos,
7496
+ show3dExport: (catalogData === null || catalogData === void 0 ? void 0 : catalogData.find(function (c) {
7497
+ return !c.disable3DExport;
7498
+ })) && (catalogData === null || catalogData === void 0 ? void 0 : catalogData.find(function (c) {
7499
+ return c.has3D;
7500
+ })) && organization.settings.enable3DExport,
7501
+ showSendOrder: organization.settings.sendOrders ? true : false,
7502
+ sendMail: {
7503
+ show: configSaveButtons.includes('SAVE_AND_SEND'),
7504
+ disabled: orderEmpty || !userInfoPresent
7505
+ }
7506
+ };
7211
7507
  return /*#__PURE__*/jsx(CheckOut, {
7212
7508
  startWithEmptyBasket: startWithEmptyBasket,
7213
7509
  onClickSave: onClickSave,
@@ -7215,18 +7511,31 @@ function Step3Checkout(_ref) {
7215
7511
  setStatus: setStatus,
7216
7512
  basket: basket,
7217
7513
  statusArray: statusArray,
7218
- schema: (config === null || config === void 0 || (_config$checkout = config.checkout) === null || _config$checkout === void 0 ? void 0 : _config$checkout.schema) || schema(!organization.hasIwoFurn),
7219
- uiSchema: (config === null || config === void 0 || (_config$checkout2 = config.checkout) === null || _config$checkout2 === void 0 ? void 0 : _config$checkout2.uiSchema) || uiSchema(!organization.hasIwoFurn, config === null || config === void 0 ? void 0 : config.enableSellerInfos),
7514
+ schema: (config === null || config === void 0 || (_config$checkout3 = config.checkout) === null || _config$checkout3 === void 0 ? void 0 : _config$checkout3.schema) || schema(schemaSettings),
7515
+ uiSchema: (config === null || config === void 0 || (_config$checkout4 = config.checkout) === null || _config$checkout4 === void 0 ? void 0 : _config$checkout4.uiSchema) || uiSchema(schemaSettings),
7220
7516
  updateBasket: updateBasket,
7221
- renderService: config === null || config === void 0 || (_config$checkout3 = config.checkout) === null || _config$checkout3 === void 0 ? void 0 : _config$checkout3.renderService,
7222
- configSaveButtons: (config === null || config === void 0 || (_config$checkout4 = config.checkout) === null || _config$checkout4 === void 0 ? void 0 : _config$checkout4.saveButtons) || ['SAVE', 'SAVE_AND_OPEN', 'SAVE_AND_SEND', 'NEW'],
7223
- gdpr: config === null || config === void 0 || (_config$checkout5 = config.checkout) === null || _config$checkout5 === void 0 ? void 0 : _config$checkout5.checkGdpr,
7517
+ renderService: config === null || config === void 0 || (_config$checkout5 = config.checkout) === null || _config$checkout5 === void 0 ? void 0 : _config$checkout5.renderService,
7518
+ configSaveButtons: configSaveButtons,
7519
+ gdpr: config === null || config === void 0 || (_config$checkout6 = config.checkout) === null || _config$checkout6 === void 0 ? void 0 : _config$checkout6.checkGdpr,
7224
7520
  currentProduct: currentProduct,
7225
7521
  productIsLoading: productIsLoading,
7226
7522
  saveProduct: saveProduct,
7227
7523
  updateProductData: updateProductData
7228
7524
  });
7229
7525
  }
7526
+ function isEmpty(data) {
7527
+ if (!data) {
7528
+ return true;
7529
+ }
7530
+ if (Object.keys(data).length === 0 && data.constructor === Object) {
7531
+ return true;
7532
+ } else if (data.constructor !== Object) {
7533
+ return false;
7534
+ }
7535
+ return Object.keys(data).every(function (k) {
7536
+ return isEmpty(data[k]);
7537
+ });
7538
+ }
7230
7539
 
7231
7540
  function Step4Checkout(_ref) {
7232
7541
  var currentProduct = _ref.currentProduct,
@@ -7483,7 +7792,8 @@ function Basket(_ref) {
7483
7792
  openBasket = _useSellerState$actio.openBasket,
7484
7793
  openModal = _useSellerState$actio.openModal,
7485
7794
  sendEmail = _useSellerState$actio.sendEmail,
7486
- resetBasketState = _useSellerState$actio.resetBasketState;
7795
+ resetBasketState = _useSellerState$actio.resetBasketState,
7796
+ setOrdered = _useSellerState$actio.setOrdered;
7487
7797
  var _useProduct = useProduct(currentBasketState === null || currentBasketState === void 0 ? void 0 : currentBasketState.basket),
7488
7798
  currentProduct = _useProduct.currentProduct,
7489
7799
  saveProduct = _useProduct.saveProduct,
@@ -7639,7 +7949,7 @@ function Basket(_ref) {
7639
7949
  }
7640
7950
  };
7641
7951
  var onClickSave = /*#__PURE__*/function () {
7642
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(pdf, doSendEmail, export3D) {
7952
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(pdf, doSendEmail, export3D, sendOrder) {
7643
7953
  var _configurationData$Ch, _configurationData$re;
7644
7954
  var getPdf, response, _configurationData$Ch2, _ref3, pdfUrl, idx, o, d3dp, newRenderJob, _configurationData$Ch3, _configurationData$Ch4, _currentBasket$Client, _opener;
7645
7955
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -7663,7 +7973,7 @@ function Basket(_ref) {
7663
7973
  break;
7664
7974
  }
7665
7975
  errorOnSaving(response);
7666
- _context.next = 41;
7976
+ _context.next = 44;
7667
7977
  break;
7668
7978
  case 12:
7669
7979
  _ref3 = response, pdfUrl = _ref3.pdfUrl;
@@ -7741,11 +8051,25 @@ function Basket(_ref) {
7741
8051
  autoHideDuration: (_configurationData$Ch3 = configurationData === null || configurationData === void 0 || (_configurationData$Ch4 = configurationData.Checkout) === null || _configurationData$Ch4 === void 0 ? void 0 : _configurationData$Ch4.pdfQRAutoHideDuration) !== null && _configurationData$Ch3 !== void 0 ? _configurationData$Ch3 : 1000 * 60 * 2
7742
8052
  });
7743
8053
  }
8054
+ if (!sendOrder) {
8055
+ _context.next = 40;
8056
+ break;
8057
+ }
8058
+ _context.next = 40;
8059
+ return setOrdered(currentBasket, true);
8060
+ case 40:
7744
8061
  if (doSendEmail) {
7745
8062
  sendEmail({
7746
8063
  dialogText: t('basket.modals.email.text', {
7747
8064
  divaNr: currentBasket.DivaNr + '-' + currentBasket.getDocumentVersion()
7748
8065
  }),
8066
+ showDialog: true,
8067
+ dialogAcceptMailSend: pdf == 'open' ? t('modals.open_pdf_now') : undefined,
8068
+ mailSendCallback: function mailSendCallback() {
8069
+ if (pdf == 'open') {
8070
+ window.open(pdfUrl, '_blank');
8071
+ }
8072
+ },
7749
8073
  content: {
7750
8074
  type: 'basket',
7751
8075
  to: ((_currentBasket$Client = currentBasket.Client) === null || _currentBasket$Client === void 0 ? void 0 : _currentBasket$Client.email) || '',
@@ -7762,17 +8086,19 @@ function Basket(_ref) {
7762
8086
  }, '*');
7763
8087
  window.close();
7764
8088
  } else {
7765
- openModal({
7766
- title: t('modals.saving'),
7767
- reject: false,
7768
- accept: pdf == 'open' ? t('modals.open_now') : true,
7769
- text: t('modals.saving_successful').replace('%1', currentBasket.DivaNr + '-' + currentBasket.getDocumentVersion()),
7770
- callback: function callback() {
7771
- if (pdf == 'open') {
7772
- window.open(pdfUrl, '_blank');
8089
+ if (!sendOrder) {
8090
+ openModal({
8091
+ title: t('modals.saving'),
8092
+ reject: t('modals.close'),
8093
+ accept: pdf == 'open' ? t('modals.open_now') : true,
8094
+ text: t('modals.saving_successful').replace('%1', currentBasket.DivaNr + '-' + currentBasket.getDocumentVersion()),
8095
+ callback: function callback(accepted) {
8096
+ if (accepted && pdf == 'open') {
8097
+ window.open(pdfUrl, '_blank');
8098
+ }
7773
8099
  }
7774
- }
7775
- });
8100
+ });
8101
+ }
7776
8102
  }
7777
8103
  /* TODO used with SM integration in divaProtal
7778
8104
  openModal({
@@ -7796,13 +8122,13 @@ function Basket(_ref) {
7796
8122
  });
7797
8123
  currentBasket.setDocumentVersion(currentBasket.getDocumentVersion() + 1);
7798
8124
  setActBasketPage('Step1');
7799
- case 41:
8125
+ case 44:
7800
8126
  case "end":
7801
8127
  return _context.stop();
7802
8128
  }
7803
8129
  }, _callee, null, [[14, 32]]);
7804
8130
  }));
7805
- return function onClickSave(_x, _x2, _x3) {
8131
+ return function onClickSave(_x, _x2, _x3, _x4) {
7806
8132
  return _ref2.apply(this, arguments);
7807
8133
  };
7808
8134
  }();