diff options
author | Joris Guyonvarch | 2015-07-19 17:28:19 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-07-19 17:28:19 +0200 |
commit | 331d506281760ac62e8f1715ef729e1b2a91e280 (patch) | |
tree | a26e49d9a41de26fbb5602b293f44c5f7f592efc /src/client/View | |
parent | 0d589e12a0c32936303de46b1e462dd19648170d (diff) |
Showing either error or success message at sign in page
Diffstat (limited to 'src/client/View')
-rw-r--r-- | src/client/View/Page.elm | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/client/View/Page.elm b/src/client/View/Page.elm index eb86132..bf61dc1 100644 --- a/src/client/View/Page.elm +++ b/src/client/View/Page.elm @@ -18,6 +18,7 @@ import Json.Decode as Json import Model exposing (Model) import Model.Payment exposing (Payments, Payment) import Model.View exposing (..) +import Model.View.SignIn exposing (..) import Update exposing (..) import Update.SignIn exposing (..) @@ -60,27 +61,33 @@ renderMain model = case model.view of LoadingView -> loadingView - SignInView { login } -> - signInView login + SignInView signIn -> + signInView signIn PaymentView payments -> paymentsView payments loadingView : Html loadingView = text "" -signInView : String -> Html -signInView login = +signInView : SignIn -> Html +signInView signIn = div [ class "signIn" ] - [ input - [ value login - , on "input" targetValue (Signal.message actions.address << UpdateSignIn << UpdateLogin) - , onEnter serverCommunications.address (SC.SignIn login) + [ div + [ class "form" ] + [ input + [ value signIn.login + , on "input" targetValue (Signal.message actions.address << UpdateSignIn << UpdateLogin) + , onEnter serverCommunications.address (SC.SignIn signIn.login) + ] + [] + , button + [ onClick serverCommunications.address (SC.SignIn signIn.login) ] + [ text "Sign in" ] ] - [] - , button - [ onClick serverCommunications.address (SC.SignIn login) ] - [ text "Sign in" ] + , div + [ class "result" ] + [ signInResult signIn ] ] onEnter : Signal.Address a -> a -> Attribute @@ -89,6 +96,22 @@ onEnter address value = (Json.customDecoder keyCode (\code -> if code == 13 then Ok () else Err "")) (\_ -> Signal.message address value) +signInResult : SignIn -> Html +signInResult signIn = + case signIn.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 "" + paymentsView : Payments -> Html paymentsView payments = table |