blob: d81d63a2fdbfea7f7af7983d9d3607d0b0631c4b (
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
58
59
60
61
|
module SignIn.View
( view
) where
import Html as H exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Signal exposing (Address)
import Json.Decode as Json
import SignIn.Action as SignInAction
import SignIn.Model as SignInModel
import Update exposing (..)
import Model exposing (Model)
import Action exposing (..)
import Model.Translations exposing (getMessage)
import View.Events exposing (onSubmitPrevDefault)
import View.Icon exposing (renderSpinIcon)
view : Address Action -> Model -> SignInModel.Model -> Html
view address model signInModel =
div
[ class "signIn" ]
[ H.form
[ onSubmitPrevDefault address (SignIn signInModel.login) ]
[ input
[ value signInModel.login
, on "input" targetValue (Signal.message address << UpdateSignIn << SignInAction.UpdateLogin)
, name "email"
]
[]
, button
[]
[ if signInModel.waitingServer
then renderSpinIcon
else text (getMessage "SignIn" model.translations)
]
]
, div
[ class "result" ]
[ signInResult model signInModel ]
]
signInResult : Model -> SignInModel.Model -> Html
signInResult model signInModel =
case signInModel.result of
Just result ->
case result of
Ok login ->
div
[ class "success" ]
[ text (getMessage "SignInEmailSent" model.translations) ]
Err error ->
div
[ class "error" ]
[ text (getMessage error model.translations) ]
Nothing ->
text ""
|