aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update.elm
blob: 1d0fe9538bb381b7fc5aab5e43d49a130c3a80d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
  | 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 }
    UpdateSignIn signInAction ->
      case model.view of
        SignInView signIn ->
          { model | view <- SignInView (updateSignIn signInAction signIn) }
        _ ->
          model
    UpdatePayments payments ->
      { model | view <- PaymentView payments }