diff --git a/src/data/form-publish.json b/src/data/form-publish.json index 37c7c6e..5c57de2 100644 --- a/src/data/form-publish.json +++ b/src/data/form-publish.json @@ -100,12 +100,6 @@ ] } } - }, - { - "title": "Wallet" - }, - { - "title": "Complete" } ] } diff --git a/src/routes/Publish/Step.tsx b/src/routes/Publish/Step.tsx index 56f72b7..6677e1a 100644 --- a/src/routes/Publish/Step.tsx +++ b/src/routes/Publish/Step.tsx @@ -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 { @@ -31,8 +32,9 @@ export default class Step extends PureComponent { } public nextButton() { - let { currentStep, next } = this.props - if (currentStep < 3) { + let { currentStep, next, totalSteps } = this.props + + if (currentStep < totalSteps) { return } return null @@ -47,7 +49,8 @@ export default class Step extends PureComponent { inputChange, inputToArrayChange, files, - state + state, + totalSteps } = this.props if (currentStep !== index + 1) { @@ -102,17 +105,19 @@ export default class Step extends PureComponent { {this.previousButton()} {this.nextButton()} - - {states => - states.isLogged ? ( - - ) : ( - - ) - } - + {currentStep === totalSteps && ( + + {states => + states.isLogged ? ( + + ) : ( + + ) + } + + )} ) } diff --git a/src/routes/Publish/index.tsx b/src/routes/Publish/index.tsx index f27f981..3583534 100644 --- a/src/routes/Publish/index.tsx +++ b/src/routes/Publish/index.tsx @@ -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} /> ))}