feat(web): currency becomes a closed select (ALL / EUR / USD)
Currency was free text in the tariff editor (composer page + lab draft modal — shared form) and the subscription plan editor; a typo could publish an unknown code onto immutable versions. Both now offer a closed select from lib/currencies.ts. An out-of-set code already stored on an old record is appended as an extra option so it displays + round-trips unchanged. Blank tariff form defaults to ALL (was EUR) — the site's actual currency. Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// The currencies the booth can price in (ISO 4217). Money is always stored as
|
||||
// integer minor units + one of these codes; the UI offers a closed select rather
|
||||
// than free text so a typo can never publish an unknown currency.
|
||||
export const CURRENCIES = ["ALL", "EUR", "USD"] as const;
|
||||
|
||||
/** The select options: the known set, plus the current value when it's some
|
||||
* historical code outside it (so an old record still displays + round-trips). */
|
||||
export function currencyOptions(current: string): string[] {
|
||||
const cur = current.trim().toUpperCase();
|
||||
return cur && !CURRENCIES.includes(cur as (typeof CURRENCIES)[number]) ? [...CURRENCIES, cur] : [...CURRENCIES];
|
||||
}
|
||||
Reference in New Issue
Block a user