blob: 6fba7646e14450c7ce551100bc9f6aae556d14d7 (
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
62
|
module View.SignIn
( renderSignIn
) where
import Html as H exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Signal exposing (Address)
import Json.Decode as Json
import Update exposing (..)
import Update.SignIn exposing (..)
import Model exposing (Model)
import Model.Action exposing (..)
import Model.Action.SignInAction exposing (..)
import Model.View.SignInView exposing (..)
import Model.Translations exposing (getMessage)
import View.Events exposing (onSubmitPrevDefault)
import View.Icon exposing (renderSpinIcon)
renderSignIn : Address Action -> Model -> SignInView -> Html
renderSignIn address model signInView =
div
[ class "signIn" ]
[ H.form
[ onSubmitPrevDefault address (SignIn signInView.login) ]
[ input
[ value signInView.login
, on "input" targetValue (Signal.message address << UpdateSignIn << UpdateLogin)
, type' "text"
, autocomplete True
]
[]
, button
[]
[ if signInView.waitingServer
then renderSpinIcon
else text (getMessage "SignIn" model.translations)
]
]
, div
[ class "result" ]
[ signInResult model signInView ]
]
signInResult : Model -> SignInView -> Html
signInResult model signInView =
case signInView.result of
Just result ->
case result of
Ok login ->
div
[ class "success" ]
[ text (getMessage "SignInEmailSent" model.translations) ]
Err error ->
div
[ class "error" ]
[ text error ]
Nothing ->
text ""
|