@shipengine/elements 0.6.46 → 0.6.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +14 -1
  2. package/index.js +14 -1
  3. package/package.json +4 -4
package/index.cjs CHANGED
@@ -2908,6 +2908,8 @@ const ShipmentForm = ({
2908
2908
  });
2909
2909
 
2910
2910
  const handleApplyPreset = preset => __awaiter(void 0, void 0, void 0, function* () {
2911
+ var _a, _b;
2912
+
2911
2913
  const updatedShipment = yield createOrUpdateShipment(Object.assign(Object.assign(Object.assign({}, shipment), preset.serviceCode && preset.carrierId && {
2912
2914
  carrierId: preset.carrierId,
2913
2915
  serviceCode: preset.serviceCode
@@ -2919,13 +2921,24 @@ const ShipmentForm = ({
2919
2921
  weight: preset.weight,
2920
2922
  insuredValue: preset.insuredValue,
2921
2923
  packageCode: preset.packageCode
2924
+ }] : preset.packageCode ? [{
2925
+ dimensions: preset.dimensions,
2926
+ // default to 1 lb, otherwise packageCode will NOT be saved
2927
+ weight: {
2928
+ value: 16,
2929
+ unit: "ounce"
2930
+ },
2931
+ insuredValue: preset.insuredValue,
2932
+ packageCode: preset.packageCode
2922
2933
  }] : undefined
2923
2934
  }));
2924
2935
 
2925
2936
  if (updatedShipment) {
2937
+ const updatedPackage = (_a = updateShipment.data) === null || _a === void 0 ? void 0 : _a.packages[0];
2926
2938
  yield onApplyPreset === null || onApplyPreset === void 0 ? void 0 : onApplyPreset(preset, updatedShipment);
2927
2939
  yield onShipmentUpdated(updatedShipment, {
2928
- shouldCalculateRates: !!(preset.dimensions && preset.weight),
2940
+ // custom presets require dimensions, but not flat-rate presets
2941
+ shouldCalculateRates: !!((_b = updatedPackage === null || updatedPackage === void 0 ? void 0 : updatedPackage.weight) === null || _b === void 0 ? void 0 : _b.value),
2929
2942
  shouldResetAddressPreference: false
2930
2943
  });
2931
2944
  }
package/index.js CHANGED
@@ -2904,6 +2904,8 @@ const ShipmentForm = ({
2904
2904
  });
2905
2905
 
2906
2906
  const handleApplyPreset = preset => __awaiter(void 0, void 0, void 0, function* () {
2907
+ var _a, _b;
2908
+
2907
2909
  const updatedShipment = yield createOrUpdateShipment(Object.assign(Object.assign(Object.assign({}, shipment), preset.serviceCode && preset.carrierId && {
2908
2910
  carrierId: preset.carrierId,
2909
2911
  serviceCode: preset.serviceCode
@@ -2915,13 +2917,24 @@ const ShipmentForm = ({
2915
2917
  weight: preset.weight,
2916
2918
  insuredValue: preset.insuredValue,
2917
2919
  packageCode: preset.packageCode
2920
+ }] : preset.packageCode ? [{
2921
+ dimensions: preset.dimensions,
2922
+ // default to 1 lb, otherwise packageCode will NOT be saved
2923
+ weight: {
2924
+ value: 16,
2925
+ unit: "ounce"
2926
+ },
2927
+ insuredValue: preset.insuredValue,
2928
+ packageCode: preset.packageCode
2918
2929
  }] : undefined
2919
2930
  }));
2920
2931
 
2921
2932
  if (updatedShipment) {
2933
+ const updatedPackage = (_a = updateShipment.data) === null || _a === void 0 ? void 0 : _a.packages[0];
2922
2934
  yield onApplyPreset === null || onApplyPreset === void 0 ? void 0 : onApplyPreset(preset, updatedShipment);
2923
2935
  yield onShipmentUpdated(updatedShipment, {
2924
- shouldCalculateRates: !!(preset.dimensions && preset.weight),
2936
+ // custom presets require dimensions, but not flat-rate presets
2937
+ shouldCalculateRates: !!((_b = updatedPackage === null || updatedPackage === void 0 ? void 0 : updatedPackage.weight) === null || _b === void 0 ? void 0 : _b.value),
2925
2938
  shouldResetAddressPreference: false
2926
2939
  });
2927
2940
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/elements",
3
- "version": "0.6.46",
3
+ "version": "0.6.48",
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.46",
15
+ "@shipengine/elements-core": "0.6.48",
16
16
  "i18next-http-backend": "^1.4.1",
17
17
  "i18next-browser-languagedetector": "^6.1.4",
18
- "@shipengine/types": "0.6.46",
19
- "@shipengine/elements-ui": "0.6.46"
18
+ "@shipengine/types": "0.6.48",
19
+ "@shipengine/elements-ui": "0.6.48"
20
20
  }
21
21
  }