@shipengine/elements 0.6.42 → 0.6.44
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.
|
@@ -7,7 +7,8 @@ export declare type RateFormProps = {
|
|
|
7
7
|
onLabelCreateFailure?: (rate?: SE.Rate, shipment?: SE.SalesOrderShipment) => Promise<void> | void;
|
|
8
8
|
onLabelCreateSuccess?: (label: SE.Label, shipment?: SE.SalesOrderShipment) => Promise<void> | void;
|
|
9
9
|
onRateSaved?: (shipment: SE.SalesOrderShipment) => Promise<void> | void;
|
|
10
|
+
printLabelLayout?: SE.LabelLayout;
|
|
10
11
|
rates?: SE.Rate[];
|
|
11
12
|
shipment?: SE.SalesOrderShipment;
|
|
12
13
|
};
|
|
13
|
-
export declare const RateForm: ({ errors, loading, onBeforeLabelCreate, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, rates, shipment, }: RateFormProps) => JSX.Element;
|
|
14
|
+
export declare const RateForm: ({ errors, loading, onBeforeLabelCreate, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, printLabelLayout, rates, shipment, }: RateFormProps) => JSX.Element;
|
|
@@ -19,8 +19,9 @@ export declare type SalesOrderProps = {
|
|
|
19
19
|
onShipmentUpdated?: (shipment: SE.SalesOrderShipment) => Promise<void> | void;
|
|
20
20
|
onToggleAddressPreferenceDisclosure?: ShipmentFormProps["onToggleAddressPreferenceDisclosure"];
|
|
21
21
|
orderSourceCode?: string;
|
|
22
|
+
printLabelLayout?: RateFormProps["printLabelLayout"];
|
|
22
23
|
salesOrderId?: string;
|
|
23
24
|
shippingPresets?: UseShippingPresetsOptionsProps;
|
|
24
25
|
warehouseId?: string;
|
|
25
26
|
};
|
|
26
|
-
export declare const SalesOrder: ({ externalOrderId, externalOrderNumber, onAddressValidation, onApplyPreset, onBeforeLabelCreate, onChangeAddress, onChangeShipmentFormMode, onLabelCreateFailure, onLabelCreateSuccess, onLoad, onRateSaved, onRatesReturned, onShipmentUpdated, onToggleAddressPreferenceDisclosure, orderSourceCode, salesOrderId, shippingPresets, warehouseId, }: SalesOrderProps) => JSX.Element;
|
|
27
|
+
export declare const SalesOrder: ({ externalOrderId, externalOrderNumber, onAddressValidation, onApplyPreset, onBeforeLabelCreate, onChangeAddress, onChangeShipmentFormMode, onLabelCreateFailure, onLabelCreateSuccess, onLoad, onRateSaved, onRatesReturned, onShipmentUpdated, onToggleAddressPreferenceDisclosure, orderSourceCode, printLabelLayout, salesOrderId, shippingPresets, warehouseId, }: SalesOrderProps) => JSX.Element;
|
|
@@ -16,11 +16,12 @@ export declare type ShipmentFormProps = {
|
|
|
16
16
|
onChangeShipmentFormMode?: ShipmentFormTemplateProps["onChangeMode"];
|
|
17
17
|
onShipmentDirty: () => void;
|
|
18
18
|
onShipmentUpdated: (shipment: SE.SalesOrderShipment, options?: ShipmentUpdatedOptions) => Promise<void> | void;
|
|
19
|
+
onShipmentUpdateFailure?: () => void;
|
|
19
20
|
onToggleAddressPreferenceDisclosure?: ShipmentFormTemplateProps["onToggleAddressPreferenceDisclosure"];
|
|
20
21
|
salesOrder: SE.SalesOrder;
|
|
21
22
|
shipment?: SE.SalesOrderShipment;
|
|
22
23
|
shippingPresets?: UseShippingPresetsOptionsProps;
|
|
23
24
|
warehouseId?: string;
|
|
24
25
|
};
|
|
25
|
-
export declare const ShipmentForm: ({ addressPreference, onApplyPreset, onChangeAddress, onChangeShipmentFormMode, onShipmentDirty, onShipmentUpdated, onToggleAddressPreferenceDisclosure, salesOrder, shipment, shippingPresets, warehouseId, }: ShipmentFormProps) => JSX.Element;
|
|
26
|
+
export declare const ShipmentForm: ({ addressPreference, onApplyPreset, onChangeAddress, onChangeShipmentFormMode, onShipmentDirty, onShipmentUpdated, onShipmentUpdateFailure, onToggleAddressPreferenceDisclosure, salesOrder, shipment, shippingPresets, warehouseId, }: ShipmentFormProps) => JSX.Element;
|
|
26
27
|
export {};
|
package/index.cjs
CHANGED
|
@@ -2848,6 +2848,7 @@ const ShipmentForm = ({
|
|
|
2848
2848
|
onShipmentDirty,
|
|
2849
2849
|
// Must be referentially stable
|
|
2850
2850
|
onShipmentUpdated,
|
|
2851
|
+
onShipmentUpdateFailure,
|
|
2851
2852
|
onToggleAddressPreferenceDisclosure,
|
|
2852
2853
|
salesOrder,
|
|
2853
2854
|
shipment,
|
|
@@ -2901,6 +2902,8 @@ const ShipmentForm = ({
|
|
|
2901
2902
|
shouldCalculateRates: false,
|
|
2902
2903
|
shouldResetAddressPreference: options.shouldValidate
|
|
2903
2904
|
});
|
|
2905
|
+
} else if (onShipmentUpdateFailure) {
|
|
2906
|
+
onShipmentUpdateFailure();
|
|
2904
2907
|
}
|
|
2905
2908
|
});
|
|
2906
2909
|
|
|
@@ -2977,12 +2980,13 @@ const RateForm = ({
|
|
|
2977
2980
|
onLabelCreateFailure,
|
|
2978
2981
|
onLabelCreateSuccess,
|
|
2979
2982
|
onRateSaved,
|
|
2983
|
+
printLabelLayout,
|
|
2980
2984
|
rates,
|
|
2981
2985
|
shipment
|
|
2982
2986
|
}) => {
|
|
2983
2987
|
var _a;
|
|
2984
2988
|
|
|
2985
|
-
const createLabel = elementsCore.useCreateLabel();
|
|
2989
|
+
const createLabel = elementsCore.useCreateLabel(printLabelLayout);
|
|
2986
2990
|
const updateShipment = elementsCore.useUpdateShipment({
|
|
2987
2991
|
shipmentId: shipment === null || shipment === void 0 ? void 0 : shipment.shipmentId
|
|
2988
2992
|
});
|
|
@@ -20309,6 +20313,7 @@ const SalesOrder = ({
|
|
|
20309
20313
|
onShipmentUpdated,
|
|
20310
20314
|
onToggleAddressPreferenceDisclosure,
|
|
20311
20315
|
orderSourceCode,
|
|
20316
|
+
printLabelLayout,
|
|
20312
20317
|
salesOrderId,
|
|
20313
20318
|
shippingPresets,
|
|
20314
20319
|
warehouseId
|
|
@@ -20380,7 +20385,7 @@ const SalesOrder = ({
|
|
|
20380
20385
|
|
|
20381
20386
|
if (((_a = salesOrders.data) === null || _a === void 0 ? void 0 : _a.length) && shipments.data && ((_b = warehouses.data) === null || _b === void 0 ? void 0 : _b.length) && !createShipment.data && !createShipment.errors && !createShipment.isMutating) {
|
|
20382
20387
|
const currentSalesOrder = salesOrders.data[0];
|
|
20383
|
-
const pendingShipment = shipments.data
|
|
20388
|
+
const pendingShipment = elementsCore.getPendingShipment(shipments.data);
|
|
20384
20389
|
|
|
20385
20390
|
if (currentSalesOrder && !pendingShipment) {
|
|
20386
20391
|
const defaultWarehouse = (_c = warehouses.data.find(w => w.warehouseId === warehouseId)) !== null && _c !== void 0 ? _c : warehouses.data[0];
|
|
@@ -20415,40 +20420,44 @@ const SalesOrder = ({
|
|
|
20415
20420
|
yield onAddressValidation === null || onAddressValidation === void 0 ? void 0 : onAddressValidation(updatedAddressPreference);
|
|
20416
20421
|
}
|
|
20417
20422
|
} catch (error) {
|
|
20418
|
-
// Shipment creation failed most likely due to validate_and_clean
|
|
20419
|
-
//
|
|
20423
|
+
// Shipment creation failed, most likely due to validate_and_clean 500ing
|
|
20424
|
+
// and preventing a shipment from being created. Create a shipment with
|
|
20425
|
+
// the sales order ship to address without validating and setting the
|
|
20426
|
+
// address preference to an error state. This will display the not validated
|
|
20427
|
+
// error message to the user.
|
|
20420
20428
|
logger.warn("createShipment failed to create a shipment, trying plan b", error.message);
|
|
20421
|
-
|
|
20422
|
-
|
|
20423
|
-
|
|
20424
|
-
|
|
20425
|
-
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
|
|
20430
|
-
|
|
20431
|
-
|
|
20432
|
-
|
|
20433
|
-
|
|
20434
|
-
|
|
20435
|
-
|
|
20436
|
-
|
|
20437
|
-
|
|
20438
|
-
|
|
20439
|
-
|
|
20440
|
-
|
|
20441
|
-
}));
|
|
20442
|
-
yield shipments.mutate();
|
|
20429
|
+
|
|
20430
|
+
try {
|
|
20431
|
+
yield createShipment.trigger(Object.assign({
|
|
20432
|
+
// /v-beta/shipments/sales_order/:salesOrderId requires at minimum
|
|
20433
|
+
// a (warehouseId or shipFrom) and a package with weight defined.
|
|
20434
|
+
packages: [{
|
|
20435
|
+
weight: {
|
|
20436
|
+
value: 0,
|
|
20437
|
+
unit: "pound"
|
|
20438
|
+
}
|
|
20439
|
+
}],
|
|
20440
|
+
shipTo: currentSalesOrder.shipTo,
|
|
20441
|
+
warehouseId: defaultWarehouse.warehouseId
|
|
20442
|
+
}, elementsCore.getIsCustomsRequiredForSalesOrder(currentSalesOrder, defaultWarehouse) && {
|
|
20443
|
+
customs: elementsCore.getCustomsFromSalesOrder(currentSalesOrder, defaultWarehouse)
|
|
20444
|
+
}));
|
|
20445
|
+
const shipmentsMutationResult = yield shipments.mutate();
|
|
20446
|
+
const currentPendingShipment = elementsCore.getPendingShipment(shipmentsMutationResult);
|
|
20447
|
+
|
|
20448
|
+
if (currentPendingShipment) {
|
|
20443
20449
|
const updatedAddressPreference = resetAddressPreference({
|
|
20444
|
-
validation:
|
|
20445
|
-
|
|
20450
|
+
validation: {
|
|
20451
|
+
messages: [],
|
|
20452
|
+
originalAddress: currentPendingShipment.shipTo,
|
|
20453
|
+
status: "error"
|
|
20454
|
+
}
|
|
20446
20455
|
});
|
|
20447
20456
|
yield onAddressValidation === null || onAddressValidation === void 0 ? void 0 : onAddressValidation(updatedAddressPreference);
|
|
20448
|
-
} catch (error) {
|
|
20449
|
-
logger.error("createShipment failed to create a shipment", error.message);
|
|
20450
|
-
throw new Error("errorMessages.unableToLoad.shipment");
|
|
20451
20457
|
}
|
|
20458
|
+
} catch (error) {
|
|
20459
|
+
logger.error("createShipment failed to create a shipment", error.message);
|
|
20460
|
+
throw new Error("errorMessages.unableToLoad.shipment");
|
|
20452
20461
|
}
|
|
20453
20462
|
}
|
|
20454
20463
|
} else if (currentSalesOrder && pendingShipment && !validateAddresses.data && !validateAddresses.errors && !validateAddresses.isMutating) {
|
|
@@ -20473,7 +20482,28 @@ const SalesOrder = ({
|
|
|
20473
20482
|
var _a;
|
|
20474
20483
|
|
|
20475
20484
|
return !!((_a = customPackageTypes.data) === null || _a === void 0 ? void 0 : _a.find(p => p.packageId === shipment.packages[0].packageId));
|
|
20476
|
-
}, [customPackageTypes]);
|
|
20485
|
+
}, [customPackageTypes]); // validate_and_clean failure is preventing the address preference object
|
|
20486
|
+
// from being refreshed. Manualy set the address preference to an error state.
|
|
20487
|
+
// with the original address set to the newly updated shipment ship to
|
|
20488
|
+
// This will display the not validated error message with the edited address to the user.
|
|
20489
|
+
|
|
20490
|
+
const handleShipmentUpdateFailure = react.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
20491
|
+
const result = yield shipments.mutate();
|
|
20492
|
+
const currentShipment = elementsCore.getPendingShipment(result);
|
|
20493
|
+
|
|
20494
|
+
if (currentShipment) {
|
|
20495
|
+
const updatedAddressPreference = resetAddressPreference({
|
|
20496
|
+
validation: {
|
|
20497
|
+
messages: [],
|
|
20498
|
+
originalAddress: currentShipment.shipTo,
|
|
20499
|
+
status: "error"
|
|
20500
|
+
}
|
|
20501
|
+
});
|
|
20502
|
+
yield onAddressValidation === null || onAddressValidation === void 0 ? void 0 : onAddressValidation(updatedAddressPreference);
|
|
20503
|
+
yield onChangeAddress === null || onChangeAddress === void 0 ? void 0 : onChangeAddress(updatedAddressPreference);
|
|
20504
|
+
yield onShipmentUpdated === null || onShipmentUpdated === void 0 ? void 0 : onShipmentUpdated(currentShipment);
|
|
20505
|
+
}
|
|
20506
|
+
}), [onAddressValidation, onChangeAddress, resetAddressPreference, onShipmentUpdated, shipments]);
|
|
20477
20507
|
const handleShipmentUpdated = react.useCallback((shipment, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20478
20508
|
var _h, _j;
|
|
20479
20509
|
|
|
@@ -20537,7 +20567,7 @@ const SalesOrder = ({
|
|
|
20537
20567
|
message: t("loading.carriers")
|
|
20538
20568
|
});
|
|
20539
20569
|
const salesOrder = salesOrders.data[0];
|
|
20540
|
-
const shipment = shipments.data
|
|
20570
|
+
const shipment = elementsCore.getPendingShipment(shipments.data);
|
|
20541
20571
|
let rateErrors = [...((_b = calculateRates.errors) !== null && _b !== void 0 ? _b : []), ...((_d = (_c = calculateRates.data) === null || _c === void 0 ? void 0 : _c.errors) !== null && _d !== void 0 ? _d : [])]; // Sometimes no rates are returned and no top-level errors are returned
|
|
20542
20572
|
// but there are invalid rates with errors. This will expose those to the user
|
|
20543
20573
|
// so the rate list isn't empty after calculating rates.
|
|
@@ -20561,6 +20591,7 @@ const SalesOrder = ({
|
|
|
20561
20591
|
onChangeShipmentFormMode: onChangeShipmentFormMode,
|
|
20562
20592
|
onShipmentDirty: handleShipmentDirty,
|
|
20563
20593
|
onShipmentUpdated: handleShipmentUpdated,
|
|
20594
|
+
onShipmentUpdateFailure: handleShipmentUpdateFailure,
|
|
20564
20595
|
onToggleAddressPreferenceDisclosure: onToggleAddressPreferenceDisclosure,
|
|
20565
20596
|
salesOrder: salesOrder,
|
|
20566
20597
|
shipment: shipment,
|
|
@@ -20573,6 +20604,7 @@ const SalesOrder = ({
|
|
|
20573
20604
|
onLabelCreateFailure: onLabelCreateFailure,
|
|
20574
20605
|
onLabelCreateSuccess: onLabelCreateSuccess,
|
|
20575
20606
|
onRateSaved: handleRateSaved,
|
|
20607
|
+
printLabelLayout: printLabelLayout,
|
|
20576
20608
|
rates: (_g = calculateRates.data) === null || _g === void 0 ? void 0 : _g.rates,
|
|
20577
20609
|
shipment: shipment
|
|
20578
20610
|
})]
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useLogger, useListWarehouses, useListCarriers, useCreateShipment, useUpdateShipment, useParseAddress, useListCustomPackageTypes, useCreateLabel, isDomesticAddress, useListSalesOrders, useListOrderSources, useRefreshOrderSource, useCalculateRates, useValidateAddresses, useListShipments, getIsCustomsRequiredForSalesOrder, getCustomsFromSalesOrder, registerElement, useGetShipment, useListLabels, useGetLabel, useVoidLabel } from '@shipengine/elements-core';
|
|
1
|
+
import { useLogger, useListWarehouses, useListCarriers, useCreateShipment, useUpdateShipment, useParseAddress, useListCustomPackageTypes, useCreateLabel, isDomesticAddress, useListSalesOrders, useListOrderSources, useRefreshOrderSource, useCalculateRates, useValidateAddresses, useListShipments, getPendingShipment, getIsCustomsRequiredForSalesOrder, getCustomsFromSalesOrder, registerElement, useGetShipment, useListLabels, useGetLabel, useVoidLabel } from '@shipengine/elements-core';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useCallback, useState, useEffect } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
@@ -2844,6 +2844,7 @@ const ShipmentForm = ({
|
|
|
2844
2844
|
onShipmentDirty,
|
|
2845
2845
|
// Must be referentially stable
|
|
2846
2846
|
onShipmentUpdated,
|
|
2847
|
+
onShipmentUpdateFailure,
|
|
2847
2848
|
onToggleAddressPreferenceDisclosure,
|
|
2848
2849
|
salesOrder,
|
|
2849
2850
|
shipment,
|
|
@@ -2897,6 +2898,8 @@ const ShipmentForm = ({
|
|
|
2897
2898
|
shouldCalculateRates: false,
|
|
2898
2899
|
shouldResetAddressPreference: options.shouldValidate
|
|
2899
2900
|
});
|
|
2901
|
+
} else if (onShipmentUpdateFailure) {
|
|
2902
|
+
onShipmentUpdateFailure();
|
|
2900
2903
|
}
|
|
2901
2904
|
});
|
|
2902
2905
|
|
|
@@ -2973,12 +2976,13 @@ const RateForm = ({
|
|
|
2973
2976
|
onLabelCreateFailure,
|
|
2974
2977
|
onLabelCreateSuccess,
|
|
2975
2978
|
onRateSaved,
|
|
2979
|
+
printLabelLayout,
|
|
2976
2980
|
rates,
|
|
2977
2981
|
shipment
|
|
2978
2982
|
}) => {
|
|
2979
2983
|
var _a;
|
|
2980
2984
|
|
|
2981
|
-
const createLabel = useCreateLabel();
|
|
2985
|
+
const createLabel = useCreateLabel(printLabelLayout);
|
|
2982
2986
|
const updateShipment = useUpdateShipment({
|
|
2983
2987
|
shipmentId: shipment === null || shipment === void 0 ? void 0 : shipment.shipmentId
|
|
2984
2988
|
});
|
|
@@ -20305,6 +20309,7 @@ const SalesOrder = ({
|
|
|
20305
20309
|
onShipmentUpdated,
|
|
20306
20310
|
onToggleAddressPreferenceDisclosure,
|
|
20307
20311
|
orderSourceCode,
|
|
20312
|
+
printLabelLayout,
|
|
20308
20313
|
salesOrderId,
|
|
20309
20314
|
shippingPresets,
|
|
20310
20315
|
warehouseId
|
|
@@ -20376,7 +20381,7 @@ const SalesOrder = ({
|
|
|
20376
20381
|
|
|
20377
20382
|
if (((_a = salesOrders.data) === null || _a === void 0 ? void 0 : _a.length) && shipments.data && ((_b = warehouses.data) === null || _b === void 0 ? void 0 : _b.length) && !createShipment.data && !createShipment.errors && !createShipment.isMutating) {
|
|
20378
20383
|
const currentSalesOrder = salesOrders.data[0];
|
|
20379
|
-
const pendingShipment = shipments.data
|
|
20384
|
+
const pendingShipment = getPendingShipment(shipments.data);
|
|
20380
20385
|
|
|
20381
20386
|
if (currentSalesOrder && !pendingShipment) {
|
|
20382
20387
|
const defaultWarehouse = (_c = warehouses.data.find(w => w.warehouseId === warehouseId)) !== null && _c !== void 0 ? _c : warehouses.data[0];
|
|
@@ -20411,40 +20416,44 @@ const SalesOrder = ({
|
|
|
20411
20416
|
yield onAddressValidation === null || onAddressValidation === void 0 ? void 0 : onAddressValidation(updatedAddressPreference);
|
|
20412
20417
|
}
|
|
20413
20418
|
} catch (error) {
|
|
20414
|
-
// Shipment creation failed most likely due to validate_and_clean
|
|
20415
|
-
//
|
|
20419
|
+
// Shipment creation failed, most likely due to validate_and_clean 500ing
|
|
20420
|
+
// and preventing a shipment from being created. Create a shipment with
|
|
20421
|
+
// the sales order ship to address without validating and setting the
|
|
20422
|
+
// address preference to an error state. This will display the not validated
|
|
20423
|
+
// error message to the user.
|
|
20416
20424
|
logger.warn("createShipment failed to create a shipment, trying plan b", error.message);
|
|
20417
|
-
|
|
20418
|
-
|
|
20419
|
-
|
|
20420
|
-
|
|
20421
|
-
|
|
20422
|
-
|
|
20423
|
-
|
|
20424
|
-
|
|
20425
|
-
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
|
|
20430
|
-
|
|
20431
|
-
|
|
20432
|
-
|
|
20433
|
-
|
|
20434
|
-
|
|
20435
|
-
|
|
20436
|
-
|
|
20437
|
-
}));
|
|
20438
|
-
yield shipments.mutate();
|
|
20425
|
+
|
|
20426
|
+
try {
|
|
20427
|
+
yield createShipment.trigger(Object.assign({
|
|
20428
|
+
// /v-beta/shipments/sales_order/:salesOrderId requires at minimum
|
|
20429
|
+
// a (warehouseId or shipFrom) and a package with weight defined.
|
|
20430
|
+
packages: [{
|
|
20431
|
+
weight: {
|
|
20432
|
+
value: 0,
|
|
20433
|
+
unit: "pound"
|
|
20434
|
+
}
|
|
20435
|
+
}],
|
|
20436
|
+
shipTo: currentSalesOrder.shipTo,
|
|
20437
|
+
warehouseId: defaultWarehouse.warehouseId
|
|
20438
|
+
}, getIsCustomsRequiredForSalesOrder(currentSalesOrder, defaultWarehouse) && {
|
|
20439
|
+
customs: getCustomsFromSalesOrder(currentSalesOrder, defaultWarehouse)
|
|
20440
|
+
}));
|
|
20441
|
+
const shipmentsMutationResult = yield shipments.mutate();
|
|
20442
|
+
const currentPendingShipment = getPendingShipment(shipmentsMutationResult);
|
|
20443
|
+
|
|
20444
|
+
if (currentPendingShipment) {
|
|
20439
20445
|
const updatedAddressPreference = resetAddressPreference({
|
|
20440
|
-
validation:
|
|
20441
|
-
|
|
20446
|
+
validation: {
|
|
20447
|
+
messages: [],
|
|
20448
|
+
originalAddress: currentPendingShipment.shipTo,
|
|
20449
|
+
status: "error"
|
|
20450
|
+
}
|
|
20442
20451
|
});
|
|
20443
20452
|
yield onAddressValidation === null || onAddressValidation === void 0 ? void 0 : onAddressValidation(updatedAddressPreference);
|
|
20444
|
-
} catch (error) {
|
|
20445
|
-
logger.error("createShipment failed to create a shipment", error.message);
|
|
20446
|
-
throw new Error("errorMessages.unableToLoad.shipment");
|
|
20447
20453
|
}
|
|
20454
|
+
} catch (error) {
|
|
20455
|
+
logger.error("createShipment failed to create a shipment", error.message);
|
|
20456
|
+
throw new Error("errorMessages.unableToLoad.shipment");
|
|
20448
20457
|
}
|
|
20449
20458
|
}
|
|
20450
20459
|
} else if (currentSalesOrder && pendingShipment && !validateAddresses.data && !validateAddresses.errors && !validateAddresses.isMutating) {
|
|
@@ -20469,7 +20478,28 @@ const SalesOrder = ({
|
|
|
20469
20478
|
var _a;
|
|
20470
20479
|
|
|
20471
20480
|
return !!((_a = customPackageTypes.data) === null || _a === void 0 ? void 0 : _a.find(p => p.packageId === shipment.packages[0].packageId));
|
|
20472
|
-
}, [customPackageTypes]);
|
|
20481
|
+
}, [customPackageTypes]); // validate_and_clean failure is preventing the address preference object
|
|
20482
|
+
// from being refreshed. Manualy set the address preference to an error state.
|
|
20483
|
+
// with the original address set to the newly updated shipment ship to
|
|
20484
|
+
// This will display the not validated error message with the edited address to the user.
|
|
20485
|
+
|
|
20486
|
+
const handleShipmentUpdateFailure = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
20487
|
+
const result = yield shipments.mutate();
|
|
20488
|
+
const currentShipment = getPendingShipment(result);
|
|
20489
|
+
|
|
20490
|
+
if (currentShipment) {
|
|
20491
|
+
const updatedAddressPreference = resetAddressPreference({
|
|
20492
|
+
validation: {
|
|
20493
|
+
messages: [],
|
|
20494
|
+
originalAddress: currentShipment.shipTo,
|
|
20495
|
+
status: "error"
|
|
20496
|
+
}
|
|
20497
|
+
});
|
|
20498
|
+
yield onAddressValidation === null || onAddressValidation === void 0 ? void 0 : onAddressValidation(updatedAddressPreference);
|
|
20499
|
+
yield onChangeAddress === null || onChangeAddress === void 0 ? void 0 : onChangeAddress(updatedAddressPreference);
|
|
20500
|
+
yield onShipmentUpdated === null || onShipmentUpdated === void 0 ? void 0 : onShipmentUpdated(currentShipment);
|
|
20501
|
+
}
|
|
20502
|
+
}), [onAddressValidation, onChangeAddress, resetAddressPreference, onShipmentUpdated, shipments]);
|
|
20473
20503
|
const handleShipmentUpdated = useCallback((shipment, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20474
20504
|
var _h, _j;
|
|
20475
20505
|
|
|
@@ -20533,7 +20563,7 @@ const SalesOrder = ({
|
|
|
20533
20563
|
message: t("loading.carriers")
|
|
20534
20564
|
});
|
|
20535
20565
|
const salesOrder = salesOrders.data[0];
|
|
20536
|
-
const shipment = shipments.data
|
|
20566
|
+
const shipment = getPendingShipment(shipments.data);
|
|
20537
20567
|
let rateErrors = [...((_b = calculateRates.errors) !== null && _b !== void 0 ? _b : []), ...((_d = (_c = calculateRates.data) === null || _c === void 0 ? void 0 : _c.errors) !== null && _d !== void 0 ? _d : [])]; // Sometimes no rates are returned and no top-level errors are returned
|
|
20538
20568
|
// but there are invalid rates with errors. This will expose those to the user
|
|
20539
20569
|
// so the rate list isn't empty after calculating rates.
|
|
@@ -20557,6 +20587,7 @@ const SalesOrder = ({
|
|
|
20557
20587
|
onChangeShipmentFormMode: onChangeShipmentFormMode,
|
|
20558
20588
|
onShipmentDirty: handleShipmentDirty,
|
|
20559
20589
|
onShipmentUpdated: handleShipmentUpdated,
|
|
20590
|
+
onShipmentUpdateFailure: handleShipmentUpdateFailure,
|
|
20560
20591
|
onToggleAddressPreferenceDisclosure: onToggleAddressPreferenceDisclosure,
|
|
20561
20592
|
salesOrder: salesOrder,
|
|
20562
20593
|
shipment: shipment,
|
|
@@ -20569,6 +20600,7 @@ const SalesOrder = ({
|
|
|
20569
20600
|
onLabelCreateFailure: onLabelCreateFailure,
|
|
20570
20601
|
onLabelCreateSuccess: onLabelCreateSuccess,
|
|
20571
20602
|
onRateSaved: handleRateSaved,
|
|
20603
|
+
printLabelLayout: printLabelLayout,
|
|
20572
20604
|
rates: (_g = calculateRates.data) === null || _g === void 0 ? void 0 : _g.rates,
|
|
20573
20605
|
shipment: shipment
|
|
20574
20606
|
})]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipengine/elements",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.44",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@packlink/giger": "*",
|
|
6
6
|
"react-i18next": "*",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"types": "./index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"react": "^18.2.0",
|
|
15
|
-
"@shipengine/elements-core": "0.6.
|
|
15
|
+
"@shipengine/elements-core": "0.6.44",
|
|
16
16
|
"i18next-http-backend": "^1.4.1",
|
|
17
17
|
"i18next-browser-languagedetector": "^6.1.4",
|
|
18
|
-
"@shipengine/types": "0.6.
|
|
19
|
-
"@shipengine/elements-ui": "0.6.
|
|
18
|
+
"@shipengine/types": "0.6.44",
|
|
19
|
+
"@shipengine/elements-ui": "0.6.44"
|
|
20
20
|
}
|
|
21
21
|
}
|