diff options
Diffstat (limited to 'src/client/Update/LoggedIn.elm')
-rw-r--r-- | src/client/Update/LoggedIn.elm | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client/Update/LoggedIn.elm b/src/client/Update/LoggedIn.elm index 07f3426..e200b04 100644 --- a/src/client/Update/LoggedIn.elm +++ b/src/client/Update/LoggedIn.elm @@ -16,13 +16,15 @@ import Update.LoggedIn.Add exposing (..) import Update.LoggedIn.Monthly as UM import Update.LoggedIn.Account as UA +import Utils.List exposing (find) + type LoggedAction = UpdateAdd AddPaymentAction | UpdatePayments Payments | AddPayment UserId String Int Payments | AddMonthlyPayment PaymentId String Int | ToggleEdit PaymentId - | DeletePayment UserId Int Payments + | DeletePayment Payment Payments | UpdatePage Int Payments | UpdateMonthly UM.MonthlyAction | UpdateAccount UA.AccountAction @@ -39,22 +41,22 @@ updateLoggedIn model action loggedInView = | payments <- payments , currentPage <- 1 , add <- initAddPayment Punctual - , account <- UA.updateAccount (UA.UpdatePayer userId cost) loggedInView.account + , account <- UA.updateAccount (UA.UpdatePayer userId model.currentTime cost) loggedInView.account , paymentsCount <- loggedInView.paymentsCount + 1 } AddMonthlyPayment id name cost -> { loggedInView | add <- initAddPayment Monthly , monthly <- - let payment = Payment id (Date.fromTime model.currentTime) name cost loggedInView.me + let payment = Payment id (Date.fromTime model.currentTime) name cost loggedInView.account.me in UM.updateMonthly (UM.AddPayment payment) loggedInView.monthly } ToggleEdit id -> { loggedInView | paymentEdition <- if loggedInView.paymentEdition == Just id then Nothing else Just id } - DeletePayment userId cost payments -> + DeletePayment payment payments -> { loggedInView | payments <- payments - , account <- UA.updateAccount (UA.UpdatePayer userId -cost) loggedInView.account + , account <- UA.updateAccount (UA.UpdatePayer payment.userId (Date.toTime payment.creation) -payment.cost) loggedInView.account , paymentsCount <- loggedInView.paymentsCount - 1 } UpdatePage page payments -> |