WA-238 fetchDailyLimit action definition and its reducer
This commit is contained in:
parent
3cba259fc1
commit
4a30051858
|
@ -0,0 +1,12 @@
|
||||||
|
// @flow
|
||||||
|
import type { Dispatch as ReduxDispatch } from 'redux'
|
||||||
|
import { type GlobalState } from '~/store/index'
|
||||||
|
import { getDailyLimitFrom } from '~/routes/safe/component/Withdrawn/withdrawn'
|
||||||
|
import updateDailyLimit from './updateDailyLimit'
|
||||||
|
|
||||||
|
export default (safeAddress: string) => async (dispatch: ReduxDispatch<GlobalState>) => {
|
||||||
|
const ethAddress = 0
|
||||||
|
const dailyLimit: DailyLimitProps = await getDailyLimitFrom(safeAddress, ethAddress)
|
||||||
|
|
||||||
|
return dispatch(updateDailyLimit(safeAddress, dailyLimit))
|
||||||
|
}
|
|
@ -2,9 +2,11 @@
|
||||||
import { Map, List } from 'immutable'
|
import { Map, List } from 'immutable'
|
||||||
import { handleActions, type ActionType } from 'redux-actions'
|
import { handleActions, type ActionType } from 'redux-actions'
|
||||||
import addSafe, { ADD_SAFE } from '~/routes/safe/store/actions/addSafe'
|
import addSafe, { ADD_SAFE } from '~/routes/safe/store/actions/addSafe'
|
||||||
|
import updateDailyLimit, { UPDATE_DAILY_LIMIT } from '~/routes/safe/store/actions/updateDailyLimit'
|
||||||
import { makeOwner } from '~/routes/safe/store/model/owner'
|
import { makeOwner } from '~/routes/safe/store/model/owner'
|
||||||
import { type Safe, makeSafe } from '~/routes/safe/store/model/safe'
|
import { type Safe, makeSafe } from '~/routes/safe/store/model/safe'
|
||||||
import { loadSafes, saveSafes } from '~/utils/localStorage'
|
import { loadSafes, saveSafes } from '~/utils/localStorage'
|
||||||
|
import { makeDailyLimit } from '~/routes/safe/store/model/dailyLimit'
|
||||||
|
|
||||||
export const SAFE_REDUCER_ID = 'safes'
|
export const SAFE_REDUCER_ID = 'safes'
|
||||||
|
|
||||||
|
@ -45,4 +47,9 @@ export default handleActions({
|
||||||
saveSafes(safes.toJSON())
|
saveSafes(safes.toJSON())
|
||||||
return safes
|
return safes
|
||||||
},
|
},
|
||||||
|
[UPDATE_DAILY_LIMIT]: (state: State, action: ActionType<typeof updateDailyLimit>): State => {
|
||||||
|
const safes = state.updateIn([action.safeAddress, 'dailyLimit'], () => makeDailyLimit(action.dailyLimit))
|
||||||
|
saveSafes(safes.toJSON())
|
||||||
|
return safes
|
||||||
|
},
|
||||||
}, Map())
|
}, Map())
|
||||||
|
|
Loading…
Reference in New Issue