@shipengine/elements 0.17.3 → 0.18.0

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.
package/index.cjs CHANGED
@@ -25,9 +25,6 @@ var reactQuery = require('react-query');
25
25
  var stylis = require('stylis');
26
26
  var i18n = require('i18next');
27
27
  var languageDetector = require('i18next-browser-languagedetector');
28
- var faker = require('@faker-js/faker');
29
- var fishery = require('fishery');
30
- var react$2 = require('@testing-library/react');
31
28
 
32
29
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
33
30
 
@@ -1129,13 +1126,13 @@ var objectAssign = !$assign || fails$i(function () {
1129
1126
  } return T;
1130
1127
  } : $assign;
1131
1128
 
1132
- var $$l = _export;
1129
+ var $$m = _export;
1133
1130
  var assign = objectAssign;
1134
1131
 
1135
1132
  // `Object.assign` method
1136
1133
  // https://tc39.es/ecma262/#sec-object.assign
1137
1134
  // eslint-disable-next-line es/no-object-assign -- required for testing
1138
- $$l({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
1135
+ $$m({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
1139
1136
  assign: assign
1140
1137
  });
1141
1138
 
@@ -1234,7 +1231,7 @@ var global$f = global$p;
1234
1231
 
1235
1232
  var engineIsNode = classof$7(global$f.process) == 'process';
1236
1233
 
1237
- var $$k = _export;
1234
+ var $$l = _export;
1238
1235
  var $reduce = arrayReduce.left;
1239
1236
  var arrayMethodIsStrict$1 = arrayMethodIsStrict$2;
1240
1237
  var CHROME_VERSION = engineV8Version;
@@ -1247,7 +1244,7 @@ var CHROME_BUG = !IS_NODE$4 && CHROME_VERSION > 79 && CHROME_VERSION < 83;
1247
1244
 
1248
1245
  // `Array.prototype.reduce` method
1249
1246
  // https://tc39.es/ecma262/#sec-array.prototype.reduce
1250
- $$k({ target: 'Array', proto: true, forced: !STRICT_METHOD$1 || CHROME_BUG }, {
1247
+ $$l({ target: 'Array', proto: true, forced: !STRICT_METHOD$1 || CHROME_BUG }, {
1251
1248
  reduce: function reduce(callbackfn /* , initialValue */) {
1252
1249
  var length = arguments.length;
1253
1250
  return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
@@ -1542,7 +1539,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1542
1539
  };
1543
1540
  }() : undefined);
1544
1541
 
1545
- var $$j = _export;
1542
+ var $$k = _export;
1546
1543
  var call$d = functionCall;
1547
1544
  var FunctionName = functionName;
1548
1545
  var isCallable$a = isCallable$o;
@@ -1627,7 +1624,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1627
1624
  if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1628
1625
  defineBuiltIn$5(IterablePrototype, KEY, methods[KEY]);
1629
1626
  }
1630
- } else $$j({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1627
+ } else $$k({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1631
1628
  }
1632
1629
 
1633
1630
  // define iterator
@@ -1995,13 +1992,13 @@ var stringTrimForced = function (METHOD_NAME) {
1995
1992
  });
1996
1993
  };
1997
1994
 
1998
- var $$i = _export;
1995
+ var $$j = _export;
1999
1996
  var $trim = stringTrim.trim;
2000
1997
  var forcedStringTrimMethod = stringTrimForced;
2001
1998
 
2002
1999
  // `String.prototype.trim` method
2003
2000
  // https://tc39.es/ecma262/#sec-string.prototype.trim
2004
- $$i({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
2001
+ $$j({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
2005
2002
  trim: function trim() {
2006
2003
  return $trim(this);
2007
2004
  }
@@ -2196,12 +2193,12 @@ if (PATCH) {
2196
2193
 
2197
2194
  var regexpExec$2 = patchedExec;
2198
2195
 
2199
- var $$h = _export;
2196
+ var $$i = _export;
2200
2197
  var exec$2 = regexpExec$2;
2201
2198
 
2202
2199
  // `RegExp.prototype.exec` method
2203
2200
  // https://tc39.es/ecma262/#sec-regexp.prototype.exec
2204
- $$h({ target: 'RegExp', proto: true, forced: /./.exec !== exec$2 }, {
2201
+ $$i({ target: 'RegExp', proto: true, forced: /./.exec !== exec$2 }, {
2205
2202
  exec: exec$2
2206
2203
  });
2207
2204
 
@@ -2815,7 +2812,7 @@ const isPoBox = addressLine => PO_BOX_REGEX.test(addressLine);
2815
2812
  */
2816
2813
  const isPoBoxAddress = address => !!(isPoBox(address.addressLine1) || address.addressLine2 && isPoBox(address.addressLine2));
2817
2814
 
2818
- var $$g = _export;
2815
+ var $$h = _export;
2819
2816
  var $includes = arrayIncludes.includes;
2820
2817
  var fails$8 = fails$r;
2821
2818
  var addToUnscopables$2 = addToUnscopables$4;
@@ -2827,7 +2824,7 @@ var BROKEN_ON_SPARSE = fails$8(function () {
2827
2824
 
2828
2825
  // `Array.prototype.includes` method
2829
2826
  // https://tc39.es/ecma262/#sec-array.prototype.includes
2830
- $$g({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
2827
+ $$h({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
2831
2828
  includes: function includes(el /* , fromIndex = 0 */) {
2832
2829
  return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
2833
2830
  }
@@ -2912,7 +2909,7 @@ var toPropertyKey = toPropertyKey$3;
2912
2909
  var definePropertyModule$1 = objectDefineProperty;
2913
2910
  var createPropertyDescriptor = createPropertyDescriptor$4;
2914
2911
 
2915
- var createProperty$1 = function (object, key, value) {
2912
+ var createProperty$2 = function (object, key, value) {
2916
2913
  var propertyKey = toPropertyKey(key);
2917
2914
  if (propertyKey in object) definePropertyModule$1.f(object, propertyKey, createPropertyDescriptor(0, value));
2918
2915
  else object[propertyKey] = value;
@@ -2920,7 +2917,7 @@ var createProperty$1 = function (object, key, value) {
2920
2917
 
2921
2918
  var toAbsoluteIndex = toAbsoluteIndex$2;
2922
2919
  var lengthOfArrayLike$5 = lengthOfArrayLike$8;
2923
- var createProperty = createProperty$1;
2920
+ var createProperty$1 = createProperty$2;
2924
2921
 
2925
2922
  var $Array$1 = Array;
2926
2923
  var max = Math.max;
@@ -2930,7 +2927,7 @@ var arraySliceSimple = function (O, start, end) {
2930
2927
  var k = toAbsoluteIndex(start, length);
2931
2928
  var fin = toAbsoluteIndex(end === undefined ? length : end, length);
2932
2929
  var result = $Array$1(max(fin - k, 0));
2933
- for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
2930
+ for (var n = 0; k < fin; k++, n++) createProperty$1(result, n, O[k]);
2934
2931
  result.length = n;
2935
2932
  return result;
2936
2933
  };
@@ -2996,7 +2993,7 @@ var webkit = userAgent$3.match(/AppleWebKit\/(\d+)\./);
2996
2993
 
2997
2994
  var engineWebkitVersion = !!webkit && +webkit[1];
2998
2995
 
2999
- var $$f = _export;
2996
+ var $$g = _export;
3000
2997
  var uncurryThis$a = functionUncurryThis;
3001
2998
  var aCallable$7 = aCallable$a;
3002
2999
  var toObject$2 = toObject$8;
@@ -3074,7 +3071,7 @@ var getSortCompare = function (comparefn) {
3074
3071
 
3075
3072
  // `Array.prototype.sort` method
3076
3073
  // https://tc39.es/ecma262/#sec-array.prototype.sort
3077
- $$f({ target: 'Array', proto: true, forced: FORCED$3 }, {
3074
+ $$g({ target: 'Array', proto: true, forced: FORCED$3 }, {
3078
3075
  sort: function sort(comparefn) {
3079
3076
  if (comparefn !== undefined) aCallable$7(comparefn);
3080
3077
 
@@ -3189,7 +3186,7 @@ var correctIsRegexpLogic = function (METHOD_NAME) {
3189
3186
  } return false;
3190
3187
  };
3191
3188
 
3192
- var $$e = _export;
3189
+ var $$f = _export;
3193
3190
  var uncurryThis$9 = functionUncurryThis;
3194
3191
  var notARegExp$1 = notARegexp;
3195
3192
  var requireObjectCoercible$3 = requireObjectCoercible$9;
@@ -3200,7 +3197,7 @@ var stringIndexOf = uncurryThis$9(''.indexOf);
3200
3197
 
3201
3198
  // `String.prototype.includes` method
3202
3199
  // https://tc39.es/ecma262/#sec-string.prototype.includes
3203
- $$e({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, {
3200
+ $$f({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, {
3204
3201
  includes: function includes(searchString /* , position = 0 */) {
3205
3202
  return !!~stringIndexOf(
3206
3203
  toString$6(requireObjectCoercible$3(this)),
@@ -3807,7 +3804,7 @@ var arraySpeciesCreate$2 = function (originalArray, length) {
3807
3804
  return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
3808
3805
  };
3809
3806
 
3810
- var $$d = _export;
3807
+ var $$e = _export;
3811
3808
  var flattenIntoArray$1 = flattenIntoArray_1;
3812
3809
  var aCallable$5 = aCallable$a;
3813
3810
  var toObject$1 = toObject$8;
@@ -3816,7 +3813,7 @@ var arraySpeciesCreate$1 = arraySpeciesCreate$2;
3816
3813
 
3817
3814
  // `Array.prototype.flatMap` method
3818
3815
  // https://tc39.es/ecma262/#sec-array.prototype.flatmap
3819
- $$d({ target: 'Array', proto: true }, {
3816
+ $$e({ target: 'Array', proto: true }, {
3820
3817
  flatMap: function flatMap(callbackfn /* , thisArg */) {
3821
3818
  var O = toObject$1(this);
3822
3819
  var sourceLen = lengthOfArrayLike$2(O);
@@ -3976,7 +3973,7 @@ var stringRepeat = function repeat(count) {
3976
3973
  return result;
3977
3974
  };
3978
3975
 
3979
- var $$c = _export;
3976
+ var $$d = _export;
3980
3977
  var uncurryThis$5 = functionUncurryThis;
3981
3978
  var toIntegerOrInfinity$1 = toIntegerOrInfinity$7;
3982
3979
  var thisNumberValue = thisNumberValue$1;
@@ -4050,7 +4047,7 @@ var FORCED$2 = fails$5(function () {
4050
4047
 
4051
4048
  // `Number.prototype.toFixed` method
4052
4049
  // https://tc39.es/ecma262/#sec-number.prototype.tofixed
4053
- $$c({ target: 'Number', proto: true, forced: FORCED$2 }, {
4050
+ $$d({ target: 'Number', proto: true, forced: FORCED$2 }, {
4054
4051
  toFixed: function toFixed(fractionDigits) {
4055
4052
  var number = thisNumberValue(this);
4056
4053
  var fractDigits = toIntegerOrInfinity$1(fractionDigits);
@@ -4130,12 +4127,12 @@ var numberParseFloat = FORCED$1 ? function parseFloat(string) {
4130
4127
  return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
4131
4128
  } : $parseFloat$1;
4132
4129
 
4133
- var $$b = _export;
4130
+ var $$c = _export;
4134
4131
  var $parseFloat = numberParseFloat;
4135
4132
 
4136
4133
  // `parseFloat` method
4137
4134
  // https://tc39.es/ecma262/#sec-parsefloat-string
4138
- $$b({ global: true, forced: parseFloat != $parseFloat }, {
4135
+ $$c({ global: true, forced: parseFloat != $parseFloat }, {
4139
4136
  parseFloat: $parseFloat
4140
4137
  });
4141
4138
 
@@ -4290,12 +4287,12 @@ var numberParseInt = FORCED ? function parseInt(string, radix) {
4290
4287
  return $parseInt$1(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
4291
4288
  } : $parseInt$1;
4292
4289
 
4293
- var $$a = _export;
4290
+ var $$b = _export;
4294
4291
  var $parseInt = numberParseInt;
4295
4292
 
4296
4293
  // `parseInt` method
4297
4294
  // https://tc39.es/ecma262/#sec-parseint-string-radix
4298
- $$a({ global: true, forced: parseInt != $parseInt }, {
4295
+ $$b({ global: true, forced: parseInt != $parseInt }, {
4299
4296
  parseInt: $parseInt
4300
4297
  });
4301
4298
 
@@ -22807,6 +22804,240 @@ const useRunOnceOnTrue = conditionalEffect => {
22807
22804
  */
22808
22805
  const useToggle = (initialValue = false) => React.useReducer((prev, next) => next !== undefined && typeof next !== "object" ? next : !prev, initialValue);
22809
22806
 
22807
+ var wellKnownSymbol$5 = wellKnownSymbol$j;
22808
+ var Iterators$1 = iterators;
22809
+
22810
+ var ITERATOR$2 = wellKnownSymbol$5('iterator');
22811
+ var ArrayPrototype = Array.prototype;
22812
+
22813
+ // check on default Array iterator
22814
+ var isArrayIteratorMethod$1 = function (it) {
22815
+ return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$2] === it);
22816
+ };
22817
+
22818
+ var classof = classof$6;
22819
+ var getMethod$2 = getMethod$5;
22820
+ var isNullOrUndefined$2 = isNullOrUndefined$6;
22821
+ var Iterators = iterators;
22822
+ var wellKnownSymbol$4 = wellKnownSymbol$j;
22823
+
22824
+ var ITERATOR$1 = wellKnownSymbol$4('iterator');
22825
+
22826
+ var getIteratorMethod$2 = function (it) {
22827
+ if (!isNullOrUndefined$2(it)) return getMethod$2(it, ITERATOR$1)
22828
+ || getMethod$2(it, '@@iterator')
22829
+ || Iterators[classof(it)];
22830
+ };
22831
+
22832
+ var call$7 = functionCall;
22833
+ var aCallable$4 = aCallable$a;
22834
+ var anObject$5 = anObject$f;
22835
+ var tryToString$2 = tryToString$5;
22836
+ var getIteratorMethod$1 = getIteratorMethod$2;
22837
+
22838
+ var $TypeError$5 = TypeError;
22839
+
22840
+ var getIterator$1 = function (argument, usingIterator) {
22841
+ var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
22842
+ if (aCallable$4(iteratorMethod)) return anObject$5(call$7(iteratorMethod, argument));
22843
+ throw $TypeError$5(tryToString$2(argument) + ' is not iterable');
22844
+ };
22845
+
22846
+ var call$6 = functionCall;
22847
+ var anObject$4 = anObject$f;
22848
+ var getMethod$1 = getMethod$5;
22849
+
22850
+ var iteratorClose$1 = function (iterator, kind, value) {
22851
+ var innerResult, innerError;
22852
+ anObject$4(iterator);
22853
+ try {
22854
+ innerResult = getMethod$1(iterator, 'return');
22855
+ if (!innerResult) {
22856
+ if (kind === 'throw') throw value;
22857
+ return value;
22858
+ }
22859
+ innerResult = call$6(innerResult, iterator);
22860
+ } catch (error) {
22861
+ innerError = true;
22862
+ innerResult = error;
22863
+ }
22864
+ if (kind === 'throw') throw value;
22865
+ if (innerError) throw innerResult;
22866
+ anObject$4(innerResult);
22867
+ return value;
22868
+ };
22869
+
22870
+ var bind$3 = functionBindContext;
22871
+ var call$5 = functionCall;
22872
+ var anObject$3 = anObject$f;
22873
+ var tryToString$1 = tryToString$5;
22874
+ var isArrayIteratorMethod = isArrayIteratorMethod$1;
22875
+ var lengthOfArrayLike$1 = lengthOfArrayLike$8;
22876
+ var isPrototypeOf$2 = objectIsPrototypeOf;
22877
+ var getIterator = getIterator$1;
22878
+ var getIteratorMethod = getIteratorMethod$2;
22879
+ var iteratorClose = iteratorClose$1;
22880
+
22881
+ var $TypeError$4 = TypeError;
22882
+
22883
+ var Result = function (stopped, result) {
22884
+ this.stopped = stopped;
22885
+ this.result = result;
22886
+ };
22887
+
22888
+ var ResultPrototype = Result.prototype;
22889
+
22890
+ var iterate$3 = function (iterable, unboundFunction, options) {
22891
+ var that = options && options.that;
22892
+ var AS_ENTRIES = !!(options && options.AS_ENTRIES);
22893
+ var IS_RECORD = !!(options && options.IS_RECORD);
22894
+ var IS_ITERATOR = !!(options && options.IS_ITERATOR);
22895
+ var INTERRUPTED = !!(options && options.INTERRUPTED);
22896
+ var fn = bind$3(unboundFunction, that);
22897
+ var iterator, iterFn, index, length, result, next, step;
22898
+
22899
+ var stop = function (condition) {
22900
+ if (iterator) iteratorClose(iterator, 'normal', condition);
22901
+ return new Result(true, condition);
22902
+ };
22903
+
22904
+ var callFn = function (value) {
22905
+ if (AS_ENTRIES) {
22906
+ anObject$3(value);
22907
+ return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
22908
+ } return INTERRUPTED ? fn(value, stop) : fn(value);
22909
+ };
22910
+
22911
+ if (IS_RECORD) {
22912
+ iterator = iterable.iterator;
22913
+ } else if (IS_ITERATOR) {
22914
+ iterator = iterable;
22915
+ } else {
22916
+ iterFn = getIteratorMethod(iterable);
22917
+ if (!iterFn) throw $TypeError$4(tryToString$1(iterable) + ' is not iterable');
22918
+ // optimisation for array iterators
22919
+ if (isArrayIteratorMethod(iterFn)) {
22920
+ for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
22921
+ result = callFn(iterable[index]);
22922
+ if (result && isPrototypeOf$2(ResultPrototype, result)) return result;
22923
+ } return new Result(false);
22924
+ }
22925
+ iterator = getIterator(iterable, iterFn);
22926
+ }
22927
+
22928
+ next = IS_RECORD ? iterable.next : iterator.next;
22929
+ while (!(step = call$5(next, iterator)).done) {
22930
+ try {
22931
+ result = callFn(step.value);
22932
+ } catch (error) {
22933
+ iteratorClose(iterator, 'throw', error);
22934
+ }
22935
+ if (typeof result == 'object' && result && isPrototypeOf$2(ResultPrototype, result)) return result;
22936
+ } return new Result(false);
22937
+ };
22938
+
22939
+ var $$a = _export;
22940
+ var iterate$2 = iterate$3;
22941
+ var createProperty = createProperty$2;
22942
+
22943
+ // `Object.fromEntries` method
22944
+ // https://github.com/tc39/proposal-object-from-entries
22945
+ $$a({ target: 'Object', stat: true }, {
22946
+ fromEntries: function fromEntries(iterable) {
22947
+ var obj = {};
22948
+ iterate$2(iterable, function (k, v) {
22949
+ createProperty(obj, k, v);
22950
+ }, { AS_ENTRIES: true });
22951
+ return obj;
22952
+ }
22953
+ });
22954
+
22955
+ const useWarehouseValidation = () => {
22956
+ const [warehousePreference, setWarehousePreference] = React.useState();
22957
+ const {
22958
+ error: validateAddressErrors,
22959
+ mutateAsync: validateAddresses
22960
+ } = react.useValidateAddresses();
22961
+ const caseInsensitiveCompare = React.useCallback((matched, original) => {
22962
+ if (matched === undefined || original === undefined) return false;
22963
+ const originalAddress = Object.fromEntries(Object.entries(original).map(([key, value]) => [key, typeof value == "string" ? value.toLowerCase() : value]));
22964
+ const matchedAddress = Object.fromEntries(Object.entries(matched).map(([key, value]) => [key, typeof value == "string" ? value.toLowerCase() : value]));
22965
+ // SE api returns addressLine2 as an empty string if it is not provided
22966
+ if (matchedAddress.addressLine2 === "") {
22967
+ matchedAddress.addressLine2 = null;
22968
+ }
22969
+ if (_$2.isEqual(_$2.omit(matchedAddress, ["postalCode", "addressResidentialIndicator"]), _$2.omit(originalAddress, ["postalCode", "addressResidentialIndicator"]))) return true;else return false;
22970
+ }, []);
22971
+ const postalCodeCompare = React.useCallback((matched, original) => {
22972
+ if (matched === undefined || original === undefined) return false;
22973
+ if (matched === original) return true;
22974
+ return matched.includes(original);
22975
+ }, []);
22976
+ const buildWarehousePreference = React.useCallback(addressValidation => {
22977
+ /**
22978
+ * Address validation matching criteria
22979
+ * 1. Case-insensitive string comparison
22980
+ * 2. Zip Code only added 4 extra digits to the original Zip Code
22981
+ */
22982
+ var _a;
22983
+ if (addressValidation.status === "error") {
22984
+ return {
22985
+ validation: addressValidation,
22986
+ validationType: "ERROR"
22987
+ };
22988
+ }
22989
+ // Valid if the matched address and input address were EXACTLY the same
22990
+ if (addressValidation.matchedAddress && addressValidation.matchedAddress.name === addressValidation.originalAddress.name && addressValidation.matchedAddress.companyName === addressValidation.originalAddress.companyName && addressValidation.matchedAddress.addressLine1 === addressValidation.originalAddress.addressLine1 && addressValidation.matchedAddress.addressLine2 === addressValidation.originalAddress.addressLine2 && addressValidation.matchedAddress.cityLocality === addressValidation.originalAddress.cityLocality && addressValidation.matchedAddress.stateProvince === addressValidation.originalAddress.stateProvince && addressValidation.matchedAddress.postalCode === addressValidation.originalAddress.postalCode && addressValidation.matchedAddress.countryCode === addressValidation.originalAddress.countryCode) {
22991
+ return {
22992
+ address: addressValidation.originalAddress,
22993
+ validationType: "EXACT"
22994
+ };
22995
+ }
22996
+ // Valid if the matched address passes matching criteria but are not exactly the same address
22997
+ if (addressValidation.matchedAddress && caseInsensitiveCompare(addressValidation.matchedAddress, addressValidation.originalAddress) && postalCodeCompare((_a = addressValidation.matchedAddress) === null || _a === void 0 ? void 0 : _a.postalCode, addressValidation.originalAddress.postalCode)) {
22998
+ return {
22999
+ address: addressValidation.matchedAddress,
23000
+ validationType: "SOFT"
23001
+ };
23002
+ }
23003
+ // If there is a matched address and does not pass the matching criteria
23004
+ if (addressValidation.matchedAddress) {
23005
+ return {
23006
+ validation: addressValidation,
23007
+ validationType: "SUGGESTED"
23008
+ };
23009
+ }
23010
+ // error or address was not valiqated
23011
+ return {
23012
+ validation: addressValidation,
23013
+ validationType: "ERROR"
23014
+ };
23015
+ }, [caseInsensitiveCompare, postalCodeCompare]);
23016
+ const validate = React.useCallback(warehouse => __awaiter(void 0, void 0, void 0, function* () {
23017
+ const warehouseAddresses = [warehouse.originAddress, ...(warehouse.returnAddress ? [warehouse.returnAddress] : [])];
23018
+ const result = yield validateAddresses(warehouseAddresses);
23019
+ const [originAddress, returnAddress] = result;
23020
+ setWarehousePreference({
23021
+ isDefault: warehouse.isDefault,
23022
+ name: warehouse.name,
23023
+ originAddress: buildWarehousePreference(originAddress),
23024
+ returnAddress: returnAddress && buildWarehousePreference(returnAddress)
23025
+ });
23026
+ return {
23027
+ isDefault: warehouse.isDefault,
23028
+ name: warehouse.name,
23029
+ originAddress: buildWarehousePreference(originAddress),
23030
+ returnAddress: returnAddress && buildWarehousePreference(returnAddress)
23031
+ };
23032
+ }), [buildWarehousePreference, validateAddresses]);
23033
+ return {
23034
+ errors: validateAddressErrors,
23035
+ setWarehousePreference,
23036
+ validate,
23037
+ warehousePreference
23038
+ };
23039
+ };
23040
+
22810
23041
  const addressParserSchema = zod.z.object({
22811
23042
  fullAddress: zod.z.string().min(1)
22812
23043
  });
@@ -23036,14 +23267,14 @@ const extendZod = () => {
23036
23267
  zod.z.ZodObject.prototype.nullishDefault = nullishDefault;
23037
23268
  };
23038
23269
 
23039
- var call$7 = functionCall;
23270
+ var call$4 = functionCall;
23040
23271
  var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
23041
- var anObject$5 = anObject$f;
23042
- var isNullOrUndefined$2 = isNullOrUndefined$6;
23272
+ var anObject$2 = anObject$f;
23273
+ var isNullOrUndefined$1 = isNullOrUndefined$6;
23043
23274
  var toLength$1 = toLength$4;
23044
23275
  var toString$2 = toString$c;
23045
23276
  var requireObjectCoercible$1 = requireObjectCoercible$9;
23046
- var getMethod$2 = getMethod$5;
23277
+ var getMethod = getMethod$5;
23047
23278
  var advanceStringIndex = advanceStringIndex$2;
23048
23279
  var regExpExec = regexpExecAbstract;
23049
23280
 
@@ -23054,13 +23285,13 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
23054
23285
  // https://tc39.es/ecma262/#sec-string.prototype.match
23055
23286
  function match(regexp) {
23056
23287
  var O = requireObjectCoercible$1(this);
23057
- var matcher = isNullOrUndefined$2(regexp) ? undefined : getMethod$2(regexp, MATCH);
23058
- return matcher ? call$7(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$2(O));
23288
+ var matcher = isNullOrUndefined$1(regexp) ? undefined : getMethod(regexp, MATCH);
23289
+ return matcher ? call$4(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$2(O));
23059
23290
  },
23060
23291
  // `RegExp.prototype[@@match]` method
23061
23292
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
23062
23293
  function (string) {
23063
- var rx = anObject$5(this);
23294
+ var rx = anObject$2(this);
23064
23295
  var S = toString$2(string);
23065
23296
  var res = maybeCallNative(nativeMatch, rx, S);
23066
23297
 
@@ -23995,7 +24226,7 @@ var global$8 = global$p;
23995
24226
  var uncurryThis$2 = functionUncurryThis;
23996
24227
  var hasOwn$1 = hasOwnProperty_1;
23997
24228
  var isCallable$5 = isCallable$o;
23998
- var isPrototypeOf$2 = objectIsPrototypeOf;
24229
+ var isPrototypeOf$1 = objectIsPrototypeOf;
23999
24230
  var toString$1 = toString$c;
24000
24231
  var defineProperty = objectDefineProperty.f;
24001
24232
  var copyConstructorProperties = copyConstructorProperties$2;
@@ -24011,7 +24242,7 @@ if (DESCRIPTORS$1 && isCallable$5(NativeSymbol) && (!('description' in SymbolPro
24011
24242
  // wrap Symbol constructor for correct work with undefined description
24012
24243
  var SymbolWrapper = function Symbol() {
24013
24244
  var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString$1(arguments[0]);
24014
- var result = isPrototypeOf$2(SymbolPrototype, this)
24245
+ var result = isPrototypeOf$1(SymbolPrototype, this)
24015
24246
  ? new NativeSymbol(description)
24016
24247
  // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
24017
24248
  : description === undefined ? NativeSymbol() : NativeSymbol(description);
@@ -24491,6 +24722,7 @@ const getStyles$4 = (isConnected = false) => createStyles({
24491
24722
  padding: `0 ${theme.spacing(.5)}px`
24492
24723
  }, isConnected && {
24493
24724
  backgroundColor: theme.palette.success.main,
24725
+ borderRadius: theme.borderRadius.XS,
24494
24726
  color: theme.palette.white
24495
24727
  }],
24496
24728
  container: {
@@ -24517,7 +24749,7 @@ var _ref$1 = process.env.NODE_ENV === "production" ? {
24517
24749
  } : {
24518
24750
  name: "111ty02-css",
24519
24751
  styles: "align-items:center;display:flex;label:css;",
24520
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpc3QtY2FycmllcnMtcm93LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFtQmllIiwiZmlsZSI6Imxpc3QtY2FycmllcnMtcm93LnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IF9fYXdhaXRlciB9IGZyb20gXCJ0c2xpYlwiO1xyXG5pbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJAZW1vdGlvbi9yZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgeyBjc3MgfSBmcm9tIFwiQGVtb3Rpb24vcmVhY3RcIjtcclxuaW1wb3J0IHsgdXNlU3RhdGUgfSBmcm9tIFwicmVhY3RcIjtcclxuaW1wb3J0IHsgdXNlVHJhbnNsYXRpb24gfSBmcm9tIFwicmVhY3QtaTE4bmV4dFwiO1xyXG5pbXBvcnQgeyBCdXR0b24sIEJ1dHRvbkNvbG9yLCBCdXR0b25WYXJpYW50LCBUeXBvZ3JhcGh5IH0gZnJvbSBcIkBwYWNrbGluay9naWdlclwiO1xyXG5pbXBvcnQgeyBUZW1wbGF0ZXMgfSBmcm9tIFwiLi4vLi4vLi4vY29tcG9uZW50c1wiO1xyXG5pbXBvcnQgeyBnZXRTdHlsZXMgfSBmcm9tIFwiLi9saXN0LWNhcnJpZXJzLXJvdy5zdHlsZXNcIjtcclxuZXhwb3J0IGNvbnN0IExpc3RDYXJyaWVyc1JvdyA9ICh7IGNvbm5lY3RlZENhcnJpZXI6IHsgY2FycmllciwgaXNDb25uZWN0ZWQgfSwgcmVnaXN0ZXJDYXJyaWVyLCByZWdpc3RlckNhcnJpZXJFcnJvcnMsIH0pID0+IHtcclxuICAgIGNvbnN0IHsgc2hvcnRuYW1lOiBuYW1lLCBsb2dvLCByZXF1aXJlZEZpZWxkcyB9ID0gY2FycmllcjtcclxuICAgIGNvbnN0IHsgdCB9ID0gdXNlVHJhbnNsYXRpb24oW1wibGlzdC1jYXJyaWVyc1wiXSk7XHJcbiAgICBjb25zdCBbc2hvd0Ryb3BEb3duLCBzZXRTaG93RHJvcERvd25dID0gdXNlU3RhdGUoZmFsc2UpO1xyXG4gICAgY29uc3QgW2lzU3VibWl0dGluZywgc2V0SXNTdWJtaXR0aW5nXSA9IHVzZVN0YXRlKGZhbHNlKTtcclxuICAgIGNvbnN0IGhhbmRsZVJlZ2lzdGVyID0gKHZhbHVlcykgPT4gX19hd2FpdGVyKHZvaWQgMCwgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uKiAoKSB7XHJcbiAgICAgICAgc2V0SXNTdWJtaXR0aW5nKHRydWUpO1xyXG4gICAgICAgIHlpZWxkIHJlZ2lzdGVyQ2Fycmllcih2YWx1ZXMpO1xyXG4gICAgICAgIHNob3dEcm9wRG93biAmJiBzZXRTaG93RHJvcERvd24oZmFsc2UpO1xyXG4gICAgICAgIHNldElzU3VibWl0dGluZyhmYWxzZSk7XHJcbiAgICB9KTtcclxuICAgIHJldHVybiAoX2pzeHMoXCJkaXZcIiwgT2JqZWN0LmFzc2lnbih7IGNzczogZ2V0U3R5bGVzKCkuY29udGFpbmVyLCBcImRhdGEtdGVzdGlkXCI6IFwiY2Fycmllci1yb3dcIiB9LCB7IGNoaWxkcmVuOiBbX2pzeHMoXCJkaXZcIiwgT2JqZWN0LmFzc2lnbih7IGNzczogZ2V0U3R5bGVzKCkucm93Q29udGFpbmVyIH0sIHsgY2hpbGRyZW46IFtfanN4cyhcImRpdlwiLCBPYmplY3QuYXNzaWduKHsgY3NzOiBnZXRTdHlsZXMoKS5sb2dvQ29udGFpbmVyIH0sIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2hpbGRyZW46IF9qc3goXCJpbWdcIiwgeyBhbHQ6IGAke25hbWV9LWxvZ29gLCBoZWlnaHQ6IDQwLCBzcmM6IGxvZ28sIHdpZHRoOiA0MCB9KSB9KSwgX2pzeChUeXBvZ3JhcGh5LCBPYmplY3QuYXNzaWduKHsgdmFyaWFudDogXCJzdWJ0aXRsZTFcIiB9LCB7IGNoaWxkcmVuOiBuYW1lIH0pKV0gfSkpLCBfanN4KFwiZGl2XCIsIE9iamVjdC5hc3NpZ24oeyBjc3M6IGNzcyh7IGFsaWduSXRlbXM6IFwiY2VudGVyXCIsIGRpc3BsYXk6IFwiZmxleFwiIH0pIH0sIHsgY2hpbGRyZW46IF9qc3goQnV0dG9uLCBPYmplY3QuYXNzaWduKHsgY29sb3I6IEJ1dHRvbkNvbG9yLlNFQ09OREFSWSwgY3NzOiBnZXRTdHlsZXMoaXNDb25uZWN0ZWQpLmNvbm5lY3RCdXR0b24sIGRpc2FibGVkOiBpc0Nvbm5lY3RlZCB8fCBzaG93RHJvcERvd24sIGlzTG9hZGluZzogaXNTdWJtaXR0aW5nLCBvbkNsaWNrOiAoKSA9PiBfX2F3YWl0ZXIodm9pZCAwLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVxdWlyZWRGaWVsZHMgPT09IG51bGwgfHwgcmVxdWlyZWRGaWVsZHMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHJlcXVpcmVkRmllbGRzLmluY2x1ZGVzKFwiYWRkcmVzc1wiKSlcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0U2hvd0Ryb3BEb3duKHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2VcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeWllbGQgaGFuZGxlUmVnaXN0ZXIoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLCB2YXJpYW50OiBCdXR0b25WYXJpYW50LlRFWFQgfSwgeyBjaGlsZHJlbjogaXNDb25uZWN0ZWRcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IHQoXCJsaXN0LWNhcnJpZXJzOmFjdGlvbnMuc3RhdHVzLmNvbm5lY3RlZFwiKVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogdChcImxpc3QtY2FycmllcnM6YWN0aW9ucy5zdGF0dXMubm90Q29ubmVjdGVkXCIpIH0pKSB9KSldIH0pKSwgc2hvd0Ryb3BEb3duICYmIChfanN4KFRlbXBsYXRlcy5BZGRDYXJyaWVyRm9ybSwgeyBjYXJyaWVyVGVybXM6IGNhcnJpZXIudGVybXMgJiYgY2Fycmllci50ZXJtcywgb25DYW5jZWw6ICgpID0+IHNldFNob3dEcm9wRG93bihmYWxzZSksIG9uU3VibWl0OiAodmFsdWVzKSA9PiBoYW5kbGVSZWdpc3Rlcih2YWx1ZXMpLCByZWdpc3RlckNhcnJpZXJFcnJvcnM6IHJlZ2lzdGVyQ2FycmllckVycm9ycyB9KSldIH0pKSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWxpc3QtY2FycmllcnMtcm93LmpzLm1hcCJdfQ== */",
24752
+ map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpc3QtY2FycmllcnMtcm93LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFtQmllIiwiZmlsZSI6Imxpc3QtY2FycmllcnMtcm93LnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IF9fYXdhaXRlciB9IGZyb20gXCJ0c2xpYlwiO1xyXG5pbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJAZW1vdGlvbi9yZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgeyBjc3MgfSBmcm9tIFwiQGVtb3Rpb24vcmVhY3RcIjtcclxuaW1wb3J0IHsgdXNlU3RhdGUgfSBmcm9tIFwicmVhY3RcIjtcclxuaW1wb3J0IHsgdXNlVHJhbnNsYXRpb24gfSBmcm9tIFwicmVhY3QtaTE4bmV4dFwiO1xyXG5pbXBvcnQgeyBUeXBvZ3JhcGh5IH0gZnJvbSBcIkBwYWNrbGluay9naWdlclwiO1xyXG5pbXBvcnQgeyBMaW5rQWN0aW9uLCBUZW1wbGF0ZXMgfSBmcm9tIFwiLi4vLi4vLi4vY29tcG9uZW50c1wiO1xyXG5pbXBvcnQgeyBnZXRTdHlsZXMgfSBmcm9tIFwiLi9saXN0LWNhcnJpZXJzLXJvdy5zdHlsZXNcIjtcclxuZXhwb3J0IGNvbnN0IExpc3RDYXJyaWVyc1JvdyA9ICh7IGNvbm5lY3RlZENhcnJpZXI6IHsgY2FycmllciwgaXNDb25uZWN0ZWQgfSwgcmVnaXN0ZXJDYXJyaWVyLCByZWdpc3RlckNhcnJpZXJFcnJvcnMsIH0pID0+IHtcclxuICAgIGNvbnN0IHsgc2hvcnRuYW1lOiBuYW1lLCBsb2dvLCByZXF1aXJlZEZpZWxkcyB9ID0gY2FycmllcjtcclxuICAgIGNvbnN0IHsgdCB9ID0gdXNlVHJhbnNsYXRpb24oW1wibGlzdC1jYXJyaWVyc1wiXSk7XHJcbiAgICBjb25zdCBbc2hvd0Ryb3BEb3duLCBzZXRTaG93RHJvcERvd25dID0gdXNlU3RhdGUoZmFsc2UpO1xyXG4gICAgY29uc3QgW2lzU3VibWl0dGluZywgc2V0SXNTdWJtaXR0aW5nXSA9IHVzZVN0YXRlKGZhbHNlKTtcclxuICAgIGNvbnN0IGhhbmRsZVJlZ2lzdGVyID0gKHZhbHVlcykgPT4gX19hd2FpdGVyKHZvaWQgMCwgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uKiAoKSB7XHJcbiAgICAgICAgc2V0SXNTdWJtaXR0aW5nKHRydWUpO1xyXG4gICAgICAgIHlpZWxkIHJlZ2lzdGVyQ2Fycmllcih2YWx1ZXMpO1xyXG4gICAgICAgIHNob3dEcm9wRG93biAmJiBzZXRTaG93RHJvcERvd24oZmFsc2UpO1xyXG4gICAgICAgIHNldElzU3VibWl0dGluZyhmYWxzZSk7XHJcbiAgICB9KTtcclxuICAgIHJldHVybiAoX2pzeHMoXCJkaXZcIiwgT2JqZWN0LmFzc2lnbih7IGNzczogZ2V0U3R5bGVzKCkuY29udGFpbmVyLCBcImRhdGEtdGVzdGlkXCI6IFwiY2Fycmllci1yb3dcIiB9LCB7IGNoaWxkcmVuOiBbX2pzeHMoXCJkaXZcIiwgT2JqZWN0LmFzc2lnbih7IGNzczogZ2V0U3R5bGVzKCkucm93Q29udGFpbmVyIH0sIHsgY2hpbGRyZW46IFtfanN4cyhcImRpdlwiLCBPYmplY3QuYXNzaWduKHsgY3NzOiBnZXRTdHlsZXMoKS5sb2dvQ29udGFpbmVyIH0sIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2hpbGRyZW46IF9qc3goXCJpbWdcIiwgeyBhbHQ6IGAke25hbWV9LWxvZ29gLCBoZWlnaHQ6IDQwLCBzcmM6IGxvZ28sIHdpZHRoOiA0MCB9KSB9KSwgX2pzeChUeXBvZ3JhcGh5LCBPYmplY3QuYXNzaWduKHsgdmFyaWFudDogXCJzdWJ0aXRsZTFcIiB9LCB7IGNoaWxkcmVuOiBuYW1lIH0pKV0gfSkpLCBfanN4KFwiZGl2XCIsIE9iamVjdC5hc3NpZ24oeyBjc3M6IGNzcyh7IGFsaWduSXRlbXM6IFwiY2VudGVyXCIsIGRpc3BsYXk6IFwiZmxleFwiIH0pIH0sIHsgY2hpbGRyZW46IF9qc3goTGlua0FjdGlvbiwgeyBjc3M6IGdldFN0eWxlcyhpc0Nvbm5lY3RlZCkuY29ubmVjdEJ1dHRvbiwgaXNEaXNhYmxlZDogaXNDb25uZWN0ZWQgfHwgc2hvd0Ryb3BEb3duLCBpc0xvYWRpbmc6IGlzU3VibWl0dGluZywgb25DbGljazogKCkgPT4gX19hd2FpdGVyKHZvaWQgMCwgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uKiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcXVpcmVkRmllbGRzID09PSBudWxsIHx8IHJlcXVpcmVkRmllbGRzID09PSB2b2lkIDAgPyB2b2lkIDAgOiByZXF1aXJlZEZpZWxkcy5pbmNsdWRlcyhcImFkZHJlc3NcIikpXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFNob3dEcm9wRG93bih0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlpZWxkIGhhbmRsZVJlZ2lzdGVyKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSwgdGl0bGU6IGlzQ29ubmVjdGVkXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyB0KFwibGlzdC1jYXJyaWVyczphY3Rpb25zLnN0YXR1cy5jb25uZWN0ZWRcIilcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IHQoXCJsaXN0LWNhcnJpZXJzOmFjdGlvbnMuc3RhdHVzLm5vdENvbm5lY3RlZFwiKSB9KSB9KSldIH0pKSwgc2hvd0Ryb3BEb3duICYmIChfanN4KFRlbXBsYXRlcy5BZGRDYXJyaWVyRm9ybSwgeyBjYXJyaWVyVGVybXM6IGNhcnJpZXIudGVybXMgJiYgY2Fycmllci50ZXJtcywgb25DYW5jZWw6ICgpID0+IHNldFNob3dEcm9wRG93bihmYWxzZSksIG9uU3VibWl0OiAodmFsdWVzKSA9PiBoYW5kbGVSZWdpc3Rlcih2YWx1ZXMpLCByZWdpc3RlckNhcnJpZXJFcnJvcnM6IHJlZ2lzdGVyQ2FycmllckVycm9ycyB9KSldIH0pKSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWxpc3QtY2FycmllcnMtcm93LmpzLm1hcCJdfQ== */",
24521
24753
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2
24522
24754
  };
24523
24755
  const ListCarriersRow = ({
@@ -24569,18 +24801,15 @@ const ListCarriersRow = ({
24569
24801
  })), jsxRuntime.jsx("div", Object.assign({
24570
24802
  css: _ref$1
24571
24803
  }, {
24572
- children: jsxRuntime.jsx(giger.Button, Object.assign({
24573
- color: giger.ButtonColor.SECONDARY,
24804
+ children: jsxRuntime.jsx(LinkAction, {
24574
24805
  css: getStyles$4(isConnected).connectButton,
24575
- disabled: isConnected || showDropDown,
24806
+ isDisabled: isConnected || showDropDown,
24576
24807
  isLoading: isSubmitting,
24577
24808
  onClick: () => __awaiter(void 0, void 0, void 0, function* () {
24578
24809
  if (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes("address")) setShowDropDown(true);else yield handleRegister();
24579
24810
  }),
24580
- variant: giger.ButtonVariant.TEXT
24581
- }, {
24582
- children: isConnected ? t("list-carriers:actions.status.connected") : t("list-carriers:actions.status.notConnected")
24583
- }))
24811
+ title: isConnected ? t("list-carriers:actions.status.connected") : t("list-carriers:actions.status.notConnected")
24812
+ })
24584
24813
  }))]
24585
24814
  })), showDropDown && jsxRuntime.jsx(AddCarrierForm, {
24586
24815
  carrierTerms: carrier.terms && carrier.terms,
@@ -24811,6 +25040,7 @@ const WarehouseDisplay = ({
24811
25040
  returnAddress
24812
25041
  } = warehouse;
24813
25042
  return jsxRuntime.jsxs(giger.Grid, Object.assign({
25043
+ "data-testid": "warehouseDisplay",
24814
25044
  noPadding: true
24815
25045
  }, {
24816
25046
  children: [jsxRuntime.jsx(giger.GridChild, Object.assign({
@@ -24887,28 +25117,7 @@ const warehouseSchema = zod.z.discriminatedUnion("returnToAddressIsDifferent", [
24887
25117
  name: zod.z.string().trim().min(1),
24888
25118
  originAddress: warehouseAddressSchema,
24889
25119
  returnToAddressIsDifferent: zod.z.literal(false)
24890
- })]).transform(schema => {
24891
- if (schema.returnToAddressIsDifferent) {
24892
- return schema;
24893
- }
24894
- return Object.assign(Object.assign({}, schema), {
24895
- returnAddress: schema.originAddress
24896
- });
24897
- });
24898
-
24899
- const styles$3 = createStyles({
24900
- header: {
24901
- textAlign: "center"
24902
- },
24903
- onboardingWell: theme => ({
24904
- backgroundColor: theme.palette.white,
24905
- padding: theme.spacing(2)
24906
- }),
24907
- well: theme => ({
24908
- backgroundColor: theme.palette.gray.ultraLight,
24909
- padding: theme.spacing(2)
24910
- })
24911
- });
25120
+ })]);
24912
25121
 
24913
25122
  const WarehouseForm = ({
24914
25123
  isOnboarding: _isOnboarding = false,
@@ -24932,9 +25141,9 @@ const WarehouseForm = ({
24932
25141
  }),
24933
25142
  returnToAddressIsDifferent: !lodash.exports.isEqual(warehouse.originAddress, warehouse.returnAddress)
24934
25143
  }) : {
24935
- isDefault: false,
25144
+ isDefault: _isOnboarding ? true : false,
24936
25145
  originAddress: {
24937
- countryCode: "US"
25146
+ addressResidentialIndicator: false
24938
25147
  },
24939
25148
  returnToAddressIsDifferent: false
24940
25149
  },
@@ -24943,140 +25152,365 @@ const WarehouseForm = ({
24943
25152
  const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
24944
25153
  const _a = values,
24945
25154
  payload = __rest(_a, ["returnToAddressIsDifferent"]);
24946
- if (_isOnboarding) {
24947
- payload.isDefault = true;
24948
- yield onSubmit(payload);
24949
- } else {
24950
- yield onSubmit(payload);
24951
- }
25155
+ yield onSubmit(payload);
24952
25156
  }));
24953
- return jsxRuntime.jsxs("div", Object.assign({
24954
- css: _isOnboarding ? styles$3.onboardingWell : styles$3.well,
24955
- "data-testid": "warehouse-form"
25157
+ return jsxRuntime.jsxs("form", Object.assign({
25158
+ id: "warehouse-form",
25159
+ onSubmit: formLogger.capture(handleSubmit)
24956
25160
  }, {
24957
- children: [_isOnboarding && jsxRuntime.jsxs(jsxRuntime.Fragment, {
24958
- children: [jsxRuntime.jsxs("div", Object.assign({
24959
- css: styles$3.header
24960
- }, {
24961
- children: [jsxRuntime.jsx(giger.Typography, Object.assign({
24962
- variant: "heading4"
24963
- }, {
24964
- children: t("onboarding:warehouse.title")
24965
- })), jsxRuntime.jsx(Spacer, {
24966
- multiplier: 2
24967
- }), jsxRuntime.jsx(giger.Typography, Object.assign({
24968
- variant: "subtitle1"
24969
- }, {
24970
- children: t("onboarding:warehouse.subtitle")
24971
- })), jsxRuntime.jsx(Spacer, {
24972
- multiplier: 1
24973
- })]
24974
- })), jsxRuntime.jsxs("div", {
24975
- children: [jsxRuntime.jsx(giger.InlineNotification, Object.assign({
24976
- title: t("onboarding:inlineTitle"),
24977
- type: giger.NotificationType.INFO
24978
- }, {
24979
- children: t("onboarding:warehouse.inlineMessage")
24980
- })), jsxRuntime.jsx(Spacer, {
24981
- multiplier: 2
24982
- })]
24983
- })]
24984
- }), jsxRuntime.jsxs("form", Object.assign({
24985
- id: "warehouse-form",
24986
- onSubmit: formLogger.capture(handleSubmit)
24987
- }, {
24988
- children: [jsxRuntime.jsx(TextInput, {
24989
- control: form.control,
24990
- form: "warehouse-form",
24991
- label: t("manage-warehouses:locationName"),
24992
- name: "name",
24993
- nativeLabel: true
24994
- }), jsxRuntime.jsx(AddressFields, {
25161
+ children: [jsxRuntime.jsx(TextInput, {
25162
+ control: form.control,
25163
+ form: "warehouse-form",
25164
+ label: t("manage-warehouses:locationName"),
25165
+ name: "name",
25166
+ nativeLabel: true
25167
+ }), jsxRuntime.jsx(AddressFields, {
25168
+ form: form,
25169
+ formatFieldName: fieldName => `originAddress.${fieldName}`
25170
+ }), jsxRuntime.jsx(CheckboxInput, {
25171
+ checkboxLabel: t("manage-warehouses:residentialAddress"),
25172
+ control: form.control,
25173
+ form: "warehouse-form",
25174
+ label: "originAddress.addressResidentialIndicator",
25175
+ name: "originAddress.addressResidentialIndicator"
25176
+ }), !_isOnboarding && jsxRuntime.jsx(CheckboxInput, {
25177
+ checkboxLabel: t("manage-warehouses:isDefault"),
25178
+ control: form.control,
25179
+ form: "warehouse-form",
25180
+ label: "isDefault",
25181
+ name: "isDefault"
25182
+ }), jsxRuntime.jsx(CheckboxInput, {
25183
+ checkboxLabel: t("manage-warehouses:returnToAddressIsDifferent"),
25184
+ control: form.control,
25185
+ "data-testid": "returnToAddressIsDifferent",
25186
+ form: "warehouse-form",
25187
+ label: "returnToAddressIsDifferent",
25188
+ name: "returnToAddressIsDifferent",
25189
+ onClick: e => {
25190
+ if (e.currentTarget.checked) {
25191
+ form.reset(formValues => Object.assign(Object.assign({}, formValues), {
25192
+ returnAddress: Object.assign(Object.assign({}, {}), {
25193
+ addressResidentialIndicator: false,
25194
+ countryCode: "US"
25195
+ }),
25196
+ returnToAddressIsDifferent: true
25197
+ }), {
25198
+ keepErrors: true
25199
+ });
25200
+ }
25201
+ }
25202
+ }), form.watch("returnToAddressIsDifferent") && jsxRuntime.jsxs(jsxRuntime.Fragment, {
25203
+ children: [jsxRuntime.jsx(AddressFields, {
24995
25204
  form: form,
24996
- formatFieldName: fieldName => `originAddress.${fieldName}`,
24997
- optionalFields: ["addressLine2"]
25205
+ formatFieldName: fieldName => `returnAddress.${fieldName}`
24998
25206
  }), jsxRuntime.jsx(CheckboxInput, {
24999
25207
  checkboxLabel: t("manage-warehouses:residentialAddress"),
25000
25208
  control: form.control,
25001
25209
  form: "warehouse-form",
25002
- label: "originAddress.addressResidentialIndicator",
25003
- name: "originAddress.addressResidentialIndicator"
25004
- }), !_isOnboarding && jsxRuntime.jsx(CheckboxInput, {
25005
- checkboxLabel: t("manage-warehouses:isDefault"),
25006
- control: form.control,
25007
- form: "warehouse-form",
25008
- label: "isDefault",
25009
- name: "isDefault"
25010
- }), jsxRuntime.jsx(CheckboxInput, {
25011
- checkboxLabel: t("manage-warehouses:returnToAddressIsDifferent"),
25012
- control: form.control,
25013
- form: "warehouse-form",
25014
- label: "returnToAddressIsDifferent",
25015
- name: "returnToAddressIsDifferent",
25016
- onClick: e => {
25017
- if (e.currentTarget.checked) {
25018
- form.reset(formValues => Object.assign(Object.assign({}, formValues), {
25019
- returnAddress: Object.assign(Object.assign({}, {}), {
25020
- addressResidentialIndicator: false,
25021
- countryCode: "US"
25022
- }),
25023
- returnToAddressIsDifferent: true
25024
- }), {
25025
- keepErrors: true
25026
- });
25027
- }
25028
- }
25029
- }), form.watch("returnToAddressIsDifferent") && jsxRuntime.jsxs(jsxRuntime.Fragment, {
25030
- children: [jsxRuntime.jsx(AddressFields, {
25031
- form: form,
25032
- formatFieldName: fieldName => `returnAddress.${fieldName}`
25033
- }), jsxRuntime.jsx(CheckboxInput, {
25034
- checkboxLabel: t("manage-warehouses:residentialAddress"),
25035
- control: form.control,
25036
- form: "warehouse-form",
25037
- label: "returnAddress.addressResidentialIndicator",
25038
- name: "returnAddress.addressResidentialIndicator"
25039
- })]
25040
- }), jsxRuntime.jsxs(ButtonGroup, Object.assign({
25041
- justify: "center"
25210
+ label: "returnAddress.addressResidentialIndicator",
25211
+ name: "returnAddress.addressResidentialIndicator"
25212
+ })]
25213
+ }), jsxRuntime.jsxs(ButtonGroup, Object.assign({
25214
+ justify: "center"
25215
+ }, {
25216
+ children: [onDelete && jsxRuntime.jsx(giger.Button, Object.assign({
25217
+ bold: false,
25218
+ onClick: onDelete,
25219
+ type: "button",
25220
+ variant: giger.ButtonVariant.TEXT
25042
25221
  }, {
25043
- children: [onDelete && jsxRuntime.jsx(giger.Button, Object.assign({
25222
+ children: t("actions.remove")
25223
+ })), jsxRuntime.jsxs(ButtonGroup, Object.assign({
25224
+ justify: _isOnboarding ? "center" : "end"
25225
+ }, {
25226
+ children: [onCancel && jsxRuntime.jsx(giger.Button, Object.assign({
25044
25227
  bold: false,
25045
- onClick: onDelete,
25228
+ onClick: onCancel,
25046
25229
  type: "button",
25047
25230
  variant: giger.ButtonVariant.TEXT
25048
25231
  }, {
25049
- children: t("actions.remove")
25050
- })), jsxRuntime.jsxs(ButtonGroup, Object.assign({
25051
- justify: _isOnboarding ? "center" : "end"
25232
+ children: t("actions.cancel")
25233
+ })), jsxRuntime.jsx(SubmitButton, Object.assign({
25234
+ control: form.control,
25235
+ "data-testid": "warehouseFormSubmitButton",
25236
+ form: "warehouse-form",
25237
+ requireDirty: true,
25238
+ variant: _isOnboarding ? giger.ButtonVariant.FILLED : giger.ButtonVariant.OUTLINED
25052
25239
  }, {
25053
- children: [onCancel && jsxRuntime.jsx(giger.Button, Object.assign({
25054
- bold: false,
25055
- onClick: onCancel,
25056
- type: "button",
25057
- variant: giger.ButtonVariant.TEXT
25240
+ children: submitButtonTitle
25241
+ }))]
25242
+ }))]
25243
+ }))]
25244
+ }));
25245
+ };
25246
+
25247
+ const WarehousePreferenceSelect = ({
25248
+ onCancel,
25249
+ onSubmit,
25250
+ originAddress,
25251
+ returnAddress
25252
+ }) => {
25253
+ const {
25254
+ t
25255
+ } = reactI18next.useTranslation(["manage-warehouses", "common"]);
25256
+ const determineAddressPreference = address => {
25257
+ if (!address) return undefined;
25258
+ switch (address.validationType) {
25259
+ case "EXACT":
25260
+ case "SOFT":
25261
+ return address.address;
25262
+ case "SUGGESTED":
25263
+ return address.validation.matchedAddress;
25264
+ case "ERROR":
25265
+ return address.validation.originalAddress;
25266
+ default:
25267
+ return undefined;
25268
+ }
25269
+ };
25270
+ const [originAddressPreference, setOriginAddressPreference] = React.useState(determineAddressPreference(originAddress));
25271
+ const [returnAddressPreference, setReturnAddressPreference] = React.useState(determineAddressPreference(returnAddress));
25272
+ const addressPreferenceDisplay = (preference, name, onPreferenceSelect) => {
25273
+ var _a, _b;
25274
+ switch (preference.validationType) {
25275
+ case "EXACT":
25276
+ case "SOFT":
25277
+ return jsxRuntime.jsx(AddressDisplay, {
25278
+ address: preference.address
25279
+ });
25280
+ case "SUGGESTED":
25281
+ return jsxRuntime.jsxs(giger.Next.RadioGroup, Object.assign({
25282
+ name: name,
25283
+ onChange: e => {
25284
+ if (preference.validation.matchedAddress && e.target.value === "suggested") {
25285
+ onPreferenceSelect(preference.validation.matchedAddress);
25286
+ } else {
25287
+ onPreferenceSelect(preference.validation.originalAddress);
25288
+ }
25289
+ }
25290
+ }, {
25291
+ children: [jsxRuntime.jsx(Spacer, {
25292
+ multiplier: 1
25293
+ }), jsxRuntime.jsx(giger.Next.Radio, Object.assign({
25294
+ value: "suggested"
25058
25295
  }, {
25059
- children: t("actions.cancel")
25060
- })), jsxRuntime.jsx(SubmitButton, Object.assign({
25061
- control: form.control,
25062
- form: "warehouse-form",
25063
- requireDirty: true,
25064
- variant: _isOnboarding ? giger.ButtonVariant.FILLED : giger.ButtonVariant.OUTLINED
25296
+ children: t("common:address.preference.matchedAddress")
25297
+ })), preference.validation.matchedAddress && jsxRuntime.jsx(giger.GridChild, Object.assign({
25298
+ colSpan: 6,
25299
+ colStart: 4,
25300
+ css: theme => ({
25301
+ paddingLeft: theme.spacing(3)
25302
+ })
25065
25303
  }, {
25066
- children: submitButtonTitle
25304
+ children: jsxRuntime.jsx(AddressDisplay, {
25305
+ address: preference.validation.matchedAddress
25306
+ })
25307
+ })), jsxRuntime.jsx(Spacer, {
25308
+ multiplier: 1
25309
+ }), jsxRuntime.jsx(giger.Next.Radio, Object.assign({
25310
+ value: "original"
25311
+ }, {
25312
+ children: t("common:address.preference.originalAddress")
25313
+ })), jsxRuntime.jsx(Spacer, {
25314
+ multiplier: 1
25315
+ }), jsxRuntime.jsx(giger.GridChild, Object.assign({
25316
+ colSpan: 6,
25317
+ colStart: 4,
25318
+ css: theme => ({
25319
+ paddingLeft: theme.spacing(3)
25320
+ })
25321
+ }, {
25322
+ children: jsxRuntime.jsx(AddressDisplay, {
25323
+ address: (_a = preference.validation) === null || _a === void 0 ? void 0 : _a.originalAddress
25324
+ })
25067
25325
  }))]
25068
- }))]
25326
+ }));
25327
+ case "ERROR":
25328
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
25329
+ children: [jsxRuntime.jsx(Spacer, {
25330
+ multiplier: 1
25331
+ }), jsxRuntime.jsx(giger.GridChild, Object.assign({
25332
+ colSpan: 8,
25333
+ css: theme => ({
25334
+ paddingLeft: theme.spacing(1)
25335
+ })
25336
+ }, {
25337
+ children: jsxRuntime.jsx(giger.InlineNotification, Object.assign({
25338
+ type: giger.NotificationType.ALERT
25339
+ }, {
25340
+ children: t("address.preference.unableToValidate")
25341
+ }))
25342
+ })), jsxRuntime.jsx(Spacer, {
25343
+ multiplier: 1
25344
+ }), jsxRuntime.jsx(giger.GridChild, Object.assign({
25345
+ css: theme => ({
25346
+ paddingLeft: theme.spacing(1)
25347
+ })
25348
+ }, {
25349
+ children: jsxRuntime.jsx(AddressDisplay, {
25350
+ address: (_b = preference.validation) === null || _b === void 0 ? void 0 : _b.originalAddress
25351
+ })
25352
+ }))]
25353
+ });
25354
+ default:
25355
+ // This code path should never be reached.
25356
+ return jsxRuntime.jsx("div", {
25357
+ children: "not found"
25358
+ });
25359
+ }
25360
+ };
25361
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
25362
+ children: [jsxRuntime.jsxs(giger.Grid, Object.assign({
25363
+ "data-testid": "warehousePreferenceSelect",
25364
+ noPadding: true
25365
+ }, {
25366
+ children: [jsxRuntime.jsx(giger.GridChild, Object.assign({
25367
+ colSpan: 12
25368
+ }, {
25369
+ children: jsxRuntime.jsx(giger.Typography, Object.assign({
25370
+ variant: "subtitle2"
25371
+ }, {
25372
+ children: t("common:address.preference.title")
25373
+ }))
25374
+ })), jsxRuntime.jsxs(giger.GridChild, Object.assign({
25375
+ colSpan: 8
25376
+ }, {
25377
+ children: [jsxRuntime.jsx(giger.Typography, Object.assign({
25378
+ css: {
25379
+ textTransform: "capitalize"
25380
+ },
25381
+ variant: "subtitle2"
25382
+ }, {
25383
+ children: t("manage-warehouses:shipFrom")
25384
+ })), originAddress && addressPreferenceDisplay(originAddress, "originAddressPreference", preference => {
25385
+ setOriginAddressPreference(preference);
25386
+ })]
25387
+ })), returnAddress && jsxRuntime.jsxs(giger.GridChild, Object.assign({
25388
+ colSpan: 8
25389
+ }, {
25390
+ children: [jsxRuntime.jsx(giger.Typography, Object.assign({
25391
+ css: {
25392
+ textTransform: "capitalize"
25393
+ },
25394
+ variant: "subtitle2"
25395
+ }, {
25396
+ children: t("manage-warehouses:returnTo")
25397
+ })), addressPreferenceDisplay(returnAddress, "returnAddressPreference", preference => {
25398
+ setReturnAddressPreference(preference);
25399
+ })]
25400
+ }))]
25401
+ })), jsxRuntime.jsxs(ButtonGroup, Object.assign({
25402
+ justify: "end"
25403
+ }, {
25404
+ children: [onCancel && jsxRuntime.jsx(giger.Button, Object.assign({
25405
+ bold: false,
25406
+ onClick: onCancel,
25407
+ type: "button",
25408
+ variant: giger.ButtonVariant.TEXT
25409
+ }, {
25410
+ children: t("actions.cancel")
25411
+ })), jsxRuntime.jsx(giger.Button, Object.assign({
25412
+ onClick: () => onSubmit({
25413
+ originAddress: originAddressPreference,
25414
+ returnAddress: returnAddressPreference
25415
+ }),
25416
+ variant: giger.ButtonVariant.OUTLINED
25417
+ }, {
25418
+ children: t("common:address.preference.confirm")
25069
25419
  }))]
25070
25420
  }))]
25421
+ });
25422
+ };
25423
+
25424
+ const WarehousePreferenceWizard = ({
25425
+ className,
25426
+ formHeader,
25427
+ isOnboarding: _isOnboarding = false,
25428
+ onSubmit,
25429
+ onValidate,
25430
+ onWarehouseDelete,
25431
+ onWarehouseFormCancel,
25432
+ submitButtonTitle,
25433
+ warehouse,
25434
+ warehousePreference
25435
+ }) => {
25436
+ const [currentStep, setCurrentStep] = React.useState(0);
25437
+ const checkForExactOrSoft = warehousePreference => __awaiter(void 0, void 0, void 0, function* () {
25438
+ const {
25439
+ originAddress,
25440
+ returnAddress
25441
+ } = warehousePreference;
25442
+ if ((originAddress.validationType === "EXACT" || originAddress.validationType === "SOFT") && returnAddress && (returnAddress.validationType === "EXACT" || returnAddress.validationType === "SOFT")) {
25443
+ yield onSubmit({
25444
+ isDefault: !!warehousePreference.isDefault,
25445
+ name: warehousePreference.name,
25446
+ originAddress: originAddress.address,
25447
+ returnAddress: returnAddress.address
25448
+ });
25449
+ return;
25450
+ }
25451
+ if ((originAddress.validationType === "EXACT" || originAddress.validationType === "SOFT") && !returnAddress) {
25452
+ yield onSubmit({
25453
+ isDefault: !!warehousePreference.isDefault,
25454
+ name: warehousePreference.name,
25455
+ originAddress: originAddress.address
25456
+ });
25457
+ return;
25458
+ } else return;
25459
+ });
25460
+ return jsxRuntime.jsxs("div", Object.assign({
25461
+ className: className
25462
+ }, {
25463
+ children: [formHeader && formHeader, currentStep === 0 ? jsxRuntime.jsx(WarehouseForm, {
25464
+ isOnboarding: _isOnboarding,
25465
+ onCancel: onWarehouseFormCancel ? () => onWarehouseFormCancel() : undefined,
25466
+ onDelete: onWarehouseDelete ? () => onWarehouseDelete() : undefined,
25467
+ onSubmit: payload => __awaiter(void 0, void 0, void 0, function* () {
25468
+ const result = yield onValidate(payload);
25469
+ yield checkForExactOrSoft(result);
25470
+ setCurrentStep(1);
25471
+ }),
25472
+ submitButtonTitle: submitButtonTitle,
25473
+ warehouse: warehouse
25474
+ }) : warehousePreference && jsxRuntime.jsx(WarehousePreferenceSelect, {
25475
+ onCancel: () => setCurrentStep(0),
25476
+ onSubmit: payload => {
25477
+ onSubmit({
25478
+ isDefault: !!warehousePreference.isDefault,
25479
+ name: warehousePreference.name,
25480
+ originAddress: payload.originAddress,
25481
+ returnAddress: payload.returnAddress
25482
+ });
25483
+ },
25484
+ originAddress: warehousePreference.originAddress,
25485
+ returnAddress: warehousePreference.returnAddress
25486
+ })]
25071
25487
  }));
25072
25488
  };
25073
25489
 
25490
+ const styles$3 = createStyles({
25491
+ cardSpacing: theme => ({
25492
+ display: "flex",
25493
+ flexDirection: "column",
25494
+ gap: theme.spacing(2)
25495
+ }),
25496
+ header: {
25497
+ textAlign: "left"
25498
+ },
25499
+ well: theme => ({
25500
+ backgroundColor: theme.palette.gray.ultraLight,
25501
+ padding: theme.spacing(2)
25502
+ })
25503
+ });
25504
+
25074
25505
  const ManageWarehouses$1 = ({
25075
25506
  errors,
25076
25507
  onAdd,
25077
25508
  onDelete,
25078
25509
  onEdit,
25079
25510
  onSetDefault,
25511
+ onValidate,
25512
+ setWarehousePreference,
25513
+ warehousePreference,
25080
25514
  warehouses
25081
25515
  }) => {
25082
25516
  const {
@@ -25085,13 +25519,28 @@ const ManageWarehouses$1 = ({
25085
25519
  const [editWarehouseId, setEditWarehouseId] = React.useState();
25086
25520
  const [showAddNewWarehouseForm, toggleShowAddNewWarehouseForm] = useToggle(false);
25087
25521
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
25088
- children: [showAddNewWarehouseForm ? jsxRuntime.jsx(WarehouseForm, {
25089
- onCancel: () => toggleShowAddNewWarehouseForm(false),
25522
+ children: [showAddNewWarehouseForm ? jsxRuntime.jsx(WarehousePreferenceWizard, {
25523
+ css: styles$3.well,
25524
+ formHeader: jsxRuntime.jsxs("div", Object.assign({
25525
+ css: styles$3.header
25526
+ }, {
25527
+ children: [jsxRuntime.jsx(giger.Typography, Object.assign({
25528
+ variant: "subtitle1"
25529
+ }, {
25530
+ children: t("manage-warehouses:addNew")
25531
+ })), jsxRuntime.jsx(Spacer, {
25532
+ multiplier: 1
25533
+ })]
25534
+ })),
25090
25535
  onSubmit: payload => {
25091
25536
  onAdd(payload);
25092
25537
  toggleShowAddNewWarehouseForm(false);
25538
+ setWarehousePreference(undefined);
25093
25539
  },
25094
- submitButtonTitle: t("actions.add")
25540
+ onValidate: onValidate,
25541
+ onWarehouseFormCancel: () => toggleShowAddNewWarehouseForm(false),
25542
+ submitButtonTitle: t("actions.save"),
25543
+ warehousePreference: warehousePreference
25095
25544
  }) : jsxRuntime.jsx(ButtonGroup, Object.assign({
25096
25545
  justify: "end"
25097
25546
  }, {
@@ -25110,26 +25559,37 @@ const ManageWarehouses$1 = ({
25110
25559
  })]
25111
25560
  }))
25112
25561
  })), jsxRuntime.jsx("div", Object.assign({
25113
- css: theme => ({
25114
- display: "flex",
25115
- flexDirection: "column",
25116
- gap: theme.spacing(2)
25117
- })
25562
+ css: styles$3.cardSpacing
25118
25563
  }, {
25119
25564
  children: warehouses.sort((a, b) => {
25120
25565
  if (b.isDefault) return 1;
25121
25566
  return sortByCreationDate(a, b, "desc");
25122
25567
  }).map(warehouse => {
25123
25568
  if (editWarehouseId && editWarehouseId === warehouse.warehouseId) {
25124
- return jsxRuntime.jsx(WarehouseForm, {
25125
- onCancel: () => setEditWarehouseId(undefined),
25126
- onDelete: warehouse.isDefault ? undefined : () => onDelete(warehouse.warehouseId),
25569
+ return jsxRuntime.jsx(WarehousePreferenceWizard, {
25570
+ css: styles$3.well,
25571
+ formHeader: jsxRuntime.jsxs("div", Object.assign({
25572
+ css: styles$3.header
25573
+ }, {
25574
+ children: [jsxRuntime.jsx(giger.Typography, Object.assign({
25575
+ variant: "subtitle1"
25576
+ }, {
25577
+ children: t("manage-warehouses:editWarehouse")
25578
+ })), jsxRuntime.jsx(Spacer, {
25579
+ multiplier: 1
25580
+ })]
25581
+ })),
25127
25582
  onSubmit: payload => {
25128
25583
  onEdit(payload, warehouse.warehouseId);
25129
25584
  setEditWarehouseId(undefined);
25585
+ setWarehousePreference(undefined);
25130
25586
  },
25587
+ onValidate: onValidate,
25588
+ onWarehouseDelete: warehouse.isDefault ? undefined : () => onDelete(warehouse.warehouseId),
25589
+ onWarehouseFormCancel: () => setEditWarehouseId(undefined),
25131
25590
  submitButtonTitle: t("actions.save"),
25132
- warehouse: warehouse
25591
+ warehouse: warehouse,
25592
+ warehousePreference: warehousePreference
25133
25593
  }, warehouse.warehouseId);
25134
25594
  } else {
25135
25595
  return jsxRuntime.jsx(SettingsCard, Object.assign({
@@ -25159,10 +25619,10 @@ const ManageWarehouses$1 = ({
25159
25619
 
25160
25620
  var getBuiltIn$3 = getBuiltIn$9;
25161
25621
  var definePropertyModule = objectDefineProperty;
25162
- var wellKnownSymbol$5 = wellKnownSymbol$j;
25622
+ var wellKnownSymbol$3 = wellKnownSymbol$j;
25163
25623
  var DESCRIPTORS = descriptors;
25164
25624
 
25165
- var SPECIES$2 = wellKnownSymbol$5('species');
25625
+ var SPECIES$2 = wellKnownSymbol$3('species');
25166
25626
 
25167
25627
  var setSpecies$1 = function (CONSTRUCTOR_NAME) {
25168
25628
  var Constructor = getBuiltIn$3(CONSTRUCTOR_NAME);
@@ -25176,49 +25636,49 @@ var setSpecies$1 = function (CONSTRUCTOR_NAME) {
25176
25636
  }
25177
25637
  };
25178
25638
 
25179
- var isPrototypeOf$1 = objectIsPrototypeOf;
25639
+ var isPrototypeOf = objectIsPrototypeOf;
25180
25640
 
25181
- var $TypeError$5 = TypeError;
25641
+ var $TypeError$3 = TypeError;
25182
25642
 
25183
25643
  var anInstance$1 = function (it, Prototype) {
25184
- if (isPrototypeOf$1(Prototype, it)) return it;
25185
- throw $TypeError$5('Incorrect invocation');
25644
+ if (isPrototypeOf(Prototype, it)) return it;
25645
+ throw $TypeError$3('Incorrect invocation');
25186
25646
  };
25187
25647
 
25188
25648
  var isConstructor = isConstructor$2;
25189
- var tryToString$2 = tryToString$5;
25649
+ var tryToString = tryToString$5;
25190
25650
 
25191
- var $TypeError$4 = TypeError;
25651
+ var $TypeError$2 = TypeError;
25192
25652
 
25193
25653
  // `Assert: IsConstructor(argument) is true`
25194
25654
  var aConstructor$1 = function (argument) {
25195
25655
  if (isConstructor(argument)) return argument;
25196
- throw $TypeError$4(tryToString$2(argument) + ' is not a constructor');
25656
+ throw $TypeError$2(tryToString(argument) + ' is not a constructor');
25197
25657
  };
25198
25658
 
25199
- var anObject$4 = anObject$f;
25659
+ var anObject$1 = anObject$f;
25200
25660
  var aConstructor = aConstructor$1;
25201
- var isNullOrUndefined$1 = isNullOrUndefined$6;
25202
- var wellKnownSymbol$4 = wellKnownSymbol$j;
25661
+ var isNullOrUndefined = isNullOrUndefined$6;
25662
+ var wellKnownSymbol$2 = wellKnownSymbol$j;
25203
25663
 
25204
- var SPECIES$1 = wellKnownSymbol$4('species');
25664
+ var SPECIES$1 = wellKnownSymbol$2('species');
25205
25665
 
25206
25666
  // `SpeciesConstructor` abstract operation
25207
25667
  // https://tc39.es/ecma262/#sec-speciesconstructor
25208
25668
  var speciesConstructor$2 = function (O, defaultConstructor) {
25209
- var C = anObject$4(O).constructor;
25669
+ var C = anObject$1(O).constructor;
25210
25670
  var S;
25211
- return C === undefined || isNullOrUndefined$1(S = anObject$4(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S);
25671
+ return C === undefined || isNullOrUndefined(S = anObject$1(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S);
25212
25672
  };
25213
25673
 
25214
25674
  var uncurryThis$1 = functionUncurryThis;
25215
25675
 
25216
25676
  var arraySlice$1 = uncurryThis$1([].slice);
25217
25677
 
25218
- var $TypeError$3 = TypeError;
25678
+ var $TypeError$1 = TypeError;
25219
25679
 
25220
25680
  var validateArgumentsLength$1 = function (passed, required) {
25221
- if (passed < required) throw $TypeError$3('Not enough arguments');
25681
+ if (passed < required) throw $TypeError$1('Not enough arguments');
25222
25682
  return passed;
25223
25683
  };
25224
25684
 
@@ -25228,7 +25688,7 @@ var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$2);
25228
25688
 
25229
25689
  var global$7 = global$p;
25230
25690
  var apply = functionApply;
25231
- var bind$3 = functionBindContext;
25691
+ var bind$2 = functionBindContext;
25232
25692
  var isCallable$4 = isCallable$o;
25233
25693
  var hasOwn = hasOwnProperty_1;
25234
25694
  var fails$1 = fails$r;
@@ -25310,7 +25770,7 @@ if (!set || !clear) {
25310
25770
  channel = new MessageChannel();
25311
25771
  port = channel.port2;
25312
25772
  channel.port1.onmessage = listener;
25313
- defer = bind$3(port.postMessage, port);
25773
+ defer = bind$2(port.postMessage, port);
25314
25774
  // Browsers with postMessage, skip WebWorkers
25315
25775
  // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
25316
25776
  } else if (
@@ -25353,7 +25813,7 @@ var userAgent = engineUserAgent;
25353
25813
  var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent);
25354
25814
 
25355
25815
  var global$5 = global$p;
25356
- var bind$2 = functionBindContext;
25816
+ var bind$1 = functionBindContext;
25357
25817
  var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
25358
25818
  var macrotask = task$1.set;
25359
25819
  var IS_IOS = engineIsIos;
@@ -25405,7 +25865,7 @@ if (!queueMicrotask) {
25405
25865
  promise = Promise$1.resolve(undefined);
25406
25866
  // workaround of WebKit ~ iOS Safari 10.1 bug
25407
25867
  promise.constructor = Promise$1;
25408
- then = bind$2(promise.then, promise);
25868
+ then = bind$1(promise.then, promise);
25409
25869
  notify$1 = function () {
25410
25870
  then(flush);
25411
25871
  };
@@ -25422,7 +25882,7 @@ if (!queueMicrotask) {
25422
25882
  // - setTimeout
25423
25883
  } else {
25424
25884
  // strange IE + webpack dev server bug - use .bind(global)
25425
- macrotask = bind$2(macrotask, global$5);
25885
+ macrotask = bind$1(macrotask, global$5);
25426
25886
  notify$1 = function () {
25427
25887
  macrotask(flush);
25428
25888
  };
@@ -25499,13 +25959,13 @@ var NativePromiseConstructor$4 = promiseNativeConstructor;
25499
25959
  var isCallable$3 = isCallable$o;
25500
25960
  var isForced = isForced_1;
25501
25961
  var inspectSource = inspectSource$3;
25502
- var wellKnownSymbol$3 = wellKnownSymbol$j;
25962
+ var wellKnownSymbol$1 = wellKnownSymbol$j;
25503
25963
  var IS_BROWSER = engineIsBrowser;
25504
25964
  var IS_DENO = engineIsDeno;
25505
25965
  var V8_VERSION = engineV8Version;
25506
25966
 
25507
25967
  NativePromiseConstructor$4 && NativePromiseConstructor$4.prototype;
25508
- var SPECIES = wellKnownSymbol$3('species');
25968
+ var SPECIES = wellKnownSymbol$1('species');
25509
25969
  var SUBCLASSING = false;
25510
25970
  var NATIVE_PROMISE_REJECTION_EVENT$1 = isCallable$3(global$2.PromiseRejectionEvent);
25511
25971
 
@@ -25541,19 +26001,19 @@ var promiseConstructorDetection = {
25541
26001
 
25542
26002
  var newPromiseCapability$2 = {};
25543
26003
 
25544
- var aCallable$4 = aCallable$a;
26004
+ var aCallable$3 = aCallable$a;
25545
26005
 
25546
- var $TypeError$2 = TypeError;
26006
+ var $TypeError = TypeError;
25547
26007
 
25548
26008
  var PromiseCapability = function (C) {
25549
26009
  var resolve, reject;
25550
26010
  this.promise = new C(function ($$resolve, $$reject) {
25551
- if (resolve !== undefined || reject !== undefined) throw $TypeError$2('Bad Promise constructor');
26011
+ if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor');
25552
26012
  resolve = $$resolve;
25553
26013
  reject = $$reject;
25554
26014
  });
25555
- this.resolve = aCallable$4(resolve);
25556
- this.reject = aCallable$4(reject);
26015
+ this.resolve = aCallable$3(resolve);
26016
+ this.reject = aCallable$3(reject);
25557
26017
  };
25558
26018
 
25559
26019
  // `NewPromiseCapability` abstract operation
@@ -25565,12 +26025,12 @@ newPromiseCapability$2.f = function (C) {
25565
26025
  var $$8 = _export;
25566
26026
  var IS_NODE = engineIsNode;
25567
26027
  var global$1 = global$p;
25568
- var call$6 = functionCall;
26028
+ var call$3 = functionCall;
25569
26029
  var defineBuiltIn$2 = defineBuiltIn$8;
25570
26030
  var setPrototypeOf = objectSetPrototypeOf;
25571
26031
  var setToStringTag = setToStringTag$3;
25572
26032
  var setSpecies = setSpecies$1;
25573
- var aCallable$3 = aCallable$a;
26033
+ var aCallable$2 = aCallable$a;
25574
26034
  var isCallable$2 = isCallable$o;
25575
26035
  var isObject$1 = isObject$a;
25576
26036
  var anInstance = anInstance$1;
@@ -25643,7 +26103,7 @@ var callReaction = function (reaction, state) {
25643
26103
  if (result === reaction.promise) {
25644
26104
  reject(TypeError$1('Promise-chain cycle'));
25645
26105
  } else if (then = isThenable(result)) {
25646
- call$6(then, result, resolve, reject);
26106
+ call$3(then, result, resolve, reject);
25647
26107
  } else resolve(result);
25648
26108
  } else reject(value);
25649
26109
  } catch (error) {
@@ -25680,7 +26140,7 @@ var dispatchEvent = function (name, promise, reason) {
25680
26140
  };
25681
26141
 
25682
26142
  var onUnhandled = function (state) {
25683
- call$6(task, global$1, function () {
26143
+ call$3(task, global$1, function () {
25684
26144
  var promise = state.facade;
25685
26145
  var value = state.value;
25686
26146
  var IS_UNHANDLED = isUnhandled(state);
@@ -25703,7 +26163,7 @@ var isUnhandled = function (state) {
25703
26163
  };
25704
26164
 
25705
26165
  var onHandleUnhandled = function (state) {
25706
- call$6(task, global$1, function () {
26166
+ call$3(task, global$1, function () {
25707
26167
  var promise = state.facade;
25708
26168
  if (IS_NODE) {
25709
26169
  process$1.emit('rejectionHandled', promise);
@@ -25711,7 +26171,7 @@ var onHandleUnhandled = function (state) {
25711
26171
  });
25712
26172
  };
25713
26173
 
25714
- var bind$1 = function (fn, state, unwrap) {
26174
+ var bind = function (fn, state, unwrap) {
25715
26175
  return function (value) {
25716
26176
  fn(state, value, unwrap);
25717
26177
  };
@@ -25737,9 +26197,9 @@ var internalResolve = function (state, value, unwrap) {
25737
26197
  microtask(function () {
25738
26198
  var wrapper = { done: false };
25739
26199
  try {
25740
- call$6(then, value,
25741
- bind$1(internalResolve, wrapper, state),
25742
- bind$1(internalReject, wrapper, state)
26200
+ call$3(then, value,
26201
+ bind(internalResolve, wrapper, state),
26202
+ bind(internalReject, wrapper, state)
25743
26203
  );
25744
26204
  } catch (error) {
25745
26205
  internalReject(wrapper, error, state);
@@ -25760,11 +26220,11 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
25760
26220
  // 25.4.3.1 Promise(executor)
25761
26221
  PromiseConstructor = function Promise(executor) {
25762
26222
  anInstance(this, PromisePrototype);
25763
- aCallable$3(executor);
25764
- call$6(Internal, this);
26223
+ aCallable$2(executor);
26224
+ call$3(Internal, this);
25765
26225
  var state = getInternalPromiseState(this);
25766
26226
  try {
25767
- executor(bind$1(internalResolve, state), bind$1(internalReject, state));
26227
+ executor(bind(internalResolve, state), bind(internalReject, state));
25768
26228
  } catch (error) {
25769
26229
  internalReject(state, error);
25770
26230
  }
@@ -25806,8 +26266,8 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
25806
26266
  var promise = new Internal();
25807
26267
  var state = getInternalPromiseState(promise);
25808
26268
  this.promise = promise;
25809
- this.resolve = bind$1(internalResolve, state);
25810
- this.reject = bind$1(internalReject, state);
26269
+ this.resolve = bind(internalResolve, state);
26270
+ this.reject = bind(internalReject, state);
25811
26271
  };
25812
26272
 
25813
26273
  newPromiseCapabilityModule$3.f = newPromiseCapability$1 = function (C) {
@@ -25824,7 +26284,7 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
25824
26284
  defineBuiltIn$2(NativePromisePrototype$2, 'then', function then(onFulfilled, onRejected) {
25825
26285
  var that = this;
25826
26286
  return new PromiseConstructor(function (resolve, reject) {
25827
- call$6(nativeThen, that, resolve, reject);
26287
+ call$3(nativeThen, that, resolve, reject);
25828
26288
  }).then(onFulfilled, onRejected);
25829
26289
  // https://github.com/zloirock/core-js/issues/640
25830
26290
  }, { unsafe: true });
@@ -25842,144 +26302,12 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
25842
26302
  }
25843
26303
  }
25844
26304
 
25845
- $$8({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
25846
- Promise: PromiseConstructor
25847
- });
25848
-
25849
- setToStringTag(PromiseConstructor, PROMISE, false);
25850
- setSpecies(PROMISE);
25851
-
25852
- var wellKnownSymbol$2 = wellKnownSymbol$j;
25853
- var Iterators$1 = iterators;
25854
-
25855
- var ITERATOR$2 = wellKnownSymbol$2('iterator');
25856
- var ArrayPrototype = Array.prototype;
25857
-
25858
- // check on default Array iterator
25859
- var isArrayIteratorMethod$1 = function (it) {
25860
- return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$2] === it);
25861
- };
25862
-
25863
- var classof = classof$6;
25864
- var getMethod$1 = getMethod$5;
25865
- var isNullOrUndefined = isNullOrUndefined$6;
25866
- var Iterators = iterators;
25867
- var wellKnownSymbol$1 = wellKnownSymbol$j;
25868
-
25869
- var ITERATOR$1 = wellKnownSymbol$1('iterator');
25870
-
25871
- var getIteratorMethod$2 = function (it) {
25872
- if (!isNullOrUndefined(it)) return getMethod$1(it, ITERATOR$1)
25873
- || getMethod$1(it, '@@iterator')
25874
- || Iterators[classof(it)];
25875
- };
25876
-
25877
- var call$5 = functionCall;
25878
- var aCallable$2 = aCallable$a;
25879
- var anObject$3 = anObject$f;
25880
- var tryToString$1 = tryToString$5;
25881
- var getIteratorMethod$1 = getIteratorMethod$2;
25882
-
25883
- var $TypeError$1 = TypeError;
25884
-
25885
- var getIterator$1 = function (argument, usingIterator) {
25886
- var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
25887
- if (aCallable$2(iteratorMethod)) return anObject$3(call$5(iteratorMethod, argument));
25888
- throw $TypeError$1(tryToString$1(argument) + ' is not iterable');
25889
- };
25890
-
25891
- var call$4 = functionCall;
25892
- var anObject$2 = anObject$f;
25893
- var getMethod = getMethod$5;
25894
-
25895
- var iteratorClose$1 = function (iterator, kind, value) {
25896
- var innerResult, innerError;
25897
- anObject$2(iterator);
25898
- try {
25899
- innerResult = getMethod(iterator, 'return');
25900
- if (!innerResult) {
25901
- if (kind === 'throw') throw value;
25902
- return value;
25903
- }
25904
- innerResult = call$4(innerResult, iterator);
25905
- } catch (error) {
25906
- innerError = true;
25907
- innerResult = error;
25908
- }
25909
- if (kind === 'throw') throw value;
25910
- if (innerError) throw innerResult;
25911
- anObject$2(innerResult);
25912
- return value;
25913
- };
25914
-
25915
- var bind = functionBindContext;
25916
- var call$3 = functionCall;
25917
- var anObject$1 = anObject$f;
25918
- var tryToString = tryToString$5;
25919
- var isArrayIteratorMethod = isArrayIteratorMethod$1;
25920
- var lengthOfArrayLike$1 = lengthOfArrayLike$8;
25921
- var isPrototypeOf = objectIsPrototypeOf;
25922
- var getIterator = getIterator$1;
25923
- var getIteratorMethod = getIteratorMethod$2;
25924
- var iteratorClose = iteratorClose$1;
25925
-
25926
- var $TypeError = TypeError;
25927
-
25928
- var Result = function (stopped, result) {
25929
- this.stopped = stopped;
25930
- this.result = result;
25931
- };
25932
-
25933
- var ResultPrototype = Result.prototype;
25934
-
25935
- var iterate$2 = function (iterable, unboundFunction, options) {
25936
- var that = options && options.that;
25937
- var AS_ENTRIES = !!(options && options.AS_ENTRIES);
25938
- var IS_RECORD = !!(options && options.IS_RECORD);
25939
- var IS_ITERATOR = !!(options && options.IS_ITERATOR);
25940
- var INTERRUPTED = !!(options && options.INTERRUPTED);
25941
- var fn = bind(unboundFunction, that);
25942
- var iterator, iterFn, index, length, result, next, step;
25943
-
25944
- var stop = function (condition) {
25945
- if (iterator) iteratorClose(iterator, 'normal', condition);
25946
- return new Result(true, condition);
25947
- };
25948
-
25949
- var callFn = function (value) {
25950
- if (AS_ENTRIES) {
25951
- anObject$1(value);
25952
- return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
25953
- } return INTERRUPTED ? fn(value, stop) : fn(value);
25954
- };
25955
-
25956
- if (IS_RECORD) {
25957
- iterator = iterable.iterator;
25958
- } else if (IS_ITERATOR) {
25959
- iterator = iterable;
25960
- } else {
25961
- iterFn = getIteratorMethod(iterable);
25962
- if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable');
25963
- // optimisation for array iterators
25964
- if (isArrayIteratorMethod(iterFn)) {
25965
- for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
25966
- result = callFn(iterable[index]);
25967
- if (result && isPrototypeOf(ResultPrototype, result)) return result;
25968
- } return new Result(false);
25969
- }
25970
- iterator = getIterator(iterable, iterFn);
25971
- }
25972
-
25973
- next = IS_RECORD ? iterable.next : iterator.next;
25974
- while (!(step = call$3(next, iterator)).done) {
25975
- try {
25976
- result = callFn(step.value);
25977
- } catch (error) {
25978
- iteratorClose(iterator, 'throw', error);
25979
- }
25980
- if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
25981
- } return new Result(false);
25982
- };
26305
+ $$8({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
26306
+ Promise: PromiseConstructor
26307
+ });
26308
+
26309
+ setToStringTag(PromiseConstructor, PROMISE, false);
26310
+ setSpecies(PROMISE);
25983
26311
 
25984
26312
  var wellKnownSymbol = wellKnownSymbol$j;
25985
26313
 
@@ -26033,7 +26361,7 @@ var call$2 = functionCall;
26033
26361
  var aCallable$1 = aCallable$a;
26034
26362
  var newPromiseCapabilityModule$2 = newPromiseCapability$2;
26035
26363
  var perform$1 = perform$3;
26036
- var iterate$1 = iterate$2;
26364
+ var iterate$1 = iterate$3;
26037
26365
  var PROMISE_STATICS_INCORRECT_ITERATION$1 = promiseStaticsIncorrectIteration;
26038
26366
 
26039
26367
  // `Promise.all` method
@@ -26097,7 +26425,7 @@ var call$1 = functionCall;
26097
26425
  var aCallable = aCallable$a;
26098
26426
  var newPromiseCapabilityModule$1 = newPromiseCapability$2;
26099
26427
  var perform = perform$3;
26100
- var iterate = iterate$2;
26428
+ var iterate = iterate$3;
26101
26429
  var PROMISE_STATICS_INCORRECT_ITERATION = promiseStaticsIncorrectIteration;
26102
26430
 
26103
26431
  // `Promise.race` method
@@ -26956,16 +27284,20 @@ const AddFundsForm = ({
26956
27284
  });
26957
27285
  const {
26958
27286
  isSubmitted,
27287
+ isSubmitting,
26959
27288
  isValid
26960
27289
  } = form.formState;
26961
27290
  const watchAmount = form.watch("funds").amount;
26962
27291
  const formId = "add-funds-form";
26963
- const handleSubmit = formLogger.capture(form.handleSubmit(values => {
27292
+ const handleSubmit = formLogger.capture(form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
26964
27293
  const payload = values;
26965
- addFunds.mutate(payload, {
26966
- onSuccess: () => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess()
26967
- });
26968
- }));
27294
+ try {
27295
+ yield addFunds.mutateAsync(payload);
27296
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
27297
+ } catch (_a) {
27298
+ // Noop; errors available on RQ object
27299
+ }
27300
+ })));
26969
27301
  if (carrier.isLoading) return jsxRuntime.jsx(Loader, {
26970
27302
  message: t("loading.carrier")
26971
27303
  });
@@ -27040,6 +27372,7 @@ const AddFundsForm = ({
27040
27372
  justify: "end"
27041
27373
  }, {
27042
27374
  children: [onCancel && jsxRuntime.jsx(giger.Button, Object.assign({
27375
+ disabled: isSubmitting,
27043
27376
  onClick: onCancel,
27044
27377
  variant: giger.ButtonVariant.TEXT
27045
27378
  }, {
@@ -27047,7 +27380,6 @@ const AddFundsForm = ({
27047
27380
  })), jsxRuntime.jsx(SubmitButton, Object.assign({
27048
27381
  control: form.control,
27049
27382
  form: formId,
27050
- isLoading: addFunds.isLoading,
27051
27383
  variant: giger.ButtonVariant.OUTLINED
27052
27384
  }, {
27053
27385
  children: t("manage-funding:actions.addNow")
@@ -27066,7 +27398,7 @@ const AddFundsForm = ({
27066
27398
  }), children === null || children === void 0 ? void 0 : children({
27067
27399
  isCustomAmount: selectedChip.value === "custom",
27068
27400
  isSubmitted,
27069
- isSubmitting: addFunds.isLoading,
27401
+ isSubmitting,
27070
27402
  isValid,
27071
27403
  selectedAmount: watchAmount,
27072
27404
  submit: handleSubmit
@@ -27138,6 +27470,9 @@ const LinkAction = _a => {
27138
27470
  return jsxRuntime.jsx(giger.Link, Object.assign({}, props, {
27139
27471
  bold: true,
27140
27472
  css: theme => [{
27473
+ "&&&": {
27474
+ textDecoration: "none"
27475
+ },
27141
27476
  alignItems: "center",
27142
27477
  display: "flex",
27143
27478
  gap: theme.spacing(1)
@@ -27204,6 +27539,7 @@ const getStyles$1 = isCustomAmount => createStyles({
27204
27539
  const FundAndPurchase = ({
27205
27540
  carrierId,
27206
27541
  className,
27542
+ control,
27207
27543
  disabled,
27208
27544
  isFundingEnabled,
27209
27545
  isFundingRequired,
@@ -27219,11 +27555,11 @@ const FundAndPurchase = ({
27219
27555
  data: carrier,
27220
27556
  isLoading: isLoadingCarrier
27221
27557
  } = react.useGetCarrierById(carrierId);
27222
- const isAddingFunds = !!reactQuery.useIsMutating({
27223
- mutationKey: ["useAddFunds"]
27224
- });
27225
- const isCreatingLabel = !!reactQuery.useIsMutating({
27226
- mutationKey: ["useCreateLabel"]
27558
+ const {
27559
+ isSubmitting: isRateFormSubmitting,
27560
+ isValid: isRateFormValid
27561
+ } = reactHookForm.useFormState({
27562
+ control
27227
27563
  });
27228
27564
  const [isSavingRate, setIsSavingRate] = React.useState(false);
27229
27565
  const handleSaveRate = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -27241,7 +27577,7 @@ const FundAndPurchase = ({
27241
27577
  children: [jsxRuntime.jsx(giger.Button, Object.assign({
27242
27578
  bold: false,
27243
27579
  css: getStyles$1().saveRateButton,
27244
- disabled: disabled || !carrierId || isAddingFunds || isCreatingLabel,
27580
+ disabled: disabled || !carrierId || addFundsForm.isSubmitting || isRateFormSubmitting,
27245
27581
  isLoading: isSavingRate,
27246
27582
  onClick: handleSaveRate,
27247
27583
  variant: giger.ButtonVariant.OUTLINED
@@ -27249,8 +27585,8 @@ const FundAndPurchase = ({
27249
27585
  children: t("purchase-label:actions.saveRate")
27250
27586
  })), jsxRuntime.jsx(giger.Button, Object.assign({
27251
27587
  "data-testid": "submit-fund-and-purchase",
27252
- disabled: disabled || !carrierId || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
27253
- isLoading: addFundsForm.isSubmitting || isAddingFunds || isCreatingLabel,
27588
+ disabled: disabled || !carrierId || !isRateFormValid || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
27589
+ isLoading: addFundsForm.isSubmitting || isRateFormSubmitting,
27254
27590
  onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
27255
27591
  }, {
27256
27592
  children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
@@ -27269,10 +27605,6 @@ const FundAndPurchase = ({
27269
27605
  });
27270
27606
  if (!carrier || !carrierId) throw new Error("errorMessages.unableToLoad.carrier");
27271
27607
  const balance = carrier.balance;
27272
- const handleAddFundsSuccess = () => {
27273
- setIsAddFundsFormOpen(false);
27274
- onPurchase();
27275
- };
27276
27608
  // Render: walleted carrier, but funding feature is not enabled;
27277
27609
  // show balance, but not the funding form.
27278
27610
  if (!isFundingEnabled) return jsxRuntime.jsxs("div", Object.assign({
@@ -27296,7 +27628,7 @@ const FundAndPurchase = ({
27296
27628
  carrierId: carrierId
27297
27629
  }), jsxRuntime.jsx(LinkAction, {
27298
27630
  icon: "add",
27299
- isDisabled: isAddFundsFormOpen || isAddingFunds || isCreatingLabel,
27631
+ isDisabled: isAddFundsFormOpen || isRateFormSubmitting,
27300
27632
  onClick: () => setIsAddFundsFormOpen(true),
27301
27633
  title: t("manage-funding:actions.addFunds")
27302
27634
  })]
@@ -27314,7 +27646,7 @@ const FundAndPurchase = ({
27314
27646
  }), isAddFundsFormOpen ? jsxRuntime.jsx(AddFundsForm, Object.assign({
27315
27647
  carrierId: carrierId,
27316
27648
  minimumAmount: purchaseAmount - balance,
27317
- onSuccess: handleAddFundsSuccess
27649
+ onSuccess: onPurchase
27318
27650
  }, {
27319
27651
  children: addFundsForm => {
27320
27652
  var _a, _b;
@@ -27348,6 +27680,7 @@ const FundAndPurchase = ({
27348
27680
  justify: "end"
27349
27681
  }, {
27350
27682
  children: jsxRuntime.jsx(giger.Button, Object.assign({
27683
+ disabled: addFundsForm.isSubmitting || isRateFormSubmitting,
27351
27684
  onClick: () => setIsAddFundsFormOpen(false),
27352
27685
  variant: giger.ButtonVariant.TEXT
27353
27686
  }, {
@@ -27359,7 +27692,7 @@ const FundAndPurchase = ({
27359
27692
  }), renderActionButtons(addFundsForm)]
27360
27693
  });
27361
27694
  }
27362
- })) : renderActionButtons()]
27695
+ }), purchaseAmount) : renderActionButtons()]
27363
27696
  }));
27364
27697
  };
27365
27698
 
@@ -27409,6 +27742,7 @@ const RateForm = ({
27409
27742
  const {
27410
27743
  t
27411
27744
  } = reactI18next.useTranslation();
27745
+ const queryClient = reactQuery.useQueryClient();
27412
27746
  const rateFormScrollToRef = React.useRef(null);
27413
27747
  const [showHiddenRates, setShowHiddenRates] = React.useState(false);
27414
27748
  const form = reactHookForm.useForm({
@@ -27426,7 +27760,18 @@ const RateForm = ({
27426
27760
  } = form.watch("rate");
27427
27761
  const handleSubmit = formLogger.capture(form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
27428
27762
  const rateId = values;
27429
- yield onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(rateId);
27763
+ try {
27764
+ yield onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(rateId);
27765
+ } finally {
27766
+ // Invalidate carrier queries after the rate form is submitted, regardless of success.
27767
+ // This allows the carrier balance to refresh if the purchase failed but funding succeeded.
27768
+ queryClient.invalidateQueries(["useGetCarrierById", selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId], {
27769
+ exact: true
27770
+ });
27771
+ queryClient.invalidateQueries(["useListCarriers"], {
27772
+ exact: true
27773
+ });
27774
+ }
27430
27775
  })));
27431
27776
  const rateOptions = useRateOptions(rates, carriers, shipment, features.enableGlobalPostFiltering
27432
27777
  // TODO: LMNT-677: fix RecommendedRate logic
@@ -27543,6 +27888,7 @@ const RateForm = ({
27543
27888
  })]
27544
27889
  })), jsxRuntime.jsx(FundAndPurchase, {
27545
27890
  carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
27891
+ control: form.control,
27546
27892
  css: styles.fundAndPurchase,
27547
27893
  disabled: disabled,
27548
27894
  isFundingEnabled: features === null || features === void 0 ? void 0 : features.enableFunding,
@@ -27978,7 +28324,7 @@ const getShipmentSchema = ({
27978
28324
  }).nullish(),
27979
28325
  shipDate: zod.z.string(),
27980
28326
  shipmentId: zod.z.string().nullishDefault(undefined),
27981
- warehouseId: zod.z.string().refine(warehouseId => {
28327
+ warehouseId: zod.z.string().refine(warehouseId => !!warehouseId, "purchase-label:schemaErrors.shipFromAddressRequired").refine(warehouseId => {
27982
28328
  var _a;
27983
28329
  return allowInternationalShipFrom || ((_a = warehouses === null || warehouses === void 0 ? void 0 : warehouses.find(w => w.warehouseId === warehouseId)) === null || _a === void 0 ? void 0 : _a.originAddress.countryCode) === "US";
27984
28330
  }, "purchase-label:schemaErrors.shipFromUnitedStatesOnly")
@@ -28251,9 +28597,10 @@ const ShipmentForm = ({
28251
28597
  // When shipment is first loaded, hydrate the entire form
28252
28598
  useRunOnceOnTrue(shipment && (() => hydrateShipment(shipment)));
28253
28599
  React.useEffect(() => {
28254
- var _a, _b;
28600
+ var _a, _b, _c, _d;
28255
28601
  if (!shipment && (warehouses === null || warehouses === void 0 ? void 0 : warehouses.length)) {
28256
- const defaultWarehouse = (_b = (_a = warehouses.find(w => w.warehouseId === warehouseId)) === null || _a === void 0 ? void 0 : _a.warehouseId) !== null && _b !== void 0 ? _b : warehouses[0].warehouseId;
28602
+ const defaultWarehouse = (_d = (_b = (_a = warehouses.find(w => w.warehouseId === warehouseId)) === null || _a === void 0 ? void 0 : _a.warehouseId) !== null && _b !== void 0 ? _b : (_c = warehouses.find(w => w.isDefault)) === null || _c === void 0 ? void 0 : _c.warehouseId) !== null && _d !== void 0 ? _d : warehouses[0].warehouseId;
28603
+ // There will always be a default warehouse, but TS doesn't know that
28257
28604
  form.setValue("warehouseId", defaultWarehouse);
28258
28605
  }
28259
28606
  }, [form, shipment, warehouseId, warehouses]);
@@ -29145,7 +29492,9 @@ var index$1 = /*#__PURE__*/Object.freeze({
29145
29492
  styles: styles$2,
29146
29493
  billingAddressSchema: billingAddressSchema,
29147
29494
  walletSchema: walletSchema,
29148
- BillingFields: BillingFields
29495
+ BillingFields: BillingFields,
29496
+ WarehousePreferenceWizard: WarehousePreferenceWizard,
29497
+ WarehousePreferenceSelect: WarehousePreferenceSelect
29149
29498
  });
29150
29499
 
29151
29500
  const getStyles = showForm => createStyles({
@@ -29420,6 +29769,7 @@ const ManageFunding = ({
29420
29769
  const {
29421
29770
  t
29422
29771
  } = reactI18next.useTranslation();
29772
+ const queryClient = reactQuery.useQueryClient();
29423
29773
  const {
29424
29774
  isLoading: isLoadingCarrier
29425
29775
  } = react.useGetCarrierById(carrierId);
@@ -29442,7 +29792,15 @@ const ManageFunding = ({
29442
29792
  multiplier: 2
29443
29793
  }), jsxRuntime.jsx(AddFundsForm, {
29444
29794
  carrierId: carrierId,
29445
- onCancel: () => setIsAddFundsFormOpen(false)
29795
+ onCancel: () => setIsAddFundsFormOpen(false),
29796
+ onSuccess: () => {
29797
+ queryClient.invalidateQueries(["useGetCarrierById", carrierId], {
29798
+ exact: true
29799
+ });
29800
+ queryClient.invalidateQueries(["useListCarriers"], {
29801
+ exact: true
29802
+ });
29803
+ }
29446
29804
  })]
29447
29805
  }), jsxRuntime.jsx(Spacer, {
29448
29806
  multiplier: 2
@@ -30411,8 +30769,10 @@ var common = {
30411
30769
  },
30412
30770
  paste: "Paste Address",
30413
30771
  preference: {
30772
+ confirm: "Confirm",
30414
30773
  addressNotValidated: "Address not validated",
30415
30774
  modified: "modified",
30775
+ title: "To ensure accurate rate estimation, consider the changes suggested below.",
30416
30776
  originalAddress: "Original Address",
30417
30777
  matchedAddress: "Suggested Address",
30418
30778
  unableToValidate: "We were not able to validate this address. It might result in delays in your delivery.",
@@ -30673,6 +31033,7 @@ var manageFunding = {
30673
31033
  var manageWarehouses = {
30674
31034
  "manage-warehouses": {
30675
31035
  addNew: "Add New Address",
31036
+ editWarehouse: "Edit Address",
30676
31037
  contactName: "Contact Name",
30677
31038
  "default": "Default",
30678
31039
  isDefault: "Set as default Ship From address",
@@ -30787,6 +31148,7 @@ var purchaseLabel = {
30787
31148
  },
30788
31149
  schemaErrors: {
30789
31150
  shipFromUnitedStatesOnly: "Only US addresses are supported in this view",
31151
+ shipFromAddressRequired: "Ship From address is required",
30790
31152
  needToAcknowledge: "Need to accept Rate Compliance Agreement"
30791
31153
  },
30792
31154
  rates: {
@@ -31185,7 +31547,9 @@ const ListCarriers = () => {
31185
31547
 
31186
31548
  const Element$5 = registerElement("list-carriers", ListCarriers);
31187
31549
 
31188
- const ManageWarehouses = () => {
31550
+ const ManageWarehouses = ({
31551
+ onWarehouseAddressValidation
31552
+ }) => {
31189
31553
  const {
31190
31554
  t
31191
31555
  } = reactI18next.useTranslation();
@@ -31207,6 +31571,12 @@ const ManageWarehouses = () => {
31207
31571
  error: deleteWarehouseErrors,
31208
31572
  mutateAsync: deleteWarehouse
31209
31573
  } = react.useDeleteWarehouse();
31574
+ const {
31575
+ errors: validateWarehouseErrors,
31576
+ validate: validateWarehouse,
31577
+ warehousePreference,
31578
+ setWarehousePreference
31579
+ } = useWarehouseValidation();
31210
31580
  const handleDeleteWarehouse = warehouseId => __awaiter(void 0, void 0, void 0, function* () {
31211
31581
  yield deleteWarehouse({
31212
31582
  warehouseId
@@ -31240,13 +31610,16 @@ const ManageWarehouses = () => {
31240
31610
  if (listWarehouseErrors) throw new Error(listWarehouseErrors.map(e => e.message).join(", "));
31241
31611
  throw new Error("errorMessages.unableToLoad.warehouses");
31242
31612
  }
31243
- const errors = [...(updateWarehouseErrors !== null && updateWarehouseErrors !== void 0 ? updateWarehouseErrors : []), ...(createWarehouseErrors !== null && createWarehouseErrors !== void 0 ? createWarehouseErrors : []), ...(deleteWarehouseErrors !== null && deleteWarehouseErrors !== void 0 ? deleteWarehouseErrors : [])];
31613
+ const errors = [...(updateWarehouseErrors !== null && updateWarehouseErrors !== void 0 ? updateWarehouseErrors : []), ...(createWarehouseErrors !== null && createWarehouseErrors !== void 0 ? createWarehouseErrors : []), ...(deleteWarehouseErrors !== null && deleteWarehouseErrors !== void 0 ? deleteWarehouseErrors : []), ...(validateWarehouseErrors !== null && validateWarehouseErrors !== void 0 ? validateWarehouseErrors : [])];
31244
31614
  return jsxRuntime.jsx(ManageWarehouses$1, {
31245
31615
  errors: errors,
31246
31616
  onAdd: handleSubmitAddNewWarehouse,
31247
31617
  onDelete: handleDeleteWarehouse,
31248
31618
  onEdit: handleSubmitEditWarehouse,
31249
31619
  onSetDefault: handleSetDefault,
31620
+ onValidate: validateWarehouse,
31621
+ setWarehousePreference: setWarehousePreference,
31622
+ warehousePreference: warehousePreference,
31250
31623
  warehouses: warehouses
31251
31624
  });
31252
31625
  };
@@ -31562,18 +31935,16 @@ const useRequestRates = ({
31562
31935
  if (result) yield onRatesCalculated === null || onRatesCalculated === void 0 ? void 0 : onRatesCalculated(result.rateResponse.rates, shipment);
31563
31936
  }), [calculateRates, carriers, customPackageTypes, onRatesCalculated]);
31564
31937
  let ratesResponse = ratedShipment === null || ratedShipment === void 0 ? void 0 : ratedShipment.rateResponse;
31565
- if (ratesResponse) {
31566
- ratesResponse = Object.assign(Object.assign({}, ratesResponse), {
31567
- rates: ratesResponse.rates.map(rate => {
31568
- var _a, _b;
31569
- return Object.assign(Object.assign({}, rate), {
31570
- warningMessages: [
31571
- // add additional rateMessages based on combinations of serviceCode and packageType
31572
- ...((_a = rateMessages[`${rate.serviceCode}:${rate.packageType}`]) !== null && _a !== void 0 ? _a : []), ...((_b = rateMessages[rate.serviceCode]) !== null && _b !== void 0 ? _b : []), ...rate.warningMessages]
31573
- });
31574
- })
31575
- });
31576
- }
31938
+ ratesResponse = React.useMemo(() => ratesResponse && Object.assign(Object.assign({}, ratesResponse), {
31939
+ rates: ratesResponse.rates.map(rate => {
31940
+ var _a, _b;
31941
+ return Object.assign(Object.assign({}, rate), {
31942
+ warningMessages: [
31943
+ // add additional rateMessages based on combinations of serviceCode and packageType
31944
+ ...((_a = rateMessages[`${rate.serviceCode}:${rate.packageType}`]) !== null && _a !== void 0 ? _a : []), ...((_b = rateMessages[rate.serviceCode]) !== null && _b !== void 0 ? _b : []), ...rate.warningMessages]
31945
+ });
31946
+ })
31947
+ }), [ratesResponse]);
31577
31948
  return {
31578
31949
  ratesCalculating,
31579
31950
  ratesErrors,
@@ -32249,719 +32620,6 @@ const Element$1 = registerElement("view-shipment", Shipment);
32249
32620
 
32250
32621
  const Element = registerElement("void-label", VoidLabel);
32251
32622
 
32252
- /**
32253
- * @category Factories
32254
- */
32255
- const addressFactory = fishery.Factory.define(({
32256
- params,
32257
- transientParams
32258
- }) => {
32259
- var _a, _b, _c, _d;
32260
- const addressLine2 = (_a = params.addressLine2) !== null && _a !== void 0 ? _a : faker.faker.helpers.maybe(faker.faker.address.secondaryAddress, {
32261
- probability: 0.25
32262
- });
32263
- const addressLine3 = (_b = params.addressLine3) !== null && _b !== void 0 ? _b : addressLine2 && faker.faker.helpers.maybe(faker.faker.address.secondaryAddress);
32264
- let countryCode = (_c = params.countryCode) !== null && _c !== void 0 ? _c : "US";
32265
- // Random country code could still be US
32266
- while (transientParams.isInternational && countryCode === "US") {
32267
- countryCode = faker.faker.address.countryCode();
32268
- }
32269
- const stateProvince = (_d = params.stateProvince) !== null && _d !== void 0 ? _d : faker.faker.address.stateAbbr();
32270
- return {
32271
- addressLine1: faker.faker.address.streetAddress(),
32272
- addressLine2,
32273
- addressLine3,
32274
- addressResidentialIndicator: faker.faker.helpers.maybe(() => faker.faker.helpers.arrayElement(["yes", "no"])),
32275
- cityLocality: faker.faker.address.city(),
32276
- companyName: faker.faker.helpers.maybe(faker.faker.company.name),
32277
- countryCode,
32278
- name: faker.faker.name.fullName(),
32279
- phone: faker.faker.phone.number(),
32280
- postalCode: faker.faker.address.zipCodeByState(stateProvince),
32281
- stateProvince
32282
- };
32283
- });
32284
- /**
32285
- * @category Factories
32286
- */
32287
- const addressValidationFactory = fishery.Factory.define(({
32288
- associations,
32289
- params
32290
- }) => {
32291
- var _a, _b;
32292
- const status = params.status || faker.faker.helpers.arrayElement(["unverified", "verified", "warning", "error"]);
32293
- return {
32294
- matchedAddress: (_a = associations.matchedAddress) !== null && _a !== void 0 ? _a : faker.faker.helpers.maybe(() => addressFactory.build(), {
32295
- probability: ["verified", "error"].includes(status) ? 0 : 0.8
32296
- }),
32297
- messages: [],
32298
- originalAddress: (_b = associations.originalAddress) !== null && _b !== void 0 ? _b : addressFactory.build(),
32299
- status
32300
- };
32301
- });
32302
- /**
32303
- * Mock the addressValidation object used to hyrdate address valiation feature
32304
- * on the shipment form.
32305
- * @category Factory
32306
- */
32307
- const addressPreferenceFactory = fishery.Factory.define(({
32308
- associations,
32309
- params
32310
- }) => {
32311
- const addressValidation = addressValidationFactory.build({
32312
- status: params.status
32313
- }, {
32314
- associations: {
32315
- matchedAddress: addressFactory.build()
32316
- }
32317
- });
32318
- if (!addressValidation.matchedAddress) throw new Error("addressPreferenceFactory did not generate a matchedAddress");
32319
- return Object.assign(Object.assign({}, addressValidation), {
32320
- alternative: addressValidation.originalAddress,
32321
- alternativeSource: "originalAddress",
32322
- isModified: true,
32323
- selection: addressValidation.matchedAddress,
32324
- selectionSource: "matchedAddress",
32325
- toggle: () => addressFactory.build()
32326
- });
32327
- });
32328
-
32329
- const randomShipengineId = (length = 5) => `se-${faker.faker.random.numeric(length)}`;
32330
- const randomShipengineSlug = wordCount => faker.faker.lorem.slug(wordCount).replace("-", "_");
32331
- const tristateValue = (ifTrue, ifFalse, ifUndefined, value) => {
32332
- if (value === undefined) {
32333
- return ifUndefined;
32334
- }
32335
- if (value) {
32336
- return ifTrue;
32337
- }
32338
- return ifFalse;
32339
- };
32340
-
32341
- /**
32342
- * @category Factories
32343
- */
32344
- const packageFactory = fishery.Factory.define(({
32345
- transientParams
32346
- }) => ({
32347
- description: faker.faker.lorem.sentence(),
32348
- dimensions: (transientParams === null || transientParams === void 0 ? void 0 : transientParams.noDimensions) ? undefined : {
32349
- height: faker.faker.datatype.number({
32350
- max: 50,
32351
- min: 1,
32352
- precision: 0.1
32353
- }),
32354
- length: faker.faker.datatype.number({
32355
- max: 50,
32356
- min: 1,
32357
- precision: 0.1
32358
- }),
32359
- unit: faker.faker.helpers.arrayElement(["inch", "centimeter"]),
32360
- width: faker.faker.datatype.number({
32361
- max: 50,
32362
- min: 1,
32363
- precision: 0.1
32364
- })
32365
- },
32366
- name: faker.faker.random.words(),
32367
- packageCode: randomShipengineSlug(2),
32368
- packageId: randomShipengineSlug(3)
32369
- }));
32370
-
32371
- /**
32372
- * @category Factories
32373
- */
32374
- const serviceFactory = fishery.Factory.define(({
32375
- params,
32376
- transientParams
32377
- }) => {
32378
- var _a, _b, _c, _d;
32379
- const international = params.international || faker.faker.datatype.boolean();
32380
- return {
32381
- carrierCode: (_b = (_a = transientParams.carrier) === null || _a === void 0 ? void 0 : _a.carrierCode) !== null && _b !== void 0 ? _b : randomShipengineSlug(),
32382
- carrierId: (_d = (_c = transientParams.carrier) === null || _c === void 0 ? void 0 : _c.carrierId) !== null && _d !== void 0 ? _d : randomShipengineId(),
32383
- domestic: faker.faker.datatype.boolean() || !international,
32384
- international,
32385
- isMultiPackageSupported: faker.faker.datatype.boolean(),
32386
- name: faker.faker.random.words(),
32387
- serviceCode: randomShipengineSlug()
32388
- };
32389
- });
32390
-
32391
- /**
32392
- * @category Factories
32393
- */
32394
- const carrierOptionFactory = fishery.Factory.define(() => ({
32395
- defaultValue: faker.faker.random.word().toLowerCase(),
32396
- description: faker.faker.random.words(),
32397
- name: faker.faker.random.word()
32398
- }));
32399
- /**
32400
- * @category Factories
32401
- */
32402
- const carrierFactory = fishery.Factory.define(({
32403
- associations,
32404
- params,
32405
- sequence
32406
- }) => {
32407
- const carrierCode = params.carrierCode || randomShipengineSlug();
32408
- const carrierId = params.carrierId || `se-${10000 + sequence}`;
32409
- return {
32410
- accountNumber: faker.faker.random.numeric(9),
32411
- balance: faker.faker.datatype.number({
32412
- max: 0,
32413
- min: 0,
32414
- precision: 0.01
32415
- }),
32416
- carrierCode,
32417
- carrierId,
32418
- friendlyName: faker.faker.company.name(),
32419
- hasMultiPackageSupportingServices: faker.faker.datatype.boolean(),
32420
- nickname: faker.faker.random.words(3),
32421
- options: associations.options || [],
32422
- packages: associations.packages || packageFactory.buildList(faker.faker.datatype.number({
32423
- max: 10,
32424
- min: 1
32425
- }), {}, {
32426
- transient: {
32427
- noDimensions: true
32428
- }
32429
- }),
32430
- primary: false,
32431
- requiresFundedAmount: false,
32432
- services: associations.services || serviceFactory.buildList(faker.faker.datatype.number({
32433
- max: 10,
32434
- min: 1
32435
- }), {
32436
- carrierCode,
32437
- carrierId
32438
- }),
32439
- supportsLabelMessages: faker.faker.datatype.boolean()
32440
- };
32441
- });
32442
-
32443
- /**
32444
- * @category Factories
32445
- */
32446
- const moneyFactory = fishery.Factory.define(({
32447
- transientParams
32448
- }) => ({
32449
- amount: faker.faker.datatype.number({
32450
- max: 1000,
32451
- min: 5,
32452
- precision: 0.01
32453
- }),
32454
- currency: (transientParams === null || transientParams === void 0 ? void 0 : transientParams.isInternational) ? faker.faker.helpers.arrayElement(Object.values(api.SE.Currency)) : api.SE.Currency.USD
32455
- }));
32456
-
32457
- const randomOrderSourceCode = () => faker.faker.helpers.arrayElement(["3dcart", "abantecart", "acumatica", "acumatica_v2", "alibaba", "amazon", "amazon_au", "amazon_ca", "amazon_de", "amazon_es", "amazon_fr", "amazon_it", "amazon_jp", "amazon_mx", "amazon_uk", "americommerce", "auctane-orders", "back-market", "bandcamp", "big_cartel", "bigcommerce", "bigcommerce_v3", "bigcommerce_v2", "bizelo", "bluepark", "bonanza", "brightpearl", "cdiscount", "celery", "channeladvisor", "channelsale", "choxi", "cin7", "commerceinterface", "corecommerce", "coupang", "cratejoy", "cs-cart", "custom_store", "dear_systems", "dummy-marketplace", "ebay", "ebay_au", "ebay_ca", "ebay_uk", "ebay_fr", "ebay_v2", "ecwid", "ecwid_v1", "edesk", "ekm", "etsy", "facebook", "fnac", "foxycart", "freestyle", "fullscreen_direct", "geekseller", "goodsie", "google", "google_checkout", "gorgias", "groopdealz", "groupon_goods", "handshake", "hatch", "highwire", "homeroots", "houzz", "idealo_de", "inksoft", "jane", "jet", "kaufland", "labelapi", "lemonstand", "lengow", "liftoff", "linnworks", "listingmirror", "magento", "zoey", "magento_go", "memberly", "mercado_libre", "mijoshop", "best_buy_ca", "catch", "darty", "fanatics", "kohls", "kroger", "urbn", "miva_merchant", "morecommerce", "mozu", "neto", "newegg", "newegg_business", "newegg_ca", "notonthehighstreet", "oauth_dummy", "odbc", "onbuy", "opencart", "order_time", "ordersource_api", "oscommerce", "overstock", "oxatis", "paypal", "paypal_v2", "payvment", "penny", "prestashop", "rakuten", "best_buy", "rakuten-fr", "rate_browser", "redditgifts", "reverb", "revolutionparts", "salesforce_commerce_cloud", "salesforce_core", "sap_anywhere", "scout_topshelf", "sears", "securestore", "sellbrite", "selleractive", "shipengine_api", "shipengine_merchant", "shipstation", "shop_premium_outlets", "shopify", "shoppingfeed", "shopware_de", "simplepart", "skuvault", "soldsie", "sophio", "spark_shipping", "spree", "spreesy", "square", "squarespace", "stitch_labs", "storenvy", "stripe", "suredone", "tanga", "tophatter", "trade_me", "tradegecko", "ultracart", "unbranded_ecommerce_store", "unleashed", "vault", "visualsoft", "volo", "volusion", "vtex", "walmart", "walmart_ca", "wayfair", "webflow", "weebly", "wish", "wix", "woocommerce", "woocommerce_v2", "woot", "x-cart", "yahoo", "sec_yumbles", "zen_cart", "zonos"]);
32458
- /**
32459
- * @category Factories
32460
- */
32461
- const orderSourceRefreshInfoFactory = fishery.Factory.define(() => {
32462
- const lastRefreshAttempt = faker.faker.date.recent();
32463
- return {
32464
- lastRefreshAttempt: lastRefreshAttempt.toISOString(),
32465
- refreshDate: faker.faker.date.recent(1, lastRefreshAttempt).toISOString(),
32466
- status: faker.faker.helpers.arrayElement(["idle", "preparing_update", "updating", "error", "unknown"])
32467
- };
32468
- });
32469
- /**
32470
- * @category Factories
32471
- */
32472
- const orderSourceFactory = fishery.Factory.define(({
32473
- associations,
32474
- params
32475
- }) => {
32476
- var _a;
32477
- return {
32478
- active: faker.faker.datatype.boolean(),
32479
- orderSourceCode: randomOrderSourceCode(),
32480
- orderSourceFriendlyName: faker.faker.company.name(),
32481
- orderSourceId: faker.faker.datatype.uuid(),
32482
- orderSourceNickname: faker.faker.random.words(),
32483
- refreshInfo: (_a = associations.refreshInfo) !== null && _a !== void 0 ? _a : orderSourceRefreshInfoFactory.build(params.refreshInfo)
32484
- };
32485
- });
32486
-
32487
- /**
32488
- * @category Factories
32489
- */
32490
- const downloadFactory = fishery.Factory.define(() => ({
32491
- href: faker.faker.internet.url(),
32492
- pdf: faker.faker.internet.url(),
32493
- png: faker.faker.internet.url(),
32494
- zpl: faker.faker.internet.url()
32495
- }));
32496
- /**
32497
- * @category Factories
32498
- */
32499
- const linkedResourceFactory = fishery.Factory.define(() => ({
32500
- href: faker.faker.internet.url(),
32501
- type: faker.faker.word.noun()
32502
- }));
32503
-
32504
- const randomWeightUnit = () => faker.faker.helpers.arrayElement(["pound", "ounce", "gram", "kilogram"]);
32505
- /**
32506
- * @category Factories
32507
- */
32508
- const fractionalWeightFactory = fishery.Factory.define(() => ({
32509
- fractional: faker.faker.datatype.number({
32510
- max: 16,
32511
- min: 0
32512
- }),
32513
- whole: faker.faker.datatype.number({
32514
- max: 20,
32515
- min: 0
32516
- })
32517
- }));
32518
- /**
32519
- * @category Factories
32520
- */
32521
- const weightFactory = fishery.Factory.define(() => ({
32522
- value: faker.faker.datatype.number({
32523
- max: 20,
32524
- min: 1,
32525
- precision: 0.1
32526
- })
32527
- }));
32528
- /**
32529
- * @category Factories
32530
- */
32531
- const weightWithUnitFactory = fishery.Factory.define(({
32532
- params
32533
- }) => {
32534
- const weight = weightFactory.build(params);
32535
- return Object.assign(Object.assign({}, weight), {
32536
- unit: randomWeightUnit()
32537
- });
32538
- });
32539
-
32540
- const randomDeliveryConfirmation = () => faker.faker.helpers.arrayElement(Object.values(api.SE.ConfirmationType));
32541
- const randomInsuranceProvider = (allowNone = true) => {
32542
- const availableProviders = Object.values(api.SE.InsuranceProviderType).filter(p => allowNone ? p : p !== "none");
32543
- return faker.faker.helpers.arrayElement(availableProviders);
32544
- };
32545
- /**
32546
- * @category Factories
32547
- */
32548
- const customsItemFactory = fishery.Factory.define(({
32549
- associations,
32550
- params,
32551
- transientParams
32552
- }) => ({
32553
- countryOfOrigin: faker.faker.address.countryCode(),
32554
- description: faker.faker.commerce.productName(),
32555
- harmonizedTariffCode: faker.faker.datatype.string(),
32556
- quantity: faker.faker.datatype.number({
32557
- max: 10,
32558
- min: 1
32559
- }),
32560
- sku: faker.faker.random.numeric(10),
32561
- skuDescription: faker.faker.helpers.maybe(faker.faker.lorem.sentence),
32562
- unitOfMeasure: faker.faker.helpers.maybe(faker.faker.word.noun),
32563
- value: associations.value || faker.faker.datatype.number({
32564
- max: 10,
32565
- min: 1
32566
- })
32567
- }));
32568
- /**
32569
- * @category Factories
32570
- */
32571
- const shipmentItemFactory = fishery.Factory.define(({
32572
- params
32573
- }) => ({
32574
- asin: faker.faker.helpers.maybe(() => faker.faker.random.alphaNumeric(10)),
32575
- externalOrderId: faker.faker.random.alphaNumeric(10),
32576
- externalOrderItemId: faker.faker.random.alphaNumeric(10),
32577
- name: faker.faker.commerce.productName(),
32578
- orderSourceCode: randomOrderSourceCode(),
32579
- quantity: faker.faker.datatype.number({
32580
- max: 10,
32581
- min: 1
32582
- }),
32583
- salesOrderItemId: params.salesOrderId && faker.faker.random.alphaNumeric(6),
32584
- sku: faker.faker.random.numeric(10)
32585
- }));
32586
- /**
32587
- * @category Factories
32588
- */
32589
- const shipmentPackageFactory = fishery.Factory.define(({
32590
- associations,
32591
- params,
32592
- transientParams
32593
- }) => {
32594
- var _a, _b, _c, _d, _e;
32595
- const _f = packageFactory.build(params),
32596
- pkg = __rest(_f, ["name"]);
32597
- const isInsured = tristateValue(true, false, faker.faker.datatype.boolean(), (_b = (_a = params.insuredValue) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : transientParams.isInsured);
32598
- return Object.assign(Object.assign({}, pkg), {
32599
- insuredValue: (_c = associations.insuredValue) !== null && _c !== void 0 ? _c : isInsured ? moneyFactory.build(params.insuredValue) : undefined,
32600
- labelDownload: (_d = associations.labelDownload) !== null && _d !== void 0 ? _d : transientParams.isShipped ? downloadFactory.build(params.labelDownload) : undefined,
32601
- labelMessages: associations.labelMessages,
32602
- trackingNumber: transientParams.isShipped ? faker.faker.random.alphaNumeric(12, {
32603
- casing: "upper"
32604
- }) : undefined,
32605
- weight: (_e = associations.weight) !== null && _e !== void 0 ? _e : weightWithUnitFactory.build(params.weight)
32606
- });
32607
- });
32608
- /**
32609
- * @category Factories
32610
- */
32611
- const shipmentFactory = fishery.Factory.define(({
32612
- associations,
32613
- params,
32614
- sequence,
32615
- transientParams
32616
- }) => {
32617
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
32618
- const shipTo = (_a = associations.shipTo) !== null && _a !== void 0 ? _a : addressFactory.build(params.shipTo, {
32619
- transient: {
32620
- isInternational: transientParams.isInternational
32621
- }
32622
- });
32623
- let insuranceProvider = api.SE.InsuranceProviderType.NONE;
32624
- if (transientParams.insuredValue || transientParams.isInsured) {
32625
- insuranceProvider = (_b = params.insuranceProvider) !== null && _b !== void 0 ? _b : randomInsuranceProvider(false);
32626
- } else if (transientParams.insuredValue === undefined && transientParams.isInsured === undefined) {
32627
- insuranceProvider = randomInsuranceProvider(true);
32628
- }
32629
- const shipDateObj = faker.faker.date.soon(7);
32630
- shipDateObj.setHours(0, 0, 0, 0);
32631
- const totalWeight = (_c = associations.totalWeight) !== null && _c !== void 0 ? _c : weightWithUnitFactory.build(params.totalWeight);
32632
- return {
32633
- addressValidation: (_d = associations.addressValidation) !== null && _d !== void 0 ? _d : addressValidationFactory.build(params.addressValidation, {
32634
- associations: {
32635
- originalAddress: shipTo
32636
- }
32637
- }),
32638
- carrierId: (_f = (_e = transientParams === null || transientParams === void 0 ? void 0 : transientParams.service) === null || _e === void 0 ? void 0 : _e.carrierId) !== null && _f !== void 0 ? _f : randomShipengineId(),
32639
- confirmation: randomDeliveryConfirmation(),
32640
- createdAt: faker.faker.date.past().toISOString(),
32641
- customs: (_g = associations.customs) !== null && _g !== void 0 ? _g : transientParams.isInternational ? {
32642
- contents: faker.faker.helpers.arrayElement(["documents", "gift", "merchandise", "returned_goods", "sample"]),
32643
- customsItems: customsItemFactory.buildList(faker.faker.datatype.number({
32644
- max: 10,
32645
- min: 1
32646
- })),
32647
- nonDelivery: faker.faker.helpers.arrayElement(["return_to_sender", "treat_as_abandoned"])
32648
- } : undefined,
32649
- externalOrderId: faker.faker.random.alphaNumeric(10),
32650
- externalShipmentId: faker.faker.random.alphaNumeric(10),
32651
- insuranceProvider,
32652
- items: shipmentItemFactory.buildList(faker.faker.datatype.number({
32653
- max: 10,
32654
- min: 1
32655
- }), transientParams.salesOrder ? {
32656
- externalOrderId: transientParams.salesOrder.externalOrderId,
32657
- orderSourceCode: transientParams.salesOrder.orderSource.orderSourceCode,
32658
- salesOrderId: (_h = transientParams.salesOrder) === null || _h === void 0 ? void 0 : _h.salesOrderId
32659
- } : {}),
32660
- modifiedAt: faker.faker.date.recent().toISOString(),
32661
- orderSourceCode: (_k = (_j = transientParams.salesOrder) === null || _j === void 0 ? void 0 : _j.orderSource.orderSourceCode) !== null && _k !== void 0 ? _k : randomOrderSourceCode(),
32662
- packages: (_l = associations.packages) !== null && _l !== void 0 ? _l : shipmentPackageFactory.buildList(1, (_m = params.packages) === null || _m === void 0 ? void 0 : _m[0], {
32663
- associations: {
32664
- weight: totalWeight
32665
- },
32666
- transient: {
32667
- isInsured: insuranceProvider !== "none",
32668
- isShipped: transientParams.isShipped
32669
- }
32670
- }),
32671
- returnTo: (_q = (_o = associations.returnTo) !== null && _o !== void 0 ? _o : (_p = transientParams.warehouse) === null || _p === void 0 ? void 0 : _p.returnAddress) !== null && _q !== void 0 ? _q : addressFactory.build(),
32672
- serviceCode: (_s = (_r = transientParams.service) === null || _r === void 0 ? void 0 : _r.serviceCode) !== null && _s !== void 0 ? _s : randomShipengineSlug(),
32673
- shipDate: shipDateObj.toISOString(),
32674
- shipFrom: (_v = (_t = associations.shipFrom) !== null && _t !== void 0 ? _t : (_u = transientParams.warehouse) === null || _u === void 0 ? void 0 : _u.originAddress) !== null && _v !== void 0 ? _v : addressFactory.build(),
32675
- shipmentId: `se-${30000 + sequence}`,
32676
- shipmentStatus: transientParams.isShipped ? "label_purchased" : "pending",
32677
- shipTo,
32678
- tags: (_w = associations.tags) !== null && _w !== void 0 ? _w : [],
32679
- totalWeight,
32680
- warehouseId: (_x = transientParams.warehouse) === null || _x === void 0 ? void 0 : _x.warehouseId
32681
- };
32682
- });
32683
- /**
32684
- * @category Factories
32685
- */
32686
- const salesOrderShipmentFactory = fishery.Factory.define(({
32687
- associations,
32688
- params,
32689
- transientParams
32690
- }) => {
32691
- var _a, _b, _c;
32692
- const shipment = shipmentFactory.build(params, {
32693
- associations,
32694
- transient: transientParams
32695
- });
32696
- return Object.assign(Object.assign({}, shipment), {
32697
- salesOrderIds: (_a = associations.salesOrderIds) !== null && _a !== void 0 ? _a : [(_c = (_b = transientParams.salesOrder) === null || _b === void 0 ? void 0 : _b.salesOrderId) !== null && _c !== void 0 ? _c : faker.faker.datatype.uuid()]
32698
- });
32699
- });
32700
-
32701
- /**
32702
- * @category Factories
32703
- */
32704
- const labelFactory = fishery.Factory.define(({
32705
- params,
32706
- sequence,
32707
- transientParams
32708
- }) => {
32709
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
32710
- const shipTo = Object.assign(Object.assign({}, addressFactory.build((_a = transientParams.shipment) === null || _a === void 0 ? void 0 : _a.shipTo)), {
32711
- companyName: (_c = (_b = transientParams.shipment) === null || _b === void 0 ? void 0 : _b.shipTo.companyName) !== null && _c !== void 0 ? _c : faker.faker.lorem.word(),
32712
- relayPointId: faker.faker.random.numeric(10)
32713
- });
32714
- const shipFrom = Object.assign(Object.assign({}, addressFactory.build(((_d = transientParams.shipment) === null || _d === void 0 ? void 0 : _d.shipFrom) || undefined)), {
32715
- companyName: (_f = (_e = transientParams.shipment) === null || _e === void 0 ? void 0 : _e.shipTo.companyName) !== null && _f !== void 0 ? _f : faker.faker.lorem.word(),
32716
- relayPointId: faker.faker.random.numeric(10)
32717
- });
32718
- const shipDateObj = faker.faker.date.soon(7);
32719
- shipDateObj.setHours(0, 0, 0, 0);
32720
- return {
32721
- batchId: faker.faker.random.numeric(10),
32722
- carrierCode: (_h = (_g = transientParams.carrier) === null || _g === void 0 ? void 0 : _g.carrierCode) !== null && _h !== void 0 ? _h : randomShipengineSlug(),
32723
- carrierId: (_k = (_j = transientParams.shipment) === null || _j === void 0 ? void 0 : _j.carrierId) !== null && _k !== void 0 ? _k : `se-${10000 + sequence}`,
32724
- chargeEvent: "on_creation",
32725
- createdAt: faker.faker.date.past().toISOString(),
32726
- displayScheme: "label",
32727
- formDownload: {
32728
- href: faker.faker.internet.url(),
32729
- type: ""
32730
- },
32731
- insuranceClaim: {
32732
- href: faker.faker.internet.url(),
32733
- type: ""
32734
- },
32735
- insuranceCost: moneyFactory.build(),
32736
- isInternational: shipTo.countryCode !== "US",
32737
- isReturnLabel: false,
32738
- labelDownload: {
32739
- href: faker.faker.image.imageUrl(),
32740
- pdf: faker.faker.image.imageUrl(),
32741
- png: faker.faker.image.imageUrl(),
32742
- zpl: faker.faker.image.imageUrl()
32743
- },
32744
- labelFormat: "pdf",
32745
- labelId: `se-${40000 + sequence}`,
32746
- labelImageId: faker.faker.random.numeric(10),
32747
- labelLayout: "4x6",
32748
- modifiedAt: faker.faker.date.recent().toISOString(),
32749
- packageCode: (_m = (_l = transientParams.shipment) === null || _l === void 0 ? void 0 : _l.packages[0].packageCode) !== null && _m !== void 0 ? _m : randomShipengineSlug(2),
32750
- packages: (_p = (_o = transientParams.shipment) === null || _o === void 0 ? void 0 : _o.packages) !== null && _p !== void 0 ? _p : shipmentPackageFactory.buildList(1),
32751
- relayPoints: {
32752
- shipFrom,
32753
- shipTo
32754
- },
32755
- rmaNumber: faker.faker.random.alpha(10),
32756
- serviceCode: (_r = (_q = transientParams.shipment) === null || _q === void 0 ? void 0 : _q.serviceCode) !== null && _r !== void 0 ? _r : randomShipengineSlug(),
32757
- shipDate: (_t = (_s = transientParams.shipment) === null || _s === void 0 ? void 0 : _s.shipDate) !== null && _t !== void 0 ? _t : shipDateObj.toISOString(),
32758
- shipmentCost: moneyFactory.build(),
32759
- shipmentId: (_v = (_u = transientParams.shipment) === null || _u === void 0 ? void 0 : _u.shipmentId) !== null && _v !== void 0 ? _v : `se-${30000 + sequence}`,
32760
- status: (_w = params.status) !== null && _w !== void 0 ? _w : "processing",
32761
- trackable: !!((_x = transientParams.shipment) === null || _x === void 0 ? void 0 : _x.packages[0].trackingNumber),
32762
- trackingNumber: (_z = (_y = transientParams.shipment) === null || _y === void 0 ? void 0 : _y.packages[0].trackingNumber) !== null && _z !== void 0 ? _z : faker.faker.random.alpha(10),
32763
- trackingStatus: "in_transit",
32764
- voided: ((_0 = transientParams.shipment) === null || _0 === void 0 ? void 0 : _0.shipmentStatus) === "cancelled",
32765
- voidedAt: (_2 = (_1 = transientParams.shipment) === null || _1 === void 0 ? void 0 : _1.modifiedAt) !== null && _2 !== void 0 ? _2 : faker.faker.date.past().toISOString()
32766
- };
32767
- });
32768
-
32769
- const randomPaymentStatus = () => faker.faker.helpers.arrayElement(["unknown", "paid", "unpaid", "partially_paid"]);
32770
- const randomFulfillmentStatus = () => faker.faker.helpers.arrayElement(["unknown", "fulfilled", "unfulfilled", "partially_fulfilled", "on_hold"]);
32771
- /**
32772
- * @category Factories
32773
- */
32774
- const salesOrderItemFactory = fishery.Factory.define(({
32775
- associations,
32776
- params,
32777
- transientParams
32778
- }) => {
32779
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
32780
- const quantity = faker.faker.datatype.number({
32781
- max: 5,
32782
- min: 1
32783
- });
32784
- let {
32785
- priceSummary
32786
- } = associations;
32787
- if (!priceSummary) {
32788
- const unitPrice = moneyFactory.build((_a = params.priceSummary) === null || _a === void 0 ? void 0 : _a.unitPrice, {
32789
- transient: transientParams
32790
- });
32791
- const estimatedShipping = ((_b = params.priceSummary) === null || _b === void 0 ? void 0 : _b.estimatedShipping) ? moneyFactory.build(Object.assign({
32792
- currency: unitPrice.currency
32793
- }, (_c = params.priceSummary) === null || _c === void 0 ? void 0 : _c.estimatedShipping)) : undefined;
32794
- const estimatedTax = moneyFactory.build({
32795
- amount: (_f = (_e = (_d = params.priceSummary) === null || _d === void 0 ? void 0 : _d.estimatedTax) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : unitPrice.amount * quantity * 0.1,
32796
- currency: (_j = (_h = (_g = params.priceSummary) === null || _g === void 0 ? void 0 : _g.estimatedTax) === null || _h === void 0 ? void 0 : _h.currency) !== null && _j !== void 0 ? _j : unitPrice.currency
32797
- });
32798
- const total = moneyFactory.build({
32799
- amount: (_m = (_l = (_k = params.priceSummary) === null || _k === void 0 ? void 0 : _k.total) === null || _l === void 0 ? void 0 : _l.amount) !== null && _m !== void 0 ? _m : unitPrice.amount * quantity + ((_o = estimatedShipping === null || estimatedShipping === void 0 ? void 0 : estimatedShipping.amount) !== null && _o !== void 0 ? _o : 0) + estimatedTax.amount,
32800
- currency: (_r = (_q = (_p = params.priceSummary) === null || _p === void 0 ? void 0 : _p.total) === null || _q === void 0 ? void 0 : _q.currency) !== null && _r !== void 0 ? _r : unitPrice.currency
32801
- });
32802
- priceSummary = {
32803
- estimatedShipping,
32804
- estimatedTax,
32805
- total,
32806
- unitPrice
32807
- };
32808
- }
32809
- return {
32810
- isGift: faker.faker.datatype.boolean(),
32811
- lineItemDetails: (_s = associations.lineItemDetails) !== null && _s !== void 0 ? _s : {
32812
- asin: (_u = (_t = params.lineItemDetails) === null || _t === void 0 ? void 0 : _t.asin) !== null && _u !== void 0 ? _u : faker.faker.random.alphaNumeric(10),
32813
- name: (_w = (_v = params.lineItemDetails) === null || _v === void 0 ? void 0 : _v.name) !== null && _w !== void 0 ? _w : faker.faker.commerce.productName(),
32814
- sku: (_y = (_x = params.lineItemDetails) === null || _x === void 0 ? void 0 : _x.sku) !== null && _y !== void 0 ? _y : faker.faker.random.numeric(10),
32815
- weight: weightWithUnitFactory.build((_z = params.lineItemDetails) === null || _z === void 0 ? void 0 : _z.weight)
32816
- },
32817
- priceSummary,
32818
- quantity,
32819
- requestedShippingOptions: (_0 = associations.requestedShippingOptions) !== null && _0 !== void 0 ? _0 : {
32820
- shipDate: (_1 = faker.faker.helpers.maybe(() => faker.faker.date.soon(7).toISOString())) !== null && _1 !== void 0 ? _1 : null,
32821
- shippingService: faker.faker.word.adjective()
32822
- },
32823
- salesOrderItemId: faker.faker.datatype.uuid(),
32824
- shipTo: (_2 = associations.shipTo) !== null && _2 !== void 0 ? _2 : addressFactory.build(params.shipTo)
32825
- };
32826
- });
32827
- /**
32828
- * @category Factories
32829
- */
32830
- const salesOrderFactory = fishery.Factory.define(({
32831
- associations,
32832
- params,
32833
- sequence,
32834
- transientParams
32835
- }) => {
32836
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
32837
- const createdAt = (_a = params.createdAt) !== null && _a !== void 0 ? _a : faker.faker.date.recent(30).toISOString();
32838
- let {
32839
- paymentDetails
32840
- } = associations;
32841
- if (!paymentDetails) {
32842
- const subtotal = moneyFactory.build((_b = params.paymentDetails) === null || _b === void 0 ? void 0 : _b.subtotal, {
32843
- transient: transientParams
32844
- });
32845
- const estimatedShipping = moneyFactory.build(Object.assign({
32846
- currency: subtotal.currency
32847
- }, (_c = params.paymentDetails) === null || _c === void 0 ? void 0 : _c.estimatedShipping));
32848
- const estimatedTax = moneyFactory.build({
32849
- amount: (_f = (_e = (_d = params.paymentDetails) === null || _d === void 0 ? void 0 : _d.estimatedTax) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : subtotal.amount * 0.1,
32850
- currency: (_j = (_h = (_g = params.paymentDetails) === null || _g === void 0 ? void 0 : _g.estimatedTax) === null || _h === void 0 ? void 0 : _h.currency) !== null && _j !== void 0 ? _j : subtotal.currency
32851
- });
32852
- const grandTotal = moneyFactory.build({
32853
- amount: (_m = (_l = (_k = params.paymentDetails) === null || _k === void 0 ? void 0 : _k.grandTotal) === null || _l === void 0 ? void 0 : _l.amount) !== null && _m !== void 0 ? _m : subtotal.amount + estimatedShipping.amount + estimatedTax.amount,
32854
- currency: (_q = (_p = (_o = params.paymentDetails) === null || _o === void 0 ? void 0 : _o.grandTotal) === null || _p === void 0 ? void 0 : _p.currency) !== null && _q !== void 0 ? _q : subtotal.currency
32855
- });
32856
- paymentDetails = {
32857
- estimatedShipping,
32858
- estimatedTax,
32859
- grandTotal,
32860
- subtotal
32861
- };
32862
- }
32863
- const shipTo = (_r = associations.shipTo) !== null && _r !== void 0 ? _r : addressFactory.build(params.shipTo || {});
32864
- return {
32865
- billTo: (_s = associations.billTo) !== null && _s !== void 0 ? _s : {
32866
- address: addressFactory.build((_t = params.billTo) === null || _t === void 0 ? void 0 : _t.address),
32867
- email: faker.faker.internet.email()
32868
- },
32869
- createdAt,
32870
- customer: (_u = associations.customer) !== null && _u !== void 0 ? _u : {
32871
- email: faker.faker.internet.email(),
32872
- name: faker.faker.name.fullName(),
32873
- phone: faker.faker.phone.number()
32874
- },
32875
- externalOrderId: faker.faker.random.numeric(9),
32876
- externalOrderNumber: faker.faker.random.numeric(9),
32877
- modifiedAt: createdAt,
32878
- // TODO: What is this? Is it supposed to be in the future?
32879
- orderDate: createdAt,
32880
- orderSource: (_v = associations.orderSource) !== null && _v !== void 0 ? _v : orderSourceFactory.build(params.orderSource),
32881
- paymentDetails,
32882
- salesOrderId: `se-${20000 + sequence}`,
32883
- salesOrderItems: salesOrderItemFactory.buildList(2, {}, {
32884
- associations: {
32885
- shipTo
32886
- },
32887
- transient: transientParams
32888
- }),
32889
- salesOrderStatus: (_w = associations.salesOrderStatus) !== null && _w !== void 0 ? _w : {
32890
- fulfillmentStatus: randomFulfillmentStatus(),
32891
- isCancelled: false,
32892
- paymentStatus: randomPaymentStatus()
32893
- },
32894
- shipTo
32895
- };
32896
- });
32897
-
32898
- /**
32899
- * @category Factories
32900
- */
32901
- const warehouseFactory = fishery.Factory.define(({
32902
- associations,
32903
- params
32904
- }) => {
32905
- var _a, _b, _c;
32906
- return {
32907
- createdAt: faker.faker.date.past().toISOString(),
32908
- isDefault: (_a = params.isDefault) !== null && _a !== void 0 ? _a : false,
32909
- name: faker.faker.company.name(),
32910
- originAddress: (_b = associations.originAddress) !== null && _b !== void 0 ? _b : addressFactory.build(params.originAddress),
32911
- returnAddress: (_c = associations.returnAddress) !== null && _c !== void 0 ? _c : addressFactory.build(params.returnAddress),
32912
- warehouseId: randomShipengineId()
32913
- };
32914
- });
32915
-
32916
- const renderWithProviders = component => {
32917
- const theme = brands.createTheme(brands.BrandName.FALLBACK);
32918
- return react$2.render(component, {
32919
- wrapper: ({
32920
- children
32921
- }) => jsxRuntime.jsx(RootPortalProvider, {
32922
- children: jsxRuntime.jsx(giger.GigerConfigProvider, Object.assign({
32923
- resolveIcon: name => `<svg>${name}</svg>`
32924
- }, {
32925
- children: jsxRuntime.jsx(react$1.ThemeProvider, Object.assign({
32926
- theme: brands.deserialize(theme)
32927
- }, {
32928
- children: children
32929
- }))
32930
- }))
32931
- })
32932
- });
32933
- };
32934
- /**
32935
- * Wraps the test with all of the usual Shipengine / Giger / i18 / etc providers that a full, registered "Element" would have.
32936
- * This allows components to simulate usage in an Element via `decorators: [withAllProviders]`
32937
- **/
32938
- const renderWithAllProviders = component => {
32939
- const theme = brands.createTheme(brands.BrandName.FALLBACK);
32940
- return react$2.render(component, {
32941
- wrapper: ({
32942
- children
32943
- }) => jsxRuntime.jsx(react.ShipEngineProvider, Object.assign({
32944
- baseURL: "/api",
32945
- getToken: () => {
32946
- var _a;
32947
- return (_a = process.env.STORYBOOK_TOKEN) !== null && _a !== void 0 ? _a : "none";
32948
- }
32949
- }, {
32950
- children: jsxRuntime.jsx(RootPortalProvider, {
32951
- children: jsxRuntime.jsx(giger.GigerConfigProvider, Object.assign({
32952
- resolveIcon: name => `<svg>${name}</svg>`
32953
- }, {
32954
- children: jsxRuntime.jsx(react$1.ThemeProvider, Object.assign({
32955
- theme: brands.deserialize(theme)
32956
- }, {
32957
- children: children
32958
- }))
32959
- }))
32960
- })
32961
- }))
32962
- });
32963
- };
32964
-
32965
32623
  exports.Accordion = Accordion;
32966
32624
  exports.AddFundsForm = AddFundsForm;
32967
32625
  exports.AutoFundingForm = AutoFundingForm;
@@ -32998,14 +32656,9 @@ exports.UsState = UsState;
32998
32656
  exports.UsaCity = UsaCity;
32999
32657
  exports.ViewShipment = Element$1;
33000
32658
  exports.VoidLabel = Element;
33001
- exports.addressFactory = addressFactory;
33002
- exports.addressPreferenceFactory = addressPreferenceFactory;
33003
- exports.addressValidationFactory = addressValidationFactory;
33004
32659
  exports.autoFundingSchema = autoFundingSchema;
33005
32660
  exports.calculateTotal = calculateTotal;
33006
32661
  exports.capitalizeFirstLetter = capitalizeFirstLetter;
33007
- exports.carrierFactory = carrierFactory;
33008
- exports.carrierOptionFactory = carrierOptionFactory;
33009
32662
  exports.convertDimensions = convertDimensions;
33010
32663
  exports.convertWeight = convertWeight;
33011
32664
  exports.countries = countries;
@@ -33014,9 +32667,7 @@ exports.createCodedErrors = createCodedErrors;
33014
32667
  exports.createDictionary = createDictionary;
33015
32668
  exports.createStyles = createStyles;
33016
32669
  exports.currencySymbol = currencySymbol;
33017
- exports.customsItemFactory = customsItemFactory;
33018
32670
  exports.daysAfter = daysAfter;
33019
- exports.downloadFactory = downloadFactory;
33020
32671
  exports.errorMap = errorMap;
33021
32672
  exports.euCountryCodes = euCountryCodes;
33022
32673
  exports.extendZod = extendZod;
@@ -33026,7 +32677,6 @@ exports.formatDate = formatDate;
33026
32677
  exports.formatExpiration = formatExpiration;
33027
32678
  exports.formatFractionalWeight = formatFractionalWeight;
33028
32679
  exports.formatMoney = formatMoney;
33029
- exports.fractionalWeightFactory = fractionalWeightFactory;
33030
32680
  exports.getAddFundsSchema = getAddFundsSchema;
33031
32681
  exports.getCustomsFromSalesOrder = getCustomsFromSalesOrder;
33032
32682
  exports.getExpirationYears = getExpirationYears;
@@ -33047,39 +32697,15 @@ exports.isPoBoxAddress = isPoBoxAddress;
33047
32697
  exports.isString = isString;
33048
32698
  exports.isUnitedStatesTerritory = isUnitedStatesTerritory;
33049
32699
  exports.isUspsCarrier = isUspsCarrier;
33050
- exports.labelFactory = labelFactory;
33051
- exports.linkedResourceFactory = linkedResourceFactory;
33052
- exports.moneyFactory = moneyFactory;
33053
32700
  exports.moneySchema = moneySchema;
33054
32701
  exports.mostRecent = mostRecent;
33055
32702
  exports.nextDayCutoff = nextDayCutoff;
33056
32703
  exports.omitTime = omitTime;
33057
- exports.orderSourceFactory = orderSourceFactory;
33058
- exports.orderSourceRefreshInfoFactory = orderSourceRefreshInfoFactory;
33059
- exports.packageFactory = packageFactory;
33060
32704
  exports.phoneSchema = phoneSchema;
33061
32705
  exports.phoneSchemaUnvalidated = phoneSchemaUnvalidated;
33062
32706
  exports.postalCodeRegex = postalCodeRegex$3;
33063
- exports.randomDeliveryConfirmation = randomDeliveryConfirmation;
33064
- exports.randomFulfillmentStatus = randomFulfillmentStatus;
33065
- exports.randomInsuranceProvider = randomInsuranceProvider;
33066
- exports.randomOrderSourceCode = randomOrderSourceCode;
33067
- exports.randomPaymentStatus = randomPaymentStatus;
33068
- exports.randomShipengineId = randomShipengineId;
33069
- exports.randomShipengineSlug = randomShipengineSlug;
33070
- exports.randomWeightUnit = randomWeightUnit;
33071
32707
  exports.registerElement = registerElement;
33072
- exports.renderWithAllProviders = renderWithAllProviders;
33073
- exports.renderWithProviders = renderWithProviders;
33074
- exports.salesOrderFactory = salesOrderFactory;
33075
- exports.salesOrderItemFactory = salesOrderItemFactory;
33076
- exports.salesOrderShipmentFactory = salesOrderShipmentFactory;
33077
- exports.serviceFactory = serviceFactory;
33078
- exports.shipmentFactory = shipmentFactory;
33079
- exports.shipmentItemFactory = shipmentItemFactory;
33080
- exports.shipmentPackageFactory = shipmentPackageFactory;
33081
32708
  exports.sortByCreationDate = sortByCreationDate;
33082
- exports.tristateValue = tristateValue;
33083
32709
  exports.usCities = usCities;
33084
32710
  exports.usStateCodes = usStateCodes;
33085
32711
  exports.usStates = usStates;
@@ -33102,7 +32728,5 @@ exports.useShippingPresetsOptions = useShippingPresetsOptions;
33102
32728
  exports.useStateCodeOptions = useStateCodeOptions;
33103
32729
  exports.useToggle = useToggle;
33104
32730
  exports.useWarehouseOptions = useWarehouseOptions;
32731
+ exports.useWarehouseValidation = useWarehouseValidation;
33105
32732
  exports.validationResolver = validationResolver;
33106
- exports.warehouseFactory = warehouseFactory;
33107
- exports.weightFactory = weightFactory;
33108
- exports.weightWithUnitFactory = weightWithUnitFactory;