aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
diff options
context:
space:
mode:
authorJoris2016-06-23 23:43:23 +0200
committerJoris2016-06-23 23:43:23 +0200
commit4ce4de89a5400b0d8b9cddaa2922901a081fdaaa (patch)
treeb65e9ef809c2ec7608101563eb3378eaeeddf12b /src/client/elm/LoggedIn/Home/AddPayment/Update.elm
parent36a90770ebeb9bd99e136bfe035fdda5dfabc304 (diff)
downloadbudget-4ce4de89a5400b0d8b9cddaa2922901a081fdaaa.tar.gz
budget-4ce4de89a5400b0d8b9cddaa2922901a081fdaaa.tar.bz2
budget-4ce4de89a5400b0d8b9cddaa2922901a081fdaaa.zip
Use a dialog to add a payment
Diffstat (limited to 'src/client/elm/LoggedIn/Home/AddPayment/Update.elm')
-rw-r--r--src/client/elm/LoggedIn/Home/AddPayment/Update.elm58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm b/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
deleted file mode 100644
index dc1ea57..0000000
--- a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
+++ /dev/null
@@ -1,58 +0,0 @@
-module LoggedIn.Home.AddPayment.Update exposing
- ( update
- , addPaymentError
- )
-
-import Maybe
-import Json.Decode as Json exposing ((:=))
-
-import LoggedIn.Home.AddPayment.Msg as AddPaymentMsg
-import LoggedIn.Home.AddPayment.Model as AddPaymentModel
-
-import Model.Translations exposing (Translations, getMessage)
-import Model.Payment exposing (Frequency(..))
-
-update : AddPaymentMsg.Msg -> AddPaymentModel.Model -> AddPaymentModel.Model
-update msg addPayment =
- case msg of
-
- AddPaymentMsg.NoOp ->
- addPayment
-
- AddPaymentMsg.Init frequency ->
- AddPaymentModel.init frequency
-
- AddPaymentMsg.UpdateName name ->
- { addPayment | name = name }
-
- AddPaymentMsg.UpdateCost cost ->
- { addPayment | cost = cost }
-
- AddPaymentMsg.AddError nameError costError ->
- { addPayment
- | nameError = nameError
- , costError = costError
- , waitingServer = False
- }
-
- AddPaymentMsg.ToggleFrequency ->
- { addPayment
- | frequency = if addPayment.frequency == Punctual then Monthly else Punctual
- }
-
- AddPaymentMsg.WaitingServer ->
- { addPayment | waitingServer = True }
-
-addPaymentError : Translations -> String -> Maybe AddPaymentMsg.Msg
-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 <| AddPaymentMsg.AddError
- (Maybe.map (flip getMessage translations) mbNameKey)
- (Maybe.map (flip getMessage translations) mbCostKey)