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
cccc1a2a
Commit
cccc1a2a
authored
Aug 30, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Forgot password] disable input field after submit
parent
5cf74ca2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
+26
-14
ForgotPassword.purs
src/Gargantext/Components/Login/ForgotPassword.purs
+26
-14
No files found.
src/Gargantext/Components/Login/ForgotPassword.purs
View file @
cccc1a2a
...
...
@@ -33,36 +33,45 @@ forgotPasswordCpt = here.component "forgotPassword" cpt where
cpt { backend, sessions } _ = do
email <- T.useBox ""
message <- T.useBox ""
disabled <- T.useBox false
pure $ H.div { className: "row" }
[ H.form { className: "text-center col-md-12" }
[ H.h4 {} [ H.text "Forgot password" ]
, messageDisplay { message }
, formGroup
[ emailInput
email
]
, submitButton { backend, email, sessions, message }
[ emailInput
{ email, disabled}
]
, submitButton { backend, email, sessions, message
, disabled
}
]
]
emailInput :: forall cell. T.ReadWrite cell Email => cell -> R.Element
emailInput value = F.bindInput { value
, type: "email"
, className: "form-control"
, id: "id_email"
, placeholder: "email"
, name: "email"
, maxLength: "254" }
emailInput :: R2.Leaf (email :: T.Box Email, disabled :: T.Box Boolean)
emailInput = R2.leaf emailInputCpt
emailInputCpt :: R.Component (email :: T.Box Email, disabled :: T.Box Boolean)
emailInputCpt = here.component "emailInput" cpt where
cpt { email, disabled } _ = do
disabled' <- T.useLive T.unequal disabled
pure $ F.bindInput { value: email
, type: "email"
, className: "form-control"
, id: "id_email"
, placeholder: "email"
, name: "email"
, maxLength: "254"
, disabled: disabled' }
type SubmitButtonProps =
( email :: T.Box Email
, message :: T.Box String
( email :: T.Box Email
, message :: T.Box String
, disabled :: T.Box Boolean
| Props )
submitButton :: R2.Leaf SubmitButtonProps
submitButton = R2.leafComponent submitButtonCpt
submitButtonCpt :: R.Component SubmitButtonProps
submitButtonCpt = here.component "submitButton" cpt where
cpt { backend, email, sessions, message} _ = do
cpt { backend, email, sessions, message
, disabled
} _ = do
email' <- T.useLive T.unequal email
pure $ H.div {className: "form-group text-center"}
...
...
@@ -73,6 +82,7 @@ submitButtonCpt = here.component "submitButton" cpt where
where
click :: Email -> R.SyntheticEvent DE.MouseEvent -> Effect Unit
click email' e = do
liftEffect $ T.write_ true disabled
E.preventDefault e
here.log2 "email" email'
here.log2 "backend" backend
...
...
@@ -81,7 +91,9 @@ submitButtonCpt = here.component "submitButton" cpt where
res <- postForgotPasswordRequest backend email'
liftEffect $ here.log2 "res" res
liftEffect $ case res of
Left s -> T.write_ s message
Left s -> do
T.write_ false disabled
T.write_ s message
Right _ -> T.write_ "Request sent!" message
messageDisplay :: R2.Leaf (message :: T.Box String)
...
...
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