@revenexx/cover 0.1.20 → 0.1.21

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.
@@ -15,7 +15,8 @@ const props = defineProps<{
15
15
  const { getImage } = useProductImage();
16
16
  const cart = useCartStore();
17
17
  const { t } = useI18n();
18
- const { public: { locale, currency } } = useRuntimeConfig();
18
+ const { public: { locale } } = useRuntimeConfig();
19
+ const currency = useDisplayCurrency();
19
20
 
20
21
  const effectivePrice = computed(() => cart.getEffectivePrice(props.item.id));
21
22
  const taxRate = computed(() => {
@@ -33,7 +34,7 @@ const displayPrice = computed(() =>
33
34
  ),
34
35
  );
35
36
  const formattedPrice = computed(() =>
36
- displayPrice.value.toLocaleString(locale as string, { style: "currency", currency: currency as string }),
37
+ displayPrice.value.toLocaleString(locale as string, { style: "currency", currency: currency.value }),
37
38
  );
38
39
  const maxOrderQuantity = computed(() => props.item.maxOrderQuantity);
39
40
  const localePath = useLocalePath();
@@ -3,10 +3,11 @@ import { getDisplayUnitPrice, getPriceTiers, getPriceWithOptionalTax } from "../
3
3
  import type { ProductList } from "../../../interfaces/product-list";
4
4
 
5
5
  const { t } = useI18n();
6
- const { public: { locale, currency, taxIncludedPrices } } = useRuntimeConfig();
6
+ const { public: { locale, taxIncludedPrices } } = useRuntimeConfig();
7
+ const currency = useDisplayCurrency();
7
8
 
8
9
  function formatPrice(price: number) {
9
- return price.toLocaleString(locale, { style: "currency", currency });
10
+ return price.toLocaleString(locale, { style: "currency", currency: currency.value });
10
11
  }
11
12
 
12
13
  const props = defineProps<{
@@ -1,6 +1,7 @@
1
1
  export const useCartSummaryFormatting = () => {
2
2
  const { t } = useI18n();
3
- const { public: { locale, currency, taxIncludedPrices } } = useRuntimeConfig();
3
+ const { public: { locale, taxIncludedPrices } } = useRuntimeConfig();
4
+ const currency = useDisplayCurrency();
4
5
 
5
6
  const taxLabelKey = computed(() => taxIncludedPrices ? "summary.tax.incl" : "summary.tax.excl");
6
7
 
@@ -16,7 +17,7 @@ export const useCartSummaryFormatting = () => {
16
17
  }
17
18
 
18
19
  function formatCurrency(value: number): string {
19
- return (value).toLocaleString(locale as string, { style: "currency", currency: currency as string });
20
+ return (value).toLocaleString(locale as string, { style: "currency", currency: currency.value });
20
21
  }
21
22
 
22
23
  return {
@@ -0,0 +1,13 @@
1
+ import type { ComputedRef } from "vue";
2
+
3
+ /**
4
+ * The active display currency (ISO 4217) — the buyer's choice from the locale
5
+ * selector, falling back to the market's default. Price formatters use this
6
+ * instead of the static build-time currency so amounts render in the same
7
+ * currency the prices app resolved them in.
8
+ */
9
+ export function useDisplayCurrency(): ComputedRef<string> {
10
+ const { markets } = useMarkets();
11
+ const { currency } = useLocalePreferences(markets);
12
+ return currency;
13
+ }
@@ -11,7 +11,8 @@ import type {
11
11
  } from "../interfaces/product-detail";
12
12
 
13
13
  export const useProductDetail = (id: MaybeRefOrGetter<string>) => {
14
- const { public: { locale, currency, taxIncludedPrices } } = useRuntimeConfig();
14
+ const { public: { locale, taxIncludedPrices } } = useRuntimeConfig();
15
+ const currency = useDisplayCurrency();
15
16
 
16
17
  const { data: detail, status, error, refresh } = useFetch<ProductDetail | null>(
17
18
  () => productApi.detail(toValue(id)),
@@ -72,7 +73,7 @@ export const useProductDetail = (id: MaybeRefOrGetter<string>) => {
72
73
  const basePrice = cents / 100;
73
74
  const displayPrice = getPriceWithOptionalTax(basePrice, taxRate.value, taxIncludedPrices);
74
75
 
75
- return displayPrice.toLocaleString(locale, { style: "currency", currency });
76
+ return displayPrice.toLocaleString(locale, { style: "currency", currency: currency.value });
76
77
  };
77
78
 
78
79
  const getDetailImageUrl = (filename: string): string => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",