fix: pick the quote currency from a dropdown instead of a text field - #9
Conversation
The quote form had a plain three-character text input for the currency, so changing USD to EUR went through the half-typed values "E" and "EU". Autosave stores those (the schema only caps the length), and every later read that runs the amount through Intl.NumberFormat throws, which surfaces as a server error. The form now uses the CurrencyCombobox the invoice form already uses, and both currency formatters fall back to "12.50 XY" instead of throwing, so documents that already carry a broken code stay readable.
|
Reviewed and pushed one commit ( One formatting site was still unguarded. The fallback keeps the configured number format. The backend logs a warning when it falls back, so a bad code is discoverable instead of quietly shipping
Verified against a quote seeded with Agreed on leaving the Zod rule out of this. For the follow-up it is four routes, not one: |
Changing a quote's currency from USD to EUR means typing over a three-character text field, so autosave stores the half-typed values
EandEUon the way. The item schema only caps the length (z.string().max(3)), so both pass validation, and every later read that runs an amount throughIntl.NumberFormatthrowsRangeError: currency is not a well-formed currency code. That shows up as a server error, and the quote keeps failing until the stored code is corrected by hand.The quote form now uses the same
CurrencyComboboxthe invoice form already uses, so there are no half-typed states to save.Both
formatCurrencyhelpers, backend and frontend, also fall back to12.50 EUinstead of throwing. The dropdown only fixes new input; without the fallback a document that already carries a broken code keeps erroring.Not in this PR: tightening the Zod rule to a real currency list.
.max(3)currently also accepts an empty string and I didn't want to change what the API accepts inside a bug fix. Happy to follow up if you want that closed too.bun run checkpasses.