ReqoreTier: currency symbol is dropped when price is a string

Aperta Adatta ai principianti
#675 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Inizia in src/components/Tier/index.tsx dalla condizione relativa alla valuta mostrata nell’issue, quindi controlla come vengono gestiti price e salePrice. Verifica che le stringhe numeriche mostrino il simbolo della valuta, mentre le etichette non numeriche come «Custom» no, ed esegui i test Tier pertinenti; il payload non indica un file di test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

ReqoreTier drops the currency symbol whenever price is a string:

// src/components/Tier/index.tsx
currency && currencyPosition === 'before' && isNumber(price) ? currency : undefined

IReqoreTierProps declares price: string | number and currency: string, so
<ReqoreTier price="50" currency="$" /> is a perfectly legal call — it just renders
50 with no $, silently. Nothing warns, and the missing symbol is easy to miss in
review because the number itself is right.

Why it bites

Prices almost always arrive as strings: JSON payloads, CMS fields, Intl-formatted
amounts, anything with a decimal that must not be re-rounded. On the Qorus marketing
site both sources are strings — the pricing CMS global and the live Qorus SaaS
product catalogue (qorus_saas_product_prices.price) — so every plan card had lost
its currency symbol.

What the landing page does meanwhile

Coerces the value before handing it over, which is exactly the workaround this issue
asks to make unnecessary:

const priceOf = (price: string): string | number =>
  /^\d+(\.\d+)?$/.test(price) ? Number(price) : price;

Suggested fix

In ReqoreTier, gate the currency on "the price is an amount", not on the JS type —
e.g. isNumber(price) || /^\d/.test(String(price)), applied to price and
salePrice alike. A non-numeric price (Custom, Contact us) should keep today's
behaviour of showing no symbol.

If the type-based gate is deliberate, then price should be typed number for the
currency path and the prop doc should say the symbol is numeric-only — right now the
types promise something the render does not deliver.

Lingua principale
TypeScript
Stelle
4
Fork
0
Merge medio
16h 28m
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di qoretechnologies/reqore

Tutte le issue di qoretechnologies/reqore

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.