aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Update
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Update')
-rw-r--r--src/client/elm/Update/LoggedIn.elm36
-rw-r--r--src/client/elm/Update/LoggedIn/Account.elm23
2 files changed, 19 insertions, 40 deletions
diff --git a/src/client/elm/Update/LoggedIn.elm b/src/client/elm/Update/LoggedIn.elm
index dfc2a1b..300c63a 100644
--- a/src/client/elm/Update/LoggedIn.elm
+++ b/src/client/elm/Update/LoggedIn.elm
@@ -71,17 +71,15 @@ updateLoggedIn model action loggedInView =
newAdd = initAddPayment frequency
in case frequency of
Punctual ->
- let (newAccount, accountEffects) =
- updateAccount (Account.UpdatePayer loggedInView.account.me model.currentTime cost) loggedInView.account
- in ( { loggedInView
- | currentPage = 1
- , add = newAdd
- , account = newAccount
- , payments = newPayment :: loggedInView.payments
- , paymentsCount = loggedInView.paymentsCount + 1
- }
- , Effects.map UpdateAccount accountEffects
- )
+ ( { loggedInView
+ | currentPage = 1
+ , add = newAdd
+ , account = loggedInView.account
+ , payments = newPayment :: loggedInView.payments
+ , paymentsCount = loggedInView.paymentsCount + 1
+ }
+ , Effects.none
+ )
Monthly ->
( { loggedInView
| add = newAdd
@@ -112,15 +110,13 @@ updateLoggedIn model action loggedInView =
, Effects.none
)
Punctual ->
- let (newAccount, accountEffects) =
- updateAccount (Account.UpdatePayer payment.userId (Date.toTime payment.creation) -payment.cost) loggedInView.account
- in ( { loggedInView
- | account = newAccount
- , payments = deletePayment payment.id loggedInView.payments
- , paymentsCount = loggedInView.paymentsCount - 1
- }
- , Effects.map UpdateAccount accountEffects
- )
+ ( { loggedInView
+ | account = loggedInView.account
+ , payments = deletePayment payment.id loggedInView.payments
+ , paymentsCount = loggedInView.paymentsCount - 1
+ }
+ , Effects.none
+ )
UpdatePage page ->
( { loggedInView | currentPage = page }
diff --git a/src/client/elm/Update/LoggedIn/Account.elm b/src/client/elm/Update/LoggedIn/Account.elm
index 1773b9a..233efa9 100644
--- a/src/client/elm/Update/LoggedIn/Account.elm
+++ b/src/client/elm/Update/LoggedIn/Account.elm
@@ -10,7 +10,6 @@ import Effects exposing (Effects)
import Server
-import Model.Payer exposing (updatePayers)
import Model.Action.AccountAction exposing (..)
import Model.View.LoggedIn.Account exposing (..)
@@ -28,11 +27,6 @@ updateAccount action account =
, Effects.none
)
- UpdatePayer userId creation amountDiff ->
- ( { account | payers = updatePayers account.payers userId creation amountDiff }
- , Effects.none
- )
-
ToggleIncomeEdition ->
( { account | incomeEdition =
if isJust account.incomeEdition
@@ -67,25 +61,14 @@ updateAccount action account =
UpdateIncome currentTime amount ->
( account
, Server.setIncome currentTime amount
- |> Task.map (always (ValidateUpdateIncome currentTime amount))
+ |> Task.map (\incomeId -> (ValidateUpdateIncome incomeId currentTime amount))
|> flip Task.onError (always <| Task.succeed NoOp)
|> Effects.task
)
- ValidateUpdateIncome currentTime amount ->
+ ValidateUpdateIncome incomeId currentTime amount ->
( { account
- | payers =
- account.payers
- |> Dict.update account.me (\mbPayer ->
- case mbPayer of
- Just payer ->
- Just
- { payer
- | incomes = payer.incomes ++ [{ creation = currentTime, amount = amount }]
- }
- Nothing ->
- Nothing
- )
+ | incomes = Dict.insert incomeId { userId = account.me, creation = currentTime, amount = amount } account.incomes
, incomeEdition = Nothing
}
, Effects.none