Adding helper function to calculate penultimate and last page in Stepper

This commit is contained in:
apanizo 2018-10-03 17:35:19 +02:00
parent a64278bd51
commit 9d882e7a8b
1 changed files with 6 additions and 2 deletions

View File

@ -129,13 +129,16 @@ class GnoStepper extends React.PureComponent<Props, State> {
return this.next(values) return this.next(values)
} }
isLastPage = page => page === this.props.steps.length - 1
render() { render() {
const { const {
steps, children, classes, disabledWhenValidating = false, steps, children, classes, disabledWhenValidating = false,
} = this.props } = this.props
const { page, values } = this.state const { page, values } = this.state
const activePage = this.getActivePageFrom(children) const activePage = this.getActivePageFrom(children)
const isLastPage = page === steps.length - 1 const lastPage = this.isLastPage(page)
const penultimate = this.isLastPage(page + 1)
return ( return (
<React.Fragment> <React.Fragment>
@ -153,7 +156,8 @@ class GnoStepper extends React.PureComponent<Props, State> {
disabled={disabled} disabled={disabled}
onPrevious={this.previous} onPrevious={this.previous}
firstPage={page === 0} firstPage={page === 0}
lastPage={isLastPage} lastPage={lastPage}
penultimate={penultimate}
/> />
</React.Fragment> </React.Fragment>
) )