1 import React from 'react'
2 import { BaseNew } from 'features/shared/components'
3 import NewKeyAndSign from './NewKeyAndSign'
4 import NewAssetInfo from './NewAssetInfo'
5 import {withNamespaces} from 'react-i18next'
6 import { destroy } from 'redux-form';
8 class Form extends React.Component {
11 this.submitWithValidations = this.submitWithValidations.bind(this)
12 this.nextPage = this.nextPage.bind(this)
13 this.previousPage = this.previousPage.bind(this)
19 componentWillUnmount(){
20 this.props.destroyForm()
23 submitWithValidations(data) {
28 limit_height: data.reissue === 'true'? 0 : this.props.blockHeight+3,
30 name: data.alias.trim(),
31 symbol: data.symbol.trim(),
32 decimals: data.decimals,
34 reissue: data.reissue,
35 description: data.description
39 return new Promise((resolve, reject) => {
40 this.props.submitForm(resultData)
42 this.props.destroyForm()
44 .catch((err) => reject({_error: err}))
49 this.setState({ page: this.state.page + 1 })
53 this.setState({ page: this.state.page - 1 })
57 const { page } = this.state
60 {page === 1 && <NewAssetInfo onSubmit={this.nextPage}/>}
61 {page === 2 && <NewKeyAndSign previousPage={this.previousPage} onSubmit={this.submitWithValidations}/>}
67 const mapDispatchToProps = ( dispatch ) => ({
68 ...BaseNew.mapDispatchToProps('asset')(dispatch),
69 destroyForm: () => dispatch(destroy('newAssetForm')),
72 const mapStateToProps = ( state ) => ({
73 ...BaseNew.mapStateToProps('asset'),
74 blockHeight: state.core.blockHeight
77 export default withNamespaces('translations') ( BaseNew.connect(