-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathunsupportedNetwork.tsx
More file actions
69 lines (57 loc) · 1.71 KB
/
unsupportedNetwork.tsx
File metadata and controls
69 lines (57 loc) · 1.71 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { ReactElement, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import styled, { css } from 'styled-components'
import { useAccount, useSwitchChain } from 'wagmi'
import { Button, Helper } from '@ensdomains/thorin'
import { getSupportedChainById } from '@app/constants/chains'
import { useRouterWithHistory } from '@app/hooks/useRouterWithHistory'
const Card = styled.div(
({ theme }) => css`
padding: ${theme.space['3.5']};
border-radius: ${theme.radii['3xLarge']};
background-color: ${theme.colors.background};
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
width: ${theme.space.full};
gap: ${theme.space['4']};
max-height: 75vh;
overflow-y: auto;
@media (min-width: ${theme.breakpoints.sm}px) {
width: initial;
min-width: ${theme.space['128']};
}
`,
)
const Container = styled.div`
flex: 1;
display: flex;
align-items: center;
justify-content: center;
`
export default function Page() {
const { t } = useTranslation()
const router = useRouterWithHistory()
const { chainId, isConnected } = useAccount()
const { switchChain } = useSwitchChain()
useEffect(() => {
if (isConnected && getSupportedChainById(chainId)) {
router.push('/')
}
}, [isConnected, chainId, router])
const handleChangeNetwork = () => {
switchChain({ chainId: 1 })
}
return (
<Container>
<Card>
<Helper alert="error">{t('unsupportedNetwork')}</Helper>
<Button onClick={handleChangeNetwork}>{t('action.changeNetwork')}</Button>
</Card>
</Container>
)
}
Page.getLayout = function getLayout(page: ReactElement) {
return <Container>{page}</Container>
}