blob: 88f74b08dbf5fd896a66787077ece9c4b9d9f680 (
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
63
|
module SignIn.View exposing
( view
)
import Json.Decode as Decode
import FontAwesome
import View.Color as Color
import Html as H exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import SignIn.Msg as SignInMsg
import SignIn.Model as SignInModel
import Update exposing (..)
import Model exposing (Model)
import Msg exposing (..)
import Model.Translations exposing (getMessage)
import View.Events exposing (onSubmitPrevDefault)
view : Model -> SignInModel.Model -> Html Msg
view model signInModel =
div
[ class "signIn" ]
[ H.form
[ onSubmitPrevDefault (SignIn signInModel.login) ]
[ input
[ value signInModel.login
, on "input" (targetValue |> (Decode.map <| (UpdateSignIn << SignInMsg.UpdateLogin)))
, name "email"
]
[]
, button
[]
[ if signInModel.waitingServer
then FontAwesome.spinner Color.white 20
else text (getMessage model.translations "SignIn")
]
]
, div
[ class "result" ]
[ signInResult model signInModel ]
]
signInResult : Model -> SignInModel.Model -> Html Msg
signInResult model signInModel =
case signInModel.result of
Just result ->
case result of
Ok login ->
div
[ class "success" ]
[ text (getMessage model.translations "SignInEmailSent") ]
Err error ->
div
[ class "error" ]
[ text (getMessage model.translations error) ]
Nothing ->
text ""
|