formatPrice (lib/formatters.ts)

spree · packages/dashboard-core/src/lib/formatters.ts · typescript · BSD-3-Clause
ui, tag:knn-classified

Utility functions to format prices, amounts, dates, and initials for dashboard UI.

// Source: https://github.com/spree/spree | License: BSD-3-Clause | Copyright 2024-present, Vendo Sp. z o.o., Vendo Connect Inc
// Provided via justclaw.it.com; keep this notice with the code.
import type { Price } from '@spree/admin-sdk'
import { formatMoney } from '@spree/core'
import { parseISO } from 'date-fns'
import { formatInTimeZone } from 'date-fns-tz'
import i18n from 'i18next'

export { formatMoney }

/**
 * A price's amount in its currency, in the admin's own number format. A unit
 * price keeps a fraction of a cent. `display_amount` is accepted and ignored
 * so callers built against the old shape keep compiling.
 */
export function formatPrice(
  price: (Pick<Price, 'amount' | 'currency'> & { display_amount?: string | null }) | null,
  locale: string = i18n.language || 'en',


... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key