module View.SignIn ( renderSignIn ) where import Html as H 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 (..) import View.Events exposing (onSubmitPrevDefault) renderSignIn : SignInView -> Html renderSignIn signInView = div [ class "signIn" ] [ H.form [ onSubmitPrevDefault serverCommunications.address (SC.SignIn signInView.login) ] [ input [ value signInView.login , on "input" targetValue (Signal.message actions.address << UpdateSignIn << UpdateLogin) ] [] , button [] [ text "Sign in" ] ] , div [ class "result" ] [ signInResult signInView ] ] signInResult : SignInView -> Html signInResult signInView = case signInView.result of Just result -> case result of Ok login -> div [ class "success" ] [ text ("We sent you an email, please click to the provided link in order to sign in.") ] Err error -> div [ class "error" ] [ text error ] Nothing -> text ""