@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/components/fund-and-purchase/fund-and-purchase.d.ts +3 -1
- package/components/templates/index.d.ts +2 -0
- package/components/templates/manage-warehouses/manage-warehouse.styles.d.ts +1 -0
- package/components/templates/manage-warehouses/manage-warehouses.d.ts +10 -5
- package/components/templates/onboarding/onboarding.d.ts +1 -0
- package/components/templates/shipment-form/shipment-schema.d.ts +2 -2
- package/components/templates/warehouse-form/warehouse-form-schema.d.ts +2 -102
- package/components/templates/warehouse-form/warehouse-form.d.ts +2 -1
- package/components/templates/warehouse-preference-select/index.d.ts +1 -0
- package/components/templates/warehouse-preference-select/warehouse-preference-select.d.ts +24 -0
- package/components/templates/warehouse-preference-wizard/index.d.ts +1 -0
- package/components/templates/warehouse-preference-wizard/warehouse-preference-wizard.d.ts +23 -0
- package/elements/components/manage-warehouses/manage-warehouses.d.ts +5 -2
- package/elements/manage-warehouses.d.ts +1 -1
- package/factories/shipengine/warehouse.d.ts +2 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/use-warehouse-validation.d.ts +14 -0
- package/index.cjs +788 -1164
- package/index.d.ts +0 -2
- package/index.js +790 -1132
- package/locales/en/index.d.ts +4 -0
- package/package.json +3 -3
- package/components/templates/warehouse-form/warehouse-form.styles.d.ts +0 -1
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useController, get as get$1, set as set$2, useWatch, useFormState, useF
|
|
|
3
3
|
import { useTranslation, Trans, initReactI18next, I18nextProvider } from 'react-i18next';
|
|
4
4
|
import { Typography, FormField, FieldMessageType, Input, Checkbox, Icon, Divider, Link, Select as Select$1, Next, Option, Button, Switch as Switch$1, Textarea, ButtonVariant, InlineNotification, NotificationType, ButtonColor, Grid, GridChild, Tag, TagColor, Skeleton, SkeletonAnimation, SkeletonVariant, SkeletonBackgroundColor, IconSize, Stepper, Step, Spinner, SpinnerSize, ChipList, Chip, ButtonSize, Table, TableBody, TableBaseRow, TableBodyCell, TableHeader, TableHeaderCell, useToggle as useToggle$1, Popover, DropdownOptionList, BottomSheet, GigerConfigProvider, EmotionReset, FontsLoader } from '@packlink/giger';
|
|
5
5
|
import axios from 'axios';
|
|
6
|
-
import { logger, ShipEngineProvider, useAddFunds, useGetCarrierById, useUpdateAutoFunding, useGetAutoFundingConfiguration, useListCarriers, useConnectCarrier, useListWarehouses, useUpdateWarehouse, useCreateWarehouse, useDeleteWarehouse,
|
|
6
|
+
import { logger, ShipEngineProvider, useValidateAddresses, useAddFunds, useGetCarrierById, useUpdateAutoFunding, useGetAutoFundingConfiguration, useListCarriers, useConnectCarrier, useListWarehouses, useUpdateWarehouse, useCreateWarehouse, useDeleteWarehouse, useUpdateSalesOrderShipment, useParseAddress, useListCustomPackageTypes, useCalculateRates, useCreateLabel, useListSalesOrderShipments, useCreateSalesOrderShipment, useGetAccountSettings, useListSalesOrders, useGetSalesOrder, useListOrderSources, useRefreshOrderSource, useGetShipment, useGetSalesOrderShipment, useListLabels, useGetLabel, useVoidLabel } from '@shipengine/react';
|
|
7
7
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import * as React from 'react';
|
|
@@ -18,13 +18,10 @@ import { createPortal } from 'react-dom';
|
|
|
18
18
|
import { isValidPhoneNumber } from 'libphonenumber-js/min';
|
|
19
19
|
import cardValidator from 'card-validator';
|
|
20
20
|
import { encode } from 'js-base64';
|
|
21
|
-
import {
|
|
21
|
+
import { useQueryClient } from 'react-query';
|
|
22
22
|
import { stringify, COMMENT, rulesheet, middleware, RULESET, combine, match as match$1, serialize, copy, replace as replace$4, WEBKIT as WEBKIT$1, MOZ, MS, KEYFRAMES, DECLARATION, compile, dealloc, alloc, hash, charat, strlen, indexof, next, token, from, peek, delimit, slice, position, prefixer as prefixer$1 } from 'stylis';
|
|
23
23
|
import i18n from 'i18next';
|
|
24
24
|
import languageDetector from 'i18next-browser-languagedetector';
|
|
25
|
-
import { faker } from '@faker-js/faker';
|
|
26
|
-
import { Factory } from 'fishery';
|
|
27
|
-
import { render } from '@testing-library/react';
|
|
28
25
|
|
|
29
26
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
30
27
|
|
|
@@ -1099,13 +1096,13 @@ var objectAssign = !$assign || fails$i(function () {
|
|
|
1099
1096
|
} return T;
|
|
1100
1097
|
} : $assign;
|
|
1101
1098
|
|
|
1102
|
-
var $$
|
|
1099
|
+
var $$m = _export;
|
|
1103
1100
|
var assign = objectAssign;
|
|
1104
1101
|
|
|
1105
1102
|
// `Object.assign` method
|
|
1106
1103
|
// https://tc39.es/ecma262/#sec-object.assign
|
|
1107
1104
|
// eslint-disable-next-line es/no-object-assign -- required for testing
|
|
1108
|
-
$$
|
|
1105
|
+
$$m({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
|
|
1109
1106
|
assign: assign
|
|
1110
1107
|
});
|
|
1111
1108
|
|
|
@@ -1204,7 +1201,7 @@ var global$f = global$p;
|
|
|
1204
1201
|
|
|
1205
1202
|
var engineIsNode = classof$7(global$f.process) == 'process';
|
|
1206
1203
|
|
|
1207
|
-
var $$
|
|
1204
|
+
var $$l = _export;
|
|
1208
1205
|
var $reduce = arrayReduce.left;
|
|
1209
1206
|
var arrayMethodIsStrict$1 = arrayMethodIsStrict$2;
|
|
1210
1207
|
var CHROME_VERSION = engineV8Version;
|
|
@@ -1217,7 +1214,7 @@ var CHROME_BUG = !IS_NODE$4 && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
|
|
1217
1214
|
|
|
1218
1215
|
// `Array.prototype.reduce` method
|
|
1219
1216
|
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
1220
|
-
$$
|
|
1217
|
+
$$l({ target: 'Array', proto: true, forced: !STRICT_METHOD$1 || CHROME_BUG }, {
|
|
1221
1218
|
reduce: function reduce(callbackfn /* , initialValue */) {
|
|
1222
1219
|
var length = arguments.length;
|
|
1223
1220
|
return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
|
|
@@ -1512,7 +1509,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
|
|
|
1512
1509
|
};
|
|
1513
1510
|
}() : undefined);
|
|
1514
1511
|
|
|
1515
|
-
var $$
|
|
1512
|
+
var $$k = _export;
|
|
1516
1513
|
var call$d = functionCall;
|
|
1517
1514
|
var FunctionName = functionName;
|
|
1518
1515
|
var isCallable$a = isCallable$o;
|
|
@@ -1597,7 +1594,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
|
|
|
1597
1594
|
if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
|
|
1598
1595
|
defineBuiltIn$5(IterablePrototype, KEY, methods[KEY]);
|
|
1599
1596
|
}
|
|
1600
|
-
} else $$
|
|
1597
|
+
} else $$k({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
|
|
1601
1598
|
}
|
|
1602
1599
|
|
|
1603
1600
|
// define iterator
|
|
@@ -1965,13 +1962,13 @@ var stringTrimForced = function (METHOD_NAME) {
|
|
|
1965
1962
|
});
|
|
1966
1963
|
};
|
|
1967
1964
|
|
|
1968
|
-
var $$
|
|
1965
|
+
var $$j = _export;
|
|
1969
1966
|
var $trim = stringTrim.trim;
|
|
1970
1967
|
var forcedStringTrimMethod = stringTrimForced;
|
|
1971
1968
|
|
|
1972
1969
|
// `String.prototype.trim` method
|
|
1973
1970
|
// https://tc39.es/ecma262/#sec-string.prototype.trim
|
|
1974
|
-
$$
|
|
1971
|
+
$$j({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
|
|
1975
1972
|
trim: function trim() {
|
|
1976
1973
|
return $trim(this);
|
|
1977
1974
|
}
|
|
@@ -2166,12 +2163,12 @@ if (PATCH) {
|
|
|
2166
2163
|
|
|
2167
2164
|
var regexpExec$2 = patchedExec;
|
|
2168
2165
|
|
|
2169
|
-
var $$
|
|
2166
|
+
var $$i = _export;
|
|
2170
2167
|
var exec$2 = regexpExec$2;
|
|
2171
2168
|
|
|
2172
2169
|
// `RegExp.prototype.exec` method
|
|
2173
2170
|
// https://tc39.es/ecma262/#sec-regexp.prototype.exec
|
|
2174
|
-
$$
|
|
2171
|
+
$$i({ target: 'RegExp', proto: true, forced: /./.exec !== exec$2 }, {
|
|
2175
2172
|
exec: exec$2
|
|
2176
2173
|
});
|
|
2177
2174
|
|
|
@@ -2785,7 +2782,7 @@ const isPoBox = addressLine => PO_BOX_REGEX.test(addressLine);
|
|
|
2785
2782
|
*/
|
|
2786
2783
|
const isPoBoxAddress = address => !!(isPoBox(address.addressLine1) || address.addressLine2 && isPoBox(address.addressLine2));
|
|
2787
2784
|
|
|
2788
|
-
var $$
|
|
2785
|
+
var $$h = _export;
|
|
2789
2786
|
var $includes = arrayIncludes.includes;
|
|
2790
2787
|
var fails$8 = fails$r;
|
|
2791
2788
|
var addToUnscopables$2 = addToUnscopables$4;
|
|
@@ -2797,7 +2794,7 @@ var BROKEN_ON_SPARSE = fails$8(function () {
|
|
|
2797
2794
|
|
|
2798
2795
|
// `Array.prototype.includes` method
|
|
2799
2796
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
2800
|
-
$$
|
|
2797
|
+
$$h({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
2801
2798
|
includes: function includes(el /* , fromIndex = 0 */) {
|
|
2802
2799
|
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
2803
2800
|
}
|
|
@@ -2882,7 +2879,7 @@ var toPropertyKey = toPropertyKey$3;
|
|
|
2882
2879
|
var definePropertyModule$1 = objectDefineProperty;
|
|
2883
2880
|
var createPropertyDescriptor = createPropertyDescriptor$4;
|
|
2884
2881
|
|
|
2885
|
-
var createProperty$
|
|
2882
|
+
var createProperty$2 = function (object, key, value) {
|
|
2886
2883
|
var propertyKey = toPropertyKey(key);
|
|
2887
2884
|
if (propertyKey in object) definePropertyModule$1.f(object, propertyKey, createPropertyDescriptor(0, value));
|
|
2888
2885
|
else object[propertyKey] = value;
|
|
@@ -2890,7 +2887,7 @@ var createProperty$1 = function (object, key, value) {
|
|
|
2890
2887
|
|
|
2891
2888
|
var toAbsoluteIndex = toAbsoluteIndex$2;
|
|
2892
2889
|
var lengthOfArrayLike$5 = lengthOfArrayLike$8;
|
|
2893
|
-
var createProperty = createProperty$
|
|
2890
|
+
var createProperty$1 = createProperty$2;
|
|
2894
2891
|
|
|
2895
2892
|
var $Array$1 = Array;
|
|
2896
2893
|
var max = Math.max;
|
|
@@ -2900,7 +2897,7 @@ var arraySliceSimple = function (O, start, end) {
|
|
|
2900
2897
|
var k = toAbsoluteIndex(start, length);
|
|
2901
2898
|
var fin = toAbsoluteIndex(end === undefined ? length : end, length);
|
|
2902
2899
|
var result = $Array$1(max(fin - k, 0));
|
|
2903
|
-
for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
|
|
2900
|
+
for (var n = 0; k < fin; k++, n++) createProperty$1(result, n, O[k]);
|
|
2904
2901
|
result.length = n;
|
|
2905
2902
|
return result;
|
|
2906
2903
|
};
|
|
@@ -2966,7 +2963,7 @@ var webkit = userAgent$3.match(/AppleWebKit\/(\d+)\./);
|
|
|
2966
2963
|
|
|
2967
2964
|
var engineWebkitVersion = !!webkit && +webkit[1];
|
|
2968
2965
|
|
|
2969
|
-
var $$
|
|
2966
|
+
var $$g = _export;
|
|
2970
2967
|
var uncurryThis$a = functionUncurryThis;
|
|
2971
2968
|
var aCallable$7 = aCallable$a;
|
|
2972
2969
|
var toObject$2 = toObject$8;
|
|
@@ -3044,7 +3041,7 @@ var getSortCompare = function (comparefn) {
|
|
|
3044
3041
|
|
|
3045
3042
|
// `Array.prototype.sort` method
|
|
3046
3043
|
// https://tc39.es/ecma262/#sec-array.prototype.sort
|
|
3047
|
-
$$
|
|
3044
|
+
$$g({ target: 'Array', proto: true, forced: FORCED$3 }, {
|
|
3048
3045
|
sort: function sort(comparefn) {
|
|
3049
3046
|
if (comparefn !== undefined) aCallable$7(comparefn);
|
|
3050
3047
|
|
|
@@ -3159,7 +3156,7 @@ var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
|
3159
3156
|
} return false;
|
|
3160
3157
|
};
|
|
3161
3158
|
|
|
3162
|
-
var $$
|
|
3159
|
+
var $$f = _export;
|
|
3163
3160
|
var uncurryThis$9 = functionUncurryThis;
|
|
3164
3161
|
var notARegExp$1 = notARegexp;
|
|
3165
3162
|
var requireObjectCoercible$3 = requireObjectCoercible$9;
|
|
@@ -3170,7 +3167,7 @@ var stringIndexOf = uncurryThis$9(''.indexOf);
|
|
|
3170
3167
|
|
|
3171
3168
|
// `String.prototype.includes` method
|
|
3172
3169
|
// https://tc39.es/ecma262/#sec-string.prototype.includes
|
|
3173
|
-
$$
|
|
3170
|
+
$$f({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, {
|
|
3174
3171
|
includes: function includes(searchString /* , position = 0 */) {
|
|
3175
3172
|
return !!~stringIndexOf(
|
|
3176
3173
|
toString$6(requireObjectCoercible$3(this)),
|
|
@@ -3777,7 +3774,7 @@ var arraySpeciesCreate$2 = function (originalArray, length) {
|
|
|
3777
3774
|
return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
|
|
3778
3775
|
};
|
|
3779
3776
|
|
|
3780
|
-
var $$
|
|
3777
|
+
var $$e = _export;
|
|
3781
3778
|
var flattenIntoArray$1 = flattenIntoArray_1;
|
|
3782
3779
|
var aCallable$5 = aCallable$a;
|
|
3783
3780
|
var toObject$1 = toObject$8;
|
|
@@ -3786,7 +3783,7 @@ var arraySpeciesCreate$1 = arraySpeciesCreate$2;
|
|
|
3786
3783
|
|
|
3787
3784
|
// `Array.prototype.flatMap` method
|
|
3788
3785
|
// https://tc39.es/ecma262/#sec-array.prototype.flatmap
|
|
3789
|
-
$$
|
|
3786
|
+
$$e({ target: 'Array', proto: true }, {
|
|
3790
3787
|
flatMap: function flatMap(callbackfn /* , thisArg */) {
|
|
3791
3788
|
var O = toObject$1(this);
|
|
3792
3789
|
var sourceLen = lengthOfArrayLike$2(O);
|
|
@@ -3946,7 +3943,7 @@ var stringRepeat = function repeat(count) {
|
|
|
3946
3943
|
return result;
|
|
3947
3944
|
};
|
|
3948
3945
|
|
|
3949
|
-
var $$
|
|
3946
|
+
var $$d = _export;
|
|
3950
3947
|
var uncurryThis$5 = functionUncurryThis;
|
|
3951
3948
|
var toIntegerOrInfinity$1 = toIntegerOrInfinity$7;
|
|
3952
3949
|
var thisNumberValue = thisNumberValue$1;
|
|
@@ -4020,7 +4017,7 @@ var FORCED$2 = fails$5(function () {
|
|
|
4020
4017
|
|
|
4021
4018
|
// `Number.prototype.toFixed` method
|
|
4022
4019
|
// https://tc39.es/ecma262/#sec-number.prototype.tofixed
|
|
4023
|
-
$$
|
|
4020
|
+
$$d({ target: 'Number', proto: true, forced: FORCED$2 }, {
|
|
4024
4021
|
toFixed: function toFixed(fractionDigits) {
|
|
4025
4022
|
var number = thisNumberValue(this);
|
|
4026
4023
|
var fractDigits = toIntegerOrInfinity$1(fractionDigits);
|
|
@@ -4100,12 +4097,12 @@ var numberParseFloat = FORCED$1 ? function parseFloat(string) {
|
|
|
4100
4097
|
return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
|
|
4101
4098
|
} : $parseFloat$1;
|
|
4102
4099
|
|
|
4103
|
-
var $$
|
|
4100
|
+
var $$c = _export;
|
|
4104
4101
|
var $parseFloat = numberParseFloat;
|
|
4105
4102
|
|
|
4106
4103
|
// `parseFloat` method
|
|
4107
4104
|
// https://tc39.es/ecma262/#sec-parsefloat-string
|
|
4108
|
-
$$
|
|
4105
|
+
$$c({ global: true, forced: parseFloat != $parseFloat }, {
|
|
4109
4106
|
parseFloat: $parseFloat
|
|
4110
4107
|
});
|
|
4111
4108
|
|
|
@@ -4260,12 +4257,12 @@ var numberParseInt = FORCED ? function parseInt(string, radix) {
|
|
|
4260
4257
|
return $parseInt$1(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
|
|
4261
4258
|
} : $parseInt$1;
|
|
4262
4259
|
|
|
4263
|
-
var $$
|
|
4260
|
+
var $$b = _export;
|
|
4264
4261
|
var $parseInt = numberParseInt;
|
|
4265
4262
|
|
|
4266
4263
|
// `parseInt` method
|
|
4267
4264
|
// https://tc39.es/ecma262/#sec-parseint-string-radix
|
|
4268
|
-
$$
|
|
4265
|
+
$$b({ global: true, forced: parseInt != $parseInt }, {
|
|
4269
4266
|
parseInt: $parseInt
|
|
4270
4267
|
});
|
|
4271
4268
|
|
|
@@ -22777,6 +22774,240 @@ const useRunOnceOnTrue = conditionalEffect => {
|
|
|
22777
22774
|
*/
|
|
22778
22775
|
const useToggle = (initialValue = false) => useReducer((prev, next) => next !== undefined && typeof next !== "object" ? next : !prev, initialValue);
|
|
22779
22776
|
|
|
22777
|
+
var wellKnownSymbol$5 = wellKnownSymbol$j;
|
|
22778
|
+
var Iterators$1 = iterators;
|
|
22779
|
+
|
|
22780
|
+
var ITERATOR$2 = wellKnownSymbol$5('iterator');
|
|
22781
|
+
var ArrayPrototype = Array.prototype;
|
|
22782
|
+
|
|
22783
|
+
// check on default Array iterator
|
|
22784
|
+
var isArrayIteratorMethod$1 = function (it) {
|
|
22785
|
+
return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$2] === it);
|
|
22786
|
+
};
|
|
22787
|
+
|
|
22788
|
+
var classof = classof$6;
|
|
22789
|
+
var getMethod$2 = getMethod$5;
|
|
22790
|
+
var isNullOrUndefined$2 = isNullOrUndefined$6;
|
|
22791
|
+
var Iterators = iterators;
|
|
22792
|
+
var wellKnownSymbol$4 = wellKnownSymbol$j;
|
|
22793
|
+
|
|
22794
|
+
var ITERATOR$1 = wellKnownSymbol$4('iterator');
|
|
22795
|
+
|
|
22796
|
+
var getIteratorMethod$2 = function (it) {
|
|
22797
|
+
if (!isNullOrUndefined$2(it)) return getMethod$2(it, ITERATOR$1)
|
|
22798
|
+
|| getMethod$2(it, '@@iterator')
|
|
22799
|
+
|| Iterators[classof(it)];
|
|
22800
|
+
};
|
|
22801
|
+
|
|
22802
|
+
var call$7 = functionCall;
|
|
22803
|
+
var aCallable$4 = aCallable$a;
|
|
22804
|
+
var anObject$5 = anObject$f;
|
|
22805
|
+
var tryToString$2 = tryToString$5;
|
|
22806
|
+
var getIteratorMethod$1 = getIteratorMethod$2;
|
|
22807
|
+
|
|
22808
|
+
var $TypeError$5 = TypeError;
|
|
22809
|
+
|
|
22810
|
+
var getIterator$1 = function (argument, usingIterator) {
|
|
22811
|
+
var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
|
|
22812
|
+
if (aCallable$4(iteratorMethod)) return anObject$5(call$7(iteratorMethod, argument));
|
|
22813
|
+
throw $TypeError$5(tryToString$2(argument) + ' is not iterable');
|
|
22814
|
+
};
|
|
22815
|
+
|
|
22816
|
+
var call$6 = functionCall;
|
|
22817
|
+
var anObject$4 = anObject$f;
|
|
22818
|
+
var getMethod$1 = getMethod$5;
|
|
22819
|
+
|
|
22820
|
+
var iteratorClose$1 = function (iterator, kind, value) {
|
|
22821
|
+
var innerResult, innerError;
|
|
22822
|
+
anObject$4(iterator);
|
|
22823
|
+
try {
|
|
22824
|
+
innerResult = getMethod$1(iterator, 'return');
|
|
22825
|
+
if (!innerResult) {
|
|
22826
|
+
if (kind === 'throw') throw value;
|
|
22827
|
+
return value;
|
|
22828
|
+
}
|
|
22829
|
+
innerResult = call$6(innerResult, iterator);
|
|
22830
|
+
} catch (error) {
|
|
22831
|
+
innerError = true;
|
|
22832
|
+
innerResult = error;
|
|
22833
|
+
}
|
|
22834
|
+
if (kind === 'throw') throw value;
|
|
22835
|
+
if (innerError) throw innerResult;
|
|
22836
|
+
anObject$4(innerResult);
|
|
22837
|
+
return value;
|
|
22838
|
+
};
|
|
22839
|
+
|
|
22840
|
+
var bind$3 = functionBindContext;
|
|
22841
|
+
var call$5 = functionCall;
|
|
22842
|
+
var anObject$3 = anObject$f;
|
|
22843
|
+
var tryToString$1 = tryToString$5;
|
|
22844
|
+
var isArrayIteratorMethod = isArrayIteratorMethod$1;
|
|
22845
|
+
var lengthOfArrayLike$1 = lengthOfArrayLike$8;
|
|
22846
|
+
var isPrototypeOf$2 = objectIsPrototypeOf;
|
|
22847
|
+
var getIterator = getIterator$1;
|
|
22848
|
+
var getIteratorMethod = getIteratorMethod$2;
|
|
22849
|
+
var iteratorClose = iteratorClose$1;
|
|
22850
|
+
|
|
22851
|
+
var $TypeError$4 = TypeError;
|
|
22852
|
+
|
|
22853
|
+
var Result = function (stopped, result) {
|
|
22854
|
+
this.stopped = stopped;
|
|
22855
|
+
this.result = result;
|
|
22856
|
+
};
|
|
22857
|
+
|
|
22858
|
+
var ResultPrototype = Result.prototype;
|
|
22859
|
+
|
|
22860
|
+
var iterate$3 = function (iterable, unboundFunction, options) {
|
|
22861
|
+
var that = options && options.that;
|
|
22862
|
+
var AS_ENTRIES = !!(options && options.AS_ENTRIES);
|
|
22863
|
+
var IS_RECORD = !!(options && options.IS_RECORD);
|
|
22864
|
+
var IS_ITERATOR = !!(options && options.IS_ITERATOR);
|
|
22865
|
+
var INTERRUPTED = !!(options && options.INTERRUPTED);
|
|
22866
|
+
var fn = bind$3(unboundFunction, that);
|
|
22867
|
+
var iterator, iterFn, index, length, result, next, step;
|
|
22868
|
+
|
|
22869
|
+
var stop = function (condition) {
|
|
22870
|
+
if (iterator) iteratorClose(iterator, 'normal', condition);
|
|
22871
|
+
return new Result(true, condition);
|
|
22872
|
+
};
|
|
22873
|
+
|
|
22874
|
+
var callFn = function (value) {
|
|
22875
|
+
if (AS_ENTRIES) {
|
|
22876
|
+
anObject$3(value);
|
|
22877
|
+
return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
|
|
22878
|
+
} return INTERRUPTED ? fn(value, stop) : fn(value);
|
|
22879
|
+
};
|
|
22880
|
+
|
|
22881
|
+
if (IS_RECORD) {
|
|
22882
|
+
iterator = iterable.iterator;
|
|
22883
|
+
} else if (IS_ITERATOR) {
|
|
22884
|
+
iterator = iterable;
|
|
22885
|
+
} else {
|
|
22886
|
+
iterFn = getIteratorMethod(iterable);
|
|
22887
|
+
if (!iterFn) throw $TypeError$4(tryToString$1(iterable) + ' is not iterable');
|
|
22888
|
+
// optimisation for array iterators
|
|
22889
|
+
if (isArrayIteratorMethod(iterFn)) {
|
|
22890
|
+
for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
|
|
22891
|
+
result = callFn(iterable[index]);
|
|
22892
|
+
if (result && isPrototypeOf$2(ResultPrototype, result)) return result;
|
|
22893
|
+
} return new Result(false);
|
|
22894
|
+
}
|
|
22895
|
+
iterator = getIterator(iterable, iterFn);
|
|
22896
|
+
}
|
|
22897
|
+
|
|
22898
|
+
next = IS_RECORD ? iterable.next : iterator.next;
|
|
22899
|
+
while (!(step = call$5(next, iterator)).done) {
|
|
22900
|
+
try {
|
|
22901
|
+
result = callFn(step.value);
|
|
22902
|
+
} catch (error) {
|
|
22903
|
+
iteratorClose(iterator, 'throw', error);
|
|
22904
|
+
}
|
|
22905
|
+
if (typeof result == 'object' && result && isPrototypeOf$2(ResultPrototype, result)) return result;
|
|
22906
|
+
} return new Result(false);
|
|
22907
|
+
};
|
|
22908
|
+
|
|
22909
|
+
var $$a = _export;
|
|
22910
|
+
var iterate$2 = iterate$3;
|
|
22911
|
+
var createProperty = createProperty$2;
|
|
22912
|
+
|
|
22913
|
+
// `Object.fromEntries` method
|
|
22914
|
+
// https://github.com/tc39/proposal-object-from-entries
|
|
22915
|
+
$$a({ target: 'Object', stat: true }, {
|
|
22916
|
+
fromEntries: function fromEntries(iterable) {
|
|
22917
|
+
var obj = {};
|
|
22918
|
+
iterate$2(iterable, function (k, v) {
|
|
22919
|
+
createProperty(obj, k, v);
|
|
22920
|
+
}, { AS_ENTRIES: true });
|
|
22921
|
+
return obj;
|
|
22922
|
+
}
|
|
22923
|
+
});
|
|
22924
|
+
|
|
22925
|
+
const useWarehouseValidation = () => {
|
|
22926
|
+
const [warehousePreference, setWarehousePreference] = useState();
|
|
22927
|
+
const {
|
|
22928
|
+
error: validateAddressErrors,
|
|
22929
|
+
mutateAsync: validateAddresses
|
|
22930
|
+
} = useValidateAddresses();
|
|
22931
|
+
const caseInsensitiveCompare = useCallback((matched, original) => {
|
|
22932
|
+
if (matched === undefined || original === undefined) return false;
|
|
22933
|
+
const originalAddress = Object.fromEntries(Object.entries(original).map(([key, value]) => [key, typeof value == "string" ? value.toLowerCase() : value]));
|
|
22934
|
+
const matchedAddress = Object.fromEntries(Object.entries(matched).map(([key, value]) => [key, typeof value == "string" ? value.toLowerCase() : value]));
|
|
22935
|
+
// SE api returns addressLine2 as an empty string if it is not provided
|
|
22936
|
+
if (matchedAddress.addressLine2 === "") {
|
|
22937
|
+
matchedAddress.addressLine2 = null;
|
|
22938
|
+
}
|
|
22939
|
+
if (_$2.isEqual(_$2.omit(matchedAddress, ["postalCode", "addressResidentialIndicator"]), _$2.omit(originalAddress, ["postalCode", "addressResidentialIndicator"]))) return true;else return false;
|
|
22940
|
+
}, []);
|
|
22941
|
+
const postalCodeCompare = useCallback((matched, original) => {
|
|
22942
|
+
if (matched === undefined || original === undefined) return false;
|
|
22943
|
+
if (matched === original) return true;
|
|
22944
|
+
return matched.includes(original);
|
|
22945
|
+
}, []);
|
|
22946
|
+
const buildWarehousePreference = useCallback(addressValidation => {
|
|
22947
|
+
/**
|
|
22948
|
+
* Address validation matching criteria
|
|
22949
|
+
* 1. Case-insensitive string comparison
|
|
22950
|
+
* 2. Zip Code only added 4 extra digits to the original Zip Code
|
|
22951
|
+
*/
|
|
22952
|
+
var _a;
|
|
22953
|
+
if (addressValidation.status === "error") {
|
|
22954
|
+
return {
|
|
22955
|
+
validation: addressValidation,
|
|
22956
|
+
validationType: "ERROR"
|
|
22957
|
+
};
|
|
22958
|
+
}
|
|
22959
|
+
// Valid if the matched address and input address were EXACTLY the same
|
|
22960
|
+
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) {
|
|
22961
|
+
return {
|
|
22962
|
+
address: addressValidation.originalAddress,
|
|
22963
|
+
validationType: "EXACT"
|
|
22964
|
+
};
|
|
22965
|
+
}
|
|
22966
|
+
// Valid if the matched address passes matching criteria but are not exactly the same address
|
|
22967
|
+
if (addressValidation.matchedAddress && caseInsensitiveCompare(addressValidation.matchedAddress, addressValidation.originalAddress) && postalCodeCompare((_a = addressValidation.matchedAddress) === null || _a === void 0 ? void 0 : _a.postalCode, addressValidation.originalAddress.postalCode)) {
|
|
22968
|
+
return {
|
|
22969
|
+
address: addressValidation.matchedAddress,
|
|
22970
|
+
validationType: "SOFT"
|
|
22971
|
+
};
|
|
22972
|
+
}
|
|
22973
|
+
// If there is a matched address and does not pass the matching criteria
|
|
22974
|
+
if (addressValidation.matchedAddress) {
|
|
22975
|
+
return {
|
|
22976
|
+
validation: addressValidation,
|
|
22977
|
+
validationType: "SUGGESTED"
|
|
22978
|
+
};
|
|
22979
|
+
}
|
|
22980
|
+
// error or address was not valiqated
|
|
22981
|
+
return {
|
|
22982
|
+
validation: addressValidation,
|
|
22983
|
+
validationType: "ERROR"
|
|
22984
|
+
};
|
|
22985
|
+
}, [caseInsensitiveCompare, postalCodeCompare]);
|
|
22986
|
+
const validate = useCallback(warehouse => __awaiter(void 0, void 0, void 0, function* () {
|
|
22987
|
+
const warehouseAddresses = [warehouse.originAddress, ...(warehouse.returnAddress ? [warehouse.returnAddress] : [])];
|
|
22988
|
+
const result = yield validateAddresses(warehouseAddresses);
|
|
22989
|
+
const [originAddress, returnAddress] = result;
|
|
22990
|
+
setWarehousePreference({
|
|
22991
|
+
isDefault: warehouse.isDefault,
|
|
22992
|
+
name: warehouse.name,
|
|
22993
|
+
originAddress: buildWarehousePreference(originAddress),
|
|
22994
|
+
returnAddress: returnAddress && buildWarehousePreference(returnAddress)
|
|
22995
|
+
});
|
|
22996
|
+
return {
|
|
22997
|
+
isDefault: warehouse.isDefault,
|
|
22998
|
+
name: warehouse.name,
|
|
22999
|
+
originAddress: buildWarehousePreference(originAddress),
|
|
23000
|
+
returnAddress: returnAddress && buildWarehousePreference(returnAddress)
|
|
23001
|
+
};
|
|
23002
|
+
}), [buildWarehousePreference, validateAddresses]);
|
|
23003
|
+
return {
|
|
23004
|
+
errors: validateAddressErrors,
|
|
23005
|
+
setWarehousePreference,
|
|
23006
|
+
validate,
|
|
23007
|
+
warehousePreference
|
|
23008
|
+
};
|
|
23009
|
+
};
|
|
23010
|
+
|
|
22780
23011
|
const addressParserSchema = z.object({
|
|
22781
23012
|
fullAddress: z.string().min(1)
|
|
22782
23013
|
});
|
|
@@ -23006,14 +23237,14 @@ const extendZod = () => {
|
|
|
23006
23237
|
z.ZodObject.prototype.nullishDefault = nullishDefault;
|
|
23007
23238
|
};
|
|
23008
23239
|
|
|
23009
|
-
var call$
|
|
23240
|
+
var call$4 = functionCall;
|
|
23010
23241
|
var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
|
|
23011
|
-
var anObject$
|
|
23012
|
-
var isNullOrUndefined$
|
|
23242
|
+
var anObject$2 = anObject$f;
|
|
23243
|
+
var isNullOrUndefined$1 = isNullOrUndefined$6;
|
|
23013
23244
|
var toLength$1 = toLength$4;
|
|
23014
23245
|
var toString$2 = toString$c;
|
|
23015
23246
|
var requireObjectCoercible$1 = requireObjectCoercible$9;
|
|
23016
|
-
var getMethod
|
|
23247
|
+
var getMethod = getMethod$5;
|
|
23017
23248
|
var advanceStringIndex = advanceStringIndex$2;
|
|
23018
23249
|
var regExpExec = regexpExecAbstract;
|
|
23019
23250
|
|
|
@@ -23024,13 +23255,13 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
|
|
|
23024
23255
|
// https://tc39.es/ecma262/#sec-string.prototype.match
|
|
23025
23256
|
function match(regexp) {
|
|
23026
23257
|
var O = requireObjectCoercible$1(this);
|
|
23027
|
-
var matcher = isNullOrUndefined$
|
|
23028
|
-
return matcher ? call$
|
|
23258
|
+
var matcher = isNullOrUndefined$1(regexp) ? undefined : getMethod(regexp, MATCH);
|
|
23259
|
+
return matcher ? call$4(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$2(O));
|
|
23029
23260
|
},
|
|
23030
23261
|
// `RegExp.prototype[@@match]` method
|
|
23031
23262
|
// https://tc39.es/ecma262/#sec-regexp.prototype-@@match
|
|
23032
23263
|
function (string) {
|
|
23033
|
-
var rx = anObject$
|
|
23264
|
+
var rx = anObject$2(this);
|
|
23034
23265
|
var S = toString$2(string);
|
|
23035
23266
|
var res = maybeCallNative(nativeMatch, rx, S);
|
|
23036
23267
|
|
|
@@ -23965,7 +24196,7 @@ var global$8 = global$p;
|
|
|
23965
24196
|
var uncurryThis$2 = functionUncurryThis;
|
|
23966
24197
|
var hasOwn$1 = hasOwnProperty_1;
|
|
23967
24198
|
var isCallable$5 = isCallable$o;
|
|
23968
|
-
var isPrototypeOf$
|
|
24199
|
+
var isPrototypeOf$1 = objectIsPrototypeOf;
|
|
23969
24200
|
var toString$1 = toString$c;
|
|
23970
24201
|
var defineProperty = objectDefineProperty.f;
|
|
23971
24202
|
var copyConstructorProperties = copyConstructorProperties$2;
|
|
@@ -23981,7 +24212,7 @@ if (DESCRIPTORS$1 && isCallable$5(NativeSymbol) && (!('description' in SymbolPro
|
|
|
23981
24212
|
// wrap Symbol constructor for correct work with undefined description
|
|
23982
24213
|
var SymbolWrapper = function Symbol() {
|
|
23983
24214
|
var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString$1(arguments[0]);
|
|
23984
|
-
var result = isPrototypeOf$
|
|
24215
|
+
var result = isPrototypeOf$1(SymbolPrototype, this)
|
|
23985
24216
|
? new NativeSymbol(description)
|
|
23986
24217
|
// in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
|
|
23987
24218
|
: description === undefined ? NativeSymbol() : NativeSymbol(description);
|
|
@@ -24461,6 +24692,7 @@ const getStyles$4 = (isConnected = false) => createStyles({
|
|
|
24461
24692
|
padding: `0 ${theme.spacing(.5)}px`
|
|
24462
24693
|
}, isConnected && {
|
|
24463
24694
|
backgroundColor: theme.palette.success.main,
|
|
24695
|
+
borderRadius: theme.borderRadius.XS,
|
|
24464
24696
|
color: theme.palette.white
|
|
24465
24697
|
}],
|
|
24466
24698
|
container: {
|
|
@@ -24487,7 +24719,7 @@ var _ref$1 = process.env.NODE_ENV === "production" ? {
|
|
|
24487
24719
|
} : {
|
|
24488
24720
|
name: "111ty02-css",
|
|
24489
24721
|
styles: "align-items:center;display:flex;label:css;",
|
|
24490
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
24722
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpc3QtY2FycmllcnMtcm93LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFtQmllIiwiZmlsZSI6Imxpc3QtY2FycmllcnMtcm93LnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IF9fYXdhaXRlciB9IGZyb20gXCJ0c2xpYlwiO1xyXG5pbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJAZW1vdGlvbi9yZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgeyBjc3MgfSBmcm9tIFwiQGVtb3Rpb24vcmVhY3RcIjtcclxuaW1wb3J0IHsgdXNlU3RhdGUgfSBmcm9tIFwicmVhY3RcIjtcclxuaW1wb3J0IHsgdXNlVHJhbnNsYXRpb24gfSBmcm9tIFwicmVhY3QtaTE4bmV4dFwiO1xyXG5pbXBvcnQgeyBUeXBvZ3JhcGh5IH0gZnJvbSBcIkBwYWNrbGluay9naWdlclwiO1xyXG5pbXBvcnQgeyBMaW5rQWN0aW9uLCBUZW1wbGF0ZXMgfSBmcm9tIFwiLi4vLi4vLi4vY29tcG9uZW50c1wiO1xyXG5pbXBvcnQgeyBnZXRTdHlsZXMgfSBmcm9tIFwiLi9saXN0LWNhcnJpZXJzLXJvdy5zdHlsZXNcIjtcclxuZXhwb3J0IGNvbnN0IExpc3RDYXJyaWVyc1JvdyA9ICh7IGNvbm5lY3RlZENhcnJpZXI6IHsgY2FycmllciwgaXNDb25uZWN0ZWQgfSwgcmVnaXN0ZXJDYXJyaWVyLCByZWdpc3RlckNhcnJpZXJFcnJvcnMsIH0pID0+IHtcclxuICAgIGNvbnN0IHsgc2hvcnRuYW1lOiBuYW1lLCBsb2dvLCByZXF1aXJlZEZpZWxkcyB9ID0gY2FycmllcjtcclxuICAgIGNvbnN0IHsgdCB9ID0gdXNlVHJhbnNsYXRpb24oW1wibGlzdC1jYXJyaWVyc1wiXSk7XHJcbiAgICBjb25zdCBbc2hvd0Ryb3BEb3duLCBzZXRTaG93RHJvcERvd25dID0gdXNlU3RhdGUoZmFsc2UpO1xyXG4gICAgY29uc3QgW2lzU3VibWl0dGluZywgc2V0SXNTdWJtaXR0aW5nXSA9IHVzZVN0YXRlKGZhbHNlKTtcclxuICAgIGNvbnN0IGhhbmRsZVJlZ2lzdGVyID0gKHZhbHVlcykgPT4gX19hd2FpdGVyKHZvaWQgMCwgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uKiAoKSB7XHJcbiAgICAgICAgc2V0SXNTdWJtaXR0aW5nKHRydWUpO1xyXG4gICAgICAgIHlpZWxkIHJlZ2lzdGVyQ2Fycmllcih2YWx1ZXMpO1xyXG4gICAgICAgIHNob3dEcm9wRG93biAmJiBzZXRTaG93RHJvcERvd24oZmFsc2UpO1xyXG4gICAgICAgIHNldElzU3VibWl0dGluZyhmYWxzZSk7XHJcbiAgICB9KTtcclxuICAgIHJldHVybiAoX2pzeHMoXCJkaXZcIiwgT2JqZWN0LmFzc2lnbih7IGNzczogZ2V0U3R5bGVzKCkuY29udGFpbmVyLCBcImRhdGEtdGVzdGlkXCI6IFwiY2Fycmllci1yb3dcIiB9LCB7IGNoaWxkcmVuOiBbX2pzeHMoXCJkaXZcIiwgT2JqZWN0LmFzc2lnbih7IGNzczogZ2V0U3R5bGVzKCkucm93Q29udGFpbmVyIH0sIHsgY2hpbGRyZW46IFtfanN4cyhcImRpdlwiLCBPYmplY3QuYXNzaWduKHsgY3NzOiBnZXRTdHlsZXMoKS5sb2dvQ29udGFpbmVyIH0sIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2hpbGRyZW46IF9qc3goXCJpbWdcIiwgeyBhbHQ6IGAke25hbWV9LWxvZ29gLCBoZWlnaHQ6IDQwLCBzcmM6IGxvZ28sIHdpZHRoOiA0MCB9KSB9KSwgX2pzeChUeXBvZ3JhcGh5LCBPYmplY3QuYXNzaWduKHsgdmFyaWFudDogXCJzdWJ0aXRsZTFcIiB9LCB7IGNoaWxkcmVuOiBuYW1lIH0pKV0gfSkpLCBfanN4KFwiZGl2XCIsIE9iamVjdC5hc3NpZ24oeyBjc3M6IGNzcyh7IGFsaWduSXRlbXM6IFwiY2VudGVyXCIsIGRpc3BsYXk6IFwiZmxleFwiIH0pIH0sIHsgY2hpbGRyZW46IF9qc3goTGlua0FjdGlvbiwgeyBjc3M6IGdldFN0eWxlcyhpc0Nvbm5lY3RlZCkuY29ubmVjdEJ1dHRvbiwgaXNEaXNhYmxlZDogaXNDb25uZWN0ZWQgfHwgc2hvd0Ryb3BEb3duLCBpc0xvYWRpbmc6IGlzU3VibWl0dGluZywgb25DbGljazogKCkgPT4gX19hd2FpdGVyKHZvaWQgMCwgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uKiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcXVpcmVkRmllbGRzID09PSBudWxsIHx8IHJlcXVpcmVkRmllbGRzID09PSB2b2lkIDAgPyB2b2lkIDAgOiByZXF1aXJlZEZpZWxkcy5pbmNsdWRlcyhcImFkZHJlc3NcIikpXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFNob3dEcm9wRG93bih0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlpZWxkIGhhbmRsZVJlZ2lzdGVyKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSwgdGl0bGU6IGlzQ29ubmVjdGVkXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyB0KFwibGlzdC1jYXJyaWVyczphY3Rpb25zLnN0YXR1cy5jb25uZWN0ZWRcIilcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IHQoXCJsaXN0LWNhcnJpZXJzOmFjdGlvbnMuc3RhdHVzLm5vdENvbm5lY3RlZFwiKSB9KSB9KSldIH0pKSwgc2hvd0Ryb3BEb3duICYmIChfanN4KFRlbXBsYXRlcy5BZGRDYXJyaWVyRm9ybSwgeyBjYXJyaWVyVGVybXM6IGNhcnJpZXIudGVybXMgJiYgY2Fycmllci50ZXJtcywgb25DYW5jZWw6ICgpID0+IHNldFNob3dEcm9wRG93bihmYWxzZSksIG9uU3VibWl0OiAodmFsdWVzKSA9PiBoYW5kbGVSZWdpc3Rlcih2YWx1ZXMpLCByZWdpc3RlckNhcnJpZXJFcnJvcnM6IHJlZ2lzdGVyQ2FycmllckVycm9ycyB9KSldIH0pKSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWxpc3QtY2FycmllcnMtcm93LmpzLm1hcCJdfQ== */",
|
|
24491
24723
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2
|
|
24492
24724
|
};
|
|
24493
24725
|
const ListCarriersRow = ({
|
|
@@ -24539,18 +24771,15 @@ const ListCarriersRow = ({
|
|
|
24539
24771
|
})), jsx("div", Object.assign({
|
|
24540
24772
|
css: _ref$1
|
|
24541
24773
|
}, {
|
|
24542
|
-
children: jsx(
|
|
24543
|
-
color: ButtonColor.SECONDARY,
|
|
24774
|
+
children: jsx(LinkAction, {
|
|
24544
24775
|
css: getStyles$4(isConnected).connectButton,
|
|
24545
|
-
|
|
24776
|
+
isDisabled: isConnected || showDropDown,
|
|
24546
24777
|
isLoading: isSubmitting,
|
|
24547
24778
|
onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24548
24779
|
if (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes("address")) setShowDropDown(true);else yield handleRegister();
|
|
24549
24780
|
}),
|
|
24550
|
-
|
|
24551
|
-
}
|
|
24552
|
-
children: isConnected ? t("list-carriers:actions.status.connected") : t("list-carriers:actions.status.notConnected")
|
|
24553
|
-
}))
|
|
24781
|
+
title: isConnected ? t("list-carriers:actions.status.connected") : t("list-carriers:actions.status.notConnected")
|
|
24782
|
+
})
|
|
24554
24783
|
}))]
|
|
24555
24784
|
})), showDropDown && jsx(AddCarrierForm, {
|
|
24556
24785
|
carrierTerms: carrier.terms && carrier.terms,
|
|
@@ -24781,6 +25010,7 @@ const WarehouseDisplay = ({
|
|
|
24781
25010
|
returnAddress
|
|
24782
25011
|
} = warehouse;
|
|
24783
25012
|
return jsxs(Grid, Object.assign({
|
|
25013
|
+
"data-testid": "warehouseDisplay",
|
|
24784
25014
|
noPadding: true
|
|
24785
25015
|
}, {
|
|
24786
25016
|
children: [jsx(GridChild, Object.assign({
|
|
@@ -24857,28 +25087,7 @@ const warehouseSchema = z.discriminatedUnion("returnToAddressIsDifferent", [z.ob
|
|
|
24857
25087
|
name: z.string().trim().min(1),
|
|
24858
25088
|
originAddress: warehouseAddressSchema,
|
|
24859
25089
|
returnToAddressIsDifferent: z.literal(false)
|
|
24860
|
-
})])
|
|
24861
|
-
if (schema.returnToAddressIsDifferent) {
|
|
24862
|
-
return schema;
|
|
24863
|
-
}
|
|
24864
|
-
return Object.assign(Object.assign({}, schema), {
|
|
24865
|
-
returnAddress: schema.originAddress
|
|
24866
|
-
});
|
|
24867
|
-
});
|
|
24868
|
-
|
|
24869
|
-
const styles$3 = createStyles({
|
|
24870
|
-
header: {
|
|
24871
|
-
textAlign: "center"
|
|
24872
|
-
},
|
|
24873
|
-
onboardingWell: theme => ({
|
|
24874
|
-
backgroundColor: theme.palette.white,
|
|
24875
|
-
padding: theme.spacing(2)
|
|
24876
|
-
}),
|
|
24877
|
-
well: theme => ({
|
|
24878
|
-
backgroundColor: theme.palette.gray.ultraLight,
|
|
24879
|
-
padding: theme.spacing(2)
|
|
24880
|
-
})
|
|
24881
|
-
});
|
|
25090
|
+
})]);
|
|
24882
25091
|
|
|
24883
25092
|
const WarehouseForm = ({
|
|
24884
25093
|
isOnboarding: _isOnboarding = false,
|
|
@@ -24902,9 +25111,9 @@ const WarehouseForm = ({
|
|
|
24902
25111
|
}),
|
|
24903
25112
|
returnToAddressIsDifferent: !lodash.exports.isEqual(warehouse.originAddress, warehouse.returnAddress)
|
|
24904
25113
|
}) : {
|
|
24905
|
-
isDefault: false,
|
|
25114
|
+
isDefault: _isOnboarding ? true : false,
|
|
24906
25115
|
originAddress: {
|
|
24907
|
-
|
|
25116
|
+
addressResidentialIndicator: false
|
|
24908
25117
|
},
|
|
24909
25118
|
returnToAddressIsDifferent: false
|
|
24910
25119
|
},
|
|
@@ -24913,140 +25122,365 @@ const WarehouseForm = ({
|
|
|
24913
25122
|
const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
24914
25123
|
const _a = values,
|
|
24915
25124
|
payload = __rest(_a, ["returnToAddressIsDifferent"]);
|
|
24916
|
-
|
|
24917
|
-
payload.isDefault = true;
|
|
24918
|
-
yield onSubmit(payload);
|
|
24919
|
-
} else {
|
|
24920
|
-
yield onSubmit(payload);
|
|
24921
|
-
}
|
|
25125
|
+
yield onSubmit(payload);
|
|
24922
25126
|
}));
|
|
24923
|
-
return jsxs("
|
|
24924
|
-
|
|
24925
|
-
|
|
25127
|
+
return jsxs("form", Object.assign({
|
|
25128
|
+
id: "warehouse-form",
|
|
25129
|
+
onSubmit: formLogger.capture(handleSubmit)
|
|
24926
25130
|
}, {
|
|
24927
|
-
children: [
|
|
24928
|
-
|
|
24929
|
-
|
|
24930
|
-
|
|
24931
|
-
|
|
24932
|
-
|
|
24933
|
-
|
|
24934
|
-
|
|
24935
|
-
|
|
24936
|
-
|
|
24937
|
-
|
|
24938
|
-
|
|
24939
|
-
|
|
24940
|
-
|
|
24941
|
-
|
|
24942
|
-
|
|
24943
|
-
|
|
24944
|
-
|
|
24945
|
-
|
|
24946
|
-
|
|
24947
|
-
|
|
24948
|
-
|
|
24949
|
-
|
|
24950
|
-
|
|
24951
|
-
|
|
24952
|
-
|
|
24953
|
-
|
|
24954
|
-
|
|
24955
|
-
|
|
24956
|
-
|
|
24957
|
-
|
|
24958
|
-
|
|
24959
|
-
|
|
24960
|
-
|
|
24961
|
-
|
|
24962
|
-
|
|
24963
|
-
|
|
24964
|
-
|
|
25131
|
+
children: [jsx(TextInput, {
|
|
25132
|
+
control: form.control,
|
|
25133
|
+
form: "warehouse-form",
|
|
25134
|
+
label: t("manage-warehouses:locationName"),
|
|
25135
|
+
name: "name",
|
|
25136
|
+
nativeLabel: true
|
|
25137
|
+
}), jsx(AddressFields, {
|
|
25138
|
+
form: form,
|
|
25139
|
+
formatFieldName: fieldName => `originAddress.${fieldName}`
|
|
25140
|
+
}), jsx(CheckboxInput, {
|
|
25141
|
+
checkboxLabel: t("manage-warehouses:residentialAddress"),
|
|
25142
|
+
control: form.control,
|
|
25143
|
+
form: "warehouse-form",
|
|
25144
|
+
label: "originAddress.addressResidentialIndicator",
|
|
25145
|
+
name: "originAddress.addressResidentialIndicator"
|
|
25146
|
+
}), !_isOnboarding && jsx(CheckboxInput, {
|
|
25147
|
+
checkboxLabel: t("manage-warehouses:isDefault"),
|
|
25148
|
+
control: form.control,
|
|
25149
|
+
form: "warehouse-form",
|
|
25150
|
+
label: "isDefault",
|
|
25151
|
+
name: "isDefault"
|
|
25152
|
+
}), jsx(CheckboxInput, {
|
|
25153
|
+
checkboxLabel: t("manage-warehouses:returnToAddressIsDifferent"),
|
|
25154
|
+
control: form.control,
|
|
25155
|
+
"data-testid": "returnToAddressIsDifferent",
|
|
25156
|
+
form: "warehouse-form",
|
|
25157
|
+
label: "returnToAddressIsDifferent",
|
|
25158
|
+
name: "returnToAddressIsDifferent",
|
|
25159
|
+
onClick: e => {
|
|
25160
|
+
if (e.currentTarget.checked) {
|
|
25161
|
+
form.reset(formValues => Object.assign(Object.assign({}, formValues), {
|
|
25162
|
+
returnAddress: Object.assign(Object.assign({}, {}), {
|
|
25163
|
+
addressResidentialIndicator: false,
|
|
25164
|
+
countryCode: "US"
|
|
25165
|
+
}),
|
|
25166
|
+
returnToAddressIsDifferent: true
|
|
25167
|
+
}), {
|
|
25168
|
+
keepErrors: true
|
|
25169
|
+
});
|
|
25170
|
+
}
|
|
25171
|
+
}
|
|
25172
|
+
}), form.watch("returnToAddressIsDifferent") && jsxs(Fragment, {
|
|
25173
|
+
children: [jsx(AddressFields, {
|
|
24965
25174
|
form: form,
|
|
24966
|
-
formatFieldName: fieldName => `
|
|
24967
|
-
optionalFields: ["addressLine2"]
|
|
25175
|
+
formatFieldName: fieldName => `returnAddress.${fieldName}`
|
|
24968
25176
|
}), jsx(CheckboxInput, {
|
|
24969
25177
|
checkboxLabel: t("manage-warehouses:residentialAddress"),
|
|
24970
25178
|
control: form.control,
|
|
24971
25179
|
form: "warehouse-form",
|
|
24972
|
-
label: "
|
|
24973
|
-
name: "
|
|
24974
|
-
})
|
|
24975
|
-
|
|
24976
|
-
|
|
24977
|
-
|
|
24978
|
-
|
|
24979
|
-
|
|
24980
|
-
|
|
24981
|
-
|
|
24982
|
-
|
|
24983
|
-
form: "warehouse-form",
|
|
24984
|
-
label: "returnToAddressIsDifferent",
|
|
24985
|
-
name: "returnToAddressIsDifferent",
|
|
24986
|
-
onClick: e => {
|
|
24987
|
-
if (e.currentTarget.checked) {
|
|
24988
|
-
form.reset(formValues => Object.assign(Object.assign({}, formValues), {
|
|
24989
|
-
returnAddress: Object.assign(Object.assign({}, {}), {
|
|
24990
|
-
addressResidentialIndicator: false,
|
|
24991
|
-
countryCode: "US"
|
|
24992
|
-
}),
|
|
24993
|
-
returnToAddressIsDifferent: true
|
|
24994
|
-
}), {
|
|
24995
|
-
keepErrors: true
|
|
24996
|
-
});
|
|
24997
|
-
}
|
|
24998
|
-
}
|
|
24999
|
-
}), form.watch("returnToAddressIsDifferent") && jsxs(Fragment, {
|
|
25000
|
-
children: [jsx(AddressFields, {
|
|
25001
|
-
form: form,
|
|
25002
|
-
formatFieldName: fieldName => `returnAddress.${fieldName}`
|
|
25003
|
-
}), jsx(CheckboxInput, {
|
|
25004
|
-
checkboxLabel: t("manage-warehouses:residentialAddress"),
|
|
25005
|
-
control: form.control,
|
|
25006
|
-
form: "warehouse-form",
|
|
25007
|
-
label: "returnAddress.addressResidentialIndicator",
|
|
25008
|
-
name: "returnAddress.addressResidentialIndicator"
|
|
25009
|
-
})]
|
|
25010
|
-
}), jsxs(ButtonGroup, Object.assign({
|
|
25011
|
-
justify: "center"
|
|
25180
|
+
label: "returnAddress.addressResidentialIndicator",
|
|
25181
|
+
name: "returnAddress.addressResidentialIndicator"
|
|
25182
|
+
})]
|
|
25183
|
+
}), jsxs(ButtonGroup, Object.assign({
|
|
25184
|
+
justify: "center"
|
|
25185
|
+
}, {
|
|
25186
|
+
children: [onDelete && jsx(Button, Object.assign({
|
|
25187
|
+
bold: false,
|
|
25188
|
+
onClick: onDelete,
|
|
25189
|
+
type: "button",
|
|
25190
|
+
variant: ButtonVariant.TEXT
|
|
25012
25191
|
}, {
|
|
25013
|
-
children:
|
|
25192
|
+
children: t("actions.remove")
|
|
25193
|
+
})), jsxs(ButtonGroup, Object.assign({
|
|
25194
|
+
justify: _isOnboarding ? "center" : "end"
|
|
25195
|
+
}, {
|
|
25196
|
+
children: [onCancel && jsx(Button, Object.assign({
|
|
25014
25197
|
bold: false,
|
|
25015
|
-
onClick:
|
|
25198
|
+
onClick: onCancel,
|
|
25016
25199
|
type: "button",
|
|
25017
25200
|
variant: ButtonVariant.TEXT
|
|
25018
25201
|
}, {
|
|
25019
|
-
children: t("actions.
|
|
25020
|
-
})),
|
|
25021
|
-
|
|
25202
|
+
children: t("actions.cancel")
|
|
25203
|
+
})), jsx(SubmitButton, Object.assign({
|
|
25204
|
+
control: form.control,
|
|
25205
|
+
"data-testid": "warehouseFormSubmitButton",
|
|
25206
|
+
form: "warehouse-form",
|
|
25207
|
+
requireDirty: true,
|
|
25208
|
+
variant: _isOnboarding ? ButtonVariant.FILLED : ButtonVariant.OUTLINED
|
|
25022
25209
|
}, {
|
|
25023
|
-
children:
|
|
25024
|
-
|
|
25025
|
-
|
|
25026
|
-
|
|
25027
|
-
|
|
25210
|
+
children: submitButtonTitle
|
|
25211
|
+
}))]
|
|
25212
|
+
}))]
|
|
25213
|
+
}))]
|
|
25214
|
+
}));
|
|
25215
|
+
};
|
|
25216
|
+
|
|
25217
|
+
const WarehousePreferenceSelect = ({
|
|
25218
|
+
onCancel,
|
|
25219
|
+
onSubmit,
|
|
25220
|
+
originAddress,
|
|
25221
|
+
returnAddress
|
|
25222
|
+
}) => {
|
|
25223
|
+
const {
|
|
25224
|
+
t
|
|
25225
|
+
} = useTranslation(["manage-warehouses", "common"]);
|
|
25226
|
+
const determineAddressPreference = address => {
|
|
25227
|
+
if (!address) return undefined;
|
|
25228
|
+
switch (address.validationType) {
|
|
25229
|
+
case "EXACT":
|
|
25230
|
+
case "SOFT":
|
|
25231
|
+
return address.address;
|
|
25232
|
+
case "SUGGESTED":
|
|
25233
|
+
return address.validation.matchedAddress;
|
|
25234
|
+
case "ERROR":
|
|
25235
|
+
return address.validation.originalAddress;
|
|
25236
|
+
default:
|
|
25237
|
+
return undefined;
|
|
25238
|
+
}
|
|
25239
|
+
};
|
|
25240
|
+
const [originAddressPreference, setOriginAddressPreference] = useState(determineAddressPreference(originAddress));
|
|
25241
|
+
const [returnAddressPreference, setReturnAddressPreference] = useState(determineAddressPreference(returnAddress));
|
|
25242
|
+
const addressPreferenceDisplay = (preference, name, onPreferenceSelect) => {
|
|
25243
|
+
var _a, _b;
|
|
25244
|
+
switch (preference.validationType) {
|
|
25245
|
+
case "EXACT":
|
|
25246
|
+
case "SOFT":
|
|
25247
|
+
return jsx(AddressDisplay, {
|
|
25248
|
+
address: preference.address
|
|
25249
|
+
});
|
|
25250
|
+
case "SUGGESTED":
|
|
25251
|
+
return jsxs(Next.RadioGroup, Object.assign({
|
|
25252
|
+
name: name,
|
|
25253
|
+
onChange: e => {
|
|
25254
|
+
if (preference.validation.matchedAddress && e.target.value === "suggested") {
|
|
25255
|
+
onPreferenceSelect(preference.validation.matchedAddress);
|
|
25256
|
+
} else {
|
|
25257
|
+
onPreferenceSelect(preference.validation.originalAddress);
|
|
25258
|
+
}
|
|
25259
|
+
}
|
|
25260
|
+
}, {
|
|
25261
|
+
children: [jsx(Spacer, {
|
|
25262
|
+
multiplier: 1
|
|
25263
|
+
}), jsx(Next.Radio, Object.assign({
|
|
25264
|
+
value: "suggested"
|
|
25028
25265
|
}, {
|
|
25029
|
-
children: t("
|
|
25030
|
-
})), jsx(
|
|
25031
|
-
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25266
|
+
children: t("common:address.preference.matchedAddress")
|
|
25267
|
+
})), preference.validation.matchedAddress && jsx(GridChild, Object.assign({
|
|
25268
|
+
colSpan: 6,
|
|
25269
|
+
colStart: 4,
|
|
25270
|
+
css: theme => ({
|
|
25271
|
+
paddingLeft: theme.spacing(3)
|
|
25272
|
+
})
|
|
25035
25273
|
}, {
|
|
25036
|
-
children:
|
|
25274
|
+
children: jsx(AddressDisplay, {
|
|
25275
|
+
address: preference.validation.matchedAddress
|
|
25276
|
+
})
|
|
25277
|
+
})), jsx(Spacer, {
|
|
25278
|
+
multiplier: 1
|
|
25279
|
+
}), jsx(Next.Radio, Object.assign({
|
|
25280
|
+
value: "original"
|
|
25281
|
+
}, {
|
|
25282
|
+
children: t("common:address.preference.originalAddress")
|
|
25283
|
+
})), jsx(Spacer, {
|
|
25284
|
+
multiplier: 1
|
|
25285
|
+
}), jsx(GridChild, Object.assign({
|
|
25286
|
+
colSpan: 6,
|
|
25287
|
+
colStart: 4,
|
|
25288
|
+
css: theme => ({
|
|
25289
|
+
paddingLeft: theme.spacing(3)
|
|
25290
|
+
})
|
|
25291
|
+
}, {
|
|
25292
|
+
children: jsx(AddressDisplay, {
|
|
25293
|
+
address: (_a = preference.validation) === null || _a === void 0 ? void 0 : _a.originalAddress
|
|
25294
|
+
})
|
|
25037
25295
|
}))]
|
|
25038
|
-
}))
|
|
25296
|
+
}));
|
|
25297
|
+
case "ERROR":
|
|
25298
|
+
return jsxs(Fragment, {
|
|
25299
|
+
children: [jsx(Spacer, {
|
|
25300
|
+
multiplier: 1
|
|
25301
|
+
}), jsx(GridChild, Object.assign({
|
|
25302
|
+
colSpan: 8,
|
|
25303
|
+
css: theme => ({
|
|
25304
|
+
paddingLeft: theme.spacing(1)
|
|
25305
|
+
})
|
|
25306
|
+
}, {
|
|
25307
|
+
children: jsx(InlineNotification, Object.assign({
|
|
25308
|
+
type: NotificationType.ALERT
|
|
25309
|
+
}, {
|
|
25310
|
+
children: t("address.preference.unableToValidate")
|
|
25311
|
+
}))
|
|
25312
|
+
})), jsx(Spacer, {
|
|
25313
|
+
multiplier: 1
|
|
25314
|
+
}), jsx(GridChild, Object.assign({
|
|
25315
|
+
css: theme => ({
|
|
25316
|
+
paddingLeft: theme.spacing(1)
|
|
25317
|
+
})
|
|
25318
|
+
}, {
|
|
25319
|
+
children: jsx(AddressDisplay, {
|
|
25320
|
+
address: (_b = preference.validation) === null || _b === void 0 ? void 0 : _b.originalAddress
|
|
25321
|
+
})
|
|
25322
|
+
}))]
|
|
25323
|
+
});
|
|
25324
|
+
default:
|
|
25325
|
+
// This code path should never be reached.
|
|
25326
|
+
return jsx("div", {
|
|
25327
|
+
children: "not found"
|
|
25328
|
+
});
|
|
25329
|
+
}
|
|
25330
|
+
};
|
|
25331
|
+
return jsxs(Fragment, {
|
|
25332
|
+
children: [jsxs(Grid, Object.assign({
|
|
25333
|
+
"data-testid": "warehousePreferenceSelect",
|
|
25334
|
+
noPadding: true
|
|
25335
|
+
}, {
|
|
25336
|
+
children: [jsx(GridChild, Object.assign({
|
|
25337
|
+
colSpan: 12
|
|
25338
|
+
}, {
|
|
25339
|
+
children: jsx(Typography, Object.assign({
|
|
25340
|
+
variant: "subtitle2"
|
|
25341
|
+
}, {
|
|
25342
|
+
children: t("common:address.preference.title")
|
|
25343
|
+
}))
|
|
25344
|
+
})), jsxs(GridChild, Object.assign({
|
|
25345
|
+
colSpan: 8
|
|
25346
|
+
}, {
|
|
25347
|
+
children: [jsx(Typography, Object.assign({
|
|
25348
|
+
css: {
|
|
25349
|
+
textTransform: "capitalize"
|
|
25350
|
+
},
|
|
25351
|
+
variant: "subtitle2"
|
|
25352
|
+
}, {
|
|
25353
|
+
children: t("manage-warehouses:shipFrom")
|
|
25354
|
+
})), originAddress && addressPreferenceDisplay(originAddress, "originAddressPreference", preference => {
|
|
25355
|
+
setOriginAddressPreference(preference);
|
|
25356
|
+
})]
|
|
25357
|
+
})), returnAddress && jsxs(GridChild, Object.assign({
|
|
25358
|
+
colSpan: 8
|
|
25359
|
+
}, {
|
|
25360
|
+
children: [jsx(Typography, Object.assign({
|
|
25361
|
+
css: {
|
|
25362
|
+
textTransform: "capitalize"
|
|
25363
|
+
},
|
|
25364
|
+
variant: "subtitle2"
|
|
25365
|
+
}, {
|
|
25366
|
+
children: t("manage-warehouses:returnTo")
|
|
25367
|
+
})), addressPreferenceDisplay(returnAddress, "returnAddressPreference", preference => {
|
|
25368
|
+
setReturnAddressPreference(preference);
|
|
25369
|
+
})]
|
|
25370
|
+
}))]
|
|
25371
|
+
})), jsxs(ButtonGroup, Object.assign({
|
|
25372
|
+
justify: "end"
|
|
25373
|
+
}, {
|
|
25374
|
+
children: [onCancel && jsx(Button, Object.assign({
|
|
25375
|
+
bold: false,
|
|
25376
|
+
onClick: onCancel,
|
|
25377
|
+
type: "button",
|
|
25378
|
+
variant: ButtonVariant.TEXT
|
|
25379
|
+
}, {
|
|
25380
|
+
children: t("actions.cancel")
|
|
25381
|
+
})), jsx(Button, Object.assign({
|
|
25382
|
+
onClick: () => onSubmit({
|
|
25383
|
+
originAddress: originAddressPreference,
|
|
25384
|
+
returnAddress: returnAddressPreference
|
|
25385
|
+
}),
|
|
25386
|
+
variant: ButtonVariant.OUTLINED
|
|
25387
|
+
}, {
|
|
25388
|
+
children: t("common:address.preference.confirm")
|
|
25039
25389
|
}))]
|
|
25040
25390
|
}))]
|
|
25391
|
+
});
|
|
25392
|
+
};
|
|
25393
|
+
|
|
25394
|
+
const WarehousePreferenceWizard = ({
|
|
25395
|
+
className,
|
|
25396
|
+
formHeader,
|
|
25397
|
+
isOnboarding: _isOnboarding = false,
|
|
25398
|
+
onSubmit,
|
|
25399
|
+
onValidate,
|
|
25400
|
+
onWarehouseDelete,
|
|
25401
|
+
onWarehouseFormCancel,
|
|
25402
|
+
submitButtonTitle,
|
|
25403
|
+
warehouse,
|
|
25404
|
+
warehousePreference
|
|
25405
|
+
}) => {
|
|
25406
|
+
const [currentStep, setCurrentStep] = useState(0);
|
|
25407
|
+
const checkForExactOrSoft = warehousePreference => __awaiter(void 0, void 0, void 0, function* () {
|
|
25408
|
+
const {
|
|
25409
|
+
originAddress,
|
|
25410
|
+
returnAddress
|
|
25411
|
+
} = warehousePreference;
|
|
25412
|
+
if ((originAddress.validationType === "EXACT" || originAddress.validationType === "SOFT") && returnAddress && (returnAddress.validationType === "EXACT" || returnAddress.validationType === "SOFT")) {
|
|
25413
|
+
yield onSubmit({
|
|
25414
|
+
isDefault: !!warehousePreference.isDefault,
|
|
25415
|
+
name: warehousePreference.name,
|
|
25416
|
+
originAddress: originAddress.address,
|
|
25417
|
+
returnAddress: returnAddress.address
|
|
25418
|
+
});
|
|
25419
|
+
return;
|
|
25420
|
+
}
|
|
25421
|
+
if ((originAddress.validationType === "EXACT" || originAddress.validationType === "SOFT") && !returnAddress) {
|
|
25422
|
+
yield onSubmit({
|
|
25423
|
+
isDefault: !!warehousePreference.isDefault,
|
|
25424
|
+
name: warehousePreference.name,
|
|
25425
|
+
originAddress: originAddress.address
|
|
25426
|
+
});
|
|
25427
|
+
return;
|
|
25428
|
+
} else return;
|
|
25429
|
+
});
|
|
25430
|
+
return jsxs("div", Object.assign({
|
|
25431
|
+
className: className
|
|
25432
|
+
}, {
|
|
25433
|
+
children: [formHeader && formHeader, currentStep === 0 ? jsx(WarehouseForm, {
|
|
25434
|
+
isOnboarding: _isOnboarding,
|
|
25435
|
+
onCancel: onWarehouseFormCancel ? () => onWarehouseFormCancel() : undefined,
|
|
25436
|
+
onDelete: onWarehouseDelete ? () => onWarehouseDelete() : undefined,
|
|
25437
|
+
onSubmit: payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
25438
|
+
const result = yield onValidate(payload);
|
|
25439
|
+
yield checkForExactOrSoft(result);
|
|
25440
|
+
setCurrentStep(1);
|
|
25441
|
+
}),
|
|
25442
|
+
submitButtonTitle: submitButtonTitle,
|
|
25443
|
+
warehouse: warehouse
|
|
25444
|
+
}) : warehousePreference && jsx(WarehousePreferenceSelect, {
|
|
25445
|
+
onCancel: () => setCurrentStep(0),
|
|
25446
|
+
onSubmit: payload => {
|
|
25447
|
+
onSubmit({
|
|
25448
|
+
isDefault: !!warehousePreference.isDefault,
|
|
25449
|
+
name: warehousePreference.name,
|
|
25450
|
+
originAddress: payload.originAddress,
|
|
25451
|
+
returnAddress: payload.returnAddress
|
|
25452
|
+
});
|
|
25453
|
+
},
|
|
25454
|
+
originAddress: warehousePreference.originAddress,
|
|
25455
|
+
returnAddress: warehousePreference.returnAddress
|
|
25456
|
+
})]
|
|
25041
25457
|
}));
|
|
25042
25458
|
};
|
|
25043
25459
|
|
|
25460
|
+
const styles$3 = createStyles({
|
|
25461
|
+
cardSpacing: theme => ({
|
|
25462
|
+
display: "flex",
|
|
25463
|
+
flexDirection: "column",
|
|
25464
|
+
gap: theme.spacing(2)
|
|
25465
|
+
}),
|
|
25466
|
+
header: {
|
|
25467
|
+
textAlign: "left"
|
|
25468
|
+
},
|
|
25469
|
+
well: theme => ({
|
|
25470
|
+
backgroundColor: theme.palette.gray.ultraLight,
|
|
25471
|
+
padding: theme.spacing(2)
|
|
25472
|
+
})
|
|
25473
|
+
});
|
|
25474
|
+
|
|
25044
25475
|
const ManageWarehouses$1 = ({
|
|
25045
25476
|
errors,
|
|
25046
25477
|
onAdd,
|
|
25047
25478
|
onDelete,
|
|
25048
25479
|
onEdit,
|
|
25049
25480
|
onSetDefault,
|
|
25481
|
+
onValidate,
|
|
25482
|
+
setWarehousePreference,
|
|
25483
|
+
warehousePreference,
|
|
25050
25484
|
warehouses
|
|
25051
25485
|
}) => {
|
|
25052
25486
|
const {
|
|
@@ -25055,13 +25489,28 @@ const ManageWarehouses$1 = ({
|
|
|
25055
25489
|
const [editWarehouseId, setEditWarehouseId] = useState();
|
|
25056
25490
|
const [showAddNewWarehouseForm, toggleShowAddNewWarehouseForm] = useToggle(false);
|
|
25057
25491
|
return jsxs(Fragment, {
|
|
25058
|
-
children: [showAddNewWarehouseForm ? jsx(
|
|
25059
|
-
|
|
25492
|
+
children: [showAddNewWarehouseForm ? jsx(WarehousePreferenceWizard, {
|
|
25493
|
+
css: styles$3.well,
|
|
25494
|
+
formHeader: jsxs("div", Object.assign({
|
|
25495
|
+
css: styles$3.header
|
|
25496
|
+
}, {
|
|
25497
|
+
children: [jsx(Typography, Object.assign({
|
|
25498
|
+
variant: "subtitle1"
|
|
25499
|
+
}, {
|
|
25500
|
+
children: t("manage-warehouses:addNew")
|
|
25501
|
+
})), jsx(Spacer, {
|
|
25502
|
+
multiplier: 1
|
|
25503
|
+
})]
|
|
25504
|
+
})),
|
|
25060
25505
|
onSubmit: payload => {
|
|
25061
25506
|
onAdd(payload);
|
|
25062
25507
|
toggleShowAddNewWarehouseForm(false);
|
|
25508
|
+
setWarehousePreference(undefined);
|
|
25063
25509
|
},
|
|
25064
|
-
|
|
25510
|
+
onValidate: onValidate,
|
|
25511
|
+
onWarehouseFormCancel: () => toggleShowAddNewWarehouseForm(false),
|
|
25512
|
+
submitButtonTitle: t("actions.save"),
|
|
25513
|
+
warehousePreference: warehousePreference
|
|
25065
25514
|
}) : jsx(ButtonGroup, Object.assign({
|
|
25066
25515
|
justify: "end"
|
|
25067
25516
|
}, {
|
|
@@ -25080,26 +25529,37 @@ const ManageWarehouses$1 = ({
|
|
|
25080
25529
|
})]
|
|
25081
25530
|
}))
|
|
25082
25531
|
})), jsx("div", Object.assign({
|
|
25083
|
-
css:
|
|
25084
|
-
display: "flex",
|
|
25085
|
-
flexDirection: "column",
|
|
25086
|
-
gap: theme.spacing(2)
|
|
25087
|
-
})
|
|
25532
|
+
css: styles$3.cardSpacing
|
|
25088
25533
|
}, {
|
|
25089
25534
|
children: warehouses.sort((a, b) => {
|
|
25090
25535
|
if (b.isDefault) return 1;
|
|
25091
25536
|
return sortByCreationDate(a, b, "desc");
|
|
25092
25537
|
}).map(warehouse => {
|
|
25093
25538
|
if (editWarehouseId && editWarehouseId === warehouse.warehouseId) {
|
|
25094
|
-
return jsx(
|
|
25095
|
-
|
|
25096
|
-
|
|
25539
|
+
return jsx(WarehousePreferenceWizard, {
|
|
25540
|
+
css: styles$3.well,
|
|
25541
|
+
formHeader: jsxs("div", Object.assign({
|
|
25542
|
+
css: styles$3.header
|
|
25543
|
+
}, {
|
|
25544
|
+
children: [jsx(Typography, Object.assign({
|
|
25545
|
+
variant: "subtitle1"
|
|
25546
|
+
}, {
|
|
25547
|
+
children: t("manage-warehouses:editWarehouse")
|
|
25548
|
+
})), jsx(Spacer, {
|
|
25549
|
+
multiplier: 1
|
|
25550
|
+
})]
|
|
25551
|
+
})),
|
|
25097
25552
|
onSubmit: payload => {
|
|
25098
25553
|
onEdit(payload, warehouse.warehouseId);
|
|
25099
25554
|
setEditWarehouseId(undefined);
|
|
25555
|
+
setWarehousePreference(undefined);
|
|
25100
25556
|
},
|
|
25557
|
+
onValidate: onValidate,
|
|
25558
|
+
onWarehouseDelete: warehouse.isDefault ? undefined : () => onDelete(warehouse.warehouseId),
|
|
25559
|
+
onWarehouseFormCancel: () => setEditWarehouseId(undefined),
|
|
25101
25560
|
submitButtonTitle: t("actions.save"),
|
|
25102
|
-
warehouse: warehouse
|
|
25561
|
+
warehouse: warehouse,
|
|
25562
|
+
warehousePreference: warehousePreference
|
|
25103
25563
|
}, warehouse.warehouseId);
|
|
25104
25564
|
} else {
|
|
25105
25565
|
return jsx(SettingsCard, Object.assign({
|
|
@@ -25129,10 +25589,10 @@ const ManageWarehouses$1 = ({
|
|
|
25129
25589
|
|
|
25130
25590
|
var getBuiltIn$3 = getBuiltIn$9;
|
|
25131
25591
|
var definePropertyModule = objectDefineProperty;
|
|
25132
|
-
var wellKnownSymbol$
|
|
25592
|
+
var wellKnownSymbol$3 = wellKnownSymbol$j;
|
|
25133
25593
|
var DESCRIPTORS = descriptors;
|
|
25134
25594
|
|
|
25135
|
-
var SPECIES$2 = wellKnownSymbol$
|
|
25595
|
+
var SPECIES$2 = wellKnownSymbol$3('species');
|
|
25136
25596
|
|
|
25137
25597
|
var setSpecies$1 = function (CONSTRUCTOR_NAME) {
|
|
25138
25598
|
var Constructor = getBuiltIn$3(CONSTRUCTOR_NAME);
|
|
@@ -25146,49 +25606,49 @@ var setSpecies$1 = function (CONSTRUCTOR_NAME) {
|
|
|
25146
25606
|
}
|
|
25147
25607
|
};
|
|
25148
25608
|
|
|
25149
|
-
var isPrototypeOf
|
|
25609
|
+
var isPrototypeOf = objectIsPrototypeOf;
|
|
25150
25610
|
|
|
25151
|
-
var $TypeError$
|
|
25611
|
+
var $TypeError$3 = TypeError;
|
|
25152
25612
|
|
|
25153
25613
|
var anInstance$1 = function (it, Prototype) {
|
|
25154
|
-
if (isPrototypeOf
|
|
25155
|
-
throw $TypeError$
|
|
25614
|
+
if (isPrototypeOf(Prototype, it)) return it;
|
|
25615
|
+
throw $TypeError$3('Incorrect invocation');
|
|
25156
25616
|
};
|
|
25157
25617
|
|
|
25158
25618
|
var isConstructor = isConstructor$2;
|
|
25159
|
-
var tryToString
|
|
25619
|
+
var tryToString = tryToString$5;
|
|
25160
25620
|
|
|
25161
|
-
var $TypeError$
|
|
25621
|
+
var $TypeError$2 = TypeError;
|
|
25162
25622
|
|
|
25163
25623
|
// `Assert: IsConstructor(argument) is true`
|
|
25164
25624
|
var aConstructor$1 = function (argument) {
|
|
25165
25625
|
if (isConstructor(argument)) return argument;
|
|
25166
|
-
throw $TypeError$
|
|
25626
|
+
throw $TypeError$2(tryToString(argument) + ' is not a constructor');
|
|
25167
25627
|
};
|
|
25168
25628
|
|
|
25169
|
-
var anObject$
|
|
25629
|
+
var anObject$1 = anObject$f;
|
|
25170
25630
|
var aConstructor = aConstructor$1;
|
|
25171
|
-
var isNullOrUndefined
|
|
25172
|
-
var wellKnownSymbol$
|
|
25631
|
+
var isNullOrUndefined = isNullOrUndefined$6;
|
|
25632
|
+
var wellKnownSymbol$2 = wellKnownSymbol$j;
|
|
25173
25633
|
|
|
25174
|
-
var SPECIES$1 = wellKnownSymbol$
|
|
25634
|
+
var SPECIES$1 = wellKnownSymbol$2('species');
|
|
25175
25635
|
|
|
25176
25636
|
// `SpeciesConstructor` abstract operation
|
|
25177
25637
|
// https://tc39.es/ecma262/#sec-speciesconstructor
|
|
25178
25638
|
var speciesConstructor$2 = function (O, defaultConstructor) {
|
|
25179
|
-
var C = anObject$
|
|
25639
|
+
var C = anObject$1(O).constructor;
|
|
25180
25640
|
var S;
|
|
25181
|
-
return C === undefined || isNullOrUndefined
|
|
25641
|
+
return C === undefined || isNullOrUndefined(S = anObject$1(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S);
|
|
25182
25642
|
};
|
|
25183
25643
|
|
|
25184
25644
|
var uncurryThis$1 = functionUncurryThis;
|
|
25185
25645
|
|
|
25186
25646
|
var arraySlice$1 = uncurryThis$1([].slice);
|
|
25187
25647
|
|
|
25188
|
-
var $TypeError$
|
|
25648
|
+
var $TypeError$1 = TypeError;
|
|
25189
25649
|
|
|
25190
25650
|
var validateArgumentsLength$1 = function (passed, required) {
|
|
25191
|
-
if (passed < required) throw $TypeError$
|
|
25651
|
+
if (passed < required) throw $TypeError$1('Not enough arguments');
|
|
25192
25652
|
return passed;
|
|
25193
25653
|
};
|
|
25194
25654
|
|
|
@@ -25198,7 +25658,7 @@ var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$2);
|
|
|
25198
25658
|
|
|
25199
25659
|
var global$7 = global$p;
|
|
25200
25660
|
var apply = functionApply;
|
|
25201
|
-
var bind$
|
|
25661
|
+
var bind$2 = functionBindContext;
|
|
25202
25662
|
var isCallable$4 = isCallable$o;
|
|
25203
25663
|
var hasOwn = hasOwnProperty_1;
|
|
25204
25664
|
var fails$1 = fails$r;
|
|
@@ -25280,7 +25740,7 @@ if (!set || !clear) {
|
|
|
25280
25740
|
channel = new MessageChannel();
|
|
25281
25741
|
port = channel.port2;
|
|
25282
25742
|
channel.port1.onmessage = listener;
|
|
25283
|
-
defer = bind$
|
|
25743
|
+
defer = bind$2(port.postMessage, port);
|
|
25284
25744
|
// Browsers with postMessage, skip WebWorkers
|
|
25285
25745
|
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
|
|
25286
25746
|
} else if (
|
|
@@ -25323,7 +25783,7 @@ var userAgent = engineUserAgent;
|
|
|
25323
25783
|
var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent);
|
|
25324
25784
|
|
|
25325
25785
|
var global$5 = global$p;
|
|
25326
|
-
var bind$
|
|
25786
|
+
var bind$1 = functionBindContext;
|
|
25327
25787
|
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
|
25328
25788
|
var macrotask = task$1.set;
|
|
25329
25789
|
var IS_IOS = engineIsIos;
|
|
@@ -25375,7 +25835,7 @@ if (!queueMicrotask) {
|
|
|
25375
25835
|
promise = Promise$1.resolve(undefined);
|
|
25376
25836
|
// workaround of WebKit ~ iOS Safari 10.1 bug
|
|
25377
25837
|
promise.constructor = Promise$1;
|
|
25378
|
-
then = bind$
|
|
25838
|
+
then = bind$1(promise.then, promise);
|
|
25379
25839
|
notify$1 = function () {
|
|
25380
25840
|
then(flush);
|
|
25381
25841
|
};
|
|
@@ -25392,7 +25852,7 @@ if (!queueMicrotask) {
|
|
|
25392
25852
|
// - setTimeout
|
|
25393
25853
|
} else {
|
|
25394
25854
|
// strange IE + webpack dev server bug - use .bind(global)
|
|
25395
|
-
macrotask = bind$
|
|
25855
|
+
macrotask = bind$1(macrotask, global$5);
|
|
25396
25856
|
notify$1 = function () {
|
|
25397
25857
|
macrotask(flush);
|
|
25398
25858
|
};
|
|
@@ -25469,13 +25929,13 @@ var NativePromiseConstructor$4 = promiseNativeConstructor;
|
|
|
25469
25929
|
var isCallable$3 = isCallable$o;
|
|
25470
25930
|
var isForced = isForced_1;
|
|
25471
25931
|
var inspectSource = inspectSource$3;
|
|
25472
|
-
var wellKnownSymbol$
|
|
25932
|
+
var wellKnownSymbol$1 = wellKnownSymbol$j;
|
|
25473
25933
|
var IS_BROWSER = engineIsBrowser;
|
|
25474
25934
|
var IS_DENO = engineIsDeno;
|
|
25475
25935
|
var V8_VERSION = engineV8Version;
|
|
25476
25936
|
|
|
25477
25937
|
NativePromiseConstructor$4 && NativePromiseConstructor$4.prototype;
|
|
25478
|
-
var SPECIES = wellKnownSymbol$
|
|
25938
|
+
var SPECIES = wellKnownSymbol$1('species');
|
|
25479
25939
|
var SUBCLASSING = false;
|
|
25480
25940
|
var NATIVE_PROMISE_REJECTION_EVENT$1 = isCallable$3(global$2.PromiseRejectionEvent);
|
|
25481
25941
|
|
|
@@ -25511,19 +25971,19 @@ var promiseConstructorDetection = {
|
|
|
25511
25971
|
|
|
25512
25972
|
var newPromiseCapability$2 = {};
|
|
25513
25973
|
|
|
25514
|
-
var aCallable$
|
|
25974
|
+
var aCallable$3 = aCallable$a;
|
|
25515
25975
|
|
|
25516
|
-
var $TypeError
|
|
25976
|
+
var $TypeError = TypeError;
|
|
25517
25977
|
|
|
25518
25978
|
var PromiseCapability = function (C) {
|
|
25519
25979
|
var resolve, reject;
|
|
25520
25980
|
this.promise = new C(function ($$resolve, $$reject) {
|
|
25521
|
-
if (resolve !== undefined || reject !== undefined) throw $TypeError
|
|
25981
|
+
if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor');
|
|
25522
25982
|
resolve = $$resolve;
|
|
25523
25983
|
reject = $$reject;
|
|
25524
25984
|
});
|
|
25525
|
-
this.resolve = aCallable$
|
|
25526
|
-
this.reject = aCallable$
|
|
25985
|
+
this.resolve = aCallable$3(resolve);
|
|
25986
|
+
this.reject = aCallable$3(reject);
|
|
25527
25987
|
};
|
|
25528
25988
|
|
|
25529
25989
|
// `NewPromiseCapability` abstract operation
|
|
@@ -25535,12 +25995,12 @@ newPromiseCapability$2.f = function (C) {
|
|
|
25535
25995
|
var $$8 = _export;
|
|
25536
25996
|
var IS_NODE = engineIsNode;
|
|
25537
25997
|
var global$1 = global$p;
|
|
25538
|
-
var call$
|
|
25998
|
+
var call$3 = functionCall;
|
|
25539
25999
|
var defineBuiltIn$2 = defineBuiltIn$8;
|
|
25540
26000
|
var setPrototypeOf = objectSetPrototypeOf;
|
|
25541
26001
|
var setToStringTag = setToStringTag$3;
|
|
25542
26002
|
var setSpecies = setSpecies$1;
|
|
25543
|
-
var aCallable$
|
|
26003
|
+
var aCallable$2 = aCallable$a;
|
|
25544
26004
|
var isCallable$2 = isCallable$o;
|
|
25545
26005
|
var isObject$1 = isObject$a;
|
|
25546
26006
|
var anInstance = anInstance$1;
|
|
@@ -25613,7 +26073,7 @@ var callReaction = function (reaction, state) {
|
|
|
25613
26073
|
if (result === reaction.promise) {
|
|
25614
26074
|
reject(TypeError$1('Promise-chain cycle'));
|
|
25615
26075
|
} else if (then = isThenable(result)) {
|
|
25616
|
-
call$
|
|
26076
|
+
call$3(then, result, resolve, reject);
|
|
25617
26077
|
} else resolve(result);
|
|
25618
26078
|
} else reject(value);
|
|
25619
26079
|
} catch (error) {
|
|
@@ -25650,7 +26110,7 @@ var dispatchEvent = function (name, promise, reason) {
|
|
|
25650
26110
|
};
|
|
25651
26111
|
|
|
25652
26112
|
var onUnhandled = function (state) {
|
|
25653
|
-
call$
|
|
26113
|
+
call$3(task, global$1, function () {
|
|
25654
26114
|
var promise = state.facade;
|
|
25655
26115
|
var value = state.value;
|
|
25656
26116
|
var IS_UNHANDLED = isUnhandled(state);
|
|
@@ -25673,7 +26133,7 @@ var isUnhandled = function (state) {
|
|
|
25673
26133
|
};
|
|
25674
26134
|
|
|
25675
26135
|
var onHandleUnhandled = function (state) {
|
|
25676
|
-
call$
|
|
26136
|
+
call$3(task, global$1, function () {
|
|
25677
26137
|
var promise = state.facade;
|
|
25678
26138
|
if (IS_NODE) {
|
|
25679
26139
|
process$1.emit('rejectionHandled', promise);
|
|
@@ -25681,7 +26141,7 @@ var onHandleUnhandled = function (state) {
|
|
|
25681
26141
|
});
|
|
25682
26142
|
};
|
|
25683
26143
|
|
|
25684
|
-
var bind
|
|
26144
|
+
var bind = function (fn, state, unwrap) {
|
|
25685
26145
|
return function (value) {
|
|
25686
26146
|
fn(state, value, unwrap);
|
|
25687
26147
|
};
|
|
@@ -25707,9 +26167,9 @@ var internalResolve = function (state, value, unwrap) {
|
|
|
25707
26167
|
microtask(function () {
|
|
25708
26168
|
var wrapper = { done: false };
|
|
25709
26169
|
try {
|
|
25710
|
-
call$
|
|
25711
|
-
bind
|
|
25712
|
-
bind
|
|
26170
|
+
call$3(then, value,
|
|
26171
|
+
bind(internalResolve, wrapper, state),
|
|
26172
|
+
bind(internalReject, wrapper, state)
|
|
25713
26173
|
);
|
|
25714
26174
|
} catch (error) {
|
|
25715
26175
|
internalReject(wrapper, error, state);
|
|
@@ -25730,11 +26190,11 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
|
|
|
25730
26190
|
// 25.4.3.1 Promise(executor)
|
|
25731
26191
|
PromiseConstructor = function Promise(executor) {
|
|
25732
26192
|
anInstance(this, PromisePrototype);
|
|
25733
|
-
aCallable$
|
|
25734
|
-
call$
|
|
26193
|
+
aCallable$2(executor);
|
|
26194
|
+
call$3(Internal, this);
|
|
25735
26195
|
var state = getInternalPromiseState(this);
|
|
25736
26196
|
try {
|
|
25737
|
-
executor(bind
|
|
26197
|
+
executor(bind(internalResolve, state), bind(internalReject, state));
|
|
25738
26198
|
} catch (error) {
|
|
25739
26199
|
internalReject(state, error);
|
|
25740
26200
|
}
|
|
@@ -25776,8 +26236,8 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
|
|
|
25776
26236
|
var promise = new Internal();
|
|
25777
26237
|
var state = getInternalPromiseState(promise);
|
|
25778
26238
|
this.promise = promise;
|
|
25779
|
-
this.resolve = bind
|
|
25780
|
-
this.reject = bind
|
|
26239
|
+
this.resolve = bind(internalResolve, state);
|
|
26240
|
+
this.reject = bind(internalReject, state);
|
|
25781
26241
|
};
|
|
25782
26242
|
|
|
25783
26243
|
newPromiseCapabilityModule$3.f = newPromiseCapability$1 = function (C) {
|
|
@@ -25794,7 +26254,7 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
|
|
|
25794
26254
|
defineBuiltIn$2(NativePromisePrototype$2, 'then', function then(onFulfilled, onRejected) {
|
|
25795
26255
|
var that = this;
|
|
25796
26256
|
return new PromiseConstructor(function (resolve, reject) {
|
|
25797
|
-
call$
|
|
26257
|
+
call$3(nativeThen, that, resolve, reject);
|
|
25798
26258
|
}).then(onFulfilled, onRejected);
|
|
25799
26259
|
// https://github.com/zloirock/core-js/issues/640
|
|
25800
26260
|
}, { unsafe: true });
|
|
@@ -25812,144 +26272,12 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
|
|
|
25812
26272
|
}
|
|
25813
26273
|
}
|
|
25814
26274
|
|
|
25815
|
-
$$8({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
|
|
25816
|
-
Promise: PromiseConstructor
|
|
25817
|
-
});
|
|
25818
|
-
|
|
25819
|
-
setToStringTag(PromiseConstructor, PROMISE, false);
|
|
25820
|
-
setSpecies(PROMISE);
|
|
25821
|
-
|
|
25822
|
-
var wellKnownSymbol$2 = wellKnownSymbol$j;
|
|
25823
|
-
var Iterators$1 = iterators;
|
|
25824
|
-
|
|
25825
|
-
var ITERATOR$2 = wellKnownSymbol$2('iterator');
|
|
25826
|
-
var ArrayPrototype = Array.prototype;
|
|
25827
|
-
|
|
25828
|
-
// check on default Array iterator
|
|
25829
|
-
var isArrayIteratorMethod$1 = function (it) {
|
|
25830
|
-
return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$2] === it);
|
|
25831
|
-
};
|
|
25832
|
-
|
|
25833
|
-
var classof = classof$6;
|
|
25834
|
-
var getMethod$1 = getMethod$5;
|
|
25835
|
-
var isNullOrUndefined = isNullOrUndefined$6;
|
|
25836
|
-
var Iterators = iterators;
|
|
25837
|
-
var wellKnownSymbol$1 = wellKnownSymbol$j;
|
|
25838
|
-
|
|
25839
|
-
var ITERATOR$1 = wellKnownSymbol$1('iterator');
|
|
25840
|
-
|
|
25841
|
-
var getIteratorMethod$2 = function (it) {
|
|
25842
|
-
if (!isNullOrUndefined(it)) return getMethod$1(it, ITERATOR$1)
|
|
25843
|
-
|| getMethod$1(it, '@@iterator')
|
|
25844
|
-
|| Iterators[classof(it)];
|
|
25845
|
-
};
|
|
25846
|
-
|
|
25847
|
-
var call$5 = functionCall;
|
|
25848
|
-
var aCallable$2 = aCallable$a;
|
|
25849
|
-
var anObject$3 = anObject$f;
|
|
25850
|
-
var tryToString$1 = tryToString$5;
|
|
25851
|
-
var getIteratorMethod$1 = getIteratorMethod$2;
|
|
25852
|
-
|
|
25853
|
-
var $TypeError$1 = TypeError;
|
|
25854
|
-
|
|
25855
|
-
var getIterator$1 = function (argument, usingIterator) {
|
|
25856
|
-
var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
|
|
25857
|
-
if (aCallable$2(iteratorMethod)) return anObject$3(call$5(iteratorMethod, argument));
|
|
25858
|
-
throw $TypeError$1(tryToString$1(argument) + ' is not iterable');
|
|
25859
|
-
};
|
|
25860
|
-
|
|
25861
|
-
var call$4 = functionCall;
|
|
25862
|
-
var anObject$2 = anObject$f;
|
|
25863
|
-
var getMethod = getMethod$5;
|
|
25864
|
-
|
|
25865
|
-
var iteratorClose$1 = function (iterator, kind, value) {
|
|
25866
|
-
var innerResult, innerError;
|
|
25867
|
-
anObject$2(iterator);
|
|
25868
|
-
try {
|
|
25869
|
-
innerResult = getMethod(iterator, 'return');
|
|
25870
|
-
if (!innerResult) {
|
|
25871
|
-
if (kind === 'throw') throw value;
|
|
25872
|
-
return value;
|
|
25873
|
-
}
|
|
25874
|
-
innerResult = call$4(innerResult, iterator);
|
|
25875
|
-
} catch (error) {
|
|
25876
|
-
innerError = true;
|
|
25877
|
-
innerResult = error;
|
|
25878
|
-
}
|
|
25879
|
-
if (kind === 'throw') throw value;
|
|
25880
|
-
if (innerError) throw innerResult;
|
|
25881
|
-
anObject$2(innerResult);
|
|
25882
|
-
return value;
|
|
25883
|
-
};
|
|
25884
|
-
|
|
25885
|
-
var bind = functionBindContext;
|
|
25886
|
-
var call$3 = functionCall;
|
|
25887
|
-
var anObject$1 = anObject$f;
|
|
25888
|
-
var tryToString = tryToString$5;
|
|
25889
|
-
var isArrayIteratorMethod = isArrayIteratorMethod$1;
|
|
25890
|
-
var lengthOfArrayLike$1 = lengthOfArrayLike$8;
|
|
25891
|
-
var isPrototypeOf = objectIsPrototypeOf;
|
|
25892
|
-
var getIterator = getIterator$1;
|
|
25893
|
-
var getIteratorMethod = getIteratorMethod$2;
|
|
25894
|
-
var iteratorClose = iteratorClose$1;
|
|
25895
|
-
|
|
25896
|
-
var $TypeError = TypeError;
|
|
25897
|
-
|
|
25898
|
-
var Result = function (stopped, result) {
|
|
25899
|
-
this.stopped = stopped;
|
|
25900
|
-
this.result = result;
|
|
25901
|
-
};
|
|
25902
|
-
|
|
25903
|
-
var ResultPrototype = Result.prototype;
|
|
25904
|
-
|
|
25905
|
-
var iterate$2 = function (iterable, unboundFunction, options) {
|
|
25906
|
-
var that = options && options.that;
|
|
25907
|
-
var AS_ENTRIES = !!(options && options.AS_ENTRIES);
|
|
25908
|
-
var IS_RECORD = !!(options && options.IS_RECORD);
|
|
25909
|
-
var IS_ITERATOR = !!(options && options.IS_ITERATOR);
|
|
25910
|
-
var INTERRUPTED = !!(options && options.INTERRUPTED);
|
|
25911
|
-
var fn = bind(unboundFunction, that);
|
|
25912
|
-
var iterator, iterFn, index, length, result, next, step;
|
|
25913
|
-
|
|
25914
|
-
var stop = function (condition) {
|
|
25915
|
-
if (iterator) iteratorClose(iterator, 'normal', condition);
|
|
25916
|
-
return new Result(true, condition);
|
|
25917
|
-
};
|
|
25918
|
-
|
|
25919
|
-
var callFn = function (value) {
|
|
25920
|
-
if (AS_ENTRIES) {
|
|
25921
|
-
anObject$1(value);
|
|
25922
|
-
return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
|
|
25923
|
-
} return INTERRUPTED ? fn(value, stop) : fn(value);
|
|
25924
|
-
};
|
|
25925
|
-
|
|
25926
|
-
if (IS_RECORD) {
|
|
25927
|
-
iterator = iterable.iterator;
|
|
25928
|
-
} else if (IS_ITERATOR) {
|
|
25929
|
-
iterator = iterable;
|
|
25930
|
-
} else {
|
|
25931
|
-
iterFn = getIteratorMethod(iterable);
|
|
25932
|
-
if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable');
|
|
25933
|
-
// optimisation for array iterators
|
|
25934
|
-
if (isArrayIteratorMethod(iterFn)) {
|
|
25935
|
-
for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
|
|
25936
|
-
result = callFn(iterable[index]);
|
|
25937
|
-
if (result && isPrototypeOf(ResultPrototype, result)) return result;
|
|
25938
|
-
} return new Result(false);
|
|
25939
|
-
}
|
|
25940
|
-
iterator = getIterator(iterable, iterFn);
|
|
25941
|
-
}
|
|
25942
|
-
|
|
25943
|
-
next = IS_RECORD ? iterable.next : iterator.next;
|
|
25944
|
-
while (!(step = call$3(next, iterator)).done) {
|
|
25945
|
-
try {
|
|
25946
|
-
result = callFn(step.value);
|
|
25947
|
-
} catch (error) {
|
|
25948
|
-
iteratorClose(iterator, 'throw', error);
|
|
25949
|
-
}
|
|
25950
|
-
if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
|
|
25951
|
-
} return new Result(false);
|
|
25952
|
-
};
|
|
26275
|
+
$$8({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
|
|
26276
|
+
Promise: PromiseConstructor
|
|
26277
|
+
});
|
|
26278
|
+
|
|
26279
|
+
setToStringTag(PromiseConstructor, PROMISE, false);
|
|
26280
|
+
setSpecies(PROMISE);
|
|
25953
26281
|
|
|
25954
26282
|
var wellKnownSymbol = wellKnownSymbol$j;
|
|
25955
26283
|
|
|
@@ -26003,7 +26331,7 @@ var call$2 = functionCall;
|
|
|
26003
26331
|
var aCallable$1 = aCallable$a;
|
|
26004
26332
|
var newPromiseCapabilityModule$2 = newPromiseCapability$2;
|
|
26005
26333
|
var perform$1 = perform$3;
|
|
26006
|
-
var iterate$1 = iterate$
|
|
26334
|
+
var iterate$1 = iterate$3;
|
|
26007
26335
|
var PROMISE_STATICS_INCORRECT_ITERATION$1 = promiseStaticsIncorrectIteration;
|
|
26008
26336
|
|
|
26009
26337
|
// `Promise.all` method
|
|
@@ -26067,7 +26395,7 @@ var call$1 = functionCall;
|
|
|
26067
26395
|
var aCallable = aCallable$a;
|
|
26068
26396
|
var newPromiseCapabilityModule$1 = newPromiseCapability$2;
|
|
26069
26397
|
var perform = perform$3;
|
|
26070
|
-
var iterate = iterate$
|
|
26398
|
+
var iterate = iterate$3;
|
|
26071
26399
|
var PROMISE_STATICS_INCORRECT_ITERATION = promiseStaticsIncorrectIteration;
|
|
26072
26400
|
|
|
26073
26401
|
// `Promise.race` method
|
|
@@ -26926,16 +27254,20 @@ const AddFundsForm = ({
|
|
|
26926
27254
|
});
|
|
26927
27255
|
const {
|
|
26928
27256
|
isSubmitted,
|
|
27257
|
+
isSubmitting,
|
|
26929
27258
|
isValid
|
|
26930
27259
|
} = form.formState;
|
|
26931
27260
|
const watchAmount = form.watch("funds").amount;
|
|
26932
27261
|
const formId = "add-funds-form";
|
|
26933
|
-
const handleSubmit = formLogger.capture(form.handleSubmit(values => {
|
|
27262
|
+
const handleSubmit = formLogger.capture(form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
26934
27263
|
const payload = values;
|
|
26935
|
-
|
|
26936
|
-
|
|
26937
|
-
|
|
26938
|
-
|
|
27264
|
+
try {
|
|
27265
|
+
yield addFunds.mutateAsync(payload);
|
|
27266
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
27267
|
+
} catch (_a) {
|
|
27268
|
+
// Noop; errors available on RQ object
|
|
27269
|
+
}
|
|
27270
|
+
})));
|
|
26939
27271
|
if (carrier.isLoading) return jsx(Loader, {
|
|
26940
27272
|
message: t("loading.carrier")
|
|
26941
27273
|
});
|
|
@@ -27010,6 +27342,7 @@ const AddFundsForm = ({
|
|
|
27010
27342
|
justify: "end"
|
|
27011
27343
|
}, {
|
|
27012
27344
|
children: [onCancel && jsx(Button, Object.assign({
|
|
27345
|
+
disabled: isSubmitting,
|
|
27013
27346
|
onClick: onCancel,
|
|
27014
27347
|
variant: ButtonVariant.TEXT
|
|
27015
27348
|
}, {
|
|
@@ -27017,7 +27350,6 @@ const AddFundsForm = ({
|
|
|
27017
27350
|
})), jsx(SubmitButton, Object.assign({
|
|
27018
27351
|
control: form.control,
|
|
27019
27352
|
form: formId,
|
|
27020
|
-
isLoading: addFunds.isLoading,
|
|
27021
27353
|
variant: ButtonVariant.OUTLINED
|
|
27022
27354
|
}, {
|
|
27023
27355
|
children: t("manage-funding:actions.addNow")
|
|
@@ -27036,7 +27368,7 @@ const AddFundsForm = ({
|
|
|
27036
27368
|
}), children === null || children === void 0 ? void 0 : children({
|
|
27037
27369
|
isCustomAmount: selectedChip.value === "custom",
|
|
27038
27370
|
isSubmitted,
|
|
27039
|
-
isSubmitting
|
|
27371
|
+
isSubmitting,
|
|
27040
27372
|
isValid,
|
|
27041
27373
|
selectedAmount: watchAmount,
|
|
27042
27374
|
submit: handleSubmit
|
|
@@ -27108,6 +27440,9 @@ const LinkAction = _a => {
|
|
|
27108
27440
|
return jsx(Link, Object.assign({}, props, {
|
|
27109
27441
|
bold: true,
|
|
27110
27442
|
css: theme => [{
|
|
27443
|
+
"&&&": {
|
|
27444
|
+
textDecoration: "none"
|
|
27445
|
+
},
|
|
27111
27446
|
alignItems: "center",
|
|
27112
27447
|
display: "flex",
|
|
27113
27448
|
gap: theme.spacing(1)
|
|
@@ -27174,6 +27509,7 @@ const getStyles$1 = isCustomAmount => createStyles({
|
|
|
27174
27509
|
const FundAndPurchase = ({
|
|
27175
27510
|
carrierId,
|
|
27176
27511
|
className,
|
|
27512
|
+
control,
|
|
27177
27513
|
disabled,
|
|
27178
27514
|
isFundingEnabled,
|
|
27179
27515
|
isFundingRequired,
|
|
@@ -27189,11 +27525,11 @@ const FundAndPurchase = ({
|
|
|
27189
27525
|
data: carrier,
|
|
27190
27526
|
isLoading: isLoadingCarrier
|
|
27191
27527
|
} = useGetCarrierById(carrierId);
|
|
27192
|
-
const
|
|
27193
|
-
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27528
|
+
const {
|
|
27529
|
+
isSubmitting: isRateFormSubmitting,
|
|
27530
|
+
isValid: isRateFormValid
|
|
27531
|
+
} = useFormState({
|
|
27532
|
+
control
|
|
27197
27533
|
});
|
|
27198
27534
|
const [isSavingRate, setIsSavingRate] = useState(false);
|
|
27199
27535
|
const handleSaveRate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -27211,7 +27547,7 @@ const FundAndPurchase = ({
|
|
|
27211
27547
|
children: [jsx(Button, Object.assign({
|
|
27212
27548
|
bold: false,
|
|
27213
27549
|
css: getStyles$1().saveRateButton,
|
|
27214
|
-
disabled: disabled || !carrierId ||
|
|
27550
|
+
disabled: disabled || !carrierId || addFundsForm.isSubmitting || isRateFormSubmitting,
|
|
27215
27551
|
isLoading: isSavingRate,
|
|
27216
27552
|
onClick: handleSaveRate,
|
|
27217
27553
|
variant: ButtonVariant.OUTLINED
|
|
@@ -27219,8 +27555,8 @@ const FundAndPurchase = ({
|
|
|
27219
27555
|
children: t("purchase-label:actions.saveRate")
|
|
27220
27556
|
})), jsx(Button, Object.assign({
|
|
27221
27557
|
"data-testid": "submit-fund-and-purchase",
|
|
27222
|
-
disabled: disabled || !carrierId || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
|
|
27223
|
-
isLoading: addFundsForm.isSubmitting ||
|
|
27558
|
+
disabled: disabled || !carrierId || !isRateFormValid || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
|
|
27559
|
+
isLoading: addFundsForm.isSubmitting || isRateFormSubmitting,
|
|
27224
27560
|
onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
|
|
27225
27561
|
}, {
|
|
27226
27562
|
children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
|
|
@@ -27239,10 +27575,6 @@ const FundAndPurchase = ({
|
|
|
27239
27575
|
});
|
|
27240
27576
|
if (!carrier || !carrierId) throw new Error("errorMessages.unableToLoad.carrier");
|
|
27241
27577
|
const balance = carrier.balance;
|
|
27242
|
-
const handleAddFundsSuccess = () => {
|
|
27243
|
-
setIsAddFundsFormOpen(false);
|
|
27244
|
-
onPurchase();
|
|
27245
|
-
};
|
|
27246
27578
|
// Render: walleted carrier, but funding feature is not enabled;
|
|
27247
27579
|
// show balance, but not the funding form.
|
|
27248
27580
|
if (!isFundingEnabled) return jsxs("div", Object.assign({
|
|
@@ -27266,7 +27598,7 @@ const FundAndPurchase = ({
|
|
|
27266
27598
|
carrierId: carrierId
|
|
27267
27599
|
}), jsx(LinkAction, {
|
|
27268
27600
|
icon: "add",
|
|
27269
|
-
isDisabled: isAddFundsFormOpen ||
|
|
27601
|
+
isDisabled: isAddFundsFormOpen || isRateFormSubmitting,
|
|
27270
27602
|
onClick: () => setIsAddFundsFormOpen(true),
|
|
27271
27603
|
title: t("manage-funding:actions.addFunds")
|
|
27272
27604
|
})]
|
|
@@ -27284,7 +27616,7 @@ const FundAndPurchase = ({
|
|
|
27284
27616
|
}), isAddFundsFormOpen ? jsx(AddFundsForm, Object.assign({
|
|
27285
27617
|
carrierId: carrierId,
|
|
27286
27618
|
minimumAmount: purchaseAmount - balance,
|
|
27287
|
-
onSuccess:
|
|
27619
|
+
onSuccess: onPurchase
|
|
27288
27620
|
}, {
|
|
27289
27621
|
children: addFundsForm => {
|
|
27290
27622
|
var _a, _b;
|
|
@@ -27318,6 +27650,7 @@ const FundAndPurchase = ({
|
|
|
27318
27650
|
justify: "end"
|
|
27319
27651
|
}, {
|
|
27320
27652
|
children: jsx(Button, Object.assign({
|
|
27653
|
+
disabled: addFundsForm.isSubmitting || isRateFormSubmitting,
|
|
27321
27654
|
onClick: () => setIsAddFundsFormOpen(false),
|
|
27322
27655
|
variant: ButtonVariant.TEXT
|
|
27323
27656
|
}, {
|
|
@@ -27329,7 +27662,7 @@ const FundAndPurchase = ({
|
|
|
27329
27662
|
}), renderActionButtons(addFundsForm)]
|
|
27330
27663
|
});
|
|
27331
27664
|
}
|
|
27332
|
-
})) : renderActionButtons()]
|
|
27665
|
+
}), purchaseAmount) : renderActionButtons()]
|
|
27333
27666
|
}));
|
|
27334
27667
|
};
|
|
27335
27668
|
|
|
@@ -27379,6 +27712,7 @@ const RateForm = ({
|
|
|
27379
27712
|
const {
|
|
27380
27713
|
t
|
|
27381
27714
|
} = useTranslation();
|
|
27715
|
+
const queryClient = useQueryClient();
|
|
27382
27716
|
const rateFormScrollToRef = useRef(null);
|
|
27383
27717
|
const [showHiddenRates, setShowHiddenRates] = useState(false);
|
|
27384
27718
|
const form = useForm({
|
|
@@ -27396,7 +27730,18 @@ const RateForm = ({
|
|
|
27396
27730
|
} = form.watch("rate");
|
|
27397
27731
|
const handleSubmit = formLogger.capture(form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
27398
27732
|
const rateId = values;
|
|
27399
|
-
|
|
27733
|
+
try {
|
|
27734
|
+
yield onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(rateId);
|
|
27735
|
+
} finally {
|
|
27736
|
+
// Invalidate carrier queries after the rate form is submitted, regardless of success.
|
|
27737
|
+
// This allows the carrier balance to refresh if the purchase failed but funding succeeded.
|
|
27738
|
+
queryClient.invalidateQueries(["useGetCarrierById", selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId], {
|
|
27739
|
+
exact: true
|
|
27740
|
+
});
|
|
27741
|
+
queryClient.invalidateQueries(["useListCarriers"], {
|
|
27742
|
+
exact: true
|
|
27743
|
+
});
|
|
27744
|
+
}
|
|
27400
27745
|
})));
|
|
27401
27746
|
const rateOptions = useRateOptions(rates, carriers, shipment, features.enableGlobalPostFiltering
|
|
27402
27747
|
// TODO: LMNT-677: fix RecommendedRate logic
|
|
@@ -27513,6 +27858,7 @@ const RateForm = ({
|
|
|
27513
27858
|
})]
|
|
27514
27859
|
})), jsx(FundAndPurchase, {
|
|
27515
27860
|
carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
|
|
27861
|
+
control: form.control,
|
|
27516
27862
|
css: styles.fundAndPurchase,
|
|
27517
27863
|
disabled: disabled,
|
|
27518
27864
|
isFundingEnabled: features === null || features === void 0 ? void 0 : features.enableFunding,
|
|
@@ -27948,7 +28294,7 @@ const getShipmentSchema = ({
|
|
|
27948
28294
|
}).nullish(),
|
|
27949
28295
|
shipDate: z.string(),
|
|
27950
28296
|
shipmentId: z.string().nullishDefault(undefined),
|
|
27951
|
-
warehouseId: z.string().refine(warehouseId => {
|
|
28297
|
+
warehouseId: z.string().refine(warehouseId => !!warehouseId, "purchase-label:schemaErrors.shipFromAddressRequired").refine(warehouseId => {
|
|
27952
28298
|
var _a;
|
|
27953
28299
|
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";
|
|
27954
28300
|
}, "purchase-label:schemaErrors.shipFromUnitedStatesOnly")
|
|
@@ -28221,9 +28567,10 @@ const ShipmentForm = ({
|
|
|
28221
28567
|
// When shipment is first loaded, hydrate the entire form
|
|
28222
28568
|
useRunOnceOnTrue(shipment && (() => hydrateShipment(shipment)));
|
|
28223
28569
|
useEffect(() => {
|
|
28224
|
-
var _a, _b;
|
|
28570
|
+
var _a, _b, _c, _d;
|
|
28225
28571
|
if (!shipment && (warehouses === null || warehouses === void 0 ? void 0 : warehouses.length)) {
|
|
28226
|
-
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;
|
|
28572
|
+
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;
|
|
28573
|
+
// There will always be a default warehouse, but TS doesn't know that
|
|
28227
28574
|
form.setValue("warehouseId", defaultWarehouse);
|
|
28228
28575
|
}
|
|
28229
28576
|
}, [form, shipment, warehouseId, warehouses]);
|
|
@@ -29115,7 +29462,9 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
29115
29462
|
styles: styles$2,
|
|
29116
29463
|
billingAddressSchema: billingAddressSchema,
|
|
29117
29464
|
walletSchema: walletSchema,
|
|
29118
|
-
BillingFields: BillingFields
|
|
29465
|
+
BillingFields: BillingFields,
|
|
29466
|
+
WarehousePreferenceWizard: WarehousePreferenceWizard,
|
|
29467
|
+
WarehousePreferenceSelect: WarehousePreferenceSelect
|
|
29119
29468
|
});
|
|
29120
29469
|
|
|
29121
29470
|
const getStyles = showForm => createStyles({
|
|
@@ -29390,6 +29739,7 @@ const ManageFunding = ({
|
|
|
29390
29739
|
const {
|
|
29391
29740
|
t
|
|
29392
29741
|
} = useTranslation();
|
|
29742
|
+
const queryClient = useQueryClient();
|
|
29393
29743
|
const {
|
|
29394
29744
|
isLoading: isLoadingCarrier
|
|
29395
29745
|
} = useGetCarrierById(carrierId);
|
|
@@ -29412,7 +29762,15 @@ const ManageFunding = ({
|
|
|
29412
29762
|
multiplier: 2
|
|
29413
29763
|
}), jsx(AddFundsForm, {
|
|
29414
29764
|
carrierId: carrierId,
|
|
29415
|
-
onCancel: () => setIsAddFundsFormOpen(false)
|
|
29765
|
+
onCancel: () => setIsAddFundsFormOpen(false),
|
|
29766
|
+
onSuccess: () => {
|
|
29767
|
+
queryClient.invalidateQueries(["useGetCarrierById", carrierId], {
|
|
29768
|
+
exact: true
|
|
29769
|
+
});
|
|
29770
|
+
queryClient.invalidateQueries(["useListCarriers"], {
|
|
29771
|
+
exact: true
|
|
29772
|
+
});
|
|
29773
|
+
}
|
|
29416
29774
|
})]
|
|
29417
29775
|
}), jsx(Spacer, {
|
|
29418
29776
|
multiplier: 2
|
|
@@ -30381,8 +30739,10 @@ var common = {
|
|
|
30381
30739
|
},
|
|
30382
30740
|
paste: "Paste Address",
|
|
30383
30741
|
preference: {
|
|
30742
|
+
confirm: "Confirm",
|
|
30384
30743
|
addressNotValidated: "Address not validated",
|
|
30385
30744
|
modified: "modified",
|
|
30745
|
+
title: "To ensure accurate rate estimation, consider the changes suggested below.",
|
|
30386
30746
|
originalAddress: "Original Address",
|
|
30387
30747
|
matchedAddress: "Suggested Address",
|
|
30388
30748
|
unableToValidate: "We were not able to validate this address. It might result in delays in your delivery.",
|
|
@@ -30643,6 +31003,7 @@ var manageFunding = {
|
|
|
30643
31003
|
var manageWarehouses = {
|
|
30644
31004
|
"manage-warehouses": {
|
|
30645
31005
|
addNew: "Add New Address",
|
|
31006
|
+
editWarehouse: "Edit Address",
|
|
30646
31007
|
contactName: "Contact Name",
|
|
30647
31008
|
"default": "Default",
|
|
30648
31009
|
isDefault: "Set as default Ship From address",
|
|
@@ -30757,6 +31118,7 @@ var purchaseLabel = {
|
|
|
30757
31118
|
},
|
|
30758
31119
|
schemaErrors: {
|
|
30759
31120
|
shipFromUnitedStatesOnly: "Only US addresses are supported in this view",
|
|
31121
|
+
shipFromAddressRequired: "Ship From address is required",
|
|
30760
31122
|
needToAcknowledge: "Need to accept Rate Compliance Agreement"
|
|
30761
31123
|
},
|
|
30762
31124
|
rates: {
|
|
@@ -31155,7 +31517,9 @@ const ListCarriers = () => {
|
|
|
31155
31517
|
|
|
31156
31518
|
const Element$5 = registerElement("list-carriers", ListCarriers);
|
|
31157
31519
|
|
|
31158
|
-
const ManageWarehouses = (
|
|
31520
|
+
const ManageWarehouses = ({
|
|
31521
|
+
onWarehouseAddressValidation
|
|
31522
|
+
}) => {
|
|
31159
31523
|
const {
|
|
31160
31524
|
t
|
|
31161
31525
|
} = useTranslation();
|
|
@@ -31177,6 +31541,12 @@ const ManageWarehouses = () => {
|
|
|
31177
31541
|
error: deleteWarehouseErrors,
|
|
31178
31542
|
mutateAsync: deleteWarehouse
|
|
31179
31543
|
} = useDeleteWarehouse();
|
|
31544
|
+
const {
|
|
31545
|
+
errors: validateWarehouseErrors,
|
|
31546
|
+
validate: validateWarehouse,
|
|
31547
|
+
warehousePreference,
|
|
31548
|
+
setWarehousePreference
|
|
31549
|
+
} = useWarehouseValidation();
|
|
31180
31550
|
const handleDeleteWarehouse = warehouseId => __awaiter(void 0, void 0, void 0, function* () {
|
|
31181
31551
|
yield deleteWarehouse({
|
|
31182
31552
|
warehouseId
|
|
@@ -31210,13 +31580,16 @@ const ManageWarehouses = () => {
|
|
|
31210
31580
|
if (listWarehouseErrors) throw new Error(listWarehouseErrors.map(e => e.message).join(", "));
|
|
31211
31581
|
throw new Error("errorMessages.unableToLoad.warehouses");
|
|
31212
31582
|
}
|
|
31213
|
-
const errors = [...(updateWarehouseErrors !== null && updateWarehouseErrors !== void 0 ? updateWarehouseErrors : []), ...(createWarehouseErrors !== null && createWarehouseErrors !== void 0 ? createWarehouseErrors : []), ...(deleteWarehouseErrors !== null && deleteWarehouseErrors !== void 0 ? deleteWarehouseErrors : [])];
|
|
31583
|
+
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 : [])];
|
|
31214
31584
|
return jsx(ManageWarehouses$1, {
|
|
31215
31585
|
errors: errors,
|
|
31216
31586
|
onAdd: handleSubmitAddNewWarehouse,
|
|
31217
31587
|
onDelete: handleDeleteWarehouse,
|
|
31218
31588
|
onEdit: handleSubmitEditWarehouse,
|
|
31219
31589
|
onSetDefault: handleSetDefault,
|
|
31590
|
+
onValidate: validateWarehouse,
|
|
31591
|
+
setWarehousePreference: setWarehousePreference,
|
|
31592
|
+
warehousePreference: warehousePreference,
|
|
31220
31593
|
warehouses: warehouses
|
|
31221
31594
|
});
|
|
31222
31595
|
};
|
|
@@ -31532,18 +31905,16 @@ const useRequestRates = ({
|
|
|
31532
31905
|
if (result) yield onRatesCalculated === null || onRatesCalculated === void 0 ? void 0 : onRatesCalculated(result.rateResponse.rates, shipment);
|
|
31533
31906
|
}), [calculateRates, carriers, customPackageTypes, onRatesCalculated]);
|
|
31534
31907
|
let ratesResponse = ratedShipment === null || ratedShipment === void 0 ? void 0 : ratedShipment.rateResponse;
|
|
31535
|
-
|
|
31536
|
-
ratesResponse
|
|
31537
|
-
|
|
31538
|
-
|
|
31539
|
-
|
|
31540
|
-
|
|
31541
|
-
|
|
31542
|
-
|
|
31543
|
-
|
|
31544
|
-
|
|
31545
|
-
});
|
|
31546
|
-
}
|
|
31908
|
+
ratesResponse = useMemo(() => ratesResponse && Object.assign(Object.assign({}, ratesResponse), {
|
|
31909
|
+
rates: ratesResponse.rates.map(rate => {
|
|
31910
|
+
var _a, _b;
|
|
31911
|
+
return Object.assign(Object.assign({}, rate), {
|
|
31912
|
+
warningMessages: [
|
|
31913
|
+
// add additional rateMessages based on combinations of serviceCode and packageType
|
|
31914
|
+
...((_a = rateMessages[`${rate.serviceCode}:${rate.packageType}`]) !== null && _a !== void 0 ? _a : []), ...((_b = rateMessages[rate.serviceCode]) !== null && _b !== void 0 ? _b : []), ...rate.warningMessages]
|
|
31915
|
+
});
|
|
31916
|
+
})
|
|
31917
|
+
}), [ratesResponse]);
|
|
31547
31918
|
return {
|
|
31548
31919
|
ratesCalculating,
|
|
31549
31920
|
ratesErrors,
|
|
@@ -32219,717 +32590,4 @@ const Element$1 = registerElement("view-shipment", Shipment);
|
|
|
32219
32590
|
|
|
32220
32591
|
const Element = registerElement("void-label", VoidLabel);
|
|
32221
32592
|
|
|
32222
|
-
|
|
32223
|
-
* @category Factories
|
|
32224
|
-
*/
|
|
32225
|
-
const addressFactory = Factory.define(({
|
|
32226
|
-
params,
|
|
32227
|
-
transientParams
|
|
32228
|
-
}) => {
|
|
32229
|
-
var _a, _b, _c, _d;
|
|
32230
|
-
const addressLine2 = (_a = params.addressLine2) !== null && _a !== void 0 ? _a : faker.helpers.maybe(faker.address.secondaryAddress, {
|
|
32231
|
-
probability: 0.25
|
|
32232
|
-
});
|
|
32233
|
-
const addressLine3 = (_b = params.addressLine3) !== null && _b !== void 0 ? _b : addressLine2 && faker.helpers.maybe(faker.address.secondaryAddress);
|
|
32234
|
-
let countryCode = (_c = params.countryCode) !== null && _c !== void 0 ? _c : "US";
|
|
32235
|
-
// Random country code could still be US
|
|
32236
|
-
while (transientParams.isInternational && countryCode === "US") {
|
|
32237
|
-
countryCode = faker.address.countryCode();
|
|
32238
|
-
}
|
|
32239
|
-
const stateProvince = (_d = params.stateProvince) !== null && _d !== void 0 ? _d : faker.address.stateAbbr();
|
|
32240
|
-
return {
|
|
32241
|
-
addressLine1: faker.address.streetAddress(),
|
|
32242
|
-
addressLine2,
|
|
32243
|
-
addressLine3,
|
|
32244
|
-
addressResidentialIndicator: faker.helpers.maybe(() => faker.helpers.arrayElement(["yes", "no"])),
|
|
32245
|
-
cityLocality: faker.address.city(),
|
|
32246
|
-
companyName: faker.helpers.maybe(faker.company.name),
|
|
32247
|
-
countryCode,
|
|
32248
|
-
name: faker.name.fullName(),
|
|
32249
|
-
phone: faker.phone.number(),
|
|
32250
|
-
postalCode: faker.address.zipCodeByState(stateProvince),
|
|
32251
|
-
stateProvince
|
|
32252
|
-
};
|
|
32253
|
-
});
|
|
32254
|
-
/**
|
|
32255
|
-
* @category Factories
|
|
32256
|
-
*/
|
|
32257
|
-
const addressValidationFactory = Factory.define(({
|
|
32258
|
-
associations,
|
|
32259
|
-
params
|
|
32260
|
-
}) => {
|
|
32261
|
-
var _a, _b;
|
|
32262
|
-
const status = params.status || faker.helpers.arrayElement(["unverified", "verified", "warning", "error"]);
|
|
32263
|
-
return {
|
|
32264
|
-
matchedAddress: (_a = associations.matchedAddress) !== null && _a !== void 0 ? _a : faker.helpers.maybe(() => addressFactory.build(), {
|
|
32265
|
-
probability: ["verified", "error"].includes(status) ? 0 : 0.8
|
|
32266
|
-
}),
|
|
32267
|
-
messages: [],
|
|
32268
|
-
originalAddress: (_b = associations.originalAddress) !== null && _b !== void 0 ? _b : addressFactory.build(),
|
|
32269
|
-
status
|
|
32270
|
-
};
|
|
32271
|
-
});
|
|
32272
|
-
/**
|
|
32273
|
-
* Mock the addressValidation object used to hyrdate address valiation feature
|
|
32274
|
-
* on the shipment form.
|
|
32275
|
-
* @category Factory
|
|
32276
|
-
*/
|
|
32277
|
-
const addressPreferenceFactory = Factory.define(({
|
|
32278
|
-
associations,
|
|
32279
|
-
params
|
|
32280
|
-
}) => {
|
|
32281
|
-
const addressValidation = addressValidationFactory.build({
|
|
32282
|
-
status: params.status
|
|
32283
|
-
}, {
|
|
32284
|
-
associations: {
|
|
32285
|
-
matchedAddress: addressFactory.build()
|
|
32286
|
-
}
|
|
32287
|
-
});
|
|
32288
|
-
if (!addressValidation.matchedAddress) throw new Error("addressPreferenceFactory did not generate a matchedAddress");
|
|
32289
|
-
return Object.assign(Object.assign({}, addressValidation), {
|
|
32290
|
-
alternative: addressValidation.originalAddress,
|
|
32291
|
-
alternativeSource: "originalAddress",
|
|
32292
|
-
isModified: true,
|
|
32293
|
-
selection: addressValidation.matchedAddress,
|
|
32294
|
-
selectionSource: "matchedAddress",
|
|
32295
|
-
toggle: () => addressFactory.build()
|
|
32296
|
-
});
|
|
32297
|
-
});
|
|
32298
|
-
|
|
32299
|
-
const randomShipengineId = (length = 5) => `se-${faker.random.numeric(length)}`;
|
|
32300
|
-
const randomShipengineSlug = wordCount => faker.lorem.slug(wordCount).replace("-", "_");
|
|
32301
|
-
const tristateValue = (ifTrue, ifFalse, ifUndefined, value) => {
|
|
32302
|
-
if (value === undefined) {
|
|
32303
|
-
return ifUndefined;
|
|
32304
|
-
}
|
|
32305
|
-
if (value) {
|
|
32306
|
-
return ifTrue;
|
|
32307
|
-
}
|
|
32308
|
-
return ifFalse;
|
|
32309
|
-
};
|
|
32310
|
-
|
|
32311
|
-
/**
|
|
32312
|
-
* @category Factories
|
|
32313
|
-
*/
|
|
32314
|
-
const packageFactory = Factory.define(({
|
|
32315
|
-
transientParams
|
|
32316
|
-
}) => ({
|
|
32317
|
-
description: faker.lorem.sentence(),
|
|
32318
|
-
dimensions: (transientParams === null || transientParams === void 0 ? void 0 : transientParams.noDimensions) ? undefined : {
|
|
32319
|
-
height: faker.datatype.number({
|
|
32320
|
-
max: 50,
|
|
32321
|
-
min: 1,
|
|
32322
|
-
precision: 0.1
|
|
32323
|
-
}),
|
|
32324
|
-
length: faker.datatype.number({
|
|
32325
|
-
max: 50,
|
|
32326
|
-
min: 1,
|
|
32327
|
-
precision: 0.1
|
|
32328
|
-
}),
|
|
32329
|
-
unit: faker.helpers.arrayElement(["inch", "centimeter"]),
|
|
32330
|
-
width: faker.datatype.number({
|
|
32331
|
-
max: 50,
|
|
32332
|
-
min: 1,
|
|
32333
|
-
precision: 0.1
|
|
32334
|
-
})
|
|
32335
|
-
},
|
|
32336
|
-
name: faker.random.words(),
|
|
32337
|
-
packageCode: randomShipengineSlug(2),
|
|
32338
|
-
packageId: randomShipengineSlug(3)
|
|
32339
|
-
}));
|
|
32340
|
-
|
|
32341
|
-
/**
|
|
32342
|
-
* @category Factories
|
|
32343
|
-
*/
|
|
32344
|
-
const serviceFactory = Factory.define(({
|
|
32345
|
-
params,
|
|
32346
|
-
transientParams
|
|
32347
|
-
}) => {
|
|
32348
|
-
var _a, _b, _c, _d;
|
|
32349
|
-
const international = params.international || faker.datatype.boolean();
|
|
32350
|
-
return {
|
|
32351
|
-
carrierCode: (_b = (_a = transientParams.carrier) === null || _a === void 0 ? void 0 : _a.carrierCode) !== null && _b !== void 0 ? _b : randomShipengineSlug(),
|
|
32352
|
-
carrierId: (_d = (_c = transientParams.carrier) === null || _c === void 0 ? void 0 : _c.carrierId) !== null && _d !== void 0 ? _d : randomShipengineId(),
|
|
32353
|
-
domestic: faker.datatype.boolean() || !international,
|
|
32354
|
-
international,
|
|
32355
|
-
isMultiPackageSupported: faker.datatype.boolean(),
|
|
32356
|
-
name: faker.random.words(),
|
|
32357
|
-
serviceCode: randomShipengineSlug()
|
|
32358
|
-
};
|
|
32359
|
-
});
|
|
32360
|
-
|
|
32361
|
-
/**
|
|
32362
|
-
* @category Factories
|
|
32363
|
-
*/
|
|
32364
|
-
const carrierOptionFactory = Factory.define(() => ({
|
|
32365
|
-
defaultValue: faker.random.word().toLowerCase(),
|
|
32366
|
-
description: faker.random.words(),
|
|
32367
|
-
name: faker.random.word()
|
|
32368
|
-
}));
|
|
32369
|
-
/**
|
|
32370
|
-
* @category Factories
|
|
32371
|
-
*/
|
|
32372
|
-
const carrierFactory = Factory.define(({
|
|
32373
|
-
associations,
|
|
32374
|
-
params,
|
|
32375
|
-
sequence
|
|
32376
|
-
}) => {
|
|
32377
|
-
const carrierCode = params.carrierCode || randomShipengineSlug();
|
|
32378
|
-
const carrierId = params.carrierId || `se-${10000 + sequence}`;
|
|
32379
|
-
return {
|
|
32380
|
-
accountNumber: faker.random.numeric(9),
|
|
32381
|
-
balance: faker.datatype.number({
|
|
32382
|
-
max: 0,
|
|
32383
|
-
min: 0,
|
|
32384
|
-
precision: 0.01
|
|
32385
|
-
}),
|
|
32386
|
-
carrierCode,
|
|
32387
|
-
carrierId,
|
|
32388
|
-
friendlyName: faker.company.name(),
|
|
32389
|
-
hasMultiPackageSupportingServices: faker.datatype.boolean(),
|
|
32390
|
-
nickname: faker.random.words(3),
|
|
32391
|
-
options: associations.options || [],
|
|
32392
|
-
packages: associations.packages || packageFactory.buildList(faker.datatype.number({
|
|
32393
|
-
max: 10,
|
|
32394
|
-
min: 1
|
|
32395
|
-
}), {}, {
|
|
32396
|
-
transient: {
|
|
32397
|
-
noDimensions: true
|
|
32398
|
-
}
|
|
32399
|
-
}),
|
|
32400
|
-
primary: false,
|
|
32401
|
-
requiresFundedAmount: false,
|
|
32402
|
-
services: associations.services || serviceFactory.buildList(faker.datatype.number({
|
|
32403
|
-
max: 10,
|
|
32404
|
-
min: 1
|
|
32405
|
-
}), {
|
|
32406
|
-
carrierCode,
|
|
32407
|
-
carrierId
|
|
32408
|
-
}),
|
|
32409
|
-
supportsLabelMessages: faker.datatype.boolean()
|
|
32410
|
-
};
|
|
32411
|
-
});
|
|
32412
|
-
|
|
32413
|
-
/**
|
|
32414
|
-
* @category Factories
|
|
32415
|
-
*/
|
|
32416
|
-
const moneyFactory = Factory.define(({
|
|
32417
|
-
transientParams
|
|
32418
|
-
}) => ({
|
|
32419
|
-
amount: faker.datatype.number({
|
|
32420
|
-
max: 1000,
|
|
32421
|
-
min: 5,
|
|
32422
|
-
precision: 0.01
|
|
32423
|
-
}),
|
|
32424
|
-
currency: (transientParams === null || transientParams === void 0 ? void 0 : transientParams.isInternational) ? faker.helpers.arrayElement(Object.values(SE.Currency)) : SE.Currency.USD
|
|
32425
|
-
}));
|
|
32426
|
-
|
|
32427
|
-
const randomOrderSourceCode = () => 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"]);
|
|
32428
|
-
/**
|
|
32429
|
-
* @category Factories
|
|
32430
|
-
*/
|
|
32431
|
-
const orderSourceRefreshInfoFactory = Factory.define(() => {
|
|
32432
|
-
const lastRefreshAttempt = faker.date.recent();
|
|
32433
|
-
return {
|
|
32434
|
-
lastRefreshAttempt: lastRefreshAttempt.toISOString(),
|
|
32435
|
-
refreshDate: faker.date.recent(1, lastRefreshAttempt).toISOString(),
|
|
32436
|
-
status: faker.helpers.arrayElement(["idle", "preparing_update", "updating", "error", "unknown"])
|
|
32437
|
-
};
|
|
32438
|
-
});
|
|
32439
|
-
/**
|
|
32440
|
-
* @category Factories
|
|
32441
|
-
*/
|
|
32442
|
-
const orderSourceFactory = Factory.define(({
|
|
32443
|
-
associations,
|
|
32444
|
-
params
|
|
32445
|
-
}) => {
|
|
32446
|
-
var _a;
|
|
32447
|
-
return {
|
|
32448
|
-
active: faker.datatype.boolean(),
|
|
32449
|
-
orderSourceCode: randomOrderSourceCode(),
|
|
32450
|
-
orderSourceFriendlyName: faker.company.name(),
|
|
32451
|
-
orderSourceId: faker.datatype.uuid(),
|
|
32452
|
-
orderSourceNickname: faker.random.words(),
|
|
32453
|
-
refreshInfo: (_a = associations.refreshInfo) !== null && _a !== void 0 ? _a : orderSourceRefreshInfoFactory.build(params.refreshInfo)
|
|
32454
|
-
};
|
|
32455
|
-
});
|
|
32456
|
-
|
|
32457
|
-
/**
|
|
32458
|
-
* @category Factories
|
|
32459
|
-
*/
|
|
32460
|
-
const downloadFactory = Factory.define(() => ({
|
|
32461
|
-
href: faker.internet.url(),
|
|
32462
|
-
pdf: faker.internet.url(),
|
|
32463
|
-
png: faker.internet.url(),
|
|
32464
|
-
zpl: faker.internet.url()
|
|
32465
|
-
}));
|
|
32466
|
-
/**
|
|
32467
|
-
* @category Factories
|
|
32468
|
-
*/
|
|
32469
|
-
const linkedResourceFactory = Factory.define(() => ({
|
|
32470
|
-
href: faker.internet.url(),
|
|
32471
|
-
type: faker.word.noun()
|
|
32472
|
-
}));
|
|
32473
|
-
|
|
32474
|
-
const randomWeightUnit = () => faker.helpers.arrayElement(["pound", "ounce", "gram", "kilogram"]);
|
|
32475
|
-
/**
|
|
32476
|
-
* @category Factories
|
|
32477
|
-
*/
|
|
32478
|
-
const fractionalWeightFactory = Factory.define(() => ({
|
|
32479
|
-
fractional: faker.datatype.number({
|
|
32480
|
-
max: 16,
|
|
32481
|
-
min: 0
|
|
32482
|
-
}),
|
|
32483
|
-
whole: faker.datatype.number({
|
|
32484
|
-
max: 20,
|
|
32485
|
-
min: 0
|
|
32486
|
-
})
|
|
32487
|
-
}));
|
|
32488
|
-
/**
|
|
32489
|
-
* @category Factories
|
|
32490
|
-
*/
|
|
32491
|
-
const weightFactory = Factory.define(() => ({
|
|
32492
|
-
value: faker.datatype.number({
|
|
32493
|
-
max: 20,
|
|
32494
|
-
min: 1,
|
|
32495
|
-
precision: 0.1
|
|
32496
|
-
})
|
|
32497
|
-
}));
|
|
32498
|
-
/**
|
|
32499
|
-
* @category Factories
|
|
32500
|
-
*/
|
|
32501
|
-
const weightWithUnitFactory = Factory.define(({
|
|
32502
|
-
params
|
|
32503
|
-
}) => {
|
|
32504
|
-
const weight = weightFactory.build(params);
|
|
32505
|
-
return Object.assign(Object.assign({}, weight), {
|
|
32506
|
-
unit: randomWeightUnit()
|
|
32507
|
-
});
|
|
32508
|
-
});
|
|
32509
|
-
|
|
32510
|
-
const randomDeliveryConfirmation = () => faker.helpers.arrayElement(Object.values(SE.ConfirmationType));
|
|
32511
|
-
const randomInsuranceProvider = (allowNone = true) => {
|
|
32512
|
-
const availableProviders = Object.values(SE.InsuranceProviderType).filter(p => allowNone ? p : p !== "none");
|
|
32513
|
-
return faker.helpers.arrayElement(availableProviders);
|
|
32514
|
-
};
|
|
32515
|
-
/**
|
|
32516
|
-
* @category Factories
|
|
32517
|
-
*/
|
|
32518
|
-
const customsItemFactory = Factory.define(({
|
|
32519
|
-
associations,
|
|
32520
|
-
params,
|
|
32521
|
-
transientParams
|
|
32522
|
-
}) => ({
|
|
32523
|
-
countryOfOrigin: faker.address.countryCode(),
|
|
32524
|
-
description: faker.commerce.productName(),
|
|
32525
|
-
harmonizedTariffCode: faker.datatype.string(),
|
|
32526
|
-
quantity: faker.datatype.number({
|
|
32527
|
-
max: 10,
|
|
32528
|
-
min: 1
|
|
32529
|
-
}),
|
|
32530
|
-
sku: faker.random.numeric(10),
|
|
32531
|
-
skuDescription: faker.helpers.maybe(faker.lorem.sentence),
|
|
32532
|
-
unitOfMeasure: faker.helpers.maybe(faker.word.noun),
|
|
32533
|
-
value: associations.value || faker.datatype.number({
|
|
32534
|
-
max: 10,
|
|
32535
|
-
min: 1
|
|
32536
|
-
})
|
|
32537
|
-
}));
|
|
32538
|
-
/**
|
|
32539
|
-
* @category Factories
|
|
32540
|
-
*/
|
|
32541
|
-
const shipmentItemFactory = Factory.define(({
|
|
32542
|
-
params
|
|
32543
|
-
}) => ({
|
|
32544
|
-
asin: faker.helpers.maybe(() => faker.random.alphaNumeric(10)),
|
|
32545
|
-
externalOrderId: faker.random.alphaNumeric(10),
|
|
32546
|
-
externalOrderItemId: faker.random.alphaNumeric(10),
|
|
32547
|
-
name: faker.commerce.productName(),
|
|
32548
|
-
orderSourceCode: randomOrderSourceCode(),
|
|
32549
|
-
quantity: faker.datatype.number({
|
|
32550
|
-
max: 10,
|
|
32551
|
-
min: 1
|
|
32552
|
-
}),
|
|
32553
|
-
salesOrderItemId: params.salesOrderId && faker.random.alphaNumeric(6),
|
|
32554
|
-
sku: faker.random.numeric(10)
|
|
32555
|
-
}));
|
|
32556
|
-
/**
|
|
32557
|
-
* @category Factories
|
|
32558
|
-
*/
|
|
32559
|
-
const shipmentPackageFactory = Factory.define(({
|
|
32560
|
-
associations,
|
|
32561
|
-
params,
|
|
32562
|
-
transientParams
|
|
32563
|
-
}) => {
|
|
32564
|
-
var _a, _b, _c, _d, _e;
|
|
32565
|
-
const _f = packageFactory.build(params),
|
|
32566
|
-
pkg = __rest(_f, ["name"]);
|
|
32567
|
-
const isInsured = tristateValue(true, false, faker.datatype.boolean(), (_b = (_a = params.insuredValue) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : transientParams.isInsured);
|
|
32568
|
-
return Object.assign(Object.assign({}, pkg), {
|
|
32569
|
-
insuredValue: (_c = associations.insuredValue) !== null && _c !== void 0 ? _c : isInsured ? moneyFactory.build(params.insuredValue) : undefined,
|
|
32570
|
-
labelDownload: (_d = associations.labelDownload) !== null && _d !== void 0 ? _d : transientParams.isShipped ? downloadFactory.build(params.labelDownload) : undefined,
|
|
32571
|
-
labelMessages: associations.labelMessages,
|
|
32572
|
-
trackingNumber: transientParams.isShipped ? faker.random.alphaNumeric(12, {
|
|
32573
|
-
casing: "upper"
|
|
32574
|
-
}) : undefined,
|
|
32575
|
-
weight: (_e = associations.weight) !== null && _e !== void 0 ? _e : weightWithUnitFactory.build(params.weight)
|
|
32576
|
-
});
|
|
32577
|
-
});
|
|
32578
|
-
/**
|
|
32579
|
-
* @category Factories
|
|
32580
|
-
*/
|
|
32581
|
-
const shipmentFactory = Factory.define(({
|
|
32582
|
-
associations,
|
|
32583
|
-
params,
|
|
32584
|
-
sequence,
|
|
32585
|
-
transientParams
|
|
32586
|
-
}) => {
|
|
32587
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
32588
|
-
const shipTo = (_a = associations.shipTo) !== null && _a !== void 0 ? _a : addressFactory.build(params.shipTo, {
|
|
32589
|
-
transient: {
|
|
32590
|
-
isInternational: transientParams.isInternational
|
|
32591
|
-
}
|
|
32592
|
-
});
|
|
32593
|
-
let insuranceProvider = SE.InsuranceProviderType.NONE;
|
|
32594
|
-
if (transientParams.insuredValue || transientParams.isInsured) {
|
|
32595
|
-
insuranceProvider = (_b = params.insuranceProvider) !== null && _b !== void 0 ? _b : randomInsuranceProvider(false);
|
|
32596
|
-
} else if (transientParams.insuredValue === undefined && transientParams.isInsured === undefined) {
|
|
32597
|
-
insuranceProvider = randomInsuranceProvider(true);
|
|
32598
|
-
}
|
|
32599
|
-
const shipDateObj = faker.date.soon(7);
|
|
32600
|
-
shipDateObj.setHours(0, 0, 0, 0);
|
|
32601
|
-
const totalWeight = (_c = associations.totalWeight) !== null && _c !== void 0 ? _c : weightWithUnitFactory.build(params.totalWeight);
|
|
32602
|
-
return {
|
|
32603
|
-
addressValidation: (_d = associations.addressValidation) !== null && _d !== void 0 ? _d : addressValidationFactory.build(params.addressValidation, {
|
|
32604
|
-
associations: {
|
|
32605
|
-
originalAddress: shipTo
|
|
32606
|
-
}
|
|
32607
|
-
}),
|
|
32608
|
-
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(),
|
|
32609
|
-
confirmation: randomDeliveryConfirmation(),
|
|
32610
|
-
createdAt: faker.date.past().toISOString(),
|
|
32611
|
-
customs: (_g = associations.customs) !== null && _g !== void 0 ? _g : transientParams.isInternational ? {
|
|
32612
|
-
contents: faker.helpers.arrayElement(["documents", "gift", "merchandise", "returned_goods", "sample"]),
|
|
32613
|
-
customsItems: customsItemFactory.buildList(faker.datatype.number({
|
|
32614
|
-
max: 10,
|
|
32615
|
-
min: 1
|
|
32616
|
-
})),
|
|
32617
|
-
nonDelivery: faker.helpers.arrayElement(["return_to_sender", "treat_as_abandoned"])
|
|
32618
|
-
} : undefined,
|
|
32619
|
-
externalOrderId: faker.random.alphaNumeric(10),
|
|
32620
|
-
externalShipmentId: faker.random.alphaNumeric(10),
|
|
32621
|
-
insuranceProvider,
|
|
32622
|
-
items: shipmentItemFactory.buildList(faker.datatype.number({
|
|
32623
|
-
max: 10,
|
|
32624
|
-
min: 1
|
|
32625
|
-
}), transientParams.salesOrder ? {
|
|
32626
|
-
externalOrderId: transientParams.salesOrder.externalOrderId,
|
|
32627
|
-
orderSourceCode: transientParams.salesOrder.orderSource.orderSourceCode,
|
|
32628
|
-
salesOrderId: (_h = transientParams.salesOrder) === null || _h === void 0 ? void 0 : _h.salesOrderId
|
|
32629
|
-
} : {}),
|
|
32630
|
-
modifiedAt: faker.date.recent().toISOString(),
|
|
32631
|
-
orderSourceCode: (_k = (_j = transientParams.salesOrder) === null || _j === void 0 ? void 0 : _j.orderSource.orderSourceCode) !== null && _k !== void 0 ? _k : randomOrderSourceCode(),
|
|
32632
|
-
packages: (_l = associations.packages) !== null && _l !== void 0 ? _l : shipmentPackageFactory.buildList(1, (_m = params.packages) === null || _m === void 0 ? void 0 : _m[0], {
|
|
32633
|
-
associations: {
|
|
32634
|
-
weight: totalWeight
|
|
32635
|
-
},
|
|
32636
|
-
transient: {
|
|
32637
|
-
isInsured: insuranceProvider !== "none",
|
|
32638
|
-
isShipped: transientParams.isShipped
|
|
32639
|
-
}
|
|
32640
|
-
}),
|
|
32641
|
-
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(),
|
|
32642
|
-
serviceCode: (_s = (_r = transientParams.service) === null || _r === void 0 ? void 0 : _r.serviceCode) !== null && _s !== void 0 ? _s : randomShipengineSlug(),
|
|
32643
|
-
shipDate: shipDateObj.toISOString(),
|
|
32644
|
-
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(),
|
|
32645
|
-
shipmentId: `se-${30000 + sequence}`,
|
|
32646
|
-
shipmentStatus: transientParams.isShipped ? "label_purchased" : "pending",
|
|
32647
|
-
shipTo,
|
|
32648
|
-
tags: (_w = associations.tags) !== null && _w !== void 0 ? _w : [],
|
|
32649
|
-
totalWeight,
|
|
32650
|
-
warehouseId: (_x = transientParams.warehouse) === null || _x === void 0 ? void 0 : _x.warehouseId
|
|
32651
|
-
};
|
|
32652
|
-
});
|
|
32653
|
-
/**
|
|
32654
|
-
* @category Factories
|
|
32655
|
-
*/
|
|
32656
|
-
const salesOrderShipmentFactory = Factory.define(({
|
|
32657
|
-
associations,
|
|
32658
|
-
params,
|
|
32659
|
-
transientParams
|
|
32660
|
-
}) => {
|
|
32661
|
-
var _a, _b, _c;
|
|
32662
|
-
const shipment = shipmentFactory.build(params, {
|
|
32663
|
-
associations,
|
|
32664
|
-
transient: transientParams
|
|
32665
|
-
});
|
|
32666
|
-
return Object.assign(Object.assign({}, shipment), {
|
|
32667
|
-
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.datatype.uuid()]
|
|
32668
|
-
});
|
|
32669
|
-
});
|
|
32670
|
-
|
|
32671
|
-
/**
|
|
32672
|
-
* @category Factories
|
|
32673
|
-
*/
|
|
32674
|
-
const labelFactory = Factory.define(({
|
|
32675
|
-
params,
|
|
32676
|
-
sequence,
|
|
32677
|
-
transientParams
|
|
32678
|
-
}) => {
|
|
32679
|
-
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;
|
|
32680
|
-
const shipTo = Object.assign(Object.assign({}, addressFactory.build((_a = transientParams.shipment) === null || _a === void 0 ? void 0 : _a.shipTo)), {
|
|
32681
|
-
companyName: (_c = (_b = transientParams.shipment) === null || _b === void 0 ? void 0 : _b.shipTo.companyName) !== null && _c !== void 0 ? _c : faker.lorem.word(),
|
|
32682
|
-
relayPointId: faker.random.numeric(10)
|
|
32683
|
-
});
|
|
32684
|
-
const shipFrom = Object.assign(Object.assign({}, addressFactory.build(((_d = transientParams.shipment) === null || _d === void 0 ? void 0 : _d.shipFrom) || undefined)), {
|
|
32685
|
-
companyName: (_f = (_e = transientParams.shipment) === null || _e === void 0 ? void 0 : _e.shipTo.companyName) !== null && _f !== void 0 ? _f : faker.lorem.word(),
|
|
32686
|
-
relayPointId: faker.random.numeric(10)
|
|
32687
|
-
});
|
|
32688
|
-
const shipDateObj = faker.date.soon(7);
|
|
32689
|
-
shipDateObj.setHours(0, 0, 0, 0);
|
|
32690
|
-
return {
|
|
32691
|
-
batchId: faker.random.numeric(10),
|
|
32692
|
-
carrierCode: (_h = (_g = transientParams.carrier) === null || _g === void 0 ? void 0 : _g.carrierCode) !== null && _h !== void 0 ? _h : randomShipengineSlug(),
|
|
32693
|
-
carrierId: (_k = (_j = transientParams.shipment) === null || _j === void 0 ? void 0 : _j.carrierId) !== null && _k !== void 0 ? _k : `se-${10000 + sequence}`,
|
|
32694
|
-
chargeEvent: "on_creation",
|
|
32695
|
-
createdAt: faker.date.past().toISOString(),
|
|
32696
|
-
displayScheme: "label",
|
|
32697
|
-
formDownload: {
|
|
32698
|
-
href: faker.internet.url(),
|
|
32699
|
-
type: ""
|
|
32700
|
-
},
|
|
32701
|
-
insuranceClaim: {
|
|
32702
|
-
href: faker.internet.url(),
|
|
32703
|
-
type: ""
|
|
32704
|
-
},
|
|
32705
|
-
insuranceCost: moneyFactory.build(),
|
|
32706
|
-
isInternational: shipTo.countryCode !== "US",
|
|
32707
|
-
isReturnLabel: false,
|
|
32708
|
-
labelDownload: {
|
|
32709
|
-
href: faker.image.imageUrl(),
|
|
32710
|
-
pdf: faker.image.imageUrl(),
|
|
32711
|
-
png: faker.image.imageUrl(),
|
|
32712
|
-
zpl: faker.image.imageUrl()
|
|
32713
|
-
},
|
|
32714
|
-
labelFormat: "pdf",
|
|
32715
|
-
labelId: `se-${40000 + sequence}`,
|
|
32716
|
-
labelImageId: faker.random.numeric(10),
|
|
32717
|
-
labelLayout: "4x6",
|
|
32718
|
-
modifiedAt: faker.date.recent().toISOString(),
|
|
32719
|
-
packageCode: (_m = (_l = transientParams.shipment) === null || _l === void 0 ? void 0 : _l.packages[0].packageCode) !== null && _m !== void 0 ? _m : randomShipengineSlug(2),
|
|
32720
|
-
packages: (_p = (_o = transientParams.shipment) === null || _o === void 0 ? void 0 : _o.packages) !== null && _p !== void 0 ? _p : shipmentPackageFactory.buildList(1),
|
|
32721
|
-
relayPoints: {
|
|
32722
|
-
shipFrom,
|
|
32723
|
-
shipTo
|
|
32724
|
-
},
|
|
32725
|
-
rmaNumber: faker.random.alpha(10),
|
|
32726
|
-
serviceCode: (_r = (_q = transientParams.shipment) === null || _q === void 0 ? void 0 : _q.serviceCode) !== null && _r !== void 0 ? _r : randomShipengineSlug(),
|
|
32727
|
-
shipDate: (_t = (_s = transientParams.shipment) === null || _s === void 0 ? void 0 : _s.shipDate) !== null && _t !== void 0 ? _t : shipDateObj.toISOString(),
|
|
32728
|
-
shipmentCost: moneyFactory.build(),
|
|
32729
|
-
shipmentId: (_v = (_u = transientParams.shipment) === null || _u === void 0 ? void 0 : _u.shipmentId) !== null && _v !== void 0 ? _v : `se-${30000 + sequence}`,
|
|
32730
|
-
status: (_w = params.status) !== null && _w !== void 0 ? _w : "processing",
|
|
32731
|
-
trackable: !!((_x = transientParams.shipment) === null || _x === void 0 ? void 0 : _x.packages[0].trackingNumber),
|
|
32732
|
-
trackingNumber: (_z = (_y = transientParams.shipment) === null || _y === void 0 ? void 0 : _y.packages[0].trackingNumber) !== null && _z !== void 0 ? _z : faker.random.alpha(10),
|
|
32733
|
-
trackingStatus: "in_transit",
|
|
32734
|
-
voided: ((_0 = transientParams.shipment) === null || _0 === void 0 ? void 0 : _0.shipmentStatus) === "cancelled",
|
|
32735
|
-
voidedAt: (_2 = (_1 = transientParams.shipment) === null || _1 === void 0 ? void 0 : _1.modifiedAt) !== null && _2 !== void 0 ? _2 : faker.date.past().toISOString()
|
|
32736
|
-
};
|
|
32737
|
-
});
|
|
32738
|
-
|
|
32739
|
-
const randomPaymentStatus = () => faker.helpers.arrayElement(["unknown", "paid", "unpaid", "partially_paid"]);
|
|
32740
|
-
const randomFulfillmentStatus = () => faker.helpers.arrayElement(["unknown", "fulfilled", "unfulfilled", "partially_fulfilled", "on_hold"]);
|
|
32741
|
-
/**
|
|
32742
|
-
* @category Factories
|
|
32743
|
-
*/
|
|
32744
|
-
const salesOrderItemFactory = Factory.define(({
|
|
32745
|
-
associations,
|
|
32746
|
-
params,
|
|
32747
|
-
transientParams
|
|
32748
|
-
}) => {
|
|
32749
|
-
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;
|
|
32750
|
-
const quantity = faker.datatype.number({
|
|
32751
|
-
max: 5,
|
|
32752
|
-
min: 1
|
|
32753
|
-
});
|
|
32754
|
-
let {
|
|
32755
|
-
priceSummary
|
|
32756
|
-
} = associations;
|
|
32757
|
-
if (!priceSummary) {
|
|
32758
|
-
const unitPrice = moneyFactory.build((_a = params.priceSummary) === null || _a === void 0 ? void 0 : _a.unitPrice, {
|
|
32759
|
-
transient: transientParams
|
|
32760
|
-
});
|
|
32761
|
-
const estimatedShipping = ((_b = params.priceSummary) === null || _b === void 0 ? void 0 : _b.estimatedShipping) ? moneyFactory.build(Object.assign({
|
|
32762
|
-
currency: unitPrice.currency
|
|
32763
|
-
}, (_c = params.priceSummary) === null || _c === void 0 ? void 0 : _c.estimatedShipping)) : undefined;
|
|
32764
|
-
const estimatedTax = moneyFactory.build({
|
|
32765
|
-
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,
|
|
32766
|
-
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
|
|
32767
|
-
});
|
|
32768
|
-
const total = moneyFactory.build({
|
|
32769
|
-
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,
|
|
32770
|
-
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
|
|
32771
|
-
});
|
|
32772
|
-
priceSummary = {
|
|
32773
|
-
estimatedShipping,
|
|
32774
|
-
estimatedTax,
|
|
32775
|
-
total,
|
|
32776
|
-
unitPrice
|
|
32777
|
-
};
|
|
32778
|
-
}
|
|
32779
|
-
return {
|
|
32780
|
-
isGift: faker.datatype.boolean(),
|
|
32781
|
-
lineItemDetails: (_s = associations.lineItemDetails) !== null && _s !== void 0 ? _s : {
|
|
32782
|
-
asin: (_u = (_t = params.lineItemDetails) === null || _t === void 0 ? void 0 : _t.asin) !== null && _u !== void 0 ? _u : faker.random.alphaNumeric(10),
|
|
32783
|
-
name: (_w = (_v = params.lineItemDetails) === null || _v === void 0 ? void 0 : _v.name) !== null && _w !== void 0 ? _w : faker.commerce.productName(),
|
|
32784
|
-
sku: (_y = (_x = params.lineItemDetails) === null || _x === void 0 ? void 0 : _x.sku) !== null && _y !== void 0 ? _y : faker.random.numeric(10),
|
|
32785
|
-
weight: weightWithUnitFactory.build((_z = params.lineItemDetails) === null || _z === void 0 ? void 0 : _z.weight)
|
|
32786
|
-
},
|
|
32787
|
-
priceSummary,
|
|
32788
|
-
quantity,
|
|
32789
|
-
requestedShippingOptions: (_0 = associations.requestedShippingOptions) !== null && _0 !== void 0 ? _0 : {
|
|
32790
|
-
shipDate: (_1 = faker.helpers.maybe(() => faker.date.soon(7).toISOString())) !== null && _1 !== void 0 ? _1 : null,
|
|
32791
|
-
shippingService: faker.word.adjective()
|
|
32792
|
-
},
|
|
32793
|
-
salesOrderItemId: faker.datatype.uuid(),
|
|
32794
|
-
shipTo: (_2 = associations.shipTo) !== null && _2 !== void 0 ? _2 : addressFactory.build(params.shipTo)
|
|
32795
|
-
};
|
|
32796
|
-
});
|
|
32797
|
-
/**
|
|
32798
|
-
* @category Factories
|
|
32799
|
-
*/
|
|
32800
|
-
const salesOrderFactory = Factory.define(({
|
|
32801
|
-
associations,
|
|
32802
|
-
params,
|
|
32803
|
-
sequence,
|
|
32804
|
-
transientParams
|
|
32805
|
-
}) => {
|
|
32806
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
32807
|
-
const createdAt = (_a = params.createdAt) !== null && _a !== void 0 ? _a : faker.date.recent(30).toISOString();
|
|
32808
|
-
let {
|
|
32809
|
-
paymentDetails
|
|
32810
|
-
} = associations;
|
|
32811
|
-
if (!paymentDetails) {
|
|
32812
|
-
const subtotal = moneyFactory.build((_b = params.paymentDetails) === null || _b === void 0 ? void 0 : _b.subtotal, {
|
|
32813
|
-
transient: transientParams
|
|
32814
|
-
});
|
|
32815
|
-
const estimatedShipping = moneyFactory.build(Object.assign({
|
|
32816
|
-
currency: subtotal.currency
|
|
32817
|
-
}, (_c = params.paymentDetails) === null || _c === void 0 ? void 0 : _c.estimatedShipping));
|
|
32818
|
-
const estimatedTax = moneyFactory.build({
|
|
32819
|
-
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,
|
|
32820
|
-
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
|
|
32821
|
-
});
|
|
32822
|
-
const grandTotal = moneyFactory.build({
|
|
32823
|
-
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,
|
|
32824
|
-
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
|
|
32825
|
-
});
|
|
32826
|
-
paymentDetails = {
|
|
32827
|
-
estimatedShipping,
|
|
32828
|
-
estimatedTax,
|
|
32829
|
-
grandTotal,
|
|
32830
|
-
subtotal
|
|
32831
|
-
};
|
|
32832
|
-
}
|
|
32833
|
-
const shipTo = (_r = associations.shipTo) !== null && _r !== void 0 ? _r : addressFactory.build(params.shipTo || {});
|
|
32834
|
-
return {
|
|
32835
|
-
billTo: (_s = associations.billTo) !== null && _s !== void 0 ? _s : {
|
|
32836
|
-
address: addressFactory.build((_t = params.billTo) === null || _t === void 0 ? void 0 : _t.address),
|
|
32837
|
-
email: faker.internet.email()
|
|
32838
|
-
},
|
|
32839
|
-
createdAt,
|
|
32840
|
-
customer: (_u = associations.customer) !== null && _u !== void 0 ? _u : {
|
|
32841
|
-
email: faker.internet.email(),
|
|
32842
|
-
name: faker.name.fullName(),
|
|
32843
|
-
phone: faker.phone.number()
|
|
32844
|
-
},
|
|
32845
|
-
externalOrderId: faker.random.numeric(9),
|
|
32846
|
-
externalOrderNumber: faker.random.numeric(9),
|
|
32847
|
-
modifiedAt: createdAt,
|
|
32848
|
-
// TODO: What is this? Is it supposed to be in the future?
|
|
32849
|
-
orderDate: createdAt,
|
|
32850
|
-
orderSource: (_v = associations.orderSource) !== null && _v !== void 0 ? _v : orderSourceFactory.build(params.orderSource),
|
|
32851
|
-
paymentDetails,
|
|
32852
|
-
salesOrderId: `se-${20000 + sequence}`,
|
|
32853
|
-
salesOrderItems: salesOrderItemFactory.buildList(2, {}, {
|
|
32854
|
-
associations: {
|
|
32855
|
-
shipTo
|
|
32856
|
-
},
|
|
32857
|
-
transient: transientParams
|
|
32858
|
-
}),
|
|
32859
|
-
salesOrderStatus: (_w = associations.salesOrderStatus) !== null && _w !== void 0 ? _w : {
|
|
32860
|
-
fulfillmentStatus: randomFulfillmentStatus(),
|
|
32861
|
-
isCancelled: false,
|
|
32862
|
-
paymentStatus: randomPaymentStatus()
|
|
32863
|
-
},
|
|
32864
|
-
shipTo
|
|
32865
|
-
};
|
|
32866
|
-
});
|
|
32867
|
-
|
|
32868
|
-
/**
|
|
32869
|
-
* @category Factories
|
|
32870
|
-
*/
|
|
32871
|
-
const warehouseFactory = Factory.define(({
|
|
32872
|
-
associations,
|
|
32873
|
-
params
|
|
32874
|
-
}) => {
|
|
32875
|
-
var _a, _b, _c;
|
|
32876
|
-
return {
|
|
32877
|
-
createdAt: faker.date.past().toISOString(),
|
|
32878
|
-
isDefault: (_a = params.isDefault) !== null && _a !== void 0 ? _a : false,
|
|
32879
|
-
name: faker.company.name(),
|
|
32880
|
-
originAddress: (_b = associations.originAddress) !== null && _b !== void 0 ? _b : addressFactory.build(params.originAddress),
|
|
32881
|
-
returnAddress: (_c = associations.returnAddress) !== null && _c !== void 0 ? _c : addressFactory.build(params.returnAddress),
|
|
32882
|
-
warehouseId: randomShipengineId()
|
|
32883
|
-
};
|
|
32884
|
-
});
|
|
32885
|
-
|
|
32886
|
-
const renderWithProviders = component => {
|
|
32887
|
-
const theme = createTheme(BrandName.FALLBACK);
|
|
32888
|
-
return render(component, {
|
|
32889
|
-
wrapper: ({
|
|
32890
|
-
children
|
|
32891
|
-
}) => jsx(RootPortalProvider, {
|
|
32892
|
-
children: jsx(GigerConfigProvider, Object.assign({
|
|
32893
|
-
resolveIcon: name => `<svg>${name}</svg>`
|
|
32894
|
-
}, {
|
|
32895
|
-
children: jsx(ThemeProvider, Object.assign({
|
|
32896
|
-
theme: deserialize(theme)
|
|
32897
|
-
}, {
|
|
32898
|
-
children: children
|
|
32899
|
-
}))
|
|
32900
|
-
}))
|
|
32901
|
-
})
|
|
32902
|
-
});
|
|
32903
|
-
};
|
|
32904
|
-
/**
|
|
32905
|
-
* Wraps the test with all of the usual Shipengine / Giger / i18 / etc providers that a full, registered "Element" would have.
|
|
32906
|
-
* This allows components to simulate usage in an Element via `decorators: [withAllProviders]`
|
|
32907
|
-
**/
|
|
32908
|
-
const renderWithAllProviders = component => {
|
|
32909
|
-
const theme = createTheme(BrandName.FALLBACK);
|
|
32910
|
-
return render(component, {
|
|
32911
|
-
wrapper: ({
|
|
32912
|
-
children
|
|
32913
|
-
}) => jsx(ShipEngineProvider, Object.assign({
|
|
32914
|
-
baseURL: "/api",
|
|
32915
|
-
getToken: () => {
|
|
32916
|
-
var _a;
|
|
32917
|
-
return (_a = process.env.STORYBOOK_TOKEN) !== null && _a !== void 0 ? _a : "none";
|
|
32918
|
-
}
|
|
32919
|
-
}, {
|
|
32920
|
-
children: jsx(RootPortalProvider, {
|
|
32921
|
-
children: jsx(GigerConfigProvider, Object.assign({
|
|
32922
|
-
resolveIcon: name => `<svg>${name}</svg>`
|
|
32923
|
-
}, {
|
|
32924
|
-
children: jsx(ThemeProvider, Object.assign({
|
|
32925
|
-
theme: deserialize(theme)
|
|
32926
|
-
}, {
|
|
32927
|
-
children: children
|
|
32928
|
-
}))
|
|
32929
|
-
}))
|
|
32930
|
-
})
|
|
32931
|
-
}))
|
|
32932
|
-
});
|
|
32933
|
-
};
|
|
32934
|
-
|
|
32935
|
-
export { Accordion, AddFundsForm, AutoFundingForm, ButtonGroup, CarrierBalance, Country, Cube, ElementsContext, ElementsProvider, ErrorBoundary, ErrorFallback, fields as Field, FieldLabel, FormPortal, FundAndPurchase, GigerProvider, InlineLabel, ItemsBreakdown, LinkAction, Element$5 as ListCarriers, Loader, ManageFunding, Element$4 as ManageWarehouses, Element$2 as Onboarding, PageLayoutProvider, Portal, Element$3 as PurchaseLabel, RootPortalProvider, Spacer, Spread, StoryNotes, index$1 as Templates, UsState, UsaCity, Element$1 as ViewShipment, Element as VoidLabel, addressFactory, addressPreferenceFactory, addressValidationFactory, autoFundingSchema, calculateTotal, capitalizeFirstLetter, carrierFactory, carrierOptionFactory, convertDimensions, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, customsItemFactory, daysAfter, downloadFactory, errorMap, euCountryCodes, extendZod, formLogger, formatCreditCardNumber, formatDate, formatExpiration, formatFractionalWeight, formatMoney, fractionalWeightFactory, getAddFundsSchema, getCustomsFromSalesOrder, getExpirationYears, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getTotalRateAmount, isDomesticAddress, isFlatRatePackageCode, isMilitaryAddress, isNowOrInTheFuture, isPoBox, isPoBoxAddress, isString, isUnitedStatesTerritory, isUspsCarrier, labelFactory, linkedResourceFactory, moneyFactory, moneySchema, mostRecent, nextDayCutoff, omitTime, orderSourceFactory, orderSourceRefreshInfoFactory, packageFactory, phoneSchema, phoneSchemaUnvalidated, postalCodeRegex$3 as postalCodeRegex, randomDeliveryConfirmation, randomFulfillmentStatus, randomInsuranceProvider, randomOrderSourceCode, randomPaymentStatus, randomShipengineId, randomShipengineSlug, randomWeightUnit, registerElement, renderWithAllProviders, renderWithProviders, salesOrderFactory, salesOrderItemFactory, salesOrderShipmentFactory, serviceFactory, shipmentFactory, shipmentItemFactory, shipmentPackageFactory, sortByCreationDate, tristateValue, usCities, usStateCodes, usStates, useCarrierMetadata, useConfirmationOptions, useCountryCodeOptions, useCustomsContentsOptions, useCustomsNonDeliveryOptions, useElements, useExpirationMonthOptions, useInsuranceProviderOptions, useNestedForm, usePackageOptions, usePageLayout, useRateOptions, useRootPortal, useRunOnceOnTrue, useServiceCodeOptions, useShippingPresetsOptions, useStateCodeOptions, useToggle, useWarehouseOptions, validationResolver, warehouseFactory, weightFactory, weightWithUnitFactory };
|
|
32593
|
+
export { Accordion, AddFundsForm, AutoFundingForm, ButtonGroup, CarrierBalance, Country, Cube, ElementsContext, ElementsProvider, ErrorBoundary, ErrorFallback, fields as Field, FieldLabel, FormPortal, FundAndPurchase, GigerProvider, InlineLabel, ItemsBreakdown, LinkAction, Element$5 as ListCarriers, Loader, ManageFunding, Element$4 as ManageWarehouses, Element$2 as Onboarding, PageLayoutProvider, Portal, Element$3 as PurchaseLabel, RootPortalProvider, Spacer, Spread, StoryNotes, index$1 as Templates, UsState, UsaCity, Element$1 as ViewShipment, Element as VoidLabel, autoFundingSchema, calculateTotal, capitalizeFirstLetter, convertDimensions, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, daysAfter, errorMap, euCountryCodes, extendZod, formLogger, formatCreditCardNumber, formatDate, formatExpiration, formatFractionalWeight, formatMoney, getAddFundsSchema, getCustomsFromSalesOrder, getExpirationYears, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getTotalRateAmount, isDomesticAddress, isFlatRatePackageCode, isMilitaryAddress, isNowOrInTheFuture, isPoBox, isPoBoxAddress, isString, isUnitedStatesTerritory, isUspsCarrier, moneySchema, mostRecent, nextDayCutoff, omitTime, phoneSchema, phoneSchemaUnvalidated, postalCodeRegex$3 as postalCodeRegex, registerElement, sortByCreationDate, usCities, usStateCodes, usStates, useCarrierMetadata, useConfirmationOptions, useCountryCodeOptions, useCustomsContentsOptions, useCustomsNonDeliveryOptions, useElements, useExpirationMonthOptions, useInsuranceProviderOptions, useNestedForm, usePackageOptions, usePageLayout, useRateOptions, useRootPortal, useRunOnceOnTrue, useServiceCodeOptions, useShippingPresetsOptions, useStateCodeOptions, useToggle, useWarehouseOptions, useWarehouseValidation, validationResolver };
|