@shipengine/elements 0.26.0 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -3715,7 +3715,12 @@ $$c({ target: 'String', proto: true }, {
3715
3715
  }
3716
3716
  });
3717
3717
 
3718
- let _LOCALE = navigator.language;
3718
+ // TODO: Quick Fix for White Label; The navigator object cannot be accessed from within SSR,
3719
+ // so this provides default value until this feature can be refactored to support SSR.
3720
+ let _LOCALE = "en-US";
3721
+ try {
3722
+ _LOCALE = navigator.language;
3723
+ } catch (_a) {}
3719
3724
  const loadableLocale = _LOCALE.replaceAll("-", "");
3720
3725
  const loadableBackupLocale = _LOCALE.split("-")[0];
3721
3726
  let intlLocale = undefined;
@@ -10866,36 +10871,56 @@ const FundAndPurchase = ({
10866
10871
  control
10867
10872
  });
10868
10873
  const [isSavingRate, setIsSavingRate] = React.useState(false);
10874
+ const [isSavingError, setIsSavingError] = React.useState(false);
10869
10875
  const handleSaveRate = () => __awaiter(void 0, void 0, void 0, function* () {
10870
10876
  setIsSavingRate(true);
10871
- yield onSave();
10872
- setIsSavingRate(false);
10877
+ setIsSavingError(false);
10878
+ try {
10879
+ yield onSave();
10880
+ } catch (e) {
10881
+ setIsSavingError(true);
10882
+ } finally {
10883
+ setIsSavingRate(false);
10884
+ }
10873
10885
  });
10874
10886
  // Automatically open the Add Funds form if the carrier's balance is insufficient.
