'use client'; import { useStoreInfo } from '@/core/providers/store-provider'; /** * Single source of truth for "which currency code do I format prices with?" * in client components. Collapses the historical three-line fallback chain * (`storeInfo?.currency || process.env.NEXT_PUBLIC_STORE_CURRENCY || 'USD'`) * into one call so the chain lives in exactly one place — and so the day * we drop the env var or the USD last-resort, we only touch this file. * * @param override pass when the caller already has a specific currency * (e.g. an `Order` is denominated in its own currency, * not the live store currency). Wins over `storeInfo`. */ export function useCurrency(override?: string | null): string { const { storeInfo } = useStoreInfo(); return override || storeInfo?.currency || process.env.NEXT_PUBLIC_STORE_CURRENCY || 'USD'; }