diff options
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 |