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