Skip to content

Commit 2ae1153

Browse files
Merge pull request #2639 from SalesforceCommerceCloud/W-18672776_page_not_found
@W-18672776 feat: PageNotFound chakra v3 upgrade
2 parents cd4c053 + dba8de7 commit 2ae1153

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

config/default.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
"ProductDetail": {
9090
"path": "/product/:productId"
9191
},
92+
"PageNotFound": {
93+
"path": "/test"
94+
},
9295
"ProductList": {
9396
"path": ["/search", "/category/:categoryId"],
9497
"imageViewType": "large",

src/pages/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const ProductList = loadable(() => import('overridable!./product-list'), {
3838
const SocialLoginRedirect = loadable(() => import('overridable!./social-login-redirect'), {
3939
fallback
4040
})
41+
42+
const PageNotFound = loadable(() => import('overridable!./page-not-found'), {
43+
fallback
44+
})
4145
// const Wishlist = loadable(() => import('overridable!./account/wishlist'), {
4246
// fallback
4347
// })
@@ -57,6 +61,7 @@ LoginRedirect.displayName = 'LoginRedirect'
5761
ProductDetail.displayName = 'ProductDetail'
5862
ProductList.displayName = 'ProductList'
5963
SocialLoginRedirect.displayName = 'SocialLoginRedirect'
64+
PageNotFound.displayName = 'PageNotFound'
6065

6166
export {
6267
// Account,
@@ -70,5 +75,6 @@ export {
7075
LoginRedirect,
7176
ProductDetail,
7277
ProductList,
78+
PageNotFound,
7379
SocialLoginRedirect
7480
}

src/pages/page-not-found/index.jsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const PageNotFound = () => {
2727
<Box
2828
layerStyle="page"
2929
className="page-not-found"
30-
height={'100%'}
31-
padding={{lg: 8, md: 6, sm: 0, base: 0}}
30+
height="100%"
31+
padding={{base: 0, sm: 0, md: 6, lg: 8}}
3232
>
3333
<Helmet>
3434
<title>
@@ -47,8 +47,13 @@ const PageNotFound = () => {
4747
px={{base: 5, md: 12}}
4848
py={{base: 48, md: 60}}
4949
>
50-
<SearchIcon boxSize={['30px', '32px']} mb={8} />
51-
<Heading as="h2" fontSize={['xl', '2xl', '2xl', '3xl']} mb={2} align="center">
50+
<SearchIcon boxSize={{base: '30px', md: '32px'}} mb={8} />
51+
<Heading
52+
as="h2"
53+
fontSize={{base: 'xl', md: '2xl', lg: '3xl'}}
54+
mb={2}
55+
textAlign="center"
56+
>
5257
{intl.formatMessage({
5358
defaultMessage: "The page you're looking for can't be found.",
5459
id: 'page_not_found.title.page_cant_be_found'
@@ -63,19 +68,19 @@ const PageNotFound = () => {
6368
})}
6469
</Text>
6570
</Box>
66-
<Stack direction={['column', 'row']} width={['100%', 'auto']}>
71+
<Stack direction={{base: 'column', md: 'row'}} width={{base: '100%', md: 'auto'}}>
6772
<Button
6873
variant="outline"
6974
bg="white"
7075
onClick={() => history.goBack()}
71-
borderColor={'gray.200'}
76+
borderColor="gray.200"
7277
>
7378
{intl.formatMessage({
7479
defaultMessage: 'Back to previous page',
7580
id: 'page_not_found.action.go_back'
7681
})}
7782
</Button>
78-
<Button as={Link} to={'/'}>
83+
<Button as={Link} to="/">
7984
{intl.formatMessage({
8085
defaultMessage: 'Go to home page',
8186
id: 'page_not_found.link.homepage'

src/setup-app.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ class ChakraStorefront extends ApplicationExtension<Config> {
117117
{
118118
path: config.pages.ProductList && config.pages.ProductList.path,
119119
component: Pages.ProductList
120+
},
121+
{
122+
path: config.pages.Checkout && config.pages.Checkout.path,
123+
component: Pages.Checkout,
124+
exact: true
125+
},
126+
{
127+
path: config.pages.PageNotFound && config.pages.PageNotFound.path,
128+
component: Pages.PageNotFound,
129+
exact: true
120130
}
121131
].filter((route) => route.path !== false)
122132

0 commit comments

Comments
 (0)