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
@W-15654904Showing strikethrough price on PLP #1760
Conversation
@@ -16,7 +16,6 @@ import {useQuery} from '@tanstack/react-query' | |||
import { | |||
useAccessToken, | |||
useCategory, | |||
useCustomerBaskets, |
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.
removed unused variable
packages/template-retail-react-app/app/components/display-price/index.jsx
Outdated
Show resolved
Hide resolved
import {useCurrentBasket} from '@salesforce/retail-react-app/app/hooks/use-current-basket' | ||
import {renderWithProviders} from '@salesforce/retail-react-app/app/utils/test-utils' | ||
import {useCustomerBaskets} from '@salesforce/commerce-sdk-react' | ||
import { | ||
mockCustomerBaskets, | ||
mockEmptyBasket |
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.
removed unused variable as lint complains
useShopperOrdersMutation, | ||
useShopperBasketsMutation | ||
} from '@salesforce/commerce-sdk-react' | ||
import {useShopperOrdersMutation, useShopperBasketsMutation} from '@salesforce/commerce-sdk-react' |
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.
removed unused variables as lint complains
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.
I think we should still consider merging this into a feature branch that will then later be merged into the v3/template-retail-react-app
branch. It'll be easier to keep track of the product tile revamp changes as we continue our feature work
packages/template-retail-react-app/app/components/product-tile/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/pages/product-list/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/product-view/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/product-view/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/product-tile/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/display-price/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/display-price/index.jsx
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/display-price/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/display-price/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/display-price/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/components/display-price/index.jsx
Outdated
Show resolved
Hide resolved
/** | ||
* Find the smallest value by key from a given array | ||
* @param arr | ||
* @param key | ||
*/ | ||
export const getSmallestValByProperty = (arr, key) => { | ||
if (!arr || !arr.length) return undefined | ||
if (!key) { | ||
throw new Error('Please specify a key.') | ||
} | ||
const vals = arr | ||
.map((item) => item[key]) | ||
.filter(Boolean) | ||
.filter(Number) | ||
return vals.length ? Math.min(...vals) : undefined | ||
} |
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.
I think it might be a better idea to inline this as a private function in your product utils. I don't think it's usefulness is going to be that high and we'd but have to support it forever as it's a public api
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.
Sounds good, I have moved the function into product-utils.js
if (isASet) { | ||
return renderCurrentPrice(true) | ||
} | ||
|
||
if (isMaster) { | ||
return renderPriceSet(isRange) | ||
} | ||
|
||
return <Box>{renderPriceSet(false)}</Box> |
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.
I like this result. The code feels easier to digest.
Description
This PR implemented strikethrough price for products on PLP if any product has a listing sale price
NOTE: You may notice the price may/ may not display correctly in Recommendation section/Recently View. It will be fix later in a different ticket, please ignore.
Types of Changes
Changes
How to Test-Drive This PR
Master product on first load
Bundle
Standard
Product set
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization