From 331d506281760ac62e8f1715ef729e1b2a91e280 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sun, 19 Jul 2015 17:28:19 +0200 Subject: Showing either error or success message at sign in page --- src/client/View/Page.elm | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'src/client/View/Page.elm') 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 -- cgit v1.2.3