blob: 02ee1bda23072b0e2ec5fa9ed857a6b6161bb980 (
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
|
module View.SignIn
( renderSignIn
) where
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Json.Decode as Json
import Update exposing (..)
import Update.SignIn exposing (..)
import ServerCommunication as SC
import ServerCommunication exposing (serverCommunications)
import Model.View.SignInView exposing (..)
renderSignIn : SignInView -> Html
renderSignIn signInView =
div
[ class "signIn" ]
[ div
[ class "form" ]
[ input
[ value signInView.login
, on "input" targetValue (Signal.message actions.address << UpdateSignIn << UpdateLogin)
, onEnter serverCommunications.address (SC.SignIn signInView.login)
]
[]
, button
[ onClick serverCommunications.address (SC.SignIn signInView.login) ]
[ text "Sign in" ]
]
, div
[ class "result" ]
[ signInResult signInView ]
]
onEnter : Signal.Address a -> a -> Attribute
onEnter address value =
on "keydown"
(Json.customDecoder keyCode (\code -> if code == 13 then Ok () else Err ""))
(\_ -> Signal.message address value)
signInResult : SignInView -> Html
signInResult signInView =
case signInView.result of
Just result ->
case result of
Ok login ->
div
[ class "success" ]
[ text ("We send you an email, please click to the provided link in order to sign in.") ]
Err error ->
div
[ class "error" ]
[ text error ]
Nothing ->
text ""
|