aboutsummaryrefslogtreecommitdiff
path: root/src/client/View/SignIn.elm
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-07-20 21:55:52 +0200
committerJoris Guyonvarch2015-07-20 21:55:52 +0200
commita271d6034bc4cc631a64476d25d21c83a701fa39 (patch)
tree89ffa3df69999c5c9ed3cda9f4e4ec04f7a6ae1d /src/client/View/SignIn.elm
parenta40c4825996c90d107901b0d71162f9356f1395a (diff)
downloadbudget-a271d6034bc4cc631a64476d25d21c83a701fa39.tar.gz
budget-a271d6034bc4cc631a64476d25d21c83a701fa39.tar.bz2
budget-a271d6034bc4cc631a64476d25d21c83a701fa39.zip
Add a payment from the UI, it needs polishing however
Diffstat (limited to 'src/client/View/SignIn.elm')
-rw-r--r--src/client/View/SignIn.elm60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/client/View/SignIn.elm b/src/client/View/SignIn.elm
new file mode 100644
index 0000000..02ee1bd
--- /dev/null
+++ b/src/client/View/SignIn.elm
@@ -0,0 +1,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 ""