aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Update.elm
diff options
context:
space:
mode:
authorJoris2016-03-27 21:13:37 +0200
committerJoris2016-03-27 21:13:37 +0200
commit0c9d2b91e73f045067f7bcce6e4235fc9008f309 (patch)
tree6aa101db10b72408a9cfa256312cb34e7ec22dff /src/client/elm/LoggedIn/Update.elm
parent7c050fe2d2c3e8f190e019e1613d37b9d8ef22b9 (diff)
downloadbudget-0c9d2b91e73f045067f7bcce6e4235fc9008f309.tar.gz
budget-0c9d2b91e73f045067f7bcce6e4235fc9008f309.tar.bz2
budget-0c9d2b91e73f045067f7bcce6e4235fc9008f309.zip
Regroup add payment modules
Diffstat (limited to 'src/client/elm/LoggedIn/Update.elm')
-rw-r--r--src/client/elm/LoggedIn/Update.elm17
1 files changed, 9 insertions, 8 deletions
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