module Update ( Action(..) , actions , updateModel ) where import Model exposing (Model) import Model.Payment exposing (Payments) import Model.View exposing (..) import Model.View.SignIn exposing (..) import Update.SignIn exposing (..) type Action = NoOp | SignIn | SignInError String | UpdateSignIn SignInAction | UpdatePayments Payments actions : Signal.Mailbox Action actions = Signal.mailbox NoOp updateModel : Action -> Model -> Model updateModel action model = case action of NoOp -> model SignIn -> { model | view <- SignInView initSignIn } SignInError msg -> let signIn = { initSignIn | result <- Just (Err msg) } in { model | view <- SignInView signIn } UpdateSignIn signInAction -> case model.view of SignInView signIn -> { model | view <- SignInView (updateSignIn signInAction signIn) } _ -> model UpdatePayments payments -> { model | view <- PaymentView payments }