From 936b2bc51cd3bfd25d2ddea1bd675c52e8d9ffa9 Mon Sep 17 00:00:00 2001 From: apanizo Date: Wed, 14 Nov 2018 10:50:52 +0100 Subject: [PATCH] Adding click handler when finishing load steps #75 --- src/routes/load/components/Layout.jsx | 2 +- src/routes/load/container/Load.jsx | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/routes/load/components/Layout.jsx b/src/routes/load/components/Layout.jsx index 75c36269..65c3241c 100644 --- a/src/routes/load/components/Layout.jsx +++ b/src/routes/load/components/Layout.jsx @@ -18,7 +18,7 @@ const getSteps = () => [ type Props = { provider: string, network: string, - onLoadSafeSubmit: () => Promise, + onLoadSafeSubmit: (values: Object) => Promise, } const iconStyle = { diff --git a/src/routes/load/container/Load.jsx b/src/routes/load/container/Load.jsx index 4114e70e..3997f819 100644 --- a/src/routes/load/container/Load.jsx +++ b/src/routes/load/container/Load.jsx @@ -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 { - 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() {