From b0adbb0a49a702e72e09be3ec9a43a2efe4b1e70 Mon Sep 17 00:00:00 2001 From: apanizo Date: Tue, 13 Nov 2018 17:08:17 +0100 Subject: [PATCH] Implemented loadSafe logic function #75 in Load component --- src/routes/load/container/Load.jsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/routes/load/container/Load.jsx b/src/routes/load/container/Load.jsx index e07d4f69..4114e70e 100644 --- a/src/routes/load/container/Load.jsx +++ b/src/routes/load/container/Load.jsx @@ -2,8 +2,10 @@ import * as React from 'react' 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 selector from './selector' -import actions, { type Actions } from './actions' +import actions, { type Actions, type UpdateSafe } from './actions' import Layout from '../components/Layout' type Props = Actions & { @@ -12,13 +14,21 @@ type Props = Actions & { network: string, } -export const loadSafe = async (): Promise => { +export const loadSafe = async (safeName: string, safeAddress: string, updateSafe: UpdateSafe) => { + const safeRecord = await buildSafe(safeAddress, safeName) + await updateSafe(safeRecord) + + const storedSafes = load(SAFES_KEY) || {} + storedSafes[safeAddress] = safeRecord.toJSON() + + saveSafes(storedSafes) } class Open extends React.Component { onLoadSafeSubmit = async () => { - // + // call loadSafe + // travel to safe route } render() {