@shipengine/elements 0.26.7 → 0.26.12
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
|
@@ -10805,8 +10805,10 @@ const styles$9 = createStyles({
|
|
|
10805
10805
|
});
|
|
10806
10806
|
|
|
10807
10807
|
const CarrierBalance = ({
|
|
10808
|
+
balance,
|
|
10808
10809
|
carrierId
|
|
10809
10810
|
}) => {
|
|
10811
|
+
var _a;
|
|
10810
10812
|
const {
|
|
10811
10813
|
t
|
|
10812
10814
|
} = reactI18next.useTranslation();
|
|
@@ -10815,16 +10817,16 @@ const CarrierBalance = ({
|
|
|
10815
10817
|
isLoading: isLoadingCarrier,
|
|
10816
10818
|
isRefetching: isRefetchingCarrier
|
|
10817
10819
|
} = alchemy.useGetCarrierById(carrierId);
|
|
10818
|
-
const
|
|
10820
|
+
const carrierBalance = (_a = carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== null && _a !== void 0 ? _a : balance;
|
|
10819
10821
|
return jsxRuntime.jsx(InlineLabel, Object.assign({
|
|
10820
10822
|
label: t("manage-funding:currentBalance")
|
|
10821
10823
|
}, {
|
|
10822
10824
|
children: isLoadingCarrier || isRefetchingCarrier ? jsxRuntime.jsx(giger.Spinner, {}) : jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
10823
10825
|
bold: true,
|
|
10824
|
-
css: styles$9.getBalanceText(
|
|
10826
|
+
css: styles$9.getBalanceText(carrierBalance)
|
|
10825
10827
|
}, {
|
|
10826
|
-
children:
|
|
10827
|
-
amount:
|
|
10828
|
+
children: carrierBalance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
|
|
10829
|
+
amount: carrierBalance,
|
|
10828
10830
|
currency: alchemy.SE.Currency.USD
|
|
10829
10831
|
})
|
|
10830
10832
|
}))
|
|
@@ -10872,6 +10874,7 @@ const styles$8 = createStyles({
|
|
|
10872
10874
|
* to submit the funding form followed by the purchase form.
|
|
10873
10875
|
*/
|
|
10874
10876
|
const FundAndPurchase = ({
|
|
10877
|
+
balance: uspsBalance,
|
|
10875
10878
|
carrierId,
|
|
10876
10879
|
className,
|
|
10877
10880
|
control,
|
|
@@ -10947,13 +10950,23 @@ const FundAndPurchase = ({
|
|
|
10947
10950
|
}))]
|
|
10948
10951
|
}))]
|
|
10949
10952
|
});
|
|
10950
|
-
//
|
|
10951
|
-
|
|
10952
|
-
if (!isFundingRequired) return jsxRuntime.jsx("div", Object.assign({
|
|
10953
|
+
// render when no rate has been selected yet
|
|
10954
|
+
if (!carrierId) return jsxRuntime.jsxs("div", Object.assign({
|
|
10953
10955
|
className: className,
|
|
10954
10956
|
css: styles$8.container
|
|
10955
10957
|
}, {
|
|
10956
|
-
children:
|
|
10958
|
+
children: [jsxRuntime.jsxs(Spread, {
|
|
10959
|
+
children: [jsxRuntime.jsx(CarrierBalance, {
|
|
10960
|
+
balance: uspsBalance
|
|
10961
|
+
}), isFundingEnabled ? jsxRuntime.jsx(LinkAction, {
|
|
10962
|
+
icon: "add",
|
|
10963
|
+
isDisabled: !isFundingRequired || isAddFundsFormOpen || isRateFormSubmitting,
|
|
10964
|
+
onClick: () => setIsAddFundsFormOpen(true),
|
|
10965
|
+
title: t("manage-funding:actions.addFunds")
|
|
10966
|
+
}) : null]
|
|
10967
|
+
}), jsxRuntime.jsx(Spacer, {
|
|
10968
|
+
multiplier: 2
|
|
10969
|
+
}), renderActionButtons()]
|
|
10957
10970
|
}));
|
|
10958
10971
|
if (isLoadingCarrier) return jsxRuntime.jsx(Loader, {
|
|
10959
10972
|
message: t("loading.carrier")
|
|
@@ -11652,6 +11665,10 @@ const RateForm = ({
|
|
|
11652
11665
|
}, 0);
|
|
11653
11666
|
}
|
|
11654
11667
|
}, [form, rateOptions, errors === null || errors === void 0 ? void 0 : errors.length]);
|
|
11668
|
+
const balance = React.useMemo(() => {
|
|
11669
|
+
var _a;
|
|
11670
|
+
return (_a = carriers === null || carriers === void 0 ? void 0 : carriers.find(carrier => carrier.carrierCode === "usps")) === null || _a === void 0 ? void 0 : _a.balance;
|
|
11671
|
+
}, [carriers]);
|
|
11655
11672
|
return jsxRuntime.jsxs("form", Object.assign({
|
|
11656
11673
|
id: "rate-form",
|
|
11657
11674
|
onSubmit: handleSubmit,
|
|
@@ -11717,6 +11734,7 @@ const RateForm = ({
|
|
|
11717
11734
|
display: "purchase"
|
|
11718
11735
|
})
|
|
11719
11736
|
})), jsxRuntime.jsx(FundAndPurchase, {
|
|
11737
|
+
balance: balance,
|
|
11720
11738
|
carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
|
|
11721
11739
|
control: form.control,
|
|
11722
11740
|
css: styles$4.fundAndPurchase,
|
package/index.js
CHANGED
|
@@ -10773,8 +10773,10 @@ const styles$9 = createStyles({
|
|
|
10773
10773
|
});
|
|
10774
10774
|
|
|
10775
10775
|
const CarrierBalance = ({
|
|
10776
|
+
balance,
|
|
10776
10777
|
carrierId
|
|
10777
10778
|
}) => {
|
|
10779
|
+
var _a;
|
|
10778
10780
|
const {
|
|
10779
10781
|
t
|
|
10780
10782
|
} = useTranslation();
|
|
@@ -10783,16 +10785,16 @@ const CarrierBalance = ({
|
|
|
10783
10785
|
isLoading: isLoadingCarrier,
|
|
10784
10786
|
isRefetching: isRefetchingCarrier
|
|
10785
10787
|
} = useGetCarrierById(carrierId);
|
|
10786
|
-
const
|
|
10788
|
+
const carrierBalance = (_a = carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== null && _a !== void 0 ? _a : balance;
|
|
10787
10789
|
return jsx(InlineLabel, Object.assign({
|
|
10788
10790
|
label: t("manage-funding:currentBalance")
|
|
10789
10791
|
}, {
|
|
10790
10792
|
children: isLoadingCarrier || isRefetchingCarrier ? jsx(Spinner, {}) : jsx(Typography, Object.assign({
|
|
10791
10793
|
bold: true,
|
|
10792
|
-
css: styles$9.getBalanceText(
|
|
10794
|
+
css: styles$9.getBalanceText(carrierBalance)
|
|
10793
10795
|
}, {
|
|
10794
|
-
children:
|
|
10795
|
-
amount:
|
|
10796
|
+
children: carrierBalance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
|
|
10797
|
+
amount: carrierBalance,
|
|
10796
10798
|
currency: SE.Currency.USD
|
|
10797
10799
|
})
|
|
10798
10800
|
}))
|
|
@@ -10840,6 +10842,7 @@ const styles$8 = createStyles({
|
|
|
10840
10842
|
* to submit the funding form followed by the purchase form.
|
|
10841
10843
|
*/
|
|
10842
10844
|
const FundAndPurchase = ({
|
|
10845
|
+
balance: uspsBalance,
|
|
10843
10846
|
carrierId,
|
|
10844
10847
|
className,
|
|
10845
10848
|
control,
|
|
@@ -10915,13 +10918,23 @@ const FundAndPurchase = ({
|
|
|
10915
10918
|
}))]
|
|
10916
10919
|
}))]
|
|
10917
10920
|
});
|
|
10918
|
-
//
|
|
10919
|
-
|
|
10920
|
-
if (!isFundingRequired) return jsx("div", Object.assign({
|
|
10921
|
+
// render when no rate has been selected yet
|
|
10922
|
+
if (!carrierId) return jsxs("div", Object.assign({
|
|
10921
10923
|
className: className,
|
|
10922
10924
|
css: styles$8.container
|
|
10923
10925
|
}, {
|
|
10924
|
-
children:
|
|
10926
|
+
children: [jsxs(Spread, {
|
|
10927
|
+
children: [jsx(CarrierBalance, {
|
|
10928
|
+
balance: uspsBalance
|
|
10929
|
+
}), isFundingEnabled ? jsx(LinkAction, {
|
|
10930
|
+
icon: "add",
|
|
10931
|
+
isDisabled: !isFundingRequired || isAddFundsFormOpen || isRateFormSubmitting,
|
|
10932
|
+
onClick: () => setIsAddFundsFormOpen(true),
|
|
10933
|
+
title: t("manage-funding:actions.addFunds")
|
|
10934
|
+
}) : null]
|
|
10935
|
+
}), jsx(Spacer, {
|
|
10936
|
+
multiplier: 2
|
|
10937
|
+
}), renderActionButtons()]
|
|
10925
10938
|
}));
|
|
10926
10939
|
if (isLoadingCarrier) return jsx(Loader, {
|
|
10927
10940
|
message: t("loading.carrier")
|
|
@@ -11620,6 +11633,10 @@ const RateForm = ({
|
|
|
11620
11633
|
}, 0);
|
|
11621
11634
|
}
|
|
11622
11635
|
}, [form, rateOptions, errors === null || errors === void 0 ? void 0 : errors.length]);
|
|
11636
|
+
const balance = useMemo(() => {
|
|
11637
|
+
var _a;
|
|
11638
|
+
return (_a = carriers === null || carriers === void 0 ? void 0 : carriers.find(carrier => carrier.carrierCode === "usps")) === null || _a === void 0 ? void 0 : _a.balance;
|
|
11639
|
+
}, [carriers]);
|
|
11623
11640
|
return jsxs("form", Object.assign({
|
|
11624
11641
|
id: "rate-form",
|
|
11625
11642
|
onSubmit: handleSubmit,
|
|
@@ -11685,6 +11702,7 @@ const RateForm = ({
|
|
|
11685
11702
|
display: "purchase"
|
|
11686
11703
|
})
|
|
11687
11704
|
})), jsx(FundAndPurchase, {
|
|
11705
|
+
balance: balance,
|
|
11688
11706
|
carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
|
|
11689
11707
|
control: form.control,
|
|
11690
11708
|
css: styles$4.fundAndPurchase,
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type CarrierBalanceProps = {
|
|
2
|
-
|
|
2
|
+
balance?: number;
|
|
3
|
+
carrierId?: string;
|
|
3
4
|
};
|
|
4
|
-
export declare const CarrierBalance: ({ carrierId }: CarrierBalanceProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const CarrierBalance: ({ balance, carrierId }: CarrierBalanceProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Control } from "react-hook-form";
|
|
2
2
|
export type FundAndPurchaseProps = {
|
|
3
|
+
balance?: number;
|
|
3
4
|
carrierId?: string;
|
|
4
5
|
className?: string;
|
|
5
6
|
control: Control<any, any>;
|
|
@@ -15,4 +16,4 @@ export type FundAndPurchaseProps = {
|
|
|
15
16
|
* has the necessary funds available and can add them if not. It allows a single button
|
|
16
17
|
* to submit the funding form followed by the purchase form.
|
|
17
18
|
*/
|
|
18
|
-
export declare const FundAndPurchase: ({ carrierId, className, control, disabled, isFundingEnabled, isFundingRequired, onSave, purchaseAmount, onPurchase, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const FundAndPurchase: ({ balance: uspsBalance, carrierId, className, control, disabled, isFundingEnabled, isFundingRequired, onSave, purchaseAmount, onPurchase, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|