-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayout.tsx
More file actions
42 lines (36 loc) 路 1.18 KB
/
Copy pathLayout.tsx
File metadata and controls
42 lines (36 loc) 路 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Box, ColorModeScript, theme, useBreakpointValue } from '@chakra-ui/react'
import { useRouter } from 'next/router'
import { ReactNode, useCallback, useContext, useEffect } from 'react'
import AppContext from '../context/app-context'
import Footer from './Footer'
import Head from './Head'
import Header from './Header'
type Props = {
children: ReactNode
title?: string
}
const Layout = ({
children,
title = 'Regional Sindh Emergency Flood Relief 2022',
}: Props) => {
const { query } = useRouter();
const {currency, status} = query;
const app = useContext(AppContext);
// This will read the currency from the params.
const changedCurrency = useCallback(() => app.changeCurrency(currency as string), [query]);
useEffect(() => {
if(currency && app?.state?.currency_rates && app.state.currency_rates.length > 1){
changedCurrency()
}
}, [currency, app?.state?.currency_rates])
return(<>
<Head title={title} />
<ColorModeScript initialColorMode={theme.config.initialColorMode} />
<Header status={status as string} />
<Box pt={useBreakpointValue({base: '0px', md: '100px'})}>
{children}
</Box>
<Footer />
</>)
}
export default Layout