aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Update')
-rw-r--r--src/client/Update/LoggedIn.elm9
-rw-r--r--src/client/Update/LoggedIn/Account.elm20
2 files changed, 26 insertions, 3 deletions
diff --git a/src/client/Update/LoggedIn.elm b/src/client/Update/LoggedIn.elm
index 03eb137..07f3426 100644
--- a/src/client/Update/LoggedIn.elm
+++ b/src/client/Update/LoggedIn.elm
@@ -9,12 +9,12 @@ import Dict
import Model exposing (Model)
import Model.User exposing (UserId)
import Model.Payment exposing (..)
-import Model.Payers exposing (..)
import Model.View.LoggedInView exposing (..)
import Model.View.LoggedIn.Add exposing (..)
import Update.LoggedIn.Add exposing (..)
import Update.LoggedIn.Monthly as UM
+import Update.LoggedIn.Account as UA
type LoggedAction =
UpdateAdd AddPaymentAction
@@ -25,6 +25,7 @@ type LoggedAction =
| DeletePayment UserId Int Payments
| UpdatePage Int Payments
| UpdateMonthly UM.MonthlyAction
+ | UpdateAccount UA.AccountAction
updateLoggedIn : Model -> LoggedAction -> LoggedInView -> LoggedInView
updateLoggedIn model action loggedInView =
@@ -38,7 +39,7 @@ updateLoggedIn model action loggedInView =
| payments <- payments
, currentPage <- 1
, add <- initAddPayment Punctual
- , payers <- updatePayers loggedInView.payers userId cost
+ , account <- UA.updateAccount (UA.UpdatePayer userId cost) loggedInView.account
, paymentsCount <- loggedInView.paymentsCount + 1
}
AddMonthlyPayment id name cost ->
@@ -53,7 +54,7 @@ updateLoggedIn model action loggedInView =
DeletePayment userId cost payments ->
{ loggedInView
| payments <- payments
- , payers <- updatePayers loggedInView.payers userId -cost
+ , account <- UA.updateAccount (UA.UpdatePayer userId -cost) loggedInView.account
, paymentsCount <- loggedInView.paymentsCount - 1
}
UpdatePage page payments ->
@@ -63,3 +64,5 @@ updateLoggedIn model action loggedInView =
}
UpdateMonthly monthlyAction ->
{ loggedInView | monthly <- UM.updateMonthly monthlyAction loggedInView.monthly }
+ UpdateAccount accountAction ->
+ { loggedInView | account <- UA.updateAccount accountAction loggedInView.account }
diff --git a/src/client/Update/LoggedIn/Account.elm b/src/client/Update/LoggedIn/Account.elm
new file mode 100644
index 0000000..ab07c2e
--- /dev/null
+++ b/src/client/Update/LoggedIn/Account.elm
@@ -0,0 +1,20 @@
+module Update.LoggedIn.Account
+ ( AccountAction(..)
+ , updateAccount
+ ) where
+
+import Model.User exposing (UserId)
+import Model.Payers exposing (..)
+import Model.View.LoggedIn.Account exposing (..)
+
+type AccountAction =
+ ToggleDetail
+ | UpdatePayer UserId Int
+
+updateAccount : AccountAction -> Account -> Account
+updateAccount action account =
+ case action of
+ ToggleDetail ->
+ { account | visibleDetail <- not account.visibleDetail }
+ UpdatePayer userId cost ->
+ { account | payers <- updatePayers account.payers userId cost }