aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update.elm
blob: 508ee2fb0d7b578a637278f9a71d3914124e0003 (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
38
39
40
41
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 }