WA-238 Specifying Go address and title in Stepper via props
This commit is contained in:
parent
88795cf890
commit
32f88a873c
|
@ -2,7 +2,6 @@
|
|||
import * as React from 'react'
|
||||
import Button from '~/components/layout/Button'
|
||||
import Link from '~/components/layout/Link'
|
||||
import { SAFELIST_ADDRESS } from '~/routes/routes'
|
||||
|
||||
type NextButtonProps = {
|
||||
text: string,
|
||||
|
@ -20,9 +19,14 @@ const NextButton = ({ text, disabled }: NextButtonProps) => (
|
|||
</Button>
|
||||
)
|
||||
|
||||
const GoButton = () => (
|
||||
<Link to={SAFELIST_ADDRESS}>
|
||||
<NextButton text="VISIT SAFES" disabled={false} />
|
||||
type GoProps = {
|
||||
title: string,
|
||||
to: string,
|
||||
}
|
||||
|
||||
const GoButton = ({ title, to }: GoProps) => (
|
||||
<Link to={to}>
|
||||
<NextButton text={title} disabled={false} />
|
||||
</Link>
|
||||
)
|
||||
|
||||
|
@ -54,14 +58,16 @@ type Props = {
|
|||
firstPage: boolean,
|
||||
lastPage: boolean,
|
||||
submitting: boolean,
|
||||
goTitle: string,
|
||||
goPath: string,
|
||||
}
|
||||
|
||||
const Controls = ({
|
||||
finishedTx, onPrevious, firstPage, lastPage, submitting,
|
||||
finishedTx, onPrevious, firstPage, lastPage, submitting, goTitle, goPath,
|
||||
}: Props) => (
|
||||
<React.Fragment>
|
||||
{ finishedTx
|
||||
? <GoButton />
|
||||
? <GoButton title={goTitle} to={goPath} />
|
||||
: <ControlButtons
|
||||
submitting={submitting}
|
||||
next={lastPage ? 'Finish' : 'Next'}
|
||||
|
|
|
@ -10,6 +10,8 @@ import Controls from './Controls'
|
|||
export { default as Step } from './Step'
|
||||
|
||||
type Props = {
|
||||
goTitle: string,
|
||||
goPath: string,
|
||||
steps: string[],
|
||||
finishedTransaction: boolean,
|
||||
initialValues?: Object,
|
||||
|
@ -75,7 +77,9 @@ class GnoStepper extends React.PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { steps, children, finishedTransaction } = this.props
|
||||
const {
|
||||
steps, children, finishedTransaction, goTitle, goPath,
|
||||
} = this.props
|
||||
const { page, values } = this.state
|
||||
const activePage = this.getActivePageFrom(children)
|
||||
const isLastPage = page === steps.length - 1
|
||||
|
@ -105,6 +109,8 @@ class GnoStepper extends React.PureComponent<Props, State> {
|
|||
onPrevious={this.previous}
|
||||
firstPage={page === 0}
|
||||
lastPage={isLastPage}
|
||||
goTitle={goTitle}
|
||||
goPath={goPath}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
|
|
Loading…
Reference in New Issue