blob: 23e5c84572124c590d18d7b8d6b5d0565b317a27 (
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
57
|
module Update
( Action(..)
, actions
, updateModel
) where
import Time exposing (Time)
import Model exposing (Model)
import Model.User exposing (Users, UserId)
import Model.Payment exposing (Payments)
import Model.Payers exposing (Payers)
import Model.View as V
import Model.View.SignInView exposing (..)
import Model.View.LoggedInView exposing (..)
import Update.SignIn exposing (..)
import Update.LoggedIn exposing (..)
type Action =
NoOp
| UpdateTime Time
| GoSignInView
| SignInError String
| UpdateSignIn SignInAction
| GoLoggedInView Users UserId Payments Payments Int Payers
| UpdateLoggedIn LoggedAction
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 }
GoLoggedInView users me monthlyPayments payments paymentsCount payers ->
{ model | view <- V.LoggedInView (initLoggedInView users me monthlyPayments payments paymentsCount 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
UpdateLoggedIn loggedAction ->
case model.view of
V.LoggedInView loggedInView ->
{ model | view <- V.LoggedInView (updateLoggedIn model loggedAction loggedInView) }
_ ->
model
|