diff options
Diffstat (limited to 'src/client/elm/Update')
-rw-r--r-- | src/client/elm/Update/LoggedIn.elm | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/client/elm/Update/LoggedIn.elm b/src/client/elm/Update/LoggedIn.elm index 1553141..ca4690b 100644 --- a/src/client/elm/Update/LoggedIn.elm +++ b/src/client/elm/Update/LoggedIn.elm @@ -25,22 +25,23 @@ updateLoggedIn model action loggedInView = { loggedInView | add = updateAddPayment addPaymentAction loggedInView.add } UpdatePayments payments -> { loggedInView | payments = payments } - AddPayment paymentId name cost -> + AddPayment paymentId name cost frequency -> let newPayment = Payment paymentId (Date.fromTime model.currentTime) name cost loggedInView.account.me - in { loggedInView - | currentPage = 1 - , add = initAddPayment Punctual - , account = updateAccount (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 - , monthly = - let payment = Payment id (Date.fromTime model.currentTime) name cost loggedInView.account.me - in updateMonthly (Monthly.AddPayment payment) loggedInView.monthly - } + newAdd = initAddPayment frequency + in if frequency == Punctual + then + { loggedInView + | currentPage = 1 + , add = newAdd + , account = updateAccount (UpdatePayer loggedInView.account.me model.currentTime cost) loggedInView.account + , payments = newPayment :: loggedInView.payments + , paymentsCount = loggedInView.paymentsCount + 1 + } + else + { loggedInView + | add = newAdd + , monthly = updateMonthly (Monthly.AddPayment newPayment) loggedInView.monthly + } ToggleEdit id -> { loggedInView | paymentEdition = if loggedInView.paymentEdition == Just id then Nothing else Just id } DeletePayment payment -> |