From 0c9d2b91e73f045067f7bcce6e4235fc9008f309 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 27 Mar 2016 21:13:37 +0200 Subject: Regroup add payment modules --- src/client/elm/LoggedIn/Update.elm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/client/elm/LoggedIn/Update.elm') diff --git a/src/client/elm/LoggedIn/Update.elm b/src/client/elm/LoggedIn/Update.elm index e017423..35ffaff 100644 --- a/src/client/elm/LoggedIn/Update.elm +++ b/src/client/elm/LoggedIn/Update.elm @@ -19,15 +19,16 @@ import LoggedIn.Model as LoggedInModel import LoggedIn.Account.Action as AccountAction import LoggedIn.Account.Update as AccountUpdate +import LoggedIn.AddPayment.Action as AddPaymentAction +import LoggedIn.AddPayment.Model as AddPaymentModel +import LoggedIn.AddPayment.Update as AddPaymentUpdate + import Model exposing (Model) import Model.User exposing (UserId) import Model.Payment exposing (..) import Model.Action.MonthlyAction as Monthly -import Model.Action.AddPaymentAction as AddPayment -import Model.View.LoggedIn.AddPayment exposing (..) import Model.Translations exposing (Translations, getMessage) -import Update.LoggedIn.AddPayment exposing (updateAddPayment, addPaymentError) import Update.LoggedIn.Monthly exposing (updateMonthly) update : Model -> LoggedInAction.Action -> LoggedInModel.Model -> (LoggedInModel.Model, Effects LoggedInAction.Action) @@ -37,7 +38,7 @@ update model action loggedInView = LoggedInAction.NoOp -> (loggedInView, Effects.none) LoggedInAction.UpdateAdd addPaymentAction -> - ( { loggedInView | add = updateAddPayment addPaymentAction loggedInView.add } + ( { loggedInView | add = AddPaymentUpdate.update addPaymentAction loggedInView.add } , Effects.none ) @@ -47,19 +48,19 @@ update model action loggedInView = ) LoggedInAction.AddPayment name cost frequency -> - ( { loggedInView | add = updateAddPayment AddPayment.WaitingServer loggedInView.add } + ( { loggedInView | add = AddPaymentUpdate.update AddPaymentAction.WaitingServer loggedInView.add } , Server.addPayment name cost frequency |> Task.map (\paymentId -> case String.toInt cost of Err _ -> - LoggedInAction.UpdateAdd (AddPayment.AddError Nothing (Just (getMessage "CostRequired" model.translations))) + LoggedInAction.UpdateAdd (AddPaymentAction.AddError Nothing (Just (getMessage "CostRequired" model.translations))) Ok costNumber -> LoggedInAction.ValidateAddPayment paymentId name costNumber frequency ) |> flip Task.onError (\err -> case err of BadResponse 400 jsonErr -> - case addPaymentError model.translations jsonErr of + case AddPaymentUpdate.addPaymentError model.translations jsonErr of Just addPaymentAction -> Task.succeed (LoggedInAction.UpdateAdd addPaymentAction) Nothing -> Task.succeed LoggedInAction.NoOp _ -> @@ -70,7 +71,7 @@ update model action loggedInView = LoggedInAction.ValidateAddPayment paymentId name cost frequency -> let newPayment = Payment paymentId (Date.fromTime model.currentTime) name cost loggedInView.account.me - newAdd = initAddPayment frequency + newAdd = AddPaymentModel.init frequency in case frequency of Punctual -> ( { loggedInView -- cgit v1.2.3