aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/View/SignIn.elm
blob: c21c16c9dbaec1c2493633b8c9b88366c4c4b98c (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
module View.SignIn
  ( renderSignIn
  ) where

import Json.Decode as Json
import Signal exposing (Address)

import Html as H exposing (..)
import Html.Attributes exposing (..)
import Html.Events 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 (..)

import Persona exposing (operations)

renderSignIn : Address Action -> Model -> SignInView -> Html
renderSignIn address model signInView =
  div
    [ class "signIn" ]
    [ button
        ( if signInView.waitingServer
            then [ class "waitingServer" ]
            else [ onClick operations.address Persona.SignIn ]
        )
        [ span [] [ text (getMessage "SignIn" model.translations) ]
        , if signInView.waitingServer
            then renderSpinIcon
            else renderIcon "power-off"
        ]
    , signInResult model signInView
    ]

signInResult : Model -> SignInView -> Html
signInResult model signInView =
  case signInView.error of
    Just error ->
      div
        [ class "error" ]
        [ text error ]
    Nothing ->
      text ""