@tapcart/mobile-components 0.11.2 → 0.11.3
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.
|
@@ -22,9 +22,10 @@ const moneyVariants = cva("", {
|
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
24
|
function Money(_a) {
|
|
25
|
+
var _b, _c;
|
|
25
26
|
var { price, locale, currency, hideZeroCents = false, styles } = _a, props = __rest(_a, ["price", "locale", "currency", "hideZeroCents", "styles"]);
|
|
26
27
|
// Only use routeLocale if it contains a hyphen (e.g., "en-US")
|
|
27
|
-
const routeLocale = usePathname().split("/").pop();
|
|
28
|
+
const routeLocale = ((_c = (_b = usePathname()) === null || _b === void 0 ? void 0 : _b.split("/")) === null || _c === void 0 ? void 0 : _c.pop()) || "";
|
|
28
29
|
const isValidLocale = routeLocale && routeLocale.includes("-");
|
|
29
30
|
let language = isValidLocale ? routeLocale : locale;
|
|
30
31
|
// Fix for when we want to format in USD in english
|
|
@@ -36,7 +37,7 @@ function Money(_a) {
|
|
|
36
37
|
style: "currency",
|
|
37
38
|
currency: currency,
|
|
38
39
|
currencyDisplay: "narrowSymbol",
|
|
39
|
-
}), [
|
|
40
|
+
}), [language, currency]);
|
|
40
41
|
const formattedPrice = React.useMemo(() => {
|
|
41
42
|
const formatted = formatter.format(Number(price));
|
|
42
43
|
return hideZeroCents ? formatted.replace(/(\.|,)00$/, "") : formatted;
|