Implementing back on stepper when it is first page

This commit is contained in:
apanizo 2018-09-24 16:24:28 +02:00
parent 1b4cca91a9
commit 0fc735187e
1 changed files with 10 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import * as React from 'react'
import GnoForm from '~/components/forms/GnoForm'
import Hairline from '~/components/layout/Hairline'
import Button from '~/components/layout/Button'
import { history } from '~/store'
import Controls from './Controls'
export { default as Step } from './Step'
@ -96,10 +97,17 @@ class GnoStepper extends React.PureComponent<Props, State> {
}))
}
previous = () =>
this.setState(state => ({
previous = () => {
const firstPage = this.state.page === 0
if (firstPage) {
return history.goBack()
}
return this.setState(state => ({
page: Math.max(state.page - 1, 0),
}))
}
handleSubmit = async (values: Object) => {
const { children, onSubmit } = this.props