1
0

01a-common-tasks.md 1.1 KB

Common Tasks

Formatting Dates, Currencies, and Numbers

import {useLocalFormat} from '@vendure/dashboard';
// ...
// Intl API formatting tools
const {
    formatCurrency,
    formatNumber,
    formatDate,
    formatRelativeDate,
    formatLanguageName,
    formatRegionName,
    formatCurrencyName,
    toMajorUnits,
    toMinorUnits,
} = useLocalFormat();

formatCurrency(value: number, currency: string, precision?: number)
formatCurrencyName(currencyCode: string, display: 'full' | 'symbol' | 'name' = 'full')
formatNumber(value: number) // human-readable
formatDate(value: string | Date, options?: Intl.DateTimeFormatOptions)
formatRelativeDate(value: string | Date, options?: Intl.RelativeTimeFormatOptions)

Links

Example link destinations:

  • Customer detail | text
  • Customer list | text
  • Order detail | text

Important: when linking to detail pages, prefer the DetailPageButton. If not in a table column, add className='border'.