feat: add BRL (R$) currency support - #49
Open
smllb wants to merge 1 commit into
Open
Conversation
Detect and display Brazilian Real prices: - priceParser: recognize R$/BRL incl. the 1.234,56 format - products: record the selected candidate's currency instead of hardcoded USD, falling back to the detected price currency - frontend: shared Intl.NumberFormat price formatter replacing the hardcoded EUR/GBP/CHF/$ symbol map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add Brazilian Real (R$) currency support
Summary
Adds detection, storage, and display of Brazilian Real (R$) prices. Previously
any non-mapped currency symbol fell through to the generic
$pattern and wasrecorded as
USD, which was wrong for stores likeamazon.com.br.What changed
Backend
backend/src/utils/priceParser.tsR$/BRLtocurrencyMapand a dedicated regex pattern placedbefore the generic
$one (soR$isn't swallowed by the dollar match).1.234,56(dotthousands separator, comma decimal) as well as the short form
284,90.R$inextractPricesFromTextso it's considered when scanningraw HTML.
backend/src/routes/products.ts'USD'when recording theinitial price history entry. It now records the currency of the candidate
the user actually selected (
selectedCurrency), falling back to thedetected price currency and finally
'USD'.Frontend
frontend/src/utils/formatPrice.ts(new)formatPrice()helper usingIntl.NumberFormat, so any currency(including BRL) formats correctly and is locale-aware.
PriceChart.tsx,ProductCard.tsx,PriceSelectionModal.tsx,ProductDetail.tsx€ / £ / CHF / $symbol map with the sharedformatter. BRL now renders as
R$ 284,90instead of$284.90.PriceSelectionModal.tsx,Dashboard.tsx,api/client.tscurrencythrough to the backend so therecorded currency matches what the user picked.
Why
The existing parser mapped a fixed set of symbols and fell back to
$/USDfor everything else. That made tracked BRL prices display and store as USD.
This change is additive: all previously supported currencies behave exactly as
before, and BRL (plus any other
Intl.NumberFormat-supported currency) nowworks correctly.
Testing
parsePriceagainstR$284,90,R$5.256,36,R$1.299,00,R$499,90, and$29.99(BRL cases parse to correct values +BRL,USD unaffected).
tsctypecheck and production builds pass for bothbackendandfrontend.amazon.com.brproduct records history asBRLandthe UI shows
R$formatting in the modal, cards, and price chart.