10875
10887
  React.useEffect(() => {
10876
10888
  if (isFundingEnabled && isFundingRequired && (carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== undefined && carrier.balance < purchaseAmount) setIsAddFundsFormOpen(true);
10877
10889
  }, [carrier === null || carrier === void 0 ? void 0 : carrier.balance, isFundingEnabled, isFundingRequired, purchaseAmount]);
10878
- const renderActionButtons = (addFundsForm = {}) => jsxRuntime.jsxs(ButtonGroup, Object.assign({
10879
- justify: "end"
10880
- }, {
10881
- children: [jsxRuntime.jsx(giger.Button, Object.assign({
10882
- bold: false,
10883
- css: styles$8.saveRateButton,
10884
- disabled: disabled || !carrierId || addFundsForm.isSubmitting || isRateFormSubmitting,
10885
- isLoading: isSavingRate,
10886
- onClick: handleSaveRate,
10887
- variant: giger.ButtonVariant.OUTLINED
10888
- }, {
10889
- children: t("purchase-label:actions.saveRate")
10890
- })), jsxRuntime.jsx(giger.Button, Object.assign({
10891
- "data-testid": "submit-fund-and-purchase",
10892
- disabled: disabled || !carrierId || !isRateFormValid || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
10893
- isLoading: addFundsForm.isSubmitting || isRateFormSubmitting,
10894
- onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
10890
+ const renderActionButtons = (addFundsForm = {}) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
10891
+ children: [isSavingError && jsxRuntime.jsxs(jsxRuntime.Fragment, {
10892
+ children: [jsxRuntime.jsx(giger.InlineNotification, Object.assign({
10893
+ type: giger.NotificationType.ERROR,
10894
+ title: t("purchase-label:errorMessages.saveRateFailedTitle")
10895
+ }, {
10896
+ children: jsxRuntime.jsx(giger.Typography, {
10897
+ children: t("purchase-label:errorMessages.saveRateFailedMessage")
10898
+ })
10899
+ })), jsxRuntime.jsx(Spacer, {
10900
+ multiplier: 2
10901
+ })]
10902
+ }), jsxRuntime.jsxs(ButtonGroup, Object.assign({
10903
+ justify: "end"
10895
10904
  }, {
10896
- children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
10905
+ children: [jsxRuntime.jsx(giger.Button, Object.assign({
10906
+ bold: false,
10907
+ css: styles$8.saveRateButton,
10908
+ disabled: disabled || !carrierId || addFundsForm.isSubmitting || isRateFormSubmitting,
10909
+ isLoading: isSavingRate,
10910
+ onClick: handleSaveRate,
10911
+ variant: giger.ButtonVariant.OUTLINED
10912
+ }, {
10913
+ children: t("purchase-label:actions.saveRate")
10914
+ })), jsxRuntime.jsx(giger.Button, Object.assign({
10915
+ "data-testid": "submit-fund-and-purchase",
10916
+ disabled: disabled || !carrierId || !isRateFormValid || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
10917
+ isLoading: addFundsForm.isSubmitting || isRateFormSubmitting,
10918
+ onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
10919
+ }, {
10920
+ children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
10921
+ }))]
10897
10922
  }))]
10898
- }));
10923
+ });
10899
10924
  // Render: not a walleted carrier;
10900
10925
  // don't show balance or funding form
10901
10926
  if (!isFundingRequired) return jsxRuntime.jsx("div", Object.assign({
@@ -14074,7 +14099,9 @@ var purchaseLabel$1 = {
14074
14099
  invalidAddress: "The address cannot be validated. Please confirm the address details with your customer and <link>edit the address in ShipStation</link>.",
14075
14100
  noRates: "We were unable to find any rates matching your shipment information",
14076
14101
  salesOrderNotLoaded: "Sales order has not been loaded",
14077
- unsupportedAddress: "At this time, we do not support shipping to international addresses that require customs declarations, including international, military, and US Territory addresses. You can create a label for this order in ShipStation."
14102
+ unsupportedAddress: "At this time, we do not support shipping to international addresses that require customs declarations, including international, military, and US Territory addresses. You can create a label for this order in ShipStation.",
14103
+ saveRateFailedMessage: "Saving DHL Express Worldwide rates is temporarily unavailable. Please try again later.",
14104
+ saveRateFailedTitle: "Unable To Save Rate"
14078
14105
  },
14079
14106
  errorTypes: {
14080
14107
  results: "No results returned"
package/index.js CHANGED
@@ -3683,7 +3683,12 @@ $$c({ target: 'String', proto: true }, {
3683
3683
  }
3684
3684
  });
3685
3685
 
3686
- let _LOCALE = navigator.language;
3686
+ // TODO: Quick Fix for White Label; The navigator object cannot be accessed from within SSR,
3687
+ // so this provides default value until this feature can be refactored to support SSR.
3688
+ let _LOCALE = "en-US";
3689
+ try {
3690
+ _LOCALE = navigator.language;
3691
+ } catch (_a) {}
3687
3692
  const loadableLocale = _LOCALE.replaceAll("-", "");
3688
3693
  const loadableBackupLocale = _LOCALE.split("-")[0];
3689
3694
  let intlLocale = undefined;
@@ -10834,36 +10839,56 @@ const FundAndPurchase = ({
10834
10839
  control
10835
10840
  });
10836
10841
  const [isSavingRate, setIsSavingRate] = useState(false);
10842
+ const [isSavingError, setIsSavingError] = useState(false);
10837
10843
  const handleSaveRate = () => __awaiter(void 0, void 0, void 0, function* () {
10838
10844
  setIsSavingRate(true);
10839
- yield onSave();
10840
- setIsSavingRate(false);
10845
+ setIsSavingError(false);
10846
+ try {
10847
+ yield onSave();
10848
+ } catch (e) {
10849
+ setIsSavingError(true);
10850
+ } finally {
10851
+ setIsSavingRate(false);
10852
+ }
10841
10853
  });
10842
10854
  // Automatically open the Add Funds form if the carrier's balance is insufficient.
10843
10855
  useEffect(() => {
10844
10856
  if (isFundingEnabled && isFundingRequired && (carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== undefined && carrier.balance < purchaseAmount) setIsAddFundsFormOpen(true);
10845
10857
  }, [carrier === null || carrier === void 0 ? void 0 : carrier.balance, isFundingEnabled, isFundingRequired, purchaseAmount]);
10846
- const renderActionButtons = (addFundsForm = {}) => jsxs(ButtonGroup, Object.assign({
10847
- justify: "end"
10848
- }, {
10849
- children: [jsx(Button, Object.assign({
10850
- bold: false,
10851
- css: styles$8.saveRateButton,
10852
- disabled: disabled || !carrierId || addFundsForm.isSubmitting || isRateFormSubmitting,
10853
- isLoading: isSavingRate,
10854
- onClick: handleSaveRate,
10855
- variant: ButtonVariant.OUTLINED
10856
- }, {
10857
- children: t("purchase-label:actions.saveRate")
10858
- })), jsx(Button, Object.assign({
10859
- "data-testid": "submit-fund-and-purchase",
10860
- disabled: disabled || !carrierId || !isRateFormValid || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
10861
- isLoading: addFundsForm.isSubmitting || isRateFormSubmitting,
10862
- onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
10858
+ const renderActionButtons = (addFundsForm = {}) => jsxs(Fragment, {
10859
+ children: [isSavingError && jsxs(Fragment, {
10860
+ children: [jsx(InlineNotification, Object.assign({
10861
+ type: NotificationType.ERROR,
10862
+ title: t("purchase-label:errorMessages.saveRateFailedTitle")
10863
+ }, {
10864
+ children: jsx(Typography, {
10865
+ children: t("purchase-label:errorMessages.saveRateFailedMessage")
10866
+ })
10867
+ })), jsx(Spacer, {
10868
+ multiplier: 2
10869
+ })]
10870
+ }), jsxs(ButtonGroup, Object.assign({
10871
+ justify: "end"
10863
10872
  }, {
10864
- children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
10873
+ children: [jsx(Button, Object.assign({
10874
+ bold: false,
10875
+ css: styles$8.saveRateButton,
10876
+ disabled: disabled || !carrierId || addFundsForm.isSubmitting || isRateFormSubmitting,
10877
+ isLoading: isSavingRate,
10878
+ onClick: handleSaveRate,
10879
+ variant: ButtonVariant.OUTLINED
10880
+ }, {
10881
+ children: t("purchase-label:actions.saveRate")
10882
+ })), jsx(Button, Object.assign({
10883
+ "data-testid": "submit-fund-and-purchase",
10884
+ disabled: disabled || !carrierId || !isRateFormValid || isFundingEnabled && isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
10885
+ isLoading: addFundsForm.isSubmitting || isRateFormSubmitting,
10886
+ onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
10887
+ }, {
10888
+ children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
10889
+ }))]
10865
10890
  }))]
10866
- }));
10891
+ });
10867
10892
  // Render: not a walleted carrier;
10868
10893
  // don't show balance or funding form
10869
10894
  if (!isFundingRequired) return jsx("div", Object.assign({
@@ -14042,7 +14067,9 @@ var purchaseLabel$1 = {
14042
14067
  invalidAddress: "The address cannot be validated. Please confirm the address details with your customer and <link>edit the address in ShipStation</link>.",
14043
14068
  noRates: "We were unable to find any rates matching your shipment information",
14044
14069
  salesOrderNotLoaded: "Sales order has not been loaded",
14045
- unsupportedAddress: "At this time, we do not support shipping to international addresses that require customs declarations, including international, military, and US Territory addresses. You can create a label for this order in ShipStation."
14070
+ unsupportedAddress: "At this time, we do not support shipping to international addresses that require customs declarations, including international, military, and US Territory addresses. You can create a label for this order in ShipStation.",
14071
+ saveRateFailedMessage: "Saving DHL Express Worldwide rates is temporarily unavailable. Please try again later.",
14072
+ saveRateFailedTitle: "Unable To Save Rate"
14046
14073
  },
14047
14074
  errorTypes: {
14048
14075
  results: "No results returned"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/elements",
3
- "version": "0.26.0",
3
+ "version": "0.26.2",
4
4
  "typedoc": {
5
5
  "entryPoint": "./src/index.ts",
6
6
  "readmeFile": "../../README.md",
@@ -144,6 +144,8 @@ export declare const Element: ({ resources, ...props }: object & {
144
144
  noRates: string;
145
145
  salesOrderNotLoaded: string;
146
146
  unsupportedAddress: string;
147
+ saveRateFailedMessage: string;
148
+ saveRateFailedTitle: string;
147
149
  };
148
150
  errorTypes: {
149
151
  results: string;
@@ -148,6 +148,8 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
148
148
  noRates: string;
149
149
  salesOrderNotLoaded: string;
150
150
  unsupportedAddress: string;
151
+ saveRateFailedMessage: string;
152
+ saveRateFailedTitle: string;
151
153
  };
152
154
  errorTypes: {
153
155
  results: string;
@@ -147,6 +147,8 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
147
147
  noRates: string;
148
148
  salesOrderNotLoaded: string;
149
149
  unsupportedAddress: string;
150
+ saveRateFailedMessage: string;
151
+ saveRateFailedTitle: string;
150
152
  };
151
153
  errorTypes: {
152
154
  results: string;
@@ -155,6 +155,8 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
155
155
  noRates: string;
156
156
  salesOrderNotLoaded: string;
157
157
  unsupportedAddress: string;
158
+ saveRateFailedMessage: string;
159
+ saveRateFailedTitle: string;
158
160
  };
159
161
  errorTypes: {
160
162
  results: string;
@@ -156,6 +156,8 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
156
156
  noRates: string;
157
157
  salesOrderNotLoaded: string;
158
158
  unsupportedAddress: string;
159
+ saveRateFailedMessage: string;
160
+ saveRateFailedTitle: string;
159
161
  };
160
162
  errorTypes: {
161
163
  results: string;
@@ -151,6 +151,8 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
151
151
  noRates: string;
152
152
  salesOrderNotLoaded: string;
153
153
  unsupportedAddress: string;
154
+ saveRateFailedMessage: string;
155
+ saveRateFailedTitle: string;
154
156
  };
155
157
  errorTypes: {
156
158
  results: string;
@@ -140,6 +140,8 @@ declare const _default: {
140
140
  noRates: string;
141
141
  salesOrderNotLoaded: string;
142
142
  unsupportedAddress: string;
143
+ saveRateFailedMessage: string;
144
+ saveRateFailedTitle: string;
143
145
  };
144
146
  errorTypes: {
145
147
  results: string;