import type { PublicStoreInfo } from '@/core/lib/store-info'; /** * Server-side twin of `useCurrency()` — call from Server Components, * `generateMetadata`, route handlers, and anywhere outside React render * (where the client `useStoreInfo()` hook isn't available). * * Keeps the fallback chain in one place across both client and server. * * @param storeInfo result of `fetchStoreInfo()` — may be null if the SSR * fetch failed transiently * @param override pass when the caller already has a specific currency * (e.g. order-level currency that should win over store) */ export function resolveCurrency( storeInfo: PublicStoreInfo | null | undefined, override?: string | null ): string { return override || storeInfo?.currency || process.env.NEXT_PUBLIC_STORE_CURRENCY || 'USD'; }