-
Notifications
You must be signed in to change notification settings - Fork 145
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-17443086 Allow store to be selected by Shopper #2187
Changes from all commits
05f2e55
1247e54
6cf11ec
f42ed1c
48299f6
469ec2c
8bd458e
6728456
5faed18
375e8ae
868d129
abc3421
d73464d
abbb3b6
61bd914
a602253
fd8c67c
bdf378d
e79f06e
33a631f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import React from 'react' | ||
import React, {useEffect, useState} from 'react' | ||
import {useIntl} from 'react-intl' | ||
import PropTypes from 'prop-types' | ||
|
||
|
@@ -15,78 +15,113 @@ import { | |
AccordionButton, | ||
AccordionIcon, | ||
AccordionPanel, | ||
Box | ||
Box, | ||
HStack, | ||
Radio, | ||
RadioGroup | ||
} from '@salesforce/retail-react-app/app/components/shared/ui' | ||
|
||
// Hooks | ||
import useMultiSite from '@salesforce/retail-react-app/app/hooks/use-multi-site' | ||
|
||
const StoresList = ({storesInfo}) => { | ||
const intl = useIntl() | ||
const {site} = useMultiSite() | ||
const storeInfoKey = `store_${site.id}` | ||
const [selectedStore, setSelectedStore] = useState('') | ||
|
||
return storesInfo?.map((store, index) => { | ||
return ( | ||
<AccordionItem key={index}> | ||
<Box margin="10px"> | ||
{store.name ? <Box fontSize="lg">{store.name}</Box> : ''} | ||
<Box fontSize="md" color="gray.600"> | ||
{store.address1} | ||
</Box> | ||
<Box fontSize="md" color="gray.600"> | ||
{store.city}, {store.stateCode ? store.stateCode : ''} {store.postalCode} | ||
</Box> | ||
{store.distance !== undefined ? ( | ||
<> | ||
<br /> | ||
<Box fontSize="md" color="gray.600"> | ||
{store.distance} {store.distanceUnit}{' '} | ||
{intl.formatMessage({ | ||
id: 'store_locator.description.away', | ||
defaultMessage: 'away' | ||
})} | ||
</Box> | ||
</> | ||
) : ( | ||
'' | ||
)} | ||
{store.phone !== undefined ? ( | ||
<> | ||
<br /> | ||
<Box fontSize="md" color="gray.600"> | ||
{intl.formatMessage({ | ||
id: 'store_locator.description.phone', | ||
defaultMessage: 'Phone:' | ||
})}{' '} | ||
{store.phone} | ||
</Box> | ||
</> | ||
) : ( | ||
'' | ||
)} | ||
{store?.storeHours ? ( | ||
<> | ||
{' '} | ||
<AccordionButton color="blue.700" style={{marginTop: '10px'}}> | ||
<Box fontSize="lg"> | ||
{intl.formatMessage({ | ||
id: 'store_locator.action.viewMore', | ||
defaultMessage: 'View More' | ||
})} | ||
</Box> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
<AccordionPanel mb={6} mt={4}> | ||
<div | ||
dangerouslySetInnerHTML={{ | ||
__html: store?.storeHours | ||
}} | ||
/> | ||
</AccordionPanel>{' '} | ||
</> | ||
) : ( | ||
'' | ||
)} | ||
</Box> | ||
</AccordionItem> | ||
useEffect(() => { | ||
setSelectedStore(JSON.parse(window.localStorage.getItem(storeInfoKey))?.id || '') | ||
}, [storeInfoKey]) | ||
|
||
const handleChange = (storeId) => { | ||
setSelectedStore(storeId) | ||
const store = storesInfo.find((store) => store.id === storeId) | ||
window.localStorage.setItem( | ||
storeInfoKey, | ||
JSON.stringify({ | ||
id: storeId, | ||
name: store.name || null, | ||
inventoryId: store.inventoryId || null | ||
}) | ||
) | ||
}) | ||
} | ||
|
||
return ( | ||
<RadioGroup onChange={handleChange} value={selectedStore}> | ||
{storesInfo?.map((store, index) => { | ||
return ( | ||
<AccordionItem key={index}> | ||
<HStack align="flex-start" mt="16px" mb="16px"> | ||
<Radio | ||
value={store.id} | ||
mt="1px" | ||
aria-describedby={`store-info-${store.id}`} | ||
></Radio> | ||
<Box id={`store-info-${store.id}`}> | ||
{store.name && <Box fontSize="lg">{store.name}</Box>} | ||
<Box fontSize="md" color="gray.600"> | ||
{store.address1} | ||
</Box> | ||
<Box fontSize="md" color="gray.600"> | ||
{store.city}, {store.stateCode ? store.stateCode : ''}{' '} | ||
{store.postalCode} | ||
</Box> | ||
{store.distance !== undefined && ( | ||
<> | ||
<br /> | ||
<Box fontSize="md" color="gray.600"> | ||
{store.distance} {store.distanceUnit}{' '} | ||
{intl.formatMessage({ | ||
id: 'store_locator.description.away', | ||
defaultMessage: 'away' | ||
})} | ||
</Box> | ||
</> | ||
)} | ||
{store.phone && ( | ||
<> | ||
<br /> | ||
<Box fontSize="md" color="gray.600"> | ||
{intl.formatMessage({ | ||
id: 'store_locator.description.phone', | ||
defaultMessage: 'Phone:' | ||
})}{' '} | ||
{store.phone} | ||
</Box> | ||
</> | ||
)} | ||
{store.storeHours && ( | ||
<> | ||
{' '} | ||
<AccordionButton | ||
color="blue.700" | ||
sx={{marginTop: '10px', paddingBottom: '0px'}} | ||
> | ||
<Box fontSize="lg"> | ||
{intl.formatMessage({ | ||
id: 'store_locator.action.viewMore', | ||
defaultMessage: 'View More' | ||
})} | ||
</Box> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
<AccordionPanel mb={6} mt={4}> | ||
<div | ||
dangerouslySetInnerHTML={{ | ||
__html: store?.storeHours | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wow, SUPER weird, but ok 🚢 |
||
}} | ||
/> | ||
</AccordionPanel>{' '} | ||
</> | ||
)} | ||
</Box> | ||
</HStack> | ||
</AccordionItem> | ||
) | ||
})} | ||
</RadioGroup> | ||
) | ||
} | ||
|
||
StoresList.propTypes = { | ||
|
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.
You're missing a
CHANGELOG.md
update associated with this PRThere 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.
Added! @bfeister question on the release process. Currently I have the base branch set to a feature branch
feature-bopis
. Does this make sense or should I just merge the change intodevelop
?This change does works on it's own, although it doesn't really do anything other than save the store info in local storage
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's fine to merge into
develop
since it works on it's own. It'll help to avoid a "big bang" merge and make that diff smaller