Adding click handler when finishing load steps #75

This commit is contained in:
apanizo 2018-11-14 10:50:52 +01:00
parent 7b0f8fa448
commit 936b2bc51c
2 changed files with 17 additions and 4 deletions

View File

@ -18,7 +18,7 @@ const getSteps = () => [
type Props = {
provider: string,
network: string,
onLoadSafeSubmit: () => Promise<void>,
onLoadSafeSubmit: (values: Object) => Promise<void>,
}
const iconStyle = {

View File

@ -4,9 +4,12 @@ import { connect } from 'react-redux'
import Page from '~/components/layout/Page'
import { buildSafe } from '~/routes/safe/store/actions/fetchSafe'
import { SAFES_KEY, load, saveSafes } from '~/utils/localStorage'
import { SAFELIST_ADDRESS } from '~/routes/routes'
import { history } from '~/store'
import selector from './selector'
import actions, { type Actions, type UpdateSafe } from './actions'
import Layout from '../components/Layout'
import { FIELD_LOAD_NAME, FIELD_LOAD_ADDRESS } from '../components/fields'
type Props = Actions & {
provider: string,
@ -26,9 +29,19 @@ export const loadSafe = async (safeName: string, safeAddress: string, updateSafe
}
class Open extends React.Component<Props> {
onLoadSafeSubmit = async () => {
// call loadSafe
// travel to safe route
onLoadSafeSubmit = async (values: Object) => {
try {
const { updateSafe } = this.props
const safeName = values[FIELD_LOAD_NAME]
const safeAddress = values[FIELD_LOAD_ADDRESS]
loadSafe(safeName, safeAddress, updateSafe)
const url = `${SAFELIST_ADDRESS}/${safeAddress}`
history.push(url)
} catch (error) {
// eslint-disable-next-line
console.log('Error while loading the Safe' + error)
}
}
render() {