Skip to content

Commit

Permalink
feat(neuron-ui): add check on current wallet id on leaving settings view
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Jul 24, 2019
1 parent 4c9f8fc commit b33a238
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/neuron-ui/src/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { StateWithDispatch } from 'states/stateProvider/reducer'
import GeneralSetting from 'components/GeneralSetting'
import Wallets from 'components/WalletSetting'
import NetworkSetting from 'components/NetworkSetting'
import { WalletWizardPath } from 'components/WalletWizard'

import { Routes } from 'utils/const'

Expand Down Expand Up @@ -46,15 +47,16 @@ const Settings = ({
...neuronWalletState
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
const [t] = useTranslation()
const goBack = useCallback(() => {
history.goBack()
}, [history])
const { id } = neuronWalletState.wallet
const onLeave = useCallback(() => {
return id ? history.push(Routes.Overview) : history.push(`${Routes.WalletWizard}${WalletWizardPath.Welcome}`)
}, [id, history])

return (
<Stack tokens={{ childrenGap: 15 }}>
<Stack horizontal>
<Stack.Item align="center">
<IconButton onClick={goBack} styles={{ root: { marginRight: 20 } }}>
<IconButton onClick={onLeave} styles={{ root: { marginRight: 20 } }}>
<FormPreviousLink />
</IconButton>
</Stack.Item>
Expand Down

0 comments on commit b33a238

Please sign in to comment.