1- import React , { useContext } from 'react'
1+ import React , { useCallback , useContext } from 'react'
22import { createPortal } from 'react-dom'
33import { RouteComponentProps } from 'react-router-dom'
44import { useTranslation } from 'react-i18next'
55import { Stack , getTheme , Text , ProgressIndicator } from 'office-ui-fabric-react'
66import { Alert as AlertIcon , Nodes as ConnectIcon } from 'grommet-icons'
77
88import { StateWithDispatch } from 'states/stateProvider/reducer'
9- import { ConnectStatus , FULL_SCREENS } from 'utils/const'
9+ import { ConnectStatus , FULL_SCREENS , Routes } from 'utils/const'
1010import { NeuronWalletContext } from 'states/stateProvider'
1111
1212const theme = getTheme ( )
13+ const stackStyles = {
14+ root : [
15+ {
16+ width : '100%' ,
17+ background : theme . palette . neutralLighter ,
18+ } ,
19+ ] ,
20+ }
21+ const stackItemStyles = {
22+ root : [ theme . fonts . small ] ,
23+ }
1324
1425// TODO: Listen to sync progress report and update
1526const SyncStatus = ( ) => {
@@ -34,27 +45,24 @@ const NetworkStatus = ({ name, online }: { name: string; online: boolean }) => {
3445}
3546
3647// Status bar
37- const Footer = ( { location : { pathname } } : React . PropsWithoutRef < StateWithDispatch & RouteComponentProps > ) => {
48+ const Footer = ( {
49+ history,
50+ location : { pathname } ,
51+ } : React . PropsWithoutRef < StateWithDispatch & RouteComponentProps > ) => {
3852 const {
3953 chain : { networkID, connectStatus } ,
4054 settings : { networks } ,
4155 } = useContext ( NeuronWalletContext )
56+ const [ t ] = useTranslation ( )
57+
58+ const goToNetworksSetting = useCallback ( ( ) => {
59+ history . push ( Routes . SettingsNetworks )
60+ } , [ history ] )
4261
4362 if ( FULL_SCREENS . find ( url => pathname . startsWith ( url ) ) ) {
4463 return null
4564 }
4665 const currentNetwork = networks . find ( network => network . id === networkID )
47- const stackStyles = {
48- root : [
49- {
50- width : '100%' ,
51- background : theme . palette . neutralLighter ,
52- } ,
53- ] ,
54- }
55- const stackItemStyles = {
56- root : [ theme . fonts . small ] ,
57- }
5866
5967 return (
6068 < Stack
@@ -69,11 +77,13 @@ const Footer = ({ location: { pathname } }: React.PropsWithoutRef<StateWithDispa
6977 < SyncStatus />
7078 </ Stack . Item >
7179
72- < Stack . Item styles = { stackItemStyles } >
80+ < Stack styles = { stackItemStyles } onClick = { goToNetworksSetting } >
7381 { currentNetwork ? (
7482 < NetworkStatus online = { connectStatus === ConnectStatus . Online } name = { currentNetwork . name } />
75- ) : null }
76- </ Stack . Item >
83+ ) : (
84+ < Text > { t ( 'settings.setting-tabs.network' ) } </ Text >
85+ ) }
86+ </ Stack >
7787 </ Stack >
7888 )
7989}
0 commit comments