@commercetools-frontend-extensions/import-resources-modal 1.7.6 → 1.8.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.
Files changed (20) hide show
  1. package/dist/{active-drag-drop-area-a4fd91f7.cjs.dev.js → active-drag-drop-area-b84dd578.cjs.dev.js} +3 -3
  2. package/dist/{active-drag-drop-area-bfd1ac28.esm.js → active-drag-drop-area-b855fcf6.esm.js} +3 -3
  3. package/dist/{active-drag-drop-area-abe96e04.cjs.prod.js → active-drag-drop-area-c906211c.cjs.prod.js} +3 -3
  4. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +7 -7
  5. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +7 -7
  6. package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +7 -7
  7. package/dist/declarations/src/@types/file-upload.d.ts +0 -4
  8. package/dist/{disabled-drop-area-c092ebd0.cjs.dev.js → disabled-drop-area-48c8a29e.cjs.dev.js} +7 -7
  9. package/dist/{disabled-drop-area-093742fc.esm.js → disabled-drop-area-d56b2ffb.esm.js} +7 -7
  10. package/dist/{disabled-drop-area-25e976d6.cjs.prod.js → disabled-drop-area-ead9d6e5.cjs.prod.js} +7 -7
  11. package/dist/{enabled-drop-area-db88a5da.esm.js → enabled-drop-area-4745c8da.esm.js} +7 -7
  12. package/dist/{enabled-drop-area-2e91435a.cjs.dev.js → enabled-drop-area-5c4ea376.cjs.dev.js} +7 -7
  13. package/dist/{enabled-drop-area-86aff122.cjs.prod.js → enabled-drop-area-e81190f8.cjs.prod.js} +7 -7
  14. package/dist/{file-dropped-area-88c05907.cjs.dev.js → file-dropped-area-2d51d63b.cjs.dev.js} +7 -7
  15. package/dist/{file-dropped-area-6279df47.cjs.prod.js → file-dropped-area-48990997.cjs.prod.js} +7 -7
  16. package/dist/{file-dropped-area-70be944b.esm.js → file-dropped-area-bf648f2e.esm.js} +7 -7
  17. package/dist/{index-6186162d.cjs.prod.js → index-762eed18.cjs.prod.js} +374 -110
  18. package/dist/{index-98c1d115.cjs.dev.js → index-a2c55a09.cjs.dev.js} +374 -110
  19. package/dist/{index-c388b02a.esm.js → index-d6f6d164.esm.js} +372 -108
  20. package/package.json +35 -34
@@ -27,15 +27,15 @@ var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper')
27
27
  var pluralize = require('pluralize');
28
28
  var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
29
29
  var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
30
+ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
31
+ var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
30
32
  var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
31
33
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
32
34
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
33
- var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
34
35
  var Papa = require('papaparse');
35
36
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
36
37
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
37
38
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
38
- var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
39
39
  require('@babel/runtime-corejs3/core-js-stable/instance/bind');
40
40
  require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
41
41
  require('@babel/runtime-corejs3/core-js-stable/url-search-params');
@@ -67,15 +67,15 @@ var React__default = /*#__PURE__*/_interopDefault(React);
67
67
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
68
68
  var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
69
69
  var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
70
+ var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
71
+ var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
70
72
  var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
71
73
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
72
74
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
73
- var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
74
75
  var Papa__default = /*#__PURE__*/_interopDefault(Papa);
75
76
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
76
77
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
77
78
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
78
- var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
79
79
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
80
80
 
81
81
  const EnabledResourceType = {
@@ -297,7 +297,7 @@ const fetchUsingXhr = _ref2 => {
297
297
  return xhr;
298
298
  };
299
299
 
300
- const DEFAULT_DELIMITER = ',';
300
+ const ALLOWED_DELIMITERS = [',', ';', '|', '\t'];
301
301
  const INITIAL_COLUMN_DISPLAY_COUNT = 8;
302
302
  const IMPORT_TAG_KEYS = {
303
303
  source: 'source'
@@ -387,41 +387,270 @@ const DEFAULT_SHORT_LIVED_FLAGS = {};
387
387
  const DEFAULT_LONG_LIVED_FLAGS = {};
388
388
  _objectSpread$g(_objectSpread$g({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
389
389
 
390
+ var sharedMessages = reactIntl.defineMessages({
391
+ [`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
392
+ id: 'ImportResourcesModal.modalTitle.category',
393
+ description: 'Label for the categories modal title',
394
+ defaultMessage: 'Import categories by CSV'
395
+ },
396
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
397
+ id: 'ImportResourcesModal.modalTitle.product',
398
+ description: 'Label for the products modal title',
399
+ defaultMessage: 'Import products by CSV'
400
+ },
401
+ [`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
402
+ id: 'ImportResourcesModal.modalTitle.inventoryEntry',
403
+ description: 'Label for the inventories modal title',
404
+ defaultMessage: 'Import inventories by CSV'
405
+ },
406
+ [`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
407
+ id: 'ImportResourcesModal.modalTitle.discountCode',
408
+ description: 'Label for the inventories modal title',
409
+ defaultMessage: 'Import discount codes by CSV'
410
+ },
411
+ [`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
412
+ id: 'ImportResourcesModal.modalTitle.customer',
413
+ description: 'Label for the customers modal title',
414
+ defaultMessage: 'Import customers by CSV'
415
+ },
416
+ [`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
417
+ id: 'ImportResourcesModal.modalTitle.order',
418
+ description: 'Label for the order modal title',
419
+ defaultMessage: 'Import orders by CSV'
420
+ },
421
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
422
+ id: 'ImportResourcesModal.modalTitle.productType',
423
+ description: 'Label for the product type modal title',
424
+ defaultMessage: 'Import product types by CSV'
425
+ },
426
+ uploadButton: {
427
+ id: 'ImportResourcesModal.uploadButton',
428
+ description: 'Label for the upload button',
429
+ defaultMessage: 'Upload and preview'
430
+ },
431
+ cancel: {
432
+ id: 'ImportResourcesModal.cancel',
433
+ description: 'Label for the cancel button',
434
+ defaultMessage: 'Cancel'
435
+ },
436
+ close: {
437
+ id: 'ImportResourcesModal.close',
438
+ description: 'Label for the close button',
439
+ defaultMessage: 'Close'
440
+ },
441
+ listConjunctionOr: {
442
+ id: 'ImportResourcesModal.listConjunctionOr',
443
+ description: 'Label for the list conjunction or',
444
+ defaultMessage: 'or'
445
+ },
446
+ delimiterComma: {
447
+ id: 'ImportResourcesModal.delimiterComma',
448
+ description: 'Label for the delimiter name comma',
449
+ defaultMessage: 'comma'
450
+ },
451
+ delimiterSemicolon: {
452
+ id: 'ImportResourcesModal.delimiterSemicolon',
453
+ description: 'Label for the delimiter name semicolon',
454
+ defaultMessage: 'semicolon'
455
+ },
456
+ delimiterPipe: {
457
+ id: 'ImportResourcesModal.delimiterPipe',
458
+ description: 'Label for the delimiter name pipe',
459
+ defaultMessage: 'pipe'
460
+ },
461
+ delimiterTab: {
462
+ id: 'ImportResourcesModal.delimiterTab',
463
+ description: 'Label for the delimiter name tab',
464
+ defaultMessage: 'tab'
465
+ },
466
+ // Resource types
467
+ product: {
468
+ id: 'ImportResourcesModal.product',
469
+ description: 'Label for the product resource type',
470
+ defaultMessage: 'Product'
471
+ },
472
+ products: {
473
+ id: 'ImportResourcesModal.products',
474
+ description: 'Label for the products resource type',
475
+ defaultMessage: 'Products'
476
+ },
477
+ inventory: {
478
+ id: 'ImportResourcesModal.inventory',
479
+ description: 'Label for the inventory entry resource type',
480
+ defaultMessage: 'Inventory'
481
+ },
482
+ inventories: {
483
+ id: 'ImportResourcesModal.inventories',
484
+ description: 'Label for the inventories entry resource type',
485
+ defaultMessage: 'Inventories'
486
+ },
487
+ category: {
488
+ id: 'ImportResourcesModal.category',
489
+ description: 'Label for the category resource type',
490
+ defaultMessage: 'Category'
491
+ },
492
+ categories: {
493
+ id: 'ImportResourcesModal.categories',
494
+ description: 'Label for the categories resource type',
495
+ defaultMessage: 'Categories'
496
+ },
497
+ 'custom-object': {
498
+ id: 'ImportResourcesModal.custom-object',
499
+ description: 'Label for the custom-object resource type',
500
+ defaultMessage: 'Custom object'
501
+ },
502
+ 'custom-objects': {
503
+ id: 'ImportResourcesModal.custom-objects',
504
+ description: 'Label for the custom-objects resource type',
505
+ defaultMessage: 'Custom objects'
506
+ },
507
+ customer: {
508
+ id: 'ImportResourcesModal.customer',
509
+ description: 'Label for the customer resource type',
510
+ defaultMessage: 'Customer'
511
+ },
512
+ customers: {
513
+ id: 'ImportResourcesModal.customers',
514
+ description: 'Label for the customers resource type',
515
+ defaultMessage: 'Customers'
516
+ },
517
+ order: {
518
+ id: 'ImportResourcesModal.order',
519
+ description: 'Label for the order resource type',
520
+ defaultMessage: 'Order'
521
+ },
522
+ orders: {
523
+ id: 'ImportResourcesModal.orders',
524
+ description: 'Label for the orders resource type',
525
+ defaultMessage: 'Orders'
526
+ },
527
+ 'order-patch': {
528
+ id: 'ImportResourcesModal.order-patch',
529
+ description: 'Label for the order-patch resource type',
530
+ defaultMessage: 'Order patch'
531
+ },
532
+ 'order-patches': {
533
+ id: 'ImportResourcesModal.order-patches',
534
+ description: 'Label for the order-patches resource type',
535
+ defaultMessage: 'Order patches'
536
+ },
537
+ price: {
538
+ id: 'ImportResourcesModal.price',
539
+ description: 'Label for the price resource type',
540
+ defaultMessage: 'Price'
541
+ },
542
+ prices: {
543
+ id: 'ImportResourcesModal.prices',
544
+ description: 'Label for the prices resource type',
545
+ defaultMessage: 'Prices'
546
+ },
547
+ 'product-draft': {
548
+ id: 'ImportResourcesModal.product-draft',
549
+ description: 'Label for the product-draft resource type',
550
+ defaultMessage: 'Product draft'
551
+ },
552
+ 'product-drafts': {
553
+ id: 'ImportResourcesModal.product-drafts',
554
+ description: 'Label for the product-drafts resource type',
555
+ defaultMessage: 'Product drafts'
556
+ },
557
+ 'product-type': {
558
+ id: 'ImportResourcesModal.product-type',
559
+ description: 'Label for the product-type resource type',
560
+ defaultMessage: 'Product type'
561
+ },
562
+ 'product-types': {
563
+ id: 'ImportResourcesModal.product-types',
564
+ description: 'Label for the product-types resource type',
565
+ defaultMessage: 'Product types'
566
+ },
567
+ 'product-variant': {
568
+ id: 'ImportResourcesModal.product-variant',
569
+ description: 'Label for the product-variant resource type',
570
+ defaultMessage: 'Product variant'
571
+ },
572
+ 'product-variants': {
573
+ id: 'ImportResourcesModal.product-variants',
574
+ description: 'Label for the product-variants resource type',
575
+ defaultMessage: 'Product variants'
576
+ },
577
+ 'product-variant-patch': {
578
+ id: 'ImportResourcesModal.product-variant-patch',
579
+ description: 'Label for the product-variant-patch resource type',
580
+ defaultMessage: 'Product variant patch'
581
+ },
582
+ 'product-variant-patches': {
583
+ id: 'ImportResourcesModal.product-variant-patches',
584
+ description: 'Label for the product-variant-patches resource type',
585
+ defaultMessage: 'Product variant patches'
586
+ },
587
+ 'standalone-price': {
588
+ id: 'ImportResourcesModal.standalone-price',
589
+ description: 'Label for the standalone-price resource type',
590
+ defaultMessage: 'Standalone price'
591
+ },
592
+ 'standalone-prices': {
593
+ id: 'ImportResourcesModal.standalone-prices',
594
+ description: 'Label for the standalone-prices resource type',
595
+ defaultMessage: 'Standalone prices'
596
+ },
597
+ type: {
598
+ id: 'ImportResourcesModal.type',
599
+ description: 'Label for the type resource type',
600
+ defaultMessage: 'Type'
601
+ },
602
+ types: {
603
+ id: 'ImportResourcesModal.types',
604
+ description: 'Label for the types resource type',
605
+ defaultMessage: 'Types'
606
+ },
607
+ 'discount-code': {
608
+ id: 'ImportResourcesModal.discount-code',
609
+ description: 'Label for the discount-code resource type',
610
+ defaultMessage: 'Discount code'
611
+ },
612
+ 'discount-codes': {
613
+ id: 'ImportResourcesModal.discount-codes',
614
+ description: 'Label for the discount-codes resource type',
615
+ defaultMessage: 'Discount codes'
616
+ },
617
+ unknownResourceType: {
618
+ id: 'ImportResourcesModal.unknown-resource-type',
619
+ description: 'Label for the unknown resource type',
620
+ defaultMessage: 'Unknown resource type'
621
+ }
622
+ //
623
+ });
624
+
390
625
  function ownKeys$f(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
391
- function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$f(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$f(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
392
- /**
393
- * This function checks if the provided `expectedDelimiter` is used consistently in the first 10 lines of a CSV file.
394
- * Returns a Promise that resolves to an object containing a boolean `isValid` property and the detected delimiter `delimiter`.
395
- *
396
- * @param {File} file - The CSV file to check.
397
- * @param {string} [expectedDelimiter=DEFAULT_DELIMITER] - The expected delimiter to check for in the file.
398
- * @returns {Promise<DelimiterCheck>} A Promise that resolves to a DelimiterCheck object.
399
- */
400
- const checkDelimiter = function (file) {
401
- let expectedDelimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_DELIMITER;
626
+ function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$f(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$f(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
627
+
628
+ // Delimiters not included in this array may be treated as part of a column content
629
+ // potentially causing the file to be parsed as a single-column CSV and pass this validation
630
+ const NON_ALLOWED_DELIMITERS = ['%', '.', ' '];
631
+ const DELIMITERS_TO_GUESS = [...ALLOWED_DELIMITERS, ...NON_ALLOWED_DELIMITERS];
632
+ const validateDelimiter = file => {
402
633
  return new _Promise__default["default"](resolve => {
403
- let lineCount = 0;
404
- let correctDelimiterCount = 0;
405
- let detectedDelimiter = null;
406
634
  Papa__default["default"].parse(file, {
407
- step: (results, parser) => {
408
- lineCount++;
409
- if (detectedDelimiter === null) {
410
- detectedDelimiter = results.meta.delimiter;
411
- }
412
- if (results.meta.delimiter === expectedDelimiter) {
413
- correctDelimiterCount++;
635
+ delimitersToGuess: DELIMITERS_TO_GUESS,
636
+ preview: 10,
637
+ complete: result => {
638
+ const headerRow = result.data?.[0];
639
+ const isOnlyOneColumn = _Array$isArray__default["default"](headerRow) && headerRow.length === 1;
640
+ if (isOnlyOneColumn) {
641
+ resolve(true);
642
+ return;
414
643
  }
415
- if (lineCount >= 10) {
416
- parser.abort();
644
+ const detectedDelimiter = result.meta.delimiter;
645
+ let isValid = false;
646
+ if (detectedDelimiter !== null && _includesInstanceProperty__default["default"](ALLOWED_DELIMITERS).call(ALLOWED_DELIMITERS, detectedDelimiter)) {
647
+ var _context;
648
+ const isUndetectableDelimiter = _someInstanceProperty__default["default"](_context = result.errors).call(_context, error => error.code === 'UndetectableDelimiter');
649
+ if (!isUndetectableDelimiter) {
650
+ isValid = true;
651
+ }
417
652
  }
418
- },
419
- complete: () => {
420
- const isValid = correctDelimiterCount === lineCount;
421
- resolve({
422
- isValid,
423
- delimiter: detectedDelimiter
424
- });
653
+ resolve(isValid);
425
654
  }
426
655
  });
427
656
  });
@@ -430,8 +659,8 @@ const mapUploadFileErrorsResponseToUploadFileErrorRows = uploadFileErrorsRespons
430
659
  if (!uploadFileErrorsResponse || !_Array$isArray__default["default"](uploadFileErrorsResponse)) return [];
431
660
  let idCounter = 1;
432
661
  return _flatMapInstanceProperty__default["default"](uploadFileErrorsResponse).call(uploadFileErrorsResponse, rowErrorsResponse => {
433
- var _context;
434
- return _mapInstanceProperty__default["default"](_context = rowErrorsResponse.errors).call(_context, rowError => ({
662
+ var _context2;
663
+ return _mapInstanceProperty__default["default"](_context2 = rowErrorsResponse.errors).call(_context2, rowError => ({
435
664
  // DataTable component requires unique `id` field
436
665
  id: String(idCounter++),
437
666
  row: rowErrorsResponse.row,
@@ -481,6 +710,35 @@ const toBytes = megabytes => megabytes * 1024 * 1024;
481
710
  const getValidatedColumns = (columns, ignoredColumns) => {
482
711
  return _filterInstanceProperty__default["default"](columns).call(columns, column => !_includesInstanceProperty__default["default"](ignoredColumns).call(ignoredColumns, column));
483
712
  };
713
+ const formatAllowedDelimitersForMessageDisplay = intl => {
714
+ const localizedOr = intl.formatMessage(sharedMessages.listConjunctionOr);
715
+ const descriptions = _mapInstanceProperty__default["default"](ALLOWED_DELIMITERS).call(ALLOWED_DELIMITERS, delimiter => {
716
+ let nameDescriptor;
717
+ switch (delimiter) {
718
+ case ',':
719
+ nameDescriptor = sharedMessages.delimiterComma;
720
+ break;
721
+ case ';':
722
+ nameDescriptor = sharedMessages.delimiterSemicolon;
723
+ break;
724
+ case '|':
725
+ nameDescriptor = sharedMessages.delimiterPipe;
726
+ break;
727
+ case '\t':
728
+ nameDescriptor = sharedMessages.delimiterTab;
729
+ break;
730
+ default:
731
+ nameDescriptor = undefined;
732
+ }
733
+ const name = nameDescriptor ? intl.formatMessage(nameDescriptor) : delimiter;
734
+ return delimiter === '\t' ? name : `${name} (${delimiter})`;
735
+ });
736
+ if (descriptions.length === 1) {
737
+ return descriptions[0];
738
+ }
739
+ const lastDescription = descriptions.pop();
740
+ return `${descriptions.join(', ')} ${localizedOr} ${lastDescription}`;
741
+ };
484
742
 
485
743
  function getFileUploadErrorsCount(errors) {
486
744
  if (!errors || !_Array$isArray__default["default"](errors)) return 0;
@@ -509,6 +767,57 @@ function formatErrorCode(code) {
509
767
  return code;
510
768
  }
511
769
  }
770
+ function resourceTypeToMessage(resourceType) {
771
+ const resourceTypeMap = {
772
+ category: sharedMessages.category,
773
+ product: sharedMessages.product,
774
+ 'product-type': sharedMessages['product-type'],
775
+ order: sharedMessages.order,
776
+ customer: sharedMessages.customer,
777
+ 'discount-code': sharedMessages['discount-code'],
778
+ inventory: sharedMessages.inventory,
779
+ // TODO: remove `inventory` after aligning the resource type names in the file upload API
780
+ 'inventory-entry': sharedMessages.inventory,
781
+ 'order-patch': sharedMessages['order-patch'],
782
+ price: sharedMessages.price,
783
+ 'product-draft': sharedMessages['product-draft'],
784
+ 'product-variant': sharedMessages['product-variant'],
785
+ 'product-variant-patch': sharedMessages['product-variant-patch'],
786
+ 'standalone-price': sharedMessages['standalone-price'],
787
+ 'custom-object': sharedMessages['custom-object'],
788
+ type: sharedMessages.type
789
+ };
790
+ const message = resourceTypeMap[resourceType];
791
+ if (!message) {
792
+ return sharedMessages.unknownResourceType;
793
+ }
794
+ return message;
795
+ }
796
+ function resourceTypeToPluralMessage(resourceType) {
797
+ const resourceTypePluralMap = {
798
+ category: sharedMessages.categories,
799
+ 'custom-object': sharedMessages['custom-objects'],
800
+ product: sharedMessages.products,
801
+ 'product-type': sharedMessages['product-types'],
802
+ order: sharedMessages.orders,
803
+ customer: sharedMessages.customers,
804
+ 'discount-code': sharedMessages['discount-codes'],
805
+ inventory: sharedMessages.inventories,
806
+ // TODO: remove `inventory` after aligning the resource type names in the file upload API
807
+ 'inventory-entry': sharedMessages.inventories,
808
+ 'order-patch': sharedMessages['order-patches'],
809
+ price: sharedMessages.prices,
810
+ 'product-draft': sharedMessages['product-drafts'],
811
+ 'product-variant': sharedMessages['product-variants'],
812
+ 'product-variant-patch': sharedMessages['product-variant-patches'],
813
+ 'standalone-price': sharedMessages['standalone-prices']
814
+ };
815
+ const message = resourceTypePluralMap[resourceType];
816
+ if (!message) {
817
+ return sharedMessages.unknownResourceType;
818
+ }
819
+ return message;
820
+ }
512
821
 
513
822
  const encodeFileNameWithTimestampToContainerKey = fileName => {
514
823
  return btoa(_JSON$stringify__default["default"]({
@@ -750,13 +1059,13 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
750
1059
  return /*#__PURE__*/react.css("" , "" );
751
1060
  }
752
1061
 
753
- var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-abe96e04.cjs.prod.js' /* webpackChunkName: "active-drag-drop-area" */); }));
1062
+ var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-c906211c.cjs.prod.js' /* webpackChunkName: "active-drag-drop-area" */); }));
754
1063
 
755
- var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-25e976d6.cjs.prod.js' /* webpackChunkName: "disabled-drop-area" */); }));
1064
+ var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-ead9d6e5.cjs.prod.js' /* webpackChunkName: "disabled-drop-area" */); }));
756
1065
 
757
- var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-86aff122.cjs.prod.js' /* webpackChunkName: "enabled-drop-area" */); }));
1066
+ var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-e81190f8.cjs.prod.js' /* webpackChunkName: "enabled-drop-area" */); }));
758
1067
 
759
- var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-6279df47.cjs.prod.js' /* webpackChunkName: "filed-dropped-area" */); }));
1068
+ var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-48990997.cjs.prod.js' /* webpackChunkName: "filed-dropped-area" */); }));
760
1069
 
761
1070
  function getDropArea(_ref) {
762
1071
  let dropAreaState = _ref.dropAreaState,
@@ -878,14 +1187,14 @@ var messages$6 = reactIntl.defineMessages({
878
1187
  description: 'Error description when the file contains more rows than the allowable maximum',
879
1188
  defaultMessage: 'The file contains more than the allowable maximum of {rowLimit} rows'
880
1189
  },
881
- dropAreaWrongDelimiterTitle: {
882
- id: 'ImportResourcesModal.wrongDelimiterTitle',
883
- defaultMessage: 'Wrong delimiter'
1190
+ wrongSeparatorTitle: {
1191
+ id: 'ImportResourcesModal.wrongSeparatorTitle',
1192
+ defaultMessage: 'Wrong separator'
884
1193
  },
885
- dropAreaWrongDelimiterDescription: {
886
- id: 'ImportResourcesModal.wrongDelimiterDescription',
1194
+ wrongSeparatorDescription: {
1195
+ id: 'ImportResourcesModal.wrongSeparatorDescription',
887
1196
  description: 'Message within the drop area when a CSV file uses an unexpected delimiter',
888
- defaultMessage: 'The file is using an incorrect delimiter. Please use comma (,) instead.'
1197
+ defaultMessage: 'The file is using an unsupported separator. Please use one of the allowed delimiters: {delimiterList}.'
889
1198
  },
890
1199
  dropAreaNotEnoughRowsTitle: {
891
1200
  id: 'ImportResourcesModal.dropAreaNotEnoughRowsTitle',
@@ -936,10 +1245,12 @@ const useUpload = () => {
936
1245
  }, [state.abortController]);
937
1246
  const isFileValid = async file => {
938
1247
  const errors = [];
939
- const delimiterCheck = await checkDelimiter(file);
940
- if (!delimiterCheck.isValid) errors.push({
941
- title: intl.formatMessage(messages$6.dropAreaWrongDelimiterTitle),
942
- description: intl.formatMessage(messages$6.dropAreaWrongDelimiterDescription)
1248
+ const isDelimiterValid = await validateDelimiter(file);
1249
+ if (!isDelimiterValid) errors.push({
1250
+ title: intl.formatMessage(messages$6.wrongSeparatorTitle),
1251
+ description: intl.formatMessage(messages$6.wrongSeparatorDescription, {
1252
+ delimiterList: formatAllowedDelimitersForMessageDisplay(intl)
1253
+ })
943
1254
  });
944
1255
  const rowCount = await getRowCount(file);
945
1256
  if (rowCount < 1) errors.push({
@@ -1209,59 +1520,6 @@ const UploadSettings = () => {
1209
1520
  return null;
1210
1521
  };
1211
1522
 
1212
- var sharedMessages = reactIntl.defineMessages({
1213
- [`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
1214
- id: 'ImportResourcesModal.modalTitle.category',
1215
- description: 'Label for the categories modal title',
1216
- defaultMessage: 'Import categories by CSV'
1217
- },
1218
- [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
1219
- id: 'ImportResourcesModal.modalTitle.product',
1220
- description: 'Label for the products modal title',
1221
- defaultMessage: 'Import products by CSV'
1222
- },
1223
- [`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
1224
- id: 'ImportResourcesModal.modalTitle.inventoryEntry',
1225
- description: 'Label for the inventories modal title',
1226
- defaultMessage: 'Import inventories by CSV'
1227
- },
1228
- [`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
1229
- id: 'ImportResourcesModal.modalTitle.discountCode',
1230
- description: 'Label for the inventories modal title',
1231
- defaultMessage: 'Import discount codes by CSV'
1232
- },
1233
- [`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
1234
- id: 'ImportResourcesModal.modalTitle.customer',
1235
- description: 'Label for the customers modal title',
1236
- defaultMessage: 'Import customers by CSV'
1237
- },
1238
- [`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
1239
- id: 'ImportResourcesModal.modalTitle.order',
1240
- description: 'Label for the order modal title',
1241
- defaultMessage: 'Import orders by CSV'
1242
- },
1243
- [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
1244
- id: 'ImportResourcesModal.modalTitle.productType',
1245
- description: 'Label for the product type modal title',
1246
- defaultMessage: 'Import product types by CSV'
1247
- },
1248
- uploadButton: {
1249
- id: 'ImportResourcesModal.uploadButton',
1250
- description: 'Label for the upload button',
1251
- defaultMessage: 'Upload and preview'
1252
- },
1253
- cancel: {
1254
- id: 'ImportResourcesModal.cancel',
1255
- description: 'Label for the cancel button',
1256
- defaultMessage: 'Cancel'
1257
- },
1258
- close: {
1259
- id: 'ImportResourcesModal.close',
1260
- description: 'Label for the close button',
1261
- defaultMessage: 'Close'
1262
- }
1263
- });
1264
-
1265
1523
  const Upload = () => {
1266
1524
  const _useImportResourcesCo = useImportResourcesContext(),
1267
1525
  state = _useImportResourcesCo.state,
@@ -1607,10 +1865,10 @@ var messages$3 = reactIntl.defineMessages({
1607
1865
  description: 'Label for modal path',
1608
1866
  defaultMessage: "Here's a preview of your import"
1609
1867
  },
1610
- rowsToBeImported: {
1611
- id: 'ImportResourcesModal.rowsToBeImported',
1612
- description: 'This message indicates the number of rows that are ready to be imported into the system.',
1613
- defaultMessage: '{rowCount, plural, one {<b>1</b> row to be imported} other {<b>{rowCount}</b> rows to be imported}}{publish, select, true { and published} other {}}'
1868
+ itemsToBeImported: {
1869
+ id: 'ImportResourcesModal.itemsToBeImported',
1870
+ description: 'This message indicates the number of items that are ready to be imported into the project.',
1871
+ defaultMessage: '{itemCount, plural, one {<b>1</b> {resourceType} to be imported{publish, select, true { and published} other {}}} other {<b>{itemCount}</b> {resourceTypePlural} to be imported{publish, select, true { and published} other {}}}}'
1614
1872
  },
1615
1873
  columnsToBeImported: {
1616
1874
  id: 'ImportResourcesModal.columnsToBeImported',
@@ -1704,6 +1962,10 @@ function UploadPreviewModal() {
1704
1962
  actions = _useImportResourcesCo2.actions,
1705
1963
  onClose = _useImportResourcesCo2.onClose;
1706
1964
  if (!state.resourceType || !state.uploadFileResponse) return null;
1965
+ const resourceTypeMessage = resourceTypeToMessage(state.resourceType);
1966
+ const resourceType = intl.formatMessage(resourceTypeMessage).toLowerCase();
1967
+ const resourceTypePluralMessage = resourceTypeToPluralMessage(state.resourceType);
1968
+ const resourceTypePlural = intl.formatMessage(resourceTypePluralMessage).toLowerCase();
1707
1969
  const ignoredColumns = state.uploadFileResponse.ignoredColumns;
1708
1970
  const validatedColumns = getValidatedColumns(state.uploadFileResponse.columns, ignoredColumns);
1709
1971
  return jsxRuntime.jsx(applicationComponents.FormDialog, {
@@ -1741,9 +2003,11 @@ function UploadPreviewModal() {
1741
2003
  children: [jsxRuntime.jsx(uiKit.CheckBoldIcon, {
1742
2004
  color: "success"
1743
2005
  }), jsxRuntime.jsx(uiKit.Text.Body, {
1744
- intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.rowsToBeImported), {}, {
2006
+ intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.itemsToBeImported), {}, {
1745
2007
  values: {
1746
- rowCount: intl.formatNumber(state.uploadFileResponse.rowsCount),
2008
+ resourceType,
2009
+ resourceTypePlural,
2010
+ itemCount: intl.formatNumber(state.uploadFileResponse.itemsCount),
1747
2011
  publish: state.resourceType === 'product' && state.settings?.publish,
1748
2012
  b: getBold$1
1749
2013
  }