diff options
author | Joris | 2016-08-21 14:30:40 +0200 |
---|---|---|
committer | Joris | 2016-08-21 14:30:40 +0200 |
commit | 75804df1cb231033f94183e41cdf79d36d8f6710 (patch) | |
tree | 48b7932285091fdbdaba6d77586859c1e1750ce0 /src/client/elm/Update.elm | |
parent | 3889d21ab58fbbc0134854b95013196a82e8d510 (diff) |
Show a message if there is an error during a server request
Diffstat (limited to 'src/client/elm/Update.elm')
-rw-r--r-- | src/client/elm/Update.elm | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/client/elm/Update.elm b/src/client/elm/Update.elm index 817a191..e66414e 100644 --- a/src/client/elm/Update.elm +++ b/src/client/elm/Update.elm @@ -66,12 +66,63 @@ update msg model = UpdateLoggedIn loggedInMsg -> applyLoggedIn model loggedInMsg + CreatePayment name cost date frequency -> + ( model + , Server.createPayment name cost date frequency + |> Task.perform + (always <| Error "CreatePaymentError") + (\paymentId -> UpdateLoggedIn <| LoggedInMsg.ValidateCreatePayment paymentId name cost date frequency) + ) + + EditPayment paymentId name cost date frequency -> + ( model + , Server.editPayment paymentId name cost date frequency + |> Task.perform + (always <| Error "EditPaymentError") + (always <| UpdateLoggedIn <| LoggedInMsg.ValidateEditPayment paymentId name cost date frequency) + ) + + DeletePayment paymentId -> + ( model + , Server.deletePayment paymentId + |> Task.perform + (always <| Error "DeletePaymentError") + (always <| UpdateLoggedIn <| LoggedInMsg.ValidateDeletePayment paymentId) + ) + + CreateIncome amount date -> + ( model + , Server.createIncome amount date + |> Task.perform + (always <| Error "CreateIncomeError") + (\incomeId -> UpdateLoggedIn <| LoggedInMsg.ValidateCreateIncome incomeId amount date) + ) + + EditIncome incomeId amount date -> + ( model + , Server.editIncome incomeId amount date + |> Task.perform + (always <| Error "EditIncomeError") + (always <| UpdateLoggedIn <| LoggedInMsg.ValidateEditIncome incomeId amount date) + ) + + DeleteIncome incomeId -> + ( model + , Server.deleteIncome incomeId + |> Task.perform + (always <| Error "DeleteIncomeError") + (always <| UpdateLoggedIn <| LoggedInMsg.ValidateDeleteIncome incomeId) + ) + SignOut -> ( model , Server.signOut - |> Task.perform (always NoOp) (always GoSignInView) + |> Task.perform (always <| Error "SignOutError") (always GoSignInView) ) + Error error -> + ({ model | errors = model.errors ++ [ error ] }, Cmd.none) + Dialog dialogMsg -> Dialog.update DialogUpdate.update dialogMsg model.dialog.model model.dialog |> Tuple.mapFst (\dialog -> { model | dialog = dialog }) |