@crystaldesign/diva-navigator 25.13.0-beta.9 → 25.14.0-beta.1

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.
@@ -14,8 +14,9 @@ import Switch from 'react-switch';
14
14
  import Dropdown from 'react-dropdown';
15
15
  import { md5 } from '@crystaldesign/diva-utils';
16
16
  import _typeof from '@babel/runtime/helpers/typeof';
17
+ import { Alert, Button as Button$1, Stack, Paper, Typography, Divider, TextField } from '@mui/material';
18
+ import SearchIcon from '@mui/icons-material/Search';
17
19
  import { Html5Qrcode } from 'html5-qrcode';
18
- import { Alert } from '@mui/material';
19
20
  import Snowfall from 'react-snowfall';
20
21
 
21
22
  (function() {
@@ -2014,12 +2015,13 @@ var OrganizationName = function OrganizationName(_ref) {
2014
2015
  };
2015
2016
 
2016
2017
  var button = "button-gd-lv";
2018
+ var label = "label-tExJZ";
2017
2019
  var scannerIcon = "scanner-icon-ve-jf";
2018
2020
  var scannerPlaceholder = "scanner-placeholder-HFpri";
2019
2021
  var scanner = "scanner-8R-jp";
2020
2022
  var hidden = "hidden-C49rQ";
2021
2023
  var wrapper$1 = "wrapper-urPnU";
2022
- var css_248z$3 = ".button-gd-lv {\n margin: 12px 22px;\n height: 35px;\n min-width: 35px;\n cursor: pointer;\n transition: background-color ease-in-out 0.2s;\n -webkit-mask: url(\"data:image/svg+xml,%3Csvg enable-background%3D%22new 0 0 24 24%22 height%3D%2224%22 viewBox%3D%220 0 24 24%22 width%3D%2224%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath d%3D%22m0 0h24v24h-24z%22 fill%3D%22none%22%2F%3E%3Cpath d%3D%22m9.5 6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-1.5 9.5v3h-3v-3zm1.5-1.5h-6v6h6zm6.5-6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-6 8h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm-3 3h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm0 3h1.5v1.5h-1.5zm4.5-10.5h-2v-3h-3v-2h5zm0 15v-5h-2v3h-3v2zm-20 0h5v-2h-3v-3h-2zm0-20v5h2v-3h3v-2z%22%2F%3E%3C%2Fsvg%3E\");\n mask: url(\"data:image/svg+xml,%3Csvg enable-background%3D%22new 0 0 24 24%22 height%3D%2224%22 viewBox%3D%220 0 24 24%22 width%3D%2224%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath d%3D%22m0 0h24v24h-24z%22 fill%3D%22none%22%2F%3E%3Cpath d%3D%22m9.5 6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-1.5 9.5v3h-3v-3zm1.5-1.5h-6v6h6zm6.5-6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-6 8h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm-3 3h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm0 3h1.5v1.5h-1.5zm4.5-10.5h-2v-3h-3v-2h5zm0 15v-5h-2v3h-3v2zm-20 0h5v-2h-3v-3h-2zm0-20v5h2v-3h3v-2z%22%2F%3E%3C%2Fsvg%3E\");\n background-color: black;\n -webkit-mask-size: cover;\n mask-size: cover;\n}\n.diva-component-DIVA_BACKOFFICE_NEW #diva-header.darkmode .button-gd-lv {\n background-color: white;\n}\n\n.button-gd-lv:hover {\n background-color: var(--diva-theme-palette-primary-main);\n}\n\n.scanner-icon-ve-jf {\n background-image: url(\"data:image/svg+xml,%3Csvg enable-background%3D%22new 0 0 24 24%22 height%3D%2224%22 viewBox%3D%220 0 24 24%22 width%3D%2224%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath d%3D%22m0 0h24v24h-24z%22 fill%3D%22none%22%2F%3E%3Cpath d%3D%22m9.5 6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-1.5 9.5v3h-3v-3zm1.5-1.5h-6v6h6zm6.5-6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-6 8h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm-3 3h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm0 3h1.5v1.5h-1.5zm4.5-10.5h-2v-3h-3v-2h5zm0 15v-5h-2v3h-3v2zm-20 0h5v-2h-3v-3h-2zm0-20v5h2v-3h3v-2z%22%2F%3E%3C%2Fsvg%3E\");\n background-repeat: no-repeat;\n background-size: contain;\n height: 100px;\n width: 100px;\n margin: 10px 0;\n}\n\n.scanner-placeholder-HFpri {\n margin: 0 auto;\n width: -moz-fit-content;\n width: fit-content;\n display: flex;\n flex-direction: column;\n align-items: center;\n}\n\n.scanner-8R-jp {\n width: 600px;\n max-width: 100%;\n margin-top: 10px;\n}\n\n.hidden-C49rQ {\n display: none;\n}\n\n.wrapper-urPnU {\n margin-top: -20px;\n}\n";
2024
+ var css_248z$3 = ".button-gd-lv {\n min-width: 0 !important;\n}\n\n.button-gd-lv {\n margin: 0 16px;\n text-wrap: nowrap;\n overflow: hidden;\n max-width: 40px;\n transition: max-width 200ms ease;\n}\n\n.button-gd-lv .MuiButton-startIcon {\n margin-right: 0;\n margin-left: 0;\n transition: margin-right 200ms ease;\n}\n\n.label-tExJZ {\n display: inline-block;\n opacity: 0;\n width: 0;\n white-space: nowrap;\n overflow: hidden;\n margin-left: 0;\n transition:\n opacity 150ms ease,\n width 200ms ease,\n margin-left 200ms ease;\n}\n\n.button-gd-lv:hover {\n max-width: 240px;\n}\n\n.button-gd-lv:hover .MuiButton-startIcon {\n margin-right: 8px;\n}\n\n.button-gd-lv:hover .label-tExJZ {\n opacity: 1;\n width: auto;\n margin-left: 4px;\n}\n\n.scanner-icon-ve-jf {\n background-image: url(\"data:image/svg+xml,%3Csvg enable-background%3D%22new 0 0 24 24%22 height%3D%2224%22 viewBox%3D%220 0 24 24%22 width%3D%2224%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath d%3D%22m0 0h24v24h-24z%22 fill%3D%22none%22%2F%3E%3Cpath d%3D%22m9.5 6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-1.5 9.5v3h-3v-3zm1.5-1.5h-6v6h6zm6.5-6.5v3h-3v-3zm1.5-1.5h-6v6h6zm-6 8h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm-3 3h1.5v1.5h-1.5zm1.5 1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm1.5-1.5h1.5v1.5h-1.5zm0 3h1.5v1.5h-1.5zm4.5-10.5h-2v-3h-3v-2h5zm0 15v-5h-2v3h-3v2zm-20 0h5v-2h-3v-3h-2zm0-20v5h2v-3h3v-2z%22%2F%3E%3C%2Fsvg%3E\");\n background-repeat: no-repeat;\n background-size: contain;\n height: 100px;\n width: 100px;\n margin: 10px 0;\n}\n\n.scanner-placeholder-HFpri {\n margin: 0 auto;\n width: -moz-fit-content;\n width: fit-content;\n display: flex;\n flex-direction: column;\n align-items: center;\n}\n\n.scanner-8R-jp {\n width: 600px;\n max-width: 100%;\n margin-top: 10px;\n}\n\n.hidden-C49rQ {\n display: none;\n}\n\n.wrapper-urPnU {\n margin-top: -20px;\n}\n";
2023
2025
  styleInject(css_248z$3);
2024
2026
 
2025
2027
  var LOG$1 = getLogger('Framework', 'QrCoedScanner');
@@ -2082,6 +2084,13 @@ function matchDivaNr(url) {
2082
2084
  function matchProduct(_x, _x2, _x3) {
2083
2085
  return _matchProduct.apply(this, arguments);
2084
2086
  }
2087
+
2088
+ /**
2089
+ * Gets the product by the given divaNr.
2090
+ *
2091
+ * @param divaNr The divaNr to get the product for
2092
+ * @param apiGetProductByFilter The function to get the product by filter
2093
+ */
2085
2094
  function _matchProduct() {
2086
2095
  _matchProduct = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, shopBaseUrl, apiGetProductByFilter) {
2087
2096
  var _product$data$;
@@ -2184,6 +2193,77 @@ function _matchProduct() {
2184
2193
  }));
2185
2194
  return _matchProduct.apply(this, arguments);
2186
2195
  }
2196
+ function getProductByDivaNr(_x4, _x5) {
2197
+ return _getProductByDivaNr.apply(this, arguments);
2198
+ }
2199
+ function _getProductByDivaNr() {
2200
+ _getProductByDivaNr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(divaNr, apiGetProductByFilter) {
2201
+ var _product$data$2;
2202
+ var filter, product;
2203
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
2204
+ while (1) switch (_context2.prev = _context2.next) {
2205
+ case 0:
2206
+ filter = [{
2207
+ id: 'divaNr',
2208
+ op: 'eq',
2209
+ value: divaNr
2210
+ }, {
2211
+ id: 'baseProduct',
2212
+ op: 'eq',
2213
+ value: false
2214
+ }];
2215
+ _context2.next = 3;
2216
+ return apiGetProductByFilter(filter, 1, true, true);
2217
+ case 3:
2218
+ product = _context2.sent;
2219
+ return _context2.abrupt("return", (_product$data$2 = product.data[0]) === null || _product$data$2 === void 0 ? void 0 : _product$data$2._id);
2220
+ case 5:
2221
+ case "end":
2222
+ return _context2.stop();
2223
+ }
2224
+ }, _callee2);
2225
+ }));
2226
+ return _getProductByDivaNr.apply(this, arguments);
2227
+ }
2228
+ function checkConfigurationByDivaNr(_x6, _x7, _x8) {
2229
+ return _checkConfigurationByDivaNr.apply(this, arguments);
2230
+ }
2231
+ function _checkConfigurationByDivaNr() {
2232
+ _checkConfigurationByDivaNr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(divaNr, jwt, basketService) {
2233
+ var _divaNr$split, _divaNr$split2, onlyDivaNr, version, response;
2234
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
2235
+ while (1) switch (_context3.prev = _context3.next) {
2236
+ case 0:
2237
+ _divaNr$split = divaNr.split('-'), _divaNr$split2 = _slicedToArray(_divaNr$split, 3), onlyDivaNr = _divaNr$split2[1], version = _divaNr$split2[2];
2238
+ _context3.prev = 1;
2239
+ _context3.next = 4;
2240
+ return fetch("".concat(basketService, "/baskets/configuration?divaNr=DIVA-").concat(onlyDivaNr, "&fields={DivaNr}&dontRepairBasket=true").concat(version ? '&version=' + version : ''), {
2241
+ headers: {
2242
+ Authorization: "Bearer ".concat(jwt)
2243
+ }
2244
+ });
2245
+ case 4:
2246
+ response = _context3.sent;
2247
+ if (!response.ok) {
2248
+ _context3.next = 7;
2249
+ break;
2250
+ }
2251
+ return _context3.abrupt("return", true);
2252
+ case 7:
2253
+ return _context3.abrupt("return", false);
2254
+ case 10:
2255
+ _context3.prev = 10;
2256
+ _context3.t0 = _context3["catch"](1);
2257
+ LOG$1.warn('Error checking configuration by divaNr', _context3.t0);
2258
+ return _context3.abrupt("return", false);
2259
+ case 14:
2260
+ case "end":
2261
+ return _context3.stop();
2262
+ }
2263
+ }, _callee3, null, [[1, 10]]);
2264
+ }));
2265
+ return _checkConfigurationByDivaNr.apply(this, arguments);
2266
+ }
2187
2267
 
2188
2268
  var LOG = getLogger('Framework', 'QrCoedScanner');
2189
2269
  function Scanner() {
@@ -2196,6 +2276,8 @@ function Scanner() {
2196
2276
  _useDivaCore$state = _useDivaCore.state,
2197
2277
  organization = _useDivaCore$state.organization,
2198
2278
  qrCodeScanner = _useDivaCore$state.navigationConfiguration.qrCodeScanner,
2279
+ jwt = _useDivaCore$state.jwt,
2280
+ apiConfig = _useDivaCore$state.apiConfig,
2199
2281
  productHandler = _useDivaCore.handler.productHandler;
2200
2282
  var _useState = useState(true),
2201
2283
  _useState2 = _slicedToArray(_useState, 2),
@@ -2209,57 +2291,69 @@ function Scanner() {
2209
2291
  setError = _React$useState2[1];
2210
2292
  var onScanned = /*#__PURE__*/function () {
2211
2293
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
2212
- var divaNr, productId;
2294
+ var divaNr, isValid, productId;
2213
2295
  return _regeneratorRuntime.wrap(function _callee$(_context) {
2214
2296
  while (1) switch (_context.prev = _context.next) {
2215
2297
  case 0:
2216
2298
  if (!(qrCodeScanner == true || _typeof(qrCodeScanner) == 'object' && (qrCodeScanner === null || qrCodeScanner === void 0 ? void 0 : qrCodeScanner.basket) == true)) {
2217
- _context.next = 8;
2299
+ _context.next = 15;
2218
2300
  break;
2219
2301
  }
2220
2302
  divaNr = matchDivaNr(text);
2221
2303
  if (!divaNr) {
2222
- _context.next = 8;
2304
+ _context.next = 15;
2223
2305
  break;
2224
2306
  }
2225
2307
  LOG.debug('Found DivaNR in QR Code: ' + divaNr);
2308
+ _context.next = 6;
2309
+ return checkConfigurationByDivaNr(divaNr, jwt, apiConfig.basketService);
2310
+ case 6:
2311
+ isValid = _context.sent;
2312
+ if (!isValid) {
2313
+ _context.next = 12;
2314
+ break;
2315
+ }
2226
2316
  closeModal();
2227
- _context.next = 7;
2317
+ _context.next = 11;
2228
2318
  return openComponent({
2229
2319
  type: 'DIVA_WEBPLANNER',
2230
2320
  parameters: {
2231
2321
  divaNr: divaNr
2232
2322
  }
2233
2323
  });
2234
- case 7:
2324
+ case 11:
2235
2325
  return _context.abrupt("return");
2236
- case 8:
2326
+ case 12:
2327
+ LOG.debug('Configuration is invalid');
2328
+ setError('scanner.error.unknownCode');
2329
+ return _context.abrupt("return");
2330
+ case 15:
2237
2331
  if (!((qrCodeScanner == true || _typeof(qrCodeScanner) == 'object' && (qrCodeScanner === null || qrCodeScanner === void 0 ? void 0 : qrCodeScanner.product) == true) && organization !== null && organization !== void 0 && organization.shopBaseUrl)) {
2238
- _context.next = 18;
2332
+ _context.next = 25;
2239
2333
  break;
2240
2334
  }
2241
- _context.next = 11;
2335
+ _context.next = 18;
2242
2336
  return matchProduct(text, organization.shopBaseUrl, productHandler.apiGetProductByFilter.bind(productHandler));
2243
- case 11:
2337
+ case 18:
2244
2338
  productId = _context.sent;
2245
2339
  if (!productId) {
2246
- _context.next = 18;
2340
+ _context.next = 25;
2247
2341
  break;
2248
2342
  }
2249
2343
  LOG.debug('Found Shop URL in QR Code: ' + organization.shopBaseUrl, productId);
2250
2344
  closeModal();
2251
- _context.next = 17;
2345
+ _context.next = 24;
2252
2346
  return openComponent({
2253
2347
  type: 'DIVA_WEBPLANNER',
2254
2348
  parameters: {
2255
2349
  productId: productId
2256
2350
  }
2257
2351
  });
2258
- case 17:
2352
+ case 24:
2259
2353
  return _context.abrupt("return");
2260
- case 18:
2354
+ case 25:
2261
2355
  setError('scanner.error.unknownCode');
2262
- case 19:
2356
+ case 26:
2263
2357
  case "end":
2264
2358
  return _context.stop();
2265
2359
  }
@@ -2360,22 +2454,206 @@ function Scanner() {
2360
2454
  });
2361
2455
  }
2362
2456
 
2363
- function QrCodeScanner () {
2364
- var _useDivaCore = useDivaCore(),
2365
- openModal = _useDivaCore.actions.openModal;
2457
+ function ScannerModalContent() {
2366
2458
  var _useTranslation = useTranslation(),
2367
2459
  t = _useTranslation.t;
2460
+ var _useDivaCore = useDivaCore(),
2461
+ _useDivaCore$actions = _useDivaCore.actions,
2462
+ closeModal = _useDivaCore$actions.closeModal,
2463
+ openComponent = _useDivaCore$actions.openComponent,
2464
+ _useDivaCore$state = _useDivaCore.state,
2465
+ qrCodeScanner = _useDivaCore$state.navigationConfiguration.qrCodeScanner,
2466
+ jwt = _useDivaCore$state.jwt,
2467
+ apiConfig = _useDivaCore$state.apiConfig,
2468
+ productHandler = _useDivaCore.handler.productHandler;
2469
+ var _React$useState = React.useState(false),
2470
+ _React$useState2 = _slicedToArray(_React$useState, 2),
2471
+ showScanner = _React$useState2[0],
2472
+ setShowScanner = _React$useState2[1];
2473
+ var _React$useState3 = React.useState(''),
2474
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
2475
+ divaNrInput = _React$useState4[0],
2476
+ setDivaNrInput = _React$useState4[1];
2477
+ var _React$useState5 = React.useState(undefined),
2478
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
2479
+ errorKey = _React$useState6[0],
2480
+ setErrorKey = _React$useState6[1];
2481
+ var isValidDivaNr = function isValidDivaNr(value) {
2482
+ return /^DIVA-\d+(-\d+)?$/i.test(value.trim());
2483
+ };
2484
+ var handleSubmitManual = /*#__PURE__*/function () {
2485
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
2486
+ var normalized, isValid, productId;
2487
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
2488
+ while (1) switch (_context.prev = _context.next) {
2489
+ case 0:
2490
+ normalized = divaNrInput.trim().toUpperCase();
2491
+ if (isValidDivaNr(normalized)) {
2492
+ _context.next = 4;
2493
+ break;
2494
+ }
2495
+ setErrorKey('scanner.error.invalidDivaNr');
2496
+ return _context.abrupt("return");
2497
+ case 4:
2498
+ if (!(qrCodeScanner == true || _typeof(qrCodeScanner) == 'object' && (qrCodeScanner === null || qrCodeScanner === void 0 ? void 0 : qrCodeScanner.basket) == true)) {
2499
+ _context.next = 14;
2500
+ break;
2501
+ }
2502
+ _context.next = 7;
2503
+ return checkConfigurationByDivaNr(normalized, jwt, apiConfig.basketService);
2504
+ case 7:
2505
+ isValid = _context.sent;
2506
+ if (!isValid) {
2507
+ _context.next = 13;
2508
+ break;
2509
+ }
2510
+ closeModal();
2511
+ _context.next = 12;
2512
+ return openComponent({
2513
+ type: 'DIVA_WEBPLANNER',
2514
+ parameters: {
2515
+ divaNr: normalized
2516
+ }
2517
+ });
2518
+ case 12:
2519
+ return _context.abrupt("return");
2520
+ case 13:
2521
+ setErrorKey('scanner.error.invalidDivaNr');
2522
+ case 14:
2523
+ if (!(qrCodeScanner == true || _typeof(qrCodeScanner) == 'object' && (qrCodeScanner === null || qrCodeScanner === void 0 ? void 0 : qrCodeScanner.product) == true)) {
2524
+ _context.next = 23;
2525
+ break;
2526
+ }
2527
+ _context.next = 17;
2528
+ return getProductByDivaNr(normalized, productHandler.apiGetProductByFilter.bind(productHandler));
2529
+ case 17:
2530
+ productId = _context.sent;
2531
+ if (!productId) {
2532
+ _context.next = 23;
2533
+ break;
2534
+ }
2535
+ closeModal();
2536
+ _context.next = 22;
2537
+ return openComponent({
2538
+ type: 'DIVA_WEBPLANNER',
2539
+ parameters: {
2540
+ productId: productId
2541
+ }
2542
+ });
2543
+ case 22:
2544
+ return _context.abrupt("return");
2545
+ case 23:
2546
+ setErrorKey('scanner.error.invalidDivaNr');
2547
+ case 24:
2548
+ case "end":
2549
+ return _context.stop();
2550
+ }
2551
+ }, _callee);
2552
+ }));
2553
+ return function handleSubmitManual() {
2554
+ return _ref.apply(this, arguments);
2555
+ };
2556
+ }();
2557
+ return /*#__PURE__*/jsxs(Stack, {
2558
+ spacing: 3,
2559
+ sx: {
2560
+ mt: 1
2561
+ },
2562
+ children: [/*#__PURE__*/jsx(Paper, {
2563
+ variant: "outlined",
2564
+ sx: {
2565
+ p: 2
2566
+ },
2567
+ children: /*#__PURE__*/jsxs(Stack, {
2568
+ spacing: 1,
2569
+ children: [/*#__PURE__*/jsx(Typography, {
2570
+ variant: "subtitle1",
2571
+ children: t('scanner.scanQrcode.title')
2572
+ }), /*#__PURE__*/jsx(Button$1, {
2573
+ variant: "contained",
2574
+ onClick: function onClick() {
2575
+ return setShowScanner(true);
2576
+ },
2577
+ children: t('scanner.scanQrcode.button')
2578
+ }), /*#__PURE__*/jsx(Typography, {
2579
+ variant: "caption",
2580
+ color: "text.secondary",
2581
+ children: t('scanner.scanInfo')
2582
+ }), showScanner && /*#__PURE__*/jsx(Scanner, {})]
2583
+ })
2584
+ }), /*#__PURE__*/jsx(Divider, {
2585
+ children: /*#__PURE__*/jsx(Typography, {
2586
+ variant: "caption",
2587
+ children: t('common.or')
2588
+ })
2589
+ }), /*#__PURE__*/jsx(Paper, {
2590
+ variant: "outlined",
2591
+ sx: {
2592
+ p: 2
2593
+ },
2594
+ children: /*#__PURE__*/jsxs(Stack, {
2595
+ spacing: 1,
2596
+ children: [/*#__PURE__*/jsx(Typography, {
2597
+ variant: "subtitle1",
2598
+ children: t('scanner.enterManually')
2599
+ }), errorKey && /*#__PURE__*/jsx(Alert, {
2600
+ severity: "warning",
2601
+ children: t(errorKey)
2602
+ }), /*#__PURE__*/jsx(TextField, {
2603
+ autoFocus: !showScanner,
2604
+ label: t('scanner.divaNrLabel'),
2605
+ placeholder: "DIVA-1234-2",
2606
+ value: divaNrInput,
2607
+ onChange: function onChange(e) {
2608
+ setErrorKey(undefined);
2609
+ setDivaNrInput(e.target.value);
2610
+ },
2611
+ onKeyDown: function onKeyDown(e) {
2612
+ if (e.key === 'Enter') {
2613
+ e.preventDefault();
2614
+ e.stopPropagation();
2615
+ void handleSubmitManual();
2616
+ }
2617
+ }
2618
+ }), /*#__PURE__*/jsx(Button$1, {
2619
+ type: "button",
2620
+ variant: "contained",
2621
+ onClick: function onClick() {
2622
+ return void handleSubmitManual();
2623
+ },
2624
+ disabled: !isValidDivaNr(divaNrInput),
2625
+ children: t('scanner.openDivaNr')
2626
+ }), /*#__PURE__*/jsx(Typography, {
2627
+ variant: "caption",
2628
+ color: "text.secondary",
2629
+ children: t('scanner.manualHint')
2630
+ })]
2631
+ })
2632
+ })]
2633
+ });
2634
+ }
2635
+ function QrCodeScanner () {
2636
+ var _useDivaCore2 = useDivaCore(),
2637
+ openModal = _useDivaCore2.actions.openModal;
2638
+ var _useTranslation2 = useTranslation(),
2639
+ t = _useTranslation2.t;
2368
2640
  return /*#__PURE__*/jsx(Fragment$1, {
2369
- children: /*#__PURE__*/jsx("div", {
2370
- className: button,
2641
+ children: /*#__PURE__*/jsx(Button$1, {
2371
2642
  id: "qr-code-scanner-button",
2372
2643
  onClick: function onClick() {
2373
2644
  return openModal({
2374
2645
  rejectByIcon: true,
2375
2646
  title: t('scanner.title'),
2376
- content: /*#__PURE__*/jsx(Scanner, {})
2647
+ content: /*#__PURE__*/jsx(ScannerModalContent, {})
2377
2648
  });
2378
- }
2649
+ },
2650
+ className: button,
2651
+ startIcon: /*#__PURE__*/jsx(SearchIcon, {}),
2652
+ variant: "outlined",
2653
+ children: /*#__PURE__*/jsx("span", {
2654
+ className: label,
2655
+ children: t('scanner.title')
2656
+ })
2379
2657
  })
2380
2658
  });
2381
2659
  }
@@ -2388,7 +2666,10 @@ var Header = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
2388
2666
  _useDivaCore$state = _useDivaCore.state,
2389
2667
  hideSnow = _useDivaCore$state.hideSnow,
2390
2668
  user = _useDivaCore$state.user,
2391
- isMobile = _useDivaCore$state.dimensions.isMobile,
2669
+ _useDivaCore$state$di = _useDivaCore$state.dimensions,
2670
+ isMobile = _useDivaCore$state$di.isMobile,
2671
+ isTablet = _useDivaCore$state$di.isTablet,
2672
+ isPortrait = _useDivaCore$state$di.isPortrait,
2392
2673
  _useDivaCore$state$na = _useDivaCore$state.navigationConfiguration,
2393
2674
  customHeaderElement = _useDivaCore$state$na.customHeaderElement,
2394
2675
  showLogin = _useDivaCore$state$na.showLogin,
@@ -2434,6 +2715,9 @@ var Header = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
2434
2715
  }
2435
2716
  e.stopPropagation();
2436
2717
  };
2718
+
2719
+ //still show buttons on tablet in landscape mode
2720
+ var showButtons = !isMobile || isTablet && !isPortrait;
2437
2721
  return /*#__PURE__*/jsxs(Fragment$1, {
2438
2722
  children: [/*#__PURE__*/jsxs("div", {
2439
2723
  id: "diva-header",
@@ -2452,12 +2736,12 @@ var Header = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
2452
2736
  className: headerWrapper,
2453
2737
  children: [/*#__PURE__*/jsx(Logos, {}), welcomeText && /*#__PURE__*/jsx(WelcomeText, {
2454
2738
  text: welcomeText
2455
- }), !isMobile && /*#__PURE__*/jsx(Buttons, {}), /*#__PURE__*/jsxs("div", {
2739
+ }), showButtons && /*#__PURE__*/jsx(Buttons, {}), /*#__PURE__*/jsxs("div", {
2456
2740
  className: headerWrapperRight,
2457
2741
  children: [!!qrCodeScanner && /*#__PURE__*/jsx(QrCodeScanner, {}), !!customHeaderElement && /*#__PURE__*/jsx("div", {
2458
2742
  className: customArea,
2459
2743
  children: customHeaderElement()
2460
- }), !isMobile && (showOrgName || showUserName) && /*#__PURE__*/jsx(OrganizationName, {
2744
+ }), showButtons && (showOrgName || showUserName) && /*#__PURE__*/jsx(OrganizationName, {
2461
2745
  showOrgName: showOrgName,
2462
2746
  showUserName: showUserName,
2463
2747
  onClickProfile: onClickProfile
@@ -1 +1 @@
1
- {"version":3,"file":"Scanner.d.ts","sourceRoot":"","sources":["../../../../../../src/Header/QrCodeScanner/Scanner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAU7D,wBAAgB,OAAO,sBAmFtB"}
1
+ {"version":3,"file":"Scanner.d.ts","sourceRoot":"","sources":["../../../../../../src/Header/QrCodeScanner/Scanner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAU7D,wBAAgB,OAAO,sBA2FtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/Header/QrCodeScanner/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,OAAO,gCAqBb"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/Header/QrCodeScanner/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAwG1B,MAAM,CAAC,OAAO,gCAyBb"}
@@ -31,4 +31,18 @@ export declare function matchProduct(url: string, shopBaseUrl: string, apiGetPro
31
31
  }[], limit: number, useFilter?: boolean, hierarchy?: boolean) => Promise<{
32
32
  data: any[];
33
33
  }>): Promise<any>;
34
+ /**
35
+ * Gets the product by the given divaNr.
36
+ *
37
+ * @param divaNr The divaNr to get the product for
38
+ * @param apiGetProductByFilter The function to get the product by filter
39
+ */
40
+ export declare function getProductByDivaNr(divaNr: string, apiGetProductByFilter: (filter: {
41
+ id: string;
42
+ op: string;
43
+ value: string | number | boolean;
44
+ }[], limit: number, useFilter?: boolean, hierarchy?: boolean) => Promise<{
45
+ data: any[];
46
+ }>): Promise<string | undefined>;
47
+ export declare function checkConfigurationByDivaNr(divaNr: string, jwt: string, basketService: string): Promise<boolean>;
34
48
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/Header/QrCodeScanner/utils.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,sBA0BtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,CACrB,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EACtE,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,EACnB,SAAS,CAAC,EAAE,OAAO,KAChB,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,gBAwD9B"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/Header/QrCodeScanner/utils.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,sBA0BtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,CACrB,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EACtE,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,EACnB,SAAS,CAAC,EAAE,OAAO,KAChB,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,gBAwD9B;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,qBAAqB,EAAE,CACrB,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EACtE,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,EACnB,SAAS,CAAC,EAAE,OAAO,KAChB,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAC5B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAO7B;AAED,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,oBAmBlG"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Header/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;;AAgBnD,wBAwEG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Header/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;;AAgBnD,wBA2EG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/diva-navigator",
3
- "version": "25.13.0-beta.9",
3
+ "version": "25.14.0-beta.1",
4
4
  "license": "MIT",
5
5
  "devDependencies": {
6
6
  "@testing-library/jest-dom": "^6.5.0",
@@ -24,5 +24,5 @@
24
24
  },
25
25
  "module": "build/esm/index.js",
26
26
  "types": "./build/types/navigator/src/index.d.ts",
27
- "gitHead": "422542d6013f97053147659f38446a682fa7bed0"
27
+ "gitHead": "aee149ec7fc90964b7e70e80fadde8b653605e3d"
28
28
  }