diff options
author | Joris | 2016-03-27 21:13:37 +0200 |
---|---|---|
committer | Joris | 2016-03-27 21:13:37 +0200 |
commit | 0c9d2b91e73f045067f7bcce6e4235fc9008f309 (patch) | |
tree | 6aa101db10b72408a9cfa256312cb34e7ec22dff /src/client/elm/Update/LoggedIn | |
parent | 7c050fe2d2c3e8f190e019e1613d37b9d8ef22b9 (diff) |
Regroup add payment modules
Diffstat (limited to 'src/client/elm/Update/LoggedIn')
-rw-r--r-- | src/client/elm/Update/LoggedIn/AddPayment.elm | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/client/elm/Update/LoggedIn/AddPayment.elm b/src/client/elm/Update/LoggedIn/AddPayment.elm deleted file mode 100644 index 4c9c484..0000000 --- a/src/client/elm/Update/LoggedIn/AddPayment.elm +++ /dev/null @@ -1,54 +0,0 @@ -module Update.LoggedIn.AddPayment - ( updateAddPayment - , addPaymentError - ) where - -import Maybe -import Json.Decode as Json exposing ((:=)) - -import Model.Action.AddPaymentAction exposing (..) -import Model.View.LoggedIn.AddPayment exposing (..) -import Model.Translations exposing (Translations, getMessage) -import Model.Payment exposing (PaymentFrequency(..)) - -updateAddPayment : AddPaymentAction -> AddPayment -> AddPayment -updateAddPayment action addPayment = - case action of - - NoOp -> - addPayment - - UpdateName name -> - { addPayment | name = name } - - UpdateCost cost -> - { addPayment | cost = cost } - - AddError nameError costError -> - { addPayment - | nameError = nameError - , costError = costError - , waitingServer = False - } - - ToggleFrequency -> - { addPayment - | frequency = if addPayment.frequency == Punctual then Monthly else Punctual - } - - WaitingServer -> - { addPayment | waitingServer = True } - -addPaymentError : Translations -> String -> Maybe AddPaymentAction -addPaymentError translations jsonErr = - let decoder = - Json.object2 (,) - (Json.maybe <| "name" := Json.string) - (Json.maybe <| "cost" := Json.string) - in case Json.decodeString decoder jsonErr of - Err _ -> - Nothing - Ok (mbNameKey, mbCostKey) -> - Just <| AddError - (Maybe.map (flip getMessage translations) mbNameKey) - (Maybe.map (flip getMessage translations) mbCostKey) |