@W-19688128 Order Details supports multiship and BOPIS#3414
@W-19688128 Order Details supports multiship and BOPIS#3414patricksullivansf merged 6 commits intodevelopfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| let orderNo | ||
|
|
||
| beforeEach(async () => { | ||
| const mockStore = { |
There was a problem hiding this comment.
I am wondering if we can store this data somewhere to reuse? it takes up a bit of space in here
There was a problem hiding this comment.
thanks. done.
| const pickup = [] | ||
| const delivery = [] | ||
|
|
||
| order?.shipments?.forEach((shipment) => { |
There was a problem hiding this comment.
This looks familiar 🤔 , I think I've seen this logic somewhere in multi-ship, no?
Do you think we can optimize by creating a util that will return you pick and delivery shipments based on the shipments data and it can be re-used?
There was a problem hiding this comment.
Good memory. I see this exact logic in MultiShipOrderSummary. Consolidated.
97ef997
0536c2f to
97ef997
Compare
| <Box> | ||
| {getStoreData(shipment.c_fromStoreId) ? ( | ||
| <StoreDisplay | ||
| store={getStoreData(shipment.c_fromStoreId)} |
There was a problem hiding this comment.
getStoreData(shipment.c_fromStoreId) called twice. Can we optimize it?
There was a problem hiding this comment.
not so easily because we are inside a loop (map above) so we'd have to create more complex markup for an IIFE. IMO it's not worth the complexity given the expected length of the stores array. but I'm open to counter opinions.
There was a problem hiding this comment.
you still can keep a varianble within a map fnc
{
data.map((item, index) => {
const storedata = getStoreData(shipment.c_fromStoreId)
return <div> {storeData? <div>something</div> : <div>Something else</>}
})
}
There was a problem hiding this comment.
ok, I guess I'm outvoted. I added the local var (and the accumulated source re-pretti-ing)
| gridColumn={{sm: 'span 2'}} | ||
| > | ||
| <Heading as="h2" fontSize="sm" pt={1}> | ||
| {pickupShipments.length > 1 ? ( |
There was a problem hiding this comment.
There is a better way to handle plural for translation without conditions. See CartTitle
const CartTitle = () => {
const {
derivedData: {totalItems}
} = useCurrentBasket()
return (
<Heading as="h1" fontSize={['xl', 'xl', 'xl', '2xl']}>
<FormattedMessage
defaultMessage="Cart ({itemCount, plural, =0 {0 items} one {# item} other {# items}})"
values={{itemCount: totalItems}}
id="cart_title.title.cart_num_of_items"
/>
</Heading>
)
}
There was a problem hiding this comment.
@alexvuong thanks for the heads up. I looked up the docs and learned something new!
However, this isn't actually a plural, it two distinct headers depending on if it's a single shipment or a multiple shipment situation. Similar to a greeting if we know or don't know the name we might say "Hello, John" vs "Hello". I could use a select but I think it would just make the translator confused.
There was a problem hiding this comment.
hmm if that the case. Why not break out the line instead of instructing two translations of the same terms. This will help to keep the JSX as clean as possible
<Text>
<FormattedMessage
defaultMessage="Pickup Address"
id="account_order_detail.heading.pickup_address"
/>
{pickupShipments.length > 1 ? index +1 : ''}
</Text>
There was a problem hiding this comment.
@alexvuong I think string concatenation like that "part 1" + "part 2" is a no-no for i18n. I would assume there exists some l10n where the correct multi-shipment header is "ickuppay 2 address"
| </Stack> | ||
| {/* Delivery Shipments */} | ||
| {deliveryShipments.map((shipment, index) => ( | ||
| <React.Fragment key={`delivery-${index}`}> |
There was a problem hiding this comment.
the React.Fragment will not result in a DOM node at all, so the key prop here is useless. Why not use the Box component and pass the key there?
There was a problem hiding this comment.
@alexvuong why is the key useless in this use case? I see in the docs that key is explicitly supported; although it is admittedly unclear on how it is implemented...
There was a problem hiding this comment.
The doc said if you want to use key you have to use React.Fragment explicitly. You had <> which i think may not work well with key
Fragments declared with the explicit <React.Fragment> syntax may have keys. A use case for this is mapping a collection to an array of fragments — for example, to create a description list:
| <Stack spacing={1}> | ||
| <Heading as="h2" fontSize="sm" pt={1}> | ||
| {deliveryShipments.length > 1 ? ( | ||
| <FormattedMessage |
There was a problem hiding this comment.
See above comments on how to handle plural forms for translations
| <Box> | ||
| <Text fontSize="sm" textTransform="titlecase"> | ||
| { | ||
| { |
There was a problem hiding this comment.
Nit: maybe better to hold this into a variable in rendering body
| </Stack> | ||
| <Stack spacing={1}> | ||
| <Heading as="h2" fontSize="sm" pt={1}> | ||
| {deliveryShipments.length > 1 ? ( |
There was a problem hiding this comment.
See above on how to handle plural form for translations
Description
Add support to display Multiple shipments and BOPIS shipments to the My Account order details page. Prior to this change only the first shipment was shown and it was mis-leading for pick up shipments
BEFORE

AFTER DESKTOP

AFTER MOBILE

Types of Changes
Changes
How to Test-Drive This PR
Steps to reproduce:
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization