prepare disabling button based on form validation

This commit is contained in:
Matthias Kretschmann 2019-02-20 14:58:55 +01:00
parent 1fee0cfc66
commit d58a5f1f1b
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 22 additions and 9 deletions

View File

@ -37,10 +37,9 @@
}
&:disabled {
color: rgba($brand-white, .7);
cursor: not-allowed;
pointer-events: none;
opacity: .8;
opacity: .5;
}
}

View File

@ -9,6 +9,7 @@ interface ButtonProps {
link?: boolean
href?: string
onClick?: any
disabled?: boolean
}
export default class Button extends PureComponent<ButtonProps, any> {

View File

@ -26,7 +26,17 @@ interface StepProps {
content?: string
}
export default class Step extends PureComponent<StepProps, {}> {
interface StepState {
inputInvalid: boolean
}
export default class Step extends PureComponent<StepProps, StepState> {
public state = {
// TODO: manipulate with some form validation for every step,
// should be 'true' by default here
inputInvalid: false
}
public previousButton() {
let { currentStep, prev } = this.props
@ -42,9 +52,14 @@ export default class Step extends PureComponent<StepProps, {}> {
public nextButton() {
let { currentStep, next, totalSteps } = this.props
const { inputInvalid } = this.state
if (currentStep < totalSteps) {
return <Button onClick={next}>Next </Button>
return (
<Button disabled={inputInvalid} onClick={next}>
Next
</Button>
)
}
return null
}

View File

@ -108,7 +108,8 @@ class Publish extends Component<{}, PublishState> {
publishingError: '',
isPublishing: true
})
const account = await this.context.ocean.getAccounts()
const { ocean } = this.context
const account = await ocean.getAccounts()
const newAsset = {
// OEP-08 Attributes
// https://github.com/oceanprotocol/OEPs/tree/master/8
@ -138,10 +139,7 @@ class Publish extends Component<{}, PublishState> {
}
try {
const asset = await this.context.ocean.registerAsset(
newAsset,
account[0]
)
const asset = await ocean.registerAsset(newAsset, account[0])
this.setState({
publishedDid: asset.id,
isPublished: true