blob: df19775aa19354a43a2ec5a7ba4009317fb40ab9 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
module Update
( Action(..)
, actions
, updateModel
) where
import Time exposing (Time)
import Model exposing (Model)
import Model.Payment exposing (Payments)
import Model.Payers exposing (Payers)
import Model.View as V
import Model.View.SignInView exposing (..)
import Model.View.PaymentView exposing (..)
import Update.SignIn exposing (..)
import Update.Payment exposing (..)
type Action =
NoOp
| UpdateTime Time
| GoSignInView
| SignInError String
| UpdateSignIn SignInAction
| GoPaymentView String Payments Payers
| UpdatePayment PaymentAction
actions : Signal.Mailbox Action
actions = Signal.mailbox NoOp
updateModel : Action -> Model -> Model
updateModel action model =
case action of
NoOp ->
model
UpdateTime time ->
{ model | currentTime <- time }
GoSignInView ->
{ model | view <- V.SignInView initSignInView }
GoPaymentView userName payments payers ->
{ model | view <- V.PaymentView (initPaymentView userName payments payers) }
SignInError msg ->
let signInView = { initSignInView | result <- Just (Err msg) }
in { model | view <- V.SignInView signInView }
UpdateSignIn signInAction ->
case model.view of
V.SignInView signInView ->
{ model | view <- V.SignInView (updateSignIn signInAction signInView) }
_ ->
model
UpdatePayment paymentAction ->
case model.view of
V.PaymentView paymentView ->
{ model | view <- V.PaymentView (updatePayment model paymentAction paymentView) }
_ ->
model
|