@shipengine/elements 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/configure-shipment/hooks/use-rates-form.d.ts +2 -0
- package/index.cjs +14 -4
- package/index.js +14 -4
- package/package.json +4 -4
|
@@ -13,11 +13,13 @@ export type UseRatesFormProps = {
|
|
|
13
13
|
export declare const useRatesForm: ({ onBeforeLabelCreate, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, shipment, }: UseRatesFormProps) => {
|
|
14
14
|
carriers: SE.Carrier[] | undefined;
|
|
15
15
|
errors: SE.CodedError[] | undefined;
|
|
16
|
+
labelErrors: SE.CodedError[] | undefined;
|
|
16
17
|
isLoading: boolean;
|
|
17
18
|
onSave: ({ carrierId, serviceCode }: Pick<SE.Rate, "carrierId" | "serviceCode">) => Promise<void>;
|
|
18
19
|
onSubmit: (rateId: string) => Promise<void>;
|
|
19
20
|
rates: SE.Rate[] | undefined;
|
|
20
21
|
requestRates: (shipment: SE.SalesOrderShipment) => Promise<void>;
|
|
22
|
+
resetLabel: () => void;
|
|
21
23
|
resetRates: () => void;
|
|
22
24
|
shipment: SE.SalesOrderShipment | undefined;
|
|
23
25
|
};
|
package/index.cjs
CHANGED
|
@@ -19339,6 +19339,8 @@ const useRatesForm = ({
|
|
|
19339
19339
|
shipmentId: shipment === null || shipment === void 0 ? void 0 : shipment.shipmentId
|
|
19340
19340
|
});
|
|
19341
19341
|
const {
|
|
19342
|
+
errors: labelErrors,
|
|
19343
|
+
reset: resetLabel,
|
|
19342
19344
|
trigger: createLabel
|
|
19343
19345
|
} = elementsCore.useCreateLabel(printLabelLayout);
|
|
19344
19346
|
const {
|
|
@@ -19409,11 +19411,13 @@ const useRatesForm = ({
|
|
|
19409
19411
|
return {
|
|
19410
19412
|
carriers,
|
|
19411
19413
|
errors: errors.length > 0 ? errors : undefined,
|
|
19414
|
+
labelErrors: (labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length) ? labelErrors : undefined,
|
|
19412
19415
|
isLoading: ratesCalculating,
|
|
19413
19416
|
onSave: handleSave,
|
|
19414
19417
|
onSubmit: handleSubmit,
|
|
19415
19418
|
rates: ratesResponse === null || ratesResponse === void 0 ? void 0 : ratesResponse.rates,
|
|
19416
19419
|
requestRates,
|
|
19420
|
+
resetLabel,
|
|
19417
19421
|
resetRates,
|
|
19418
19422
|
shipment
|
|
19419
19423
|
};
|
|
@@ -19527,10 +19531,11 @@ const ConfigureShipment = _a => {
|
|
|
19527
19531
|
shipment
|
|
19528
19532
|
}),
|
|
19529
19533
|
{
|
|
19534
|
+
requestRates,
|
|
19530
19535
|
resetRates,
|
|
19531
|
-
|
|
19536
|
+
resetLabel
|
|
19532
19537
|
} = _b,
|
|
19533
|
-
rateFormProps = __rest(_b, ["resetRates", "
|
|
19538
|
+
rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel"]);
|
|
19534
19539
|
const shipmentFormProps = useShipmentForm({
|
|
19535
19540
|
onAddressValidation,
|
|
19536
19541
|
onApplyPreset: react.useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -19554,14 +19559,19 @@ const ConfigureShipment = _a => {
|
|
|
19554
19559
|
setRateFormDisabled(false);
|
|
19555
19560
|
}
|
|
19556
19561
|
}, []);
|
|
19562
|
+
const handleOnDirty = react.useCallback(() => {
|
|
19563
|
+
resetRates();
|
|
19564
|
+
resetLabel();
|
|
19565
|
+
}, [resetRates, resetLabel]);
|
|
19557
19566
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
19558
19567
|
children: [jsxRuntime.jsx(elementsUi.Templates.ShipmentForm, Object.assign({}, shipmentFormProps, props, {
|
|
19559
|
-
onDirty:
|
|
19568
|
+
onDirty: handleOnDirty,
|
|
19560
19569
|
onCharsetWarning: handleCharsetWarning,
|
|
19561
19570
|
features: features === null || features === void 0 ? void 0 : features.shipmentForm
|
|
19562
19571
|
})), jsxRuntime.jsx(elementsUi.Templates.RateForm, Object.assign({}, rateFormProps, {
|
|
19563
19572
|
disabled: rateFormDisabled,
|
|
19564
|
-
features: features === null || features === void 0 ? void 0 : features.rateForm
|
|
19573
|
+
features: features === null || features === void 0 ? void 0 : features.rateForm,
|
|
19574
|
+
onSelectRate: resetLabel
|
|
19565
19575
|
}))]
|
|
19566
19576
|
});
|
|
19567
19577
|
};
|
package/index.js
CHANGED
|
@@ -19335,6 +19335,8 @@ const useRatesForm = ({
|
|
|
19335
19335
|
shipmentId: shipment === null || shipment === void 0 ? void 0 : shipment.shipmentId
|
|
19336
19336
|
});
|
|
19337
19337
|
const {
|
|
19338
|
+
errors: labelErrors,
|
|
19339
|
+
reset: resetLabel,
|
|
19338
19340
|
trigger: createLabel
|
|
19339
19341
|
} = useCreateLabel(printLabelLayout);
|
|
19340
19342
|
const {
|
|
@@ -19405,11 +19407,13 @@ const useRatesForm = ({
|
|
|
19405
19407
|
return {
|
|
19406
19408
|
carriers,
|
|
19407
19409
|
errors: errors.length > 0 ? errors : undefined,
|
|
19410
|
+
labelErrors: (labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length) ? labelErrors : undefined,
|
|
19408
19411
|
isLoading: ratesCalculating,
|
|
19409
19412
|
onSave: handleSave,
|
|
19410
19413
|
onSubmit: handleSubmit,
|
|
19411
19414
|
rates: ratesResponse === null || ratesResponse === void 0 ? void 0 : ratesResponse.rates,
|
|
19412
19415
|
requestRates,
|
|
19416
|
+
resetLabel,
|
|
19413
19417
|
resetRates,
|
|
19414
19418
|
shipment
|
|
19415
19419
|
};
|
|
@@ -19523,10 +19527,11 @@ const ConfigureShipment = _a => {
|
|
|
19523
19527
|
shipment
|
|
19524
19528
|
}),
|
|
19525
19529
|
{
|
|
19530
|
+
requestRates,
|
|
19526
19531
|
resetRates,
|
|
19527
|
-
|
|
19532
|
+
resetLabel
|
|
19528
19533
|
} = _b,
|
|
19529
|
-
rateFormProps = __rest(_b, ["resetRates", "
|
|
19534
|
+
rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel"]);
|
|
19530
19535
|
const shipmentFormProps = useShipmentForm({
|
|
19531
19536
|
onAddressValidation,
|
|
19532
19537
|
onApplyPreset: useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -19550,14 +19555,19 @@ const ConfigureShipment = _a => {
|
|
|
19550
19555
|
setRateFormDisabled(false);
|
|
19551
19556
|
}
|
|
19552
19557
|
}, []);
|
|
19558
|
+
const handleOnDirty = useCallback(() => {
|
|
19559
|
+
resetRates();
|
|
19560
|
+
resetLabel();
|
|
19561
|
+
}, [resetRates, resetLabel]);
|
|
19553
19562
|
return jsxs(Fragment, {
|
|
19554
19563
|
children: [jsx(Templates.ShipmentForm, Object.assign({}, shipmentFormProps, props, {
|
|
19555
|
-
onDirty:
|
|
19564
|
+
onDirty: handleOnDirty,
|
|
19556
19565
|
onCharsetWarning: handleCharsetWarning,
|
|
19557
19566
|
features: features === null || features === void 0 ? void 0 : features.shipmentForm
|
|
19558
19567
|
})), jsx(Templates.RateForm, Object.assign({}, rateFormProps, {
|
|
19559
19568
|
disabled: rateFormDisabled,
|
|
19560
|
-
features: features === null || features === void 0 ? void 0 : features.rateForm
|
|
19569
|
+
features: features === null || features === void 0 ? void 0 : features.rateForm,
|
|
19570
|
+
onSelectRate: resetLabel
|
|
19561
19571
|
}))]
|
|
19562
19572
|
});
|
|
19563
19573
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipengine/elements",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@packlink/giger": "*",
|
|
6
6
|
"react-i18next": "*",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"types": "./index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"react": "^18.2.0",
|
|
15
|
-
"@shipengine/elements-core": "0.10.
|
|
16
|
-
"@shipengine/elements-ui": "0.10.
|
|
17
|
-
"@shipengine/types": "0.10.
|
|
15
|
+
"@shipengine/elements-core": "0.10.1",
|
|
16
|
+
"@shipengine/elements-ui": "0.10.1",
|
|
17
|
+
"@shipengine/types": "0.10.1",
|
|
18
18
|
"@emotion/react": "^11.10.0",
|
|
19
19
|
"@packlink/brands": "^3.18.0"
|
|
20
20
|
}
|