-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use single price value instead of range in product list #2386
Conversation
Task linked: SALEOR-7906 Use single price value instead of range |
Could we improve it further by using formatRangeIntl.NumberFormat("en-US", {style: "currency", currency: "USD"}).formatRange("1.00", "21.00");
// "$1.00 – $21.00"
Intl.NumberFormat("pl-PL", {style: "currency", currency: "USD"}).formatRange("1.00", "21.00");
// "1,00–21,00 USD" formatIntl.NumberFormat("en-US", {style: "currency", currency: "USD"}).format("123.00");
// "$123.00"
Intl.NumberFormat("pl-PL", {style: "currency", currency: "USD"}).format("123.00");
// "123,00 USD" |
if (from && to) { | ||
return from.amount === to.amount | ||
? formatMoney(from, locale) | ||
: formatMoneyRange(from, to, locale); | ||
} | ||
if (from && !to) { | ||
return intl.formatMessage( | ||
{ | ||
id: "lW5uJO", | ||
defaultMessage: "from {money}", | ||
description: "money", | ||
}, | ||
{ | ||
money: formatMoney(from, locale), | ||
}, | ||
); | ||
} | ||
if (!from && to) { | ||
return intl.formatMessage( | ||
{ | ||
id: "hptDxW", | ||
defaultMessage: "to {money}", | ||
description: "money", | ||
}, | ||
{ | ||
money: formatMoney(to, locale), | ||
}, | ||
); | ||
} | ||
return "-"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if that is a component, perhaps a format component would be more reasonable here?
* Render single value when amount of money is matching * Use Intl.NumberFormat in money formatting * Extract messages
I want to merge this change because it improves product list view. With channel filter selected, we often see price ranges for single-variant products even though the price is constant. This change improves the readability by rendering single price whenever the range is not actually a range.
PR intended to be tested with API branch: main
Screenshots
Before
After
Pull Request Checklist
[data-test-id]
are added for new elementsTest environment config
API_URI=https://automation-dashboard.staging.saleor.cloud/graphql/
MARKETPLACE_URL=https://marketplace-gray.vercel.app/
Do you want to run more stable tests?
To run all tests, just select the stable checkbox. To speed up tests, increase the number of containers. Tests will be re-run only when the "run e2e" label is added.
CONTAINERS=1