aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/SignIn/View.elm
diff options
context:
space:
mode:
authorJoris2016-03-27 19:44:40 +0200
committerJoris2016-03-27 19:44:40 +0200
commit5f6c66e4c3cf02e5b1c0a1fac6036b86be06a992 (patch)
tree510b3b65d13a8003b092b4c9fe62f6456750cd38 /src/client/elm/SignIn/View.elm
parent9b7546b99411a8364eccf6b0262a3c0c7d82380c (diff)
downloadbudget-5f6c66e4c3cf02e5b1c0a1fac6036b86be06a992.tar.gz
budget-5f6c66e4c3cf02e5b1c0a1fac6036b86be06a992.tar.bz2
budget-5f6c66e4c3cf02e5b1c0a1fac6036b86be06a992.zip
Regroup signIn modules
Diffstat (limited to 'src/client/elm/SignIn/View.elm')
-rw-r--r--src/client/elm/SignIn/View.elm62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/client/elm/SignIn/View.elm b/src/client/elm/SignIn/View.elm
new file mode 100644
index 0000000..2f63651
--- /dev/null
+++ b/src/client/elm/SignIn/View.elm
@@ -0,0 +1,62 @@
+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 Model.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)
+ , type' "text"
+ , autocomplete True
+ ]
+ []
+ , 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 ""