diff options
Diffstat (limited to 'src/client/elm/Update')
-rw-r--r-- | src/client/elm/Update/LoggedIn.elm | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/client/elm/Update/LoggedIn.elm b/src/client/elm/Update/LoggedIn.elm index 2dc65c3..38901b2 100644 --- a/src/client/elm/Update/LoggedIn.elm +++ b/src/client/elm/Update/LoggedIn.elm @@ -19,7 +19,7 @@ import Update.LoggedIn.Account as UA type LoggedAction = UpdateAdd AddPaymentAction | UpdatePayments Payments - | AddPayment UserId String Int + | AddPayment PaymentId String Int | AddMonthlyPayment PaymentId String Int | ToggleEdit PaymentId | DeletePayment Payment @@ -34,13 +34,15 @@ updateLoggedIn model action loggedInView = { loggedInView | add = updateAddPayment addPaymentAction loggedInView.add } UpdatePayments payments -> { loggedInView | payments = payments } - AddPayment userId name cost -> - { loggedInView - | currentPage = 1 - , add = initAddPayment Punctual - , account = UA.updateAccount (UA.UpdatePayer userId model.currentTime cost) loggedInView.account - , paymentsCount = loggedInView.paymentsCount + 1 - } + AddPayment paymentId name cost -> + let newPayment = Payment paymentId (Date.fromTime model.currentTime) name cost loggedInView.account.me + in { loggedInView + | currentPage = 1 + , add = initAddPayment Punctual + , account = UA.updateAccount (UA.UpdatePayer loggedInView.account.me model.currentTime cost) loggedInView.account + , payments = newPayment :: loggedInView.payments + , paymentsCount = loggedInView.paymentsCount + 1 + } AddMonthlyPayment id name cost -> { loggedInView | add = initAddPayment Monthly @@ -53,6 +55,7 @@ updateLoggedIn model action loggedInView = DeletePayment payment -> { loggedInView | account = UA.updateAccount (UA.UpdatePayer payment.userId (Date.toTime payment.creation) -payment.cost) loggedInView.account + , payments = deletePayment payment.id loggedInView.payments , paymentsCount = loggedInView.paymentsCount - 1 } UpdatePage page -> |