1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

step & button fixes

This commit is contained in:
Matthias Kretschmann 2019-02-19 17:26:15 +01:00
parent e91de4a64d
commit 720705cb6c
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 27 additions and 28 deletions

View File

@ -100,12 +100,6 @@
]
}
}
},
{
"title": "Wallet"
},
{
"title": "Complete"
}
]
}

View File

@ -1,4 +1,4 @@
import React, { PureComponent } from 'react'
import React, { PureComponent, FormEvent } from 'react'
import Input from '../../components/atoms/Form/Input'
import Label from '../../components/atoms/Form/Label'
import Row from '../../components/atoms/Form/Row'
@ -18,6 +18,7 @@ interface StepProps {
title: string
next: any
prev: any
totalSteps: number
}
export default class Step extends PureComponent<StepProps, {}> {
@ -31,8 +32,9 @@ export default class Step extends PureComponent<StepProps, {}> {
}
public nextButton() {
let { currentStep, next } = this.props
if (currentStep < 3) {
let { currentStep, next, totalSteps } = this.props
if (currentStep < totalSteps) {
return <Button onClick={next}>Next</Button>
}
return null
@ -47,7 +49,8 @@ export default class Step extends PureComponent<StepProps, {}> {
inputChange,
inputToArrayChange,
files,
state
state,
totalSteps
} = this.props
if (currentStep !== index + 1) {
@ -102,17 +105,19 @@ export default class Step extends PureComponent<StepProps, {}> {
{this.previousButton()}
{this.nextButton()}
<User.Consumer>
{states =>
states.isLogged ? (
<Button primary>Register asset</Button>
) : (
<Button onClick={states.startLogin}>
Register asset (login first)
</Button>
)
}
</User.Consumer>
{currentStep === totalSteps && (
<User.Consumer>
{states =>
states.isLogged ? (
<Button primary>Register asset</Button>
) : (
<Button onClick={states.startLogin}>
Register asset (login first)
</Button>
)
}
</User.Consumer>
)}
</>
)
}

View File

@ -70,18 +70,17 @@ class Publish extends Component<{}, PublishState> {
private next = () => {
let { currentStep } = this.state
currentStep = currentStep >= 2 ? 3 : currentStep + 1
this.setState({
currentStep: currentStep
})
const totalSteps = form.steps.length
currentStep =
currentStep >= totalSteps - 1 ? totalSteps : currentStep + 1
this.setState({ currentStep })
}
private prev = () => {
let { currentStep } = this.state
currentStep = currentStep <= 1 ? 1 : currentStep - 1
this.setState({
currentStep: currentStep
})
this.setState({ currentStep })
}
private toStart = () => {
@ -186,6 +185,7 @@ class Publish extends Component<{}, PublishState> {
state={this.state}
next={this.next}
prev={this.prev}
totalSteps={form.steps.length}
/>
))}
</Form>