Implemented loadSafe logic function #75 in Load component

This commit is contained in:
apanizo 2018-11-13 17:08:17 +01:00
parent 09c4a2037f
commit b0adbb0a49
1 changed files with 13 additions and 3 deletions

View File

@ -2,8 +2,10 @@
import * as React from 'react' import * as React from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import Page from '~/components/layout/Page' 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 selector from './selector'
import actions, { type Actions } from './actions' import actions, { type Actions, type UpdateSafe } from './actions'
import Layout from '../components/Layout' import Layout from '../components/Layout'
type Props = Actions & { type Props = Actions & {
@ -12,13 +14,21 @@ type Props = Actions & {
network: string, network: string,
} }
export const loadSafe = async (): Promise<void> => { 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<Props> { class Open extends React.Component<Props> {
onLoadSafeSubmit = async () => { onLoadSafeSubmit = async () => {
// // call loadSafe
// travel to safe route
} }
render() { render() {