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
Fixed: Markets currency picker show all currencies (#14207)
Damian Legawiecb43de4e37c56
diff --git a/CLAUDE.md b/CLAUDE.mdindex 3b436dd1f5..8c925e2f8e 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -490,7 +490,7 @@ pnpm dev # http://localhost:5173 (proxies /api/* to :3000)3. **Follow `docs/plans/6.0-admin-spa.md`** for the three extension points (table registry, navigation registry, component injection) and the shadcn copy-paste ownership model.4. **Wrap SDK calls in custom hooks** under `src/hooks/` (e.g. `useOrders`, `useProduct`) — never call `adminClient` directly from components.-**Translations.** Every user-visible string in `@spree/dashboard` goes through i18next — page titles, headings, table column labels, button labels, empty states, toast messages, confirm dialog copy, select option labels, badges, status text, tooltips, helper text. Never hardcode English (or any language) into JSX, into table column definitions, or into dropdown option arrays. Keys live in `packages/dashboard/src/locales/en.json` (app-specific copy) or `packages/dashboard-core/src/locales/en.json` (cross-cutting: `admin.common.*`, `admin.fields.<attribute>.<facet>`). Reach for `i18n.t(...)` at module load (table definitions) and `useTranslation().t(...)` inside components. **Schemas in `src/schemas/` hold canonical values only — never label strings.** Build `{ value, label }` pairs at render time inside the component by mapping the canonical value list against translation keys. Same goes for the legacy Rails admin: every label/hint goes through `Spree.t` / `I18n.t` against `spree/admin/config/locales/en.yml`; run `bundle exec i18n-tasks normalize` after adding keys.+**Translations.** Every user-visible string in `@spree/dashboard` goes through i18next — page titles, headings, table column labels, button labels, empty states, toast messages, confirm dialog copy, select option labels, badges, status text, tooltips, helper text. Never hardcode English (or any language) into JSX, into table column definitions, or into dropdown option arrays. Keys live in `packages/dashboard/src/locales/en.json` (app-specific copy) or `packages/dashboard-core/src/locales/en.json` (cross-cutting: `admin.common.*`, `admin.fields.<attribute>.<facet>`). Reach for `i18n.t(...)` at module load (table definitions) and `useTranslation().t(...)` inside components. **Schemas in `src/schemas/` hold canonical values only — never label strings.** Build `{ value, label }` pairs at render time inside the component by mapping the canonical value list against translation keys. Same goes for the legacy Rails admin: every label/hint goes through `Spree.t` / `I18n.t` against `spree/admin/config/locales/en.yml`; run `bundle exec i18n-tasks normalize` after adding keys. When adding a new translation key, ALWAYS add it to the all languages files in `packages/dashboard/src/locales/` and `packages/dashboard-core/src/locales/`.**Forms.** Raw React Hook Form with `<Field>` / `<Input>` / `<FieldError>` blocks. Drive each input explicitly with `form.register(...)` or a `<Controller>` for custom widgets so the form reads top-to-bottom. Wrap RHF's `handleSubmit` with a try/catch that calls `mapSpreeErrorsToForm` (`@/lib/form-errors`) to route 422 responses onto `form.formState.errors`: flat attribute keys become field errors with `aria-invalid` + `<FieldError>`; `:base` and nested keys land on `errors.root.message` so render a destructive banner at the top of the form.diff --git a/packages/dashboard-core/src/components/currency-select.tsx b/packages/dashboard-core/src/components/currency-select.tsxindex 0c0dc5fb30..7fe2e1eeb5 100644--- a/packages/dashboard-core/src/components/currency-select.tsx+++ b/packages/dashboard-core/src/components/currency-select.tsx@@ -1,9 +1,37 @@-import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@spree/dashboard-ui'-import { useState } from 'react'+import {+ Combobox,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxInput,+ ComboboxItem,+ ComboboxList,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@spree/dashboard-ui'+import { useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { useDisplayName } from '../hooks/use-display-name'import { useStore } from '../providers/store-provider'+/**+ * Every ISO 4217 currency code the runtime knows about — the active-currency+ * counterpart to the Rails admin's `Money::Currency.table` list. Used for+ * contexts where the merchant can pick *any* currency (a market's currency)+ * rather than one the store already supports. Degrades to an empty list on+ * runtimes without `Intl.supportedValuesOf`, so callers fall back to+ * `supported_currencies`.+ */+export const ALL_CURRENCY_CODES: string[] = (() => {+ try {+ return Intl.supportedValuesOf('currency')+ } catch {+ return []+ }+})()+interface CurrencySelectProps {/** ID for the trigger — paired with the parent `<FieldLabel htmlFor>`. */id?: string@@ -15,19 +43,30 @@ interface CurrencySelectProps {value?: string/** Fires on every selection change. */onChange?: (currency: string) => void+ /**+ * Currency codes to pick from. Defaults to the current store's+ * `supported_currencies`. Pass `ALL_CURRENCY_CODES` (or any custom list) for+ * contexts where the merchant chooses a currency the store doesn't yet+ * support — e.g. a market's currency. Large lists switch to a searchable+ * combobox automatically.+ */+ options?: string[]/** Marks the field required for screen readers + native form submission. */required?: booleandisabled?: boolean}+/** Above this many options a plain `<Select>` is unwieldy — switch to search. */+const SEARCHABLE_THRESHOLD = 12+/**- * Picker for one of the current store's `supported_currencies`. Defaults to- * the store's `default_currency` so callers don't have to wire it up- * themselves. Each option reads `CODE — Full Name` (e.g.- * `USD — US Dollar`), with the name localized to the admin UI language. Use- * this anywhere the merchant is choosing a currency for an admin-side action- * (issuing store credit, recording a refund, manual money entry on an- * order, etc.).+ * Picker for a currency code. Defaults to the current store's+ * `supported_currencies` (and the store's `default_currency`), so callers+ * choosing among already-configured currencies don't have to wire anything up.+ * Pass `options` (e.g. `ALL_CURRENCY_CODES`) when the merchant may pick any+ * currency, such as a market's currency. Each option reads `CODE — Full Name`+ * (e.g. `USD — US Dollar`), with the name localized to the admin UI language.+ * Long option lists render a searchable combobox.*/export function CurrencySelect({id,@@ -35,6 +74,7 @@ export function CurrencySelect({defaultValue,value: controlledValue,onChange,+ options,required,disabled,}: CurrencySelectProps) {@@ -49,22 +89,76 @@ export function CurrencySelect({const value = isControlled ? controlledValue || defaultCurrency : internalValueconst displayNameFor = useDisplayName('currency')+ // Union of the option list and the current value so editing a record whose+ // currency isn't in the list (a store-supported list that later narrowed)+ // never silently drops the selection. An empty `options` (e.g. a runtime+ // without `Intl.supportedValuesOf` yields an empty `ALL_CURRENCY_CODES`)+ // falls back to the store's currencies rather than an empty picker.+ const items = useMemo(() => {+ const base = options?.length ? options : currencies+ return value && !base.includes(value) ? [value, ...base] : base+ }, [options, currencies, value])+const handleChange = (next: string) => {if (!isControlled) setInternalValue(next)onChange?.(next)}const renderOption = (code: string) => {- const name = displayNameFor(code)+ const currencyName = displayNameFor(code)// Avoid `USD — USD` when the resolver falls back to the code itself.- return name && name !== code ? `${code} — ${name}` : code+ return currencyName && currencyName !== code ? `${code} — ${currencyName}` : code+ }++ // Case-insensitive match against the code and its localized name so typing+ // "EUR" or "Euro" both find it.+ const filter = (code: string, query: string) => {+ const q = query.trim().toLowerCase()+ if (!q) return true+ return code.toLowerCase().includes(q) || renderOption(code).toLowerCase().includes(q)+ }++ const hiddenInput = name ? <input type="hidden" name={name} value={value} /> : null++ if (items.length > SEARCHABLE_THRESHOLD) {+ return (+ <>+ {hiddenInput}+ <Combobox+ items={items}+ value={value}+ onValueChange={(next: string | null) => handleChange(next ?? '')}+ itemToStringLabel={(code: string | null) => (code ? renderOption(code) : '')}+ itemToStringValue={(code: string | null) => code ?? ''}+ filter={filter}+ disabled={disabled}+ >+ <ComboboxInput+ id={id}+ aria-required={required}+ placeholder={t('admin.components.currency_select.placeholder')}+ disabled={disabled}+ />+ <ComboboxContent>+ <ComboboxEmpty>{t('admin.components.currency_select.empty')}</ComboboxEmpty>+ <ComboboxList>+ {(code: string) => (+ <ComboboxItem key={code} value={code}>+ {renderOption(code)}+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxContent>+ </Combobox>+ </>+ )}return (<>{/* Hidden input keeps the parent `<form>` submit / FormData path workingwithout each caller having to thread the value through state. */}- {name && <input type="hidden" name={name} value={value} />}+ {hiddenInput}<Select value={value} onValueChange={handleChange} disabled={disabled}><SelectTrigger id={id} aria-required={required}>{/* Base UI's `<SelectValue>` defaults to rendering the raw `value`@@ -75,7 +169,7 @@ export function CurrencySelect({</SelectValue></SelectTrigger><SelectContent>- {currencies.map((currency) => (+ {items.map((currency) => (<SelectItem key={currency} value={currency}>{renderOption(currency)}</SelectItem>diff --git a/packages/dashboard-core/src/locales/ar.json b/packages/dashboard-core/src/locales/ar.jsonindex 4e3c82388a..5c6e7e93a5 100644--- a/packages/dashboard-core/src/locales/ar.json+++ b/packages/dashboard-core/src/locales/ar.json@@ -310,7 +310,8 @@},"components": {"currency_select": {- "placeholder": "اختر عملة"+ "placeholder": "اختر عملة",+ "empty": "لم يتم العثور على عملات"},"channel_select": {"placeholder": "اختر قناة مبيعات"diff --git a/packages/dashboard-core/src/locales/de.json b/packages/dashboard-core/src/locales/de.jsonindex 89024a4cfe..e3a21bf89f 100644--- a/packages/dashboard-core/src/locales/de.json+++ b/packages/dashboard-core/src/locales/de.json@@ -310,7 +310,8 @@},"components": {"currency_select": {- "placeholder": "Währung auswählen"+ "placeholder": "Währung auswählen",+ "empty": "Keine Währungen gefunden"},"channel_select": {"placeholder": "Verkaufskanal auswählen"diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.jsonindex 1589c350ac..d487ecad68 100644--- a/packages/dashboard-core/src/locales/en.json+++ b/packages/dashboard-core/src/locales/en.json@@ -310,7 +310,8 @@},"components": {"currency_select": {- "placeholder": "Select a currency"+ "placeholder": "Select a currency",+ "empty": "No currencies found"},"channel_select": {"placeholder": "Select a sales channel"diff --git a/packages/dashboard-core/src/locales/fr.json b/packages/dashboard-core/src/locales/fr.jsonindex 6bf98255cc..40aee1a8b8 100644--- a/packages/dashboard-core/src/locales/fr.json+++ b/packages/dashboard-core/src/locales/fr.json@@ -310,7 +310,8 @@},"components": {"currency_select": {- "placeholder": "Sélectionner une devise"+ "placeholder": "Sélectionner une devise",+ "empty": "Aucune devise trouvée"},"channel_select": {"placeholder": "Sélectionner un canal de vente"diff --git a/packages/dashboard-core/src/locales/pl.json b/packages/dashboard-core/src/locales/pl.jsonindex 9e610acd9e..64250f7392 100644--- a/packages/dashboard-core/src/locales/pl.json+++ b/packages/dashboard-core/src/locales/pl.json@@ -310,7 +310,8 @@},"components": {"currency_select": {- "placeholder": "Wybierz walutę"+ "placeholder": "Wybierz walutę",+ "empty": "Nie znaleziono walut"},"channel_select": {"placeholder": "Wybierz kanał sprzedaży"diff --git a/packages/dashboard-core/src/locales/zh-CN.json b/packages/dashboard-core/src/locales/zh-CN.jsonindex 15e665c544..49af4fed4b 100644--- a/packages/dashboard-core/src/locales/zh-CN.json+++ b/packages/dashboard-core/src/locales/zh-CN.json@@ -310,7 +310,8 @@},"components": {"currency_select": {- "placeholder": "选择货币"+ "placeholder": "选择货币",+ "empty": "未找到货币"},"channel_select": {"placeholder": "选择销售渠道"diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsxindex cac3442a31..7bfdae4008 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/markets.tsx@@ -1,6 +1,7 @@import { zodResolver } from '@hookform/resolvers/zod'import type { Market } from '@spree/admin-sdk'import {+ ALL_CURRENCY_CODES,adminClient,Can,CountryMultiCombobox,@@ -331,7 +332,13 @@ function MarketFormFields({ form }: { form: UseFormReturn<MarketFormValues> }) {name="currency"control={form.control}render={({ field }) => (- <CurrencySelect id="market-currency" value={field.value} onChange={field.onChange} />+ <CurrencySelect+ id="market-currency"+ required+ value={field.value}+ onChange={field.onChange}+ options={ALL_CURRENCY_CODES}+ />)}/><span className="text-xs text-muted-foreground">