Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
b5f53d17
Commit
b5f53d17
authored
Jun 03, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Forgot password] Display error/success
parent
65499d20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
+23
-5
ForgotPassword.purs
src/Gargantext/Components/Login/ForgotPassword.purs
+23
-5
No files found.
src/Gargantext/Components/Login/ForgotPassword.purs
View file @
b5f53d17
module Gargantext.Components.Login.ForgotPassword where
module Gargantext.Components.Login.ForgotPassword where
import Gargantext.Prelude
import DOM.Simple.Event as DE
import DOM.Simple.Event as DE
import Data.Either (Either(..))
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Formula as F
import Gargantext.Components.Forms (formGroup)
import Gargantext.Components.Forms (formGroup)
import Gargantext.Ends (Backend)
import Gargantext.Ends (Backend)
import Gargantext.Prelude
import Gargantext.Sessions (Sessions, postForgotPasswordRequest)
import Gargantext.Sessions (Sessions, postForgotPasswordRequest)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Formula as F
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Reactix.SyntheticEvent as E
import Reactix.SyntheticEvent as E
...
@@ -30,13 +32,15 @@ forgotPasswordCpt :: R.Component Props
...
@@ -30,13 +32,15 @@ forgotPasswordCpt :: R.Component Props
forgotPasswordCpt = here.component "forgotPassword" cpt where
forgotPasswordCpt = here.component "forgotPassword" cpt where
cpt { backend, sessions } _ = do
cpt { backend, sessions } _ = do
email <- T.useBox ""
email <- T.useBox ""
message <- T.useBox ""
pure $ H.div { className: "row" }
pure $ H.div { className: "row" }
[ H.form { className: "text-center col-md-12" }
[ H.form { className: "text-center col-md-12" }
[ H.h4 {} [ H.text "Forgot password" ]
[ H.h4 {} [ H.text "Forgot password" ]
, messageDisplay { message }
, formGroup
, formGroup
[ emailInput email ]
[ emailInput email ]
, submitButton { backend, email, sessions }
, submitButton { backend, email, sessions
, message
}
]
]
]
]
...
@@ -50,14 +54,15 @@ emailInput value = F.bindInput { value
...
@@ -50,14 +54,15 @@ emailInput value = F.bindInput { value
, maxLength: "254" }
, maxLength: "254" }
type SubmitButtonProps =
type SubmitButtonProps =
( email :: T.Box Email
( email :: T.Box Email
, message :: T.Box String
| Props )
| Props )
submitButton :: R2.Leaf SubmitButtonProps
submitButton :: R2.Leaf SubmitButtonProps
submitButton = R2.leafComponent submitButtonCpt
submitButton = R2.leafComponent submitButtonCpt
submitButtonCpt :: R.Component SubmitButtonProps
submitButtonCpt :: R.Component SubmitButtonProps
submitButtonCpt = here.component "submitButton" cpt where
submitButtonCpt = here.component "submitButton" cpt where
cpt { backend, email, sessions
} _ = do
cpt { backend, email, sessions
, message
} _ = do
email' <- T.useLive T.unequal email
email' <- T.useLive T.unequal email
pure $ H.div {className: "form-group text-center"}
pure $ H.div {className: "form-group text-center"}
...
@@ -75,3 +80,16 @@ submitButtonCpt = here.component "submitButton" cpt where
...
@@ -75,3 +80,16 @@ submitButtonCpt = here.component "submitButton" cpt where
launchAff_ $ do
launchAff_ $ do
res <- postForgotPasswordRequest backend email'
res <- postForgotPasswordRequest backend email'
liftEffect $ here.log2 "res" res
liftEffect $ here.log2 "res" res
liftEffect $ case res of
Left s -> T.write_ s message
Right _ -> T.write_ "Request sent!" message
messageDisplay :: R2.Leaf (message :: T.Box String)
messageDisplay = R2.leafComponent messageDisplayCpt
messageDisplayCpt :: R.Component (message :: T.Box String)
messageDisplayCpt = here.component "messageDisplay" cpt where
cpt {message} _ = do
message' <- T.useLive T.unequal message
pure $ H.p {} [H.text message']
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment