diff options
author | Joris | 2016-08-08 20:58:17 +0200 |
---|---|---|
committer | Joris | 2016-08-08 20:58:17 +0200 |
commit | 8816cf758119a6a2073e561c8df297a833630986 (patch) | |
tree | 20e63f3c0de15945b818a6d7a78359f9134b5e82 /src/client/elm/LoggedIn/Update.elm | |
parent | b54d8e45fc8784d8fa6eaa03f58536b7a19cf70b (diff) |
Show incomes in a table and update like payments are updated
Diffstat (limited to 'src/client/elm/LoggedIn/Update.elm')
-rw-r--r-- | src/client/elm/LoggedIn/Update.elm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/client/elm/LoggedIn/Update.elm b/src/client/elm/LoggedIn/Update.elm index db851f1..68e840e 100644 --- a/src/client/elm/LoggedIn/Update.elm +++ b/src/client/elm/LoggedIn/Update.elm @@ -15,6 +15,7 @@ import Form import Model exposing (Model) import Model.Translations exposing (getMessage) import Model.Payment as Payment exposing (Payment, Frequency(..)) +import Model.Income as Income exposing (Income) import Server import LoggedData @@ -139,6 +140,24 @@ update model msg loggedIn = , Cmd.none ) + LoggedInMsg.EditIncome incomeId amount date -> + ( loggedIn + , Server.editIncome incomeId amount date + |> Task.perform + (always LoggedInMsg.NoOp) + (always <| LoggedInMsg.ValidateEditIncome incomeId amount date) + ) + + LoggedInMsg.ValidateEditIncome incomeId amount date -> + let updatedIncome = Income loggedIn.me (Date.toTime date) amount + updateIncome mbIncome = + case mbIncome of + Just _ -> Just updatedIncome + Nothing -> Just updatedIncome + in ( { loggedIn | incomes = Dict.update incomeId updateIncome loggedIn.incomes } + , Cmd.none + ) + LoggedInMsg.DeleteIncome incomeId -> ( loggedIn , Server.deleteIncome incomeId |