diff --git a/src/routes/safe/component/Safe/DailyLimit.jsx b/src/routes/safe/component/Safe/DailyLimit.jsx
index a19bb462..23b909f1 100644
--- a/src/routes/safe/component/Safe/DailyLimit.jsx
+++ b/src/routes/safe/component/Safe/DailyLimit.jsx
@@ -7,26 +7,32 @@ import Button from '~/components/layout/Button'
import ListItemText from '~/components/List/ListItemText'
type Props = {
- limit: number,
+ dailyLimit: number,
onWithdrawn: () => void,
}
export const WITHDRAWN_BUTTON_TEXT = 'Withdrawn'
-const DailyLimit = ({ limit, onWithdrawn }: Props) => (
-
-
-
-
-
-
-
-)
+const DailyLimit = ({ dailyLimit, onWithdrawn }: Props) => {
+ const limit = dailyLimit.get('value')
+ const disabled = dailyLimit.get('todaySpent') > limit
+
+ return (
+
+
+
+
+
+
+
+ )
+}
export default DailyLimit
diff --git a/src/routes/safe/component/Safe/index.jsx b/src/routes/safe/component/Safe/index.jsx
index 563f069c..752a9907 100644
--- a/src/routes/safe/component/Safe/index.jsx
+++ b/src/routes/safe/component/Safe/index.jsx
@@ -55,7 +55,7 @@ class GnoSafe extends React.PureComponent {
-
+
diff --git a/src/routes/safe/store/actions/addSafe.js b/src/routes/safe/store/actions/addSafe.js
index e4a1801e..d5a3836c 100644
--- a/src/routes/safe/store/actions/addSafe.js
+++ b/src/routes/safe/store/actions/addSafe.js
@@ -1,7 +1,7 @@
// @flow
import { List } from 'immutable'
import { createAction } from 'redux-actions'
-import { type SafeProps } from '~/routes/safe/store/model/safe'
+import { makeDailyLimit, type DailyLimit, type SafeProps } from '~/routes/safe/store/model/safe'
import { makeOwner, type Owner } from '~/routes/safe/store/model/owner'
export const ADD_SAFE = 'ADD_SAFE'
@@ -12,14 +12,18 @@ export const buildOwnersFrom = (names: string[], addresses: string[]) => {
return List(owners)
}
+export const buildDailyLimitFrom = (dailyLimit: number): DailyLimit =>
+ makeDailyLimit({ value: dailyLimit, spentToday: 0 })
+
const addSafe = createAction(
ADD_SAFE,
(
name: string, address: string,
- confirmations: number, dailyLimit: number,
+ confirmations: number, limit: number,
ownersName: string[], ownersAddress: string[],
): SafeProps => {
const owners: List = buildOwnersFrom(ownersName, ownersAddress)
+ const dailyLimit: DailyLimit = buildDailyLimitFrom(limit)
return ({
address, name, confirmations, owners, dailyLimit,
diff --git a/src/routes/safe/store/model/safe.js b/src/routes/safe/store/model/safe.js
index 28e25209..cc9149d8 100644
--- a/src/routes/safe/store/model/safe.js
+++ b/src/routes/safe/store/model/safe.js
@@ -3,6 +3,18 @@ import { List, Record } from 'immutable'
import type { RecordFactory, RecordOf } from 'immutable'
import type { Owner } from '~/routes/safe/store/model/owner'
+export type DailyLimitProps = {
+ value: number,
+ spentToday: number,
+}
+
+export const makeDailyLimit: RecordFactory = Record({
+ value: 0,
+ spentToday: 0,
+})
+
+export type DailyLimit = RecordOf
+
export type SafeProps = {
name: string,
address: string,
@@ -16,7 +28,7 @@ export const makeSafe: RecordFactory = Record({
address: '',
confirmations: 0,
owners: List([]),
- dailyLimit: 0,
+ dailyLimit: makeDailyLimit(),
})
export type Safe = RecordOf
diff --git a/src/routes/safe/store/test/builder/safe.builder.js b/src/routes/safe/store/test/builder/safe.builder.js
index 0bde9e05..5edc8e25 100644
--- a/src/routes/safe/store/test/builder/safe.builder.js
+++ b/src/routes/safe/store/test/builder/safe.builder.js
@@ -1,6 +1,6 @@
// @flow
import { makeSafe, type Safe } from '~/routes/safe/store/model/safe'
-import { buildOwnersFrom } from '~/routes/safe/store/actions'
+import { buildOwnersFrom, buildDailyLimitFrom } from '~/routes/safe/store/actions'
class SafeBuilder {
safe: Safe
@@ -25,7 +25,8 @@ class SafeBuilder {
}
withDailyLimit(limit: number) {
- this.safe = this.safe.set('dailyLimit', limit)
+ const dailyLimit = buildDailyLimitFrom(limit)
+ this.safe = this.safe.set('dailyLimit', dailyLimit)
return this
}