Skip to content

Commit b63a78c

Browse files
dannyphan2000syadupathi-sf
authored andcommitted
@W-21000344: [BOPIS] Pickup address component enhancement (#3607)
Signed-off-by: d.phan <d.phan@salesforce.com>
1 parent 0089186 commit b63a78c

File tree

2 files changed

+79
-14
lines changed

2 files changed

+79
-14
lines changed

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-pickup-address.jsx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ToggleCard,
1414
ToggleCardSummary
1515
} from '@salesforce/retail-react-app/app/components/toggle-card'
16-
import AddressDisplay from '@salesforce/retail-react-app/app/components/address-display'
16+
import StoreDisplay from '@salesforce/retail-react-app/app/components/store-display'
1717

1818
// Hooks
1919
import {useCheckout} from '@salesforce/retail-react-app/app/pages/checkout-one-click/util/checkout-context'
@@ -38,8 +38,6 @@ const PickupAddress = () => {
3838
)
3939
const pickupShipment = shipmentsWithItems.find((s) => isPickupShipment(s))
4040

41-
const selectedShippingAddress = pickupShipment?.shippingAddress
42-
4341
// Check if basket is a pickup order
4442
const isPickupOrder = !!pickupShipment
4543
const storeId = pickupShipment?.c_fromStoreId
@@ -54,6 +52,7 @@ const PickupAddress = () => {
5452
}
5553
)
5654
const store = storeData?.data?.[0]
55+
// Build address object for shipping API update (required for order processing)
5756
const pickupAddress = {
5857
address1: store?.address1,
5958
city: store?.city,
@@ -64,8 +63,6 @@ const PickupAddress = () => {
6463
lastName: 'Pickup',
6564
phone: store?.phone
6665
}
67-
// Prefer store-derived address; only fall back to shipment shippingAddress if store unavailable
68-
const displayAddress = pickupAddress || selectedShippingAddress
6966

7067
const submitAndContinue = async (address) => {
7168
setIsLoading(true)
@@ -111,8 +108,21 @@ const PickupAddress = () => {
111108
id="pickup_address.title.store_information"
112109
/>
113110
</Text>
114-
{displayAddress ? (
115-
<AddressDisplay address={displayAddress} />
111+
{store ? (
112+
<Box mb={4}>
113+
<StoreDisplay
114+
store={store}
115+
showDistance={true}
116+
showStoreHours={true}
117+
showPhone={true}
118+
showEmail={true}
119+
nameStyle={{
120+
fontSize: 'sm',
121+
fontWeight: 'normal'
122+
}}
123+
textSize="sm"
124+
/>
125+
</Box>
116126
) : isStoreLoading ? (
117127
<Text>
118128
<FormattedMessage
@@ -133,16 +143,27 @@ const PickupAddress = () => {
133143
</Box>
134144
</>
135145
)}
136-
{isPickupOrder && (displayAddress || isStoreLoading) && (
146+
{isPickupOrder && (store || isStoreLoading) && (
137147
<ToggleCardSummary>
138148
<Text fontWeight="bold" fontSize="md" mb={2}>
139149
<FormattedMessage
140150
defaultMessage="Store Information"
141151
id="pickup_address.title.store_information"
142152
/>
143153
</Text>
144-
{displayAddress ? (
145-
<AddressDisplay address={displayAddress} />
154+
{store ? (
155+
<StoreDisplay
156+
store={store}
157+
showDistance={true}
158+
showStoreHours={true}
159+
showPhone={true}
160+
showEmail={true}
161+
nameStyle={{
162+
fontSize: 'sm',
163+
fontWeight: 'normal'
164+
}}
165+
textSize="sm"
166+
/>
146167
) : (
147168
<Text>
148169
<FormattedMessage

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-pickup-address.test.js

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jest.mock('@salesforce/commerce-sdk-react', () => {
3030
postalCode: '94105',
3131
countryCode: 'US',
3232
phone: '555-123-4567',
33-
storeHours: 'Mon-Fri: 9AM-6PM',
33+
c_customerServiceEmail: 'store@example.com',
34+
storeHours: '<p>Mon-Fri: 9AM-6PM</p>',
3435
storeType: 'retail'
3536
}
3637
]
@@ -74,10 +75,11 @@ jest.mock('@salesforce/retail-react-app/app/hooks/use-current-basket', () => ({
7475
shipmentId: 'me',
7576
shipmentTotal: 25.17,
7677
shippingStatus: 'not_shipped',
77-
shippingTotal: 5.99
78+
shippingTotal: 5.99,
79+
c_fromStoreId: 'store-123',
80+
c_deliveryType: 'pickup'
7881
}
79-
],
80-
c_fromStoreId: 'store-123'
82+
]
8183
},
8284
derivedData: {
8385
hasBasket: true,
@@ -125,8 +127,18 @@ describe('PickupAddress', () => {
125127
expect(screen.getByText('Store Information')).toBeInTheDocument()
126128
expect(screen.getByText('Continue to Payment')).toBeInTheDocument()
127129

130+
// Verify store name is displayed
131+
expect(screen.getByText('Test Store')).toBeInTheDocument()
132+
133+
// Verify store address is displayed
128134
expect(screen.getByText('123 Main Street')).toBeInTheDocument()
129135
expect(screen.getByText('San Francisco, CA 94105')).toBeInTheDocument()
136+
137+
// Verify Store Hours accordion is present
138+
expect(screen.getByText('Store Hours')).toBeInTheDocument()
139+
140+
// Verify Store Contact Info accordion is present
141+
expect(screen.getByText('Store Contact Info')).toBeInTheDocument()
130142
})
131143

132144
test('submits pickup address and continues to payment', async () => {
@@ -158,4 +170,36 @@ describe('PickupAddress', () => {
158170
})
159171
})
160172
})
173+
174+
test('displays store hours when accordion is expanded', async () => {
175+
const {user} = renderWithProviders(<PickupAddress />)
176+
177+
await waitFor(() => {
178+
expect(screen.getByText('Store Hours')).toBeInTheDocument()
179+
})
180+
181+
// Click to expand the Store Hours accordion
182+
await user.click(screen.getByText('Store Hours'))
183+
184+
await waitFor(() => {
185+
expect(screen.getByText('Mon-Fri: 9AM-6PM')).toBeInTheDocument()
186+
})
187+
})
188+
189+
test('displays store contact info when accordion is expanded', async () => {
190+
const {user} = renderWithProviders(<PickupAddress />)
191+
192+
await waitFor(() => {
193+
expect(screen.getByText('Store Contact Info')).toBeInTheDocument()
194+
})
195+
196+
// Click to expand the Store Contact Info accordion
197+
await user.click(screen.getByText('Store Contact Info'))
198+
199+
await waitFor(() => {
200+
// Email and phone are in the same element separated by <br />, use substring matcher
201+
expect(screen.getByText(/Email: store@example\.com/)).toBeInTheDocument()
202+
expect(screen.getByText(/Phone: 555-123-4567/)).toBeInTheDocument()
203+
})
204+
})
161205
})

0 commit comments

Comments
 (0)