Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
import { useMoneyLocale } from '../hooks/use-money-locale'
import { formatAmount } from '../lib/formatters'
import { useOptionalStore } from '../providers/store-provider'
/**
* An API amount shown in the admin's own number format. Without a currency it
* is shown in the store's default currency, for figures the API states in it
* (a customer's total spent); the seller panel, which mounts no store, always
* passes one.
*/
export function Money({
amount,
currency,
fallback,
}: {
amount: string | null | undefined
currency?: string | null
fallback?: string
}) {
const locale = useMoneyLocale()
const store = useOptionalStore()
return <>{formatAmount(amount, currency ?? store?.defaultCurrency, locale, fallback)}</>
}