55 * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66 */
77
8- import React , { useEffect , useState } from 'react'
8+ import React , { useState } from 'react'
99import PropTypes from 'prop-types'
1010import { FormattedMessage , useIntl } from 'react-intl'
11- import { Route , Switch , Redirect , useLocation , useRouteMatch } from 'react-router-dom'
11+ import { Redirect , useLocation , useRouteMatch } from 'react-router-dom'
12+ import { Route , Switch } from 'react-router-dom'
1213import {
13- Accordion ,
14- AccordionButton ,
15- AccordionItem ,
16- AccordionPanel ,
1714 Box ,
1815 Button ,
1916 Flex ,
2017 Grid ,
2118 Heading ,
2219 Stack ,
23- Text ,
24- Divider
20+ Text
2521} from '@chakra-ui/react'
2622import Seo from '../../components/seo'
2723import Link from '../../components/link'
28- import { ChevronDownIcon , ChevronUpIcon , SignoutIcon } from '../../components/icons'
29- import AccountDetail from '../../pages/account/profile'
3024import AccountAddresses from '../../pages/account/addresses'
31- import AccountOrders from '../../pages/account/orders'
32- import AccountWishlist from '../../pages/account/wishlist/index'
33-
3425import { messages , navLinks } from '../../pages/account/constant'
3526import useNavigation from '../../hooks/use-navigation'
36- import LoadingSpinner from '../../components/loading-spinner'
3727import useMultiSite from '../../hooks/use-multi-site'
3828import useEinstein from '../../hooks/use-einstein'
3929import useDataCloud from '../../hooks/use-datacloud'
@@ -81,7 +71,8 @@ const Account = () => {
8171 const { formatMessage} = useIntl ( )
8272 const { data : customer } = useCurrentCustomer ( )
8373 const { isRegistered, customerType} = customer
84-
74+ const { buildUrl} = useMultiSite ( )
75+
8576 const logout = useAuthHelper ( AuthHelpers . Logout )
8677 const location = useLocation ( )
8778 const navigate = useNavigation ( )
@@ -92,27 +83,23 @@ const Account = () => {
9283 const einstein = useEinstein ( )
9384 const dataCloud = useDataCloud ( )
9485
95- const { buildUrl} = useMultiSite ( )
96- /**************** Einstein ****************/
97- useEffect ( ( ) => {
86+ React . useEffect ( ( ) => {
9887 einstein . sendViewPage ( location . pathname )
9988 dataCloud . sendViewPage ( location . pathname )
10089 } , [ location ] )
10190
10291 const onSignoutClick = async ( ) => {
10392 setShowLoading ( true )
104- await logout . mutateAsync ( )
105- navigate ( '/login' )
93+ // await logout.mutateAsync()
94+ // navigate('/login')
10695 }
10796
10897 // If we have customer data and they are not registered, push to login page
109- // Using Redirect allows us to store the directed page to location
110- // so we can direct users back after they are successfully log in
11198 if ( customerType !== null && ! isRegistered && onClient ) {
11299 const path = buildUrl ( '/login' )
113100 return < Redirect to = { { pathname : path , state : { directedFrom : '/account' } } } />
114101 }
115-
102+
116103 return (
117104 < Box
118105 data-testid = { isRegistered && isHydrated ( ) ? 'account-page' : 'account-page-skeleton' }
@@ -121,85 +108,14 @@ const Account = () => {
121108 >
122109 < Seo title = "My Account" description = "Customer Account Page" />
123110 < Grid templateColumns = { { base : '1fr' , lg : '320px 1fr' } } gap = { { base : 10 , lg : 24 } } >
124- { /* small screen nav accordion */ }
125- < Accordion
126- display = { { base : 'block' , lg : 'none' } }
127- allowToggle = { true }
128- reduceMotion = { true }
129- index = { mobileNavIndex }
130- onChange = { setMobileNavIndex }
131- >
132- < AccordionItem border = "none" background = "gray.50" borderRadius = "base" >
133- { ( { isExpanded} ) => (
134- < >
135- < AccordionButton
136- as = { Button }
137- height = { 16 }
138- paddingLeft = { 8 }
139- variant = "ghost"
140- color = "black"
141- _active = { { background : 'gray.100' } }
142- _expanded = { { background : 'transparent' } }
143- >
144- < Flex align = "center" justify = "center" >
145- < Heading as = "h2" fontSize = "16px" >
146- < FormattedMessage
147- defaultMessage = "My Account"
148- id = "account.accordion.button.my_account"
149- />
150- </ Heading >
151- { isExpanded ? < ChevronUpIcon /> : < ChevronDownIcon /> }
152- </ Flex >
153- </ AccordionButton >
154- < AccordionPanel px = { 4 } paddingBottom = { 4 } >
155- < Flex as = "nav" spacing = { 0 } direction = "column" >
156- < Stack spacing = { 0 } as = "ul" data-testid = "account-nav" >
157- { navLinks . map ( ( link ) => (
158- < Box
159- align = "center"
160- key = { link . name }
161- as = "li"
162- listStyleType = "none"
163- >
164- < Button
165- as = { Link }
166- to = { `/account${ link . path } ` }
167- useNavLink = { true }
168- variant = "menu-link-mobile"
169- justifyContent = "center"
170- fontSize = "md"
171- fontWeight = "normal"
172- width = "100%"
173- onClick = { ( ) => setMobileNavIndex ( - 1 ) }
174- >
175- { formatMessage ( messages [ link . name ] ) }
176- </ Button >
177- </ Box >
178- ) ) }
179-
180- < LogoutButton
181- justify = "center"
182- onClick = { onSignoutClick }
183- />
184- </ Stack >
185- </ Flex >
186- </ AccordionPanel >
187- </ >
188- ) }
189- </ AccordionItem >
190- </ Accordion >
191-
192- { /* large screen nav sidebar */ }
111+ { /* Navigation Sidebar */ }
193112 < Stack display = { { base : 'none' , lg : 'flex' } } spacing = { 4 } >
194- { showLoading && < LoadingSpinner wrapperStyles = { { height : '100vh' } } /> }
195-
196113 < Heading as = "h2" fontSize = "18px" >
197114 < FormattedMessage
198115 defaultMessage = "My Account"
199116 id = "account.heading.my_account"
200117 />
201118 </ Heading >
202-
203119 < Flex spacing = { 0 } as = "nav" data-testid = "account-detail-nav" direction = "column" >
204120 { navLinks . map ( ( link ) => {
205121 const LinkIcon = link . icon
@@ -216,24 +132,27 @@ const Account = () => {
216132 </ Button >
217133 )
218134 } ) }
219- < LogoutButton onClick = { onSignoutClick } />
220135 </ Flex >
136+ < Button onClick = { onSignoutClick } > Logout</ Button >
221137 </ Stack >
222138
223- < Switch >
224- < Route exact path = { path } >
225- < AccountDetail />
226- </ Route >
227- < Route exact path = { `${ path } /wishlist` } >
228- < AccountWishlist />
229- </ Route >
230- < Route exact path = { `${ path } /addresses` } >
231- < AccountAddresses />
232- </ Route >
233- < Route path = { `${ path } /orders` } >
234- < AccountOrders />
235- </ Route >
236- </ Switch >
139+ { /* Main Content */ }
140+ < Box >
141+ < Heading > Account Page</ Heading >
142+ < Text > Path: { path } </ Text >
143+ < Text > Registered: { isRegistered ? 'Yes' : 'No' } </ Text >
144+ < Text > Customer Type: { customerType } </ Text >
145+
146+ < Switch >
147+ < Route path = { `${ path } /addresses` } component = { AccountAddresses } />
148+ < Route exact path = { path } >
149+ < Box >
150+ < Heading > Account Profile</ Heading >
151+ < Text > This is the account profile page</ Text >
152+ </ Box >
153+ </ Route >
154+ </ Switch >
155+ </ Box >
237156 </ Grid >
238157 </ Box >
239158 )
@@ -245,4 +164,4 @@ Account.propTypes = {
245164 match : PropTypes . object
246165}
247166
248- export default Account
167+ export default Account
0 commit comments