Skip to content
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-15621253 Initial Store Locator Implementation #1827

Merged
merged 26 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3eef96c
store locator implementation
jeremy-jung1 Jun 12, 2024
69f6d36
margin update
jeremy-jung1 Jun 12, 2024
e72d90a
increase bundle size
jeremy-jung1 Jun 12, 2024
4587460
handle undefined/empty fields
jeremy-jung1 Jun 12, 2024
82954ee
lint
jeremy-jung1 Jun 12, 2024
a5c5ca5
update existing store locator references
jeremy-jung1 Jun 12, 2024
67d8073
remove unnecessary change
jeremy-jung1 Jun 12, 2024
147efc7
add SSR and local storage and switch order of input fields
jeremy-jung1 Jun 13, 2024
d6ba3ac
clean up
jeremy-jung1 Jun 13, 2024
e63fbe8
more clean up
jeremy-jung1 Jun 13, 2024
170de81
remove translations
jeremy-jung1 Jun 13, 2024
028e3d5
remove compiled translations
jeremy-jung1 Jun 13, 2024
87e7a1f
Delete packages/stores.xml
jeremy-jung1 Jun 13, 2024
f23966b
remove remaining translations
jeremy-jung1 Jun 13, 2024
cc70d9c
Merge branch 'store-locator' of github.com:SalesforceCommerceCloud/pw…
jeremy-jung1 Jun 13, 2024
6344342
remember input for modal only without using local storage
jeremy-jung1 Jun 13, 2024
f746054
address more feedback
jeremy-jung1 Jun 14, 2024
d782625
address some feedback
jeremy-jung1 Jun 14, 2024
9fc8b66
use useDisclosure
jeremy-jung1 Jun 14, 2024
b9112d9
lint
jeremy-jung1 Jun 14, 2024
23e7897
more cleaning
jeremy-jung1 Jun 17, 2024
b62f8f6
show "stores are loading" indication
jeremy-jung1 Jun 17, 2024
a8447b5
linting
jeremy-jung1 Jun 17, 2024
c9247b8
apply more feedback
jeremy-jung1 Jun 20, 2024
9aac80d
update form id
jeremy-jung1 Jun 20, 2024
d922ab4
lint
jeremy-jung1 Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/template-retail-react-app/app/assets/svg/store.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
317 changes: 168 additions & 149 deletions packages/template-retail-react-app/app/components/_app/index.jsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import {
HamburgerIcon,
ChevronDownIcon,
HeartIcon,
SignoutIcon
SignoutIcon,
StoreIcon
} from '@salesforce/retail-react-app/app/components/icons'

import {navLinks, messages} from '@salesforce/retail-react-app/app/pages/account/constant'
Expand Down Expand Up @@ -74,6 +75,7 @@ const Header = ({
onLogoClick = noop,
onMyCartClick = noop,
onWishlistClick = noop,
onStoreLocatorClick = noop,
...props
}) => {
const intl = useIntl()
Expand Down Expand Up @@ -258,6 +260,17 @@ const Header = ({
{...styles.wishlistIcon}
onClick={onWishlistClick}
/>
<IconButton
aria-label={intl.formatMessage({
defaultMessage: 'Store Locator',
id: 'header.button.assistive_msg.store_locator'
})}
icon={<StoreIcon />}
{...styles.icons}
variant="unstyled"
onClick={onStoreLocatorClick}
/>

<IconButton
aria-label={intl.formatMessage(
{
Expand Down Expand Up @@ -291,6 +304,7 @@ Header.propTypes = {
onMyAccountClick: PropTypes.func,
onWishlistClick: PropTypes.func,
onMyCartClick: PropTypes.func,
onStoreLocatorClick: PropTypes.func,
searchInputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({current: PropTypes.elementType})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import '@salesforce/retail-react-app/app/assets/svg/social-facebook.svg'
import '@salesforce/retail-react-app/app/assets/svg/social-instagram.svg'
import '@salesforce/retail-react-app/app/assets/svg/social-twitter.svg'
import '@salesforce/retail-react-app/app/assets/svg/social-youtube.svg'
import '@salesforce/retail-react-app/app/assets/svg/store.svg'
import '@salesforce/retail-react-app/app/assets/svg/like.svg'
import '@salesforce/retail-react-app/app/assets/svg/lock.svg'
import '@salesforce/retail-react-app/app/assets/svg/plug.svg'
Expand Down Expand Up @@ -191,6 +192,7 @@ export const SocialPinterestIcon = icon('social-pinterest', {
})
export const SocialTwitterIcon = icon('social-twitter')
export const SocialYoutubeIcon = icon('social-youtube')
export const StoreIcon = icon('store')
export const SignoutIcon = icon('signout')
export const UserIcon = icon('user')
export const VisaIcon = icon('cc-visa', {viewBox: VisaSymbol.viewBox})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* 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 PropTypes from 'prop-types'
import {
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
useBreakpointValue
} from '@salesforce/retail-react-app/app/components/shared/ui'
import StoreLocatorContent from '@salesforce/retail-react-app/app/components/store-locator/store-locator-content'

const StoreLocatorModal = (props) => {
const {isOpen, setIsOpen} = props
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than implementing this logic ourselves, let's use the one provided by Chakra: useDisclosure

Suggested change
const {isOpen, setIsOpen} = props
const {isOpen, onOpen, onClose} = useDisclosure()

So we can convert the existing:

  • setIsOpen(true) to onOpen()
  • setIsOpen(false) to onClose()


const isDesktopView = useBreakpointValue({base: false, lg: true})

return (
<>
{isDesktopView ? (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a breakpoint value boolean instead of the <HideFrom...> components because the latter wasn't super compatible for chakra UI modals:

  1. Modal overrides some aspect of display, requiring inline styling anyways
  2. display "none" applied to modal still rendered in the DOM

<Modal size="4xl" isOpen={isOpen}>
<ModalContent
display={{base: 'none', lg: 'block'}}
position="absolute"
top="0"
right="0"
width="33.33%"
height="100vh"
borderLeft="1px solid"
borderColor="gray.200"
marginTop="0px"
>
<ModalCloseButton
onClick={() => {
setIsOpen(false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is a current pattern of calling this prop "onClose". Please check the _app component for the DrawerMenu usage.

}}
/>
<ModalBody pb={8} bg="white" paddingBottom={6} marginTop={6}>
<StoreLocatorContent></StoreLocatorContent>
</ModalBody>
</ModalContent>
</Modal>
) : (
<Modal size="4xl" isOpen={isOpen}>
<ModalContent
position="absolute"
top="0"
right="0"
height="100vh"
borderLeft="1px solid"
borderColor="gray.200"
marginTop="0px"
>
<ModalCloseButton
onClick={() => {
setIsOpen(false)
}}
/>
<ModalBody pb={8} bg="white" paddingBottom={6} marginTop={6}>
<StoreLocatorContent></StoreLocatorContent>
</ModalBody>
</ModalContent>
</Modal>
)}
</>
)
}

StoreLocatorModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
setIsOpen: PropTypes.func.isRequired
}

export default StoreLocatorModal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also rename the folder to "components/store-locator-modal/" to be consistent.

Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* 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 StoreLocatorModal from '@salesforce/retail-react-app/app/components/store-locator/store-locator-content'
import {renderWithProviders} from '@salesforce/retail-react-app/app/utils/test-utils'
import {prependHandlersToServer} from '@salesforce/retail-react-app/jest-setup'

const mockStores = {
limit: 4,
data: [
{
address1: 'Kirchgasse 12',
city: 'Wiesbaden',
countryCode: 'DE',
distance: 0.74,
distanceUnit: 'km',
id: '00019',
inventoryId: 'inventory_m_store_store11',
latitude: 50.0826,
longitude: 8.24,
name: 'Wiesbaden Tech Depot',
phone: '+49 611 876543',
posEnabled: false,
postalCode: '65185',
storeHours:
'Monday 9 AM–7 PM\nTuesday 9 AM–7 PM\nWednesday 9 AM–7 PM\nThursday 9 AM–8 PM\nFriday 9 AM–7 PM\nSaturday 9 AM–6 PM\nSunday Closed',
storeLocatorEnabled: true
},
{
address1: 'Schaumainkai 63',
city: 'Frankfurt am Main',
countryCode: 'DE',
distance: 30.78,
distanceUnit: 'km',
id: '00002',
inventoryId: 'inventory_m_store_store4',
latitude: 50.097416,
longitude: 8.669059,
name: 'Frankfurt Electronics Store',
phone: '+49 69 111111111',
posEnabled: false,
postalCode: '60596',
storeHours:
'Monday 10 AM–6 PM\nTuesday 10 AM–6 PM\nWednesday 10 AM–6 PM\nThursday 10 AM–9 PM\nFriday 10 AM–6 PM\nSaturday 10 AM–6 PM\nSunday 10 AM–6 PM',
storeLocatorEnabled: true
},
{
address1: 'Löhrstraße 87',
city: 'Koblenz',
countryCode: 'DE',
distance: 55.25,
distanceUnit: 'km',
id: '00035',
inventoryId: 'inventory_m_store_store27',
latitude: 50.3533,
longitude: 7.5946,
name: 'Koblenz Electronics Store',
phone: '+49 261 123456',
posEnabled: false,
postalCode: '56068',
storeHours:
'Monday 9 AM–7 PM\nTuesday 9 AM–7 PM\nWednesday 9 AM–7 PM\nThursday 9 AM–8 PM\nFriday 9 AM–7 PM\nSaturday 9 AM–6 PM\nSunday Closed',
storeLocatorEnabled: true
},
{
address1: 'Hauptstraße 47',
city: 'Heidelberg',
countryCode: 'DE',
distance: 81.1,
distanceUnit: 'km',
id: '00021',
inventoryId: 'inventory_m_store_store13',
latitude: 49.4077,
longitude: 8.6908,
name: 'Heidelberg Tech Mart',
phone: '+49 6221 123456',
posEnabled: false,
postalCode: '69117',
storeHours:
'Monday 10 AM–7 PM\nTuesday 10 AM–7 PM\nWednesday 10 AM–7 PM\nThursday 10 AM–8 PM\nFriday 10 AM–7 PM\nSaturday 10 AM–6 PM\nSunday Closed',
storeLocatorEnabled: true
}
],
offset: 0,
total: 4
}

describe('StoreLocatorModal', () => {
beforeEach(() => {
prependHandlersToServer([
{
path: '*/shopper-stores/v1/organizations/*',
res: () => {
return mockStores
}
}
])
})
test('renders without crashing', () => {
const setIsOpen = jest.fn()
expect(() => {
renderWithProviders(<StoreLocatorModal isOpen={false} setIsOpen={setIsOpen} />)
}).not.toThrow()
})
})
Loading
Loading