1
1
import { Box , Container , ContainerProps } from '@chakra-ui/react' ;
2
2
import { FC , ReactNode } from 'react' ;
3
- import { useRouter } from 'next/router' ;
4
3
5
4
import { Footer , FooterBackgroundImage , HomepageHero } from '../UI' ;
5
+ import { useCurrentPath } from '../../hooks/useCurrentPath' ;
6
6
import { Forms } from '../forms' ;
7
7
8
8
import {
@@ -40,10 +40,10 @@ import {
40
40
} from '../../constants' ;
41
41
42
42
export const Layout : FC < ContainerProps > = ( { children, ...props } ) => {
43
- const router = useRouter ( ) ;
43
+ const path = useCurrentPath ( ) ;
44
44
45
45
const renderContent = ( ) : ReactNode => {
46
- if ( router . pathname === HOME_URL ) {
46
+ if ( path === HOME_URL ) {
47
47
return (
48
48
< >
49
49
< HomepageHero />
@@ -53,7 +53,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
53
53
) ;
54
54
}
55
55
56
- if ( router . pathname . startsWith ( APPLICANTS_URL ) ) {
56
+ if ( path . startsWith ( APPLICANTS_URL ) ) {
57
57
return (
58
58
< Box mt = { - 6 } >
59
59
< main >
@@ -63,7 +63,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
63
63
) ;
64
64
}
65
65
66
- if ( router . pathname . startsWith ( ABOUT_URL ) ) {
66
+ if ( path . startsWith ( ABOUT_URL ) ) {
67
67
return (
68
68
< Box mt = { - 6 } >
69
69
< main >
@@ -73,7 +73,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
73
73
) ;
74
74
}
75
75
76
- if ( router . pathname === DEVCON_GRANTS_URL ) {
76
+ if ( path === DEVCON_GRANTS_URL ) {
77
77
return (
78
78
< Box mt = { { md : - 10 , lg : 0 } } >
79
79
< main >
@@ -83,7 +83,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
83
83
) ;
84
84
}
85
85
86
- if ( router . pathname === ACADEMIC_GRANTS_2022_URL ) {
86
+ if ( path === ACADEMIC_GRANTS_2022_URL ) {
87
87
return (
88
88
< Box mt = { { md : - 10 , lg : 0 } } >
89
89
< main >
@@ -93,7 +93,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
93
93
) ;
94
94
}
95
95
96
- if ( router . pathname === ACADEMIC_GRANTS_2023_URL ) {
96
+ if ( path === ACADEMIC_GRANTS_2023_URL ) {
97
97
return (
98
98
< Box mt = { { md : - 10 , lg : 0 } } >
99
99
< main >
@@ -103,7 +103,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
103
103
) ;
104
104
}
105
105
106
- if ( router . pathname === ACADEMIC_GRANTS_URL ) {
106
+ if ( path === ACADEMIC_GRANTS_URL ) {
107
107
return (
108
108
< Box mt = { { md : - 10 , lg : 0 } } >
109
109
< main >
@@ -113,7 +113,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
113
113
) ;
114
114
}
115
115
116
- if ( router . pathname === MERGE_DATA_CHALLENGE_URL ) {
116
+ if ( path === MERGE_DATA_CHALLENGE_URL ) {
117
117
return (
118
118
< Box mt = { { md : - 10 , lg : 0 } } >
119
119
< main >
@@ -124,7 +124,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
124
124
}
125
125
126
126
// TODO: refactor these if conditions ????
127
- if ( router . pathname === SEMAPHORE_GRANT_URL ) {
127
+ if ( path === SEMAPHORE_GRANT_URL ) {
128
128
return (
129
129
< Box mt = { { md : - 10 , lg : 0 } } >
130
130
< main >
@@ -134,7 +134,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
134
134
) ;
135
135
}
136
136
137
- if ( router . pathname === LAYER_2_GRANTS_URL ) {
137
+ if ( path === LAYER_2_GRANTS_URL ) {
138
138
return (
139
139
< Box mt = { { md : - 10 , lg : 0 } } >
140
140
< main >
@@ -144,7 +144,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
144
144
) ;
145
145
}
146
146
147
- if ( router . pathname === ACCOUNT_ABSTRACTION_GRANTS_URL ) {
147
+ if ( path === ACCOUNT_ABSTRACTION_GRANTS_URL ) {
148
148
return (
149
149
< Box mt = { { md : - 10 , lg : 0 } } >
150
150
< main >
@@ -154,7 +154,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
154
154
) ;
155
155
}
156
156
157
- if ( router . pathname === RUN_A_NODE_GRANTS_URL ) {
157
+ if ( path === RUN_A_NODE_GRANTS_URL ) {
158
158
return (
159
159
< Box mt = { { md : - 10 , lg : 0 } } >
160
160
< main >
@@ -164,7 +164,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
164
164
) ;
165
165
}
166
166
167
- if ( router . pathname === DATA_COLLECTION_ROUND_URL ) {
167
+ if ( path === DATA_COLLECTION_ROUND_URL ) {
168
168
return (
169
169
< Box mt = { { md : - 10 , lg : 0 } } >
170
170
< main >
@@ -174,7 +174,7 @@ export const Layout: FC<ContainerProps> = ({ children, ...props }) => {
174
174
) ;
175
175
}
176
176
177
- if ( GRANTS_URLS . includes ( router . pathname ) ) {
177
+ if ( GRANTS_URLS . includes ( path ) ) {
178
178
return (
179
179
< Box mt = { - 6 } >
180
180
< main >
0 commit comments