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
9e3eeab9
Commit
9e3eeab9
authored
Sep 26, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/431-dev-lost-password-email' into dev-merge
parents
8dcbc1c4
6c842cd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
ForgotPassword.purs
src/Gargantext/Components/Login/ForgotPassword.purs
+28
-14
No files found.
src/Gargantext/Components/Login/ForgotPassword.purs
View file @
9e3eeab9
...
@@ -33,46 +33,58 @@ forgotPasswordCpt = here.component "forgotPassword" cpt where
...
@@ -33,46 +33,58 @@ forgotPasswordCpt = here.component "forgotPassword" cpt where
cpt { backend, sessions } _ = do
cpt { backend, sessions } _ = do
email <- T.useBox ""
email <- T.useBox ""
message <- T.useBox ""
message <- T.useBox ""
disabled <- T.useBox false
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 }
, messageDisplay { message }
, formGroup
, formGroup
[ emailInput
email
]
[ emailInput
{ email, disabled}
]
, submitButton { backend, email, sessions, message }
, submitButton { backend, email, sessions, message
, disabled
}
]
]
]
]
emailInput :: forall cell. T.ReadWrite cell Email => cell -> R.Element
emailInput :: R2.Leaf (email :: T.Box Email, disabled :: T.Box Boolean)
emailInput value = F.bindInput { value
emailInput = R2.leaf emailInputCpt
, type: "email"
, className: "form-control"
emailInputCpt :: R.Component (email :: T.Box Email, disabled :: T.Box Boolean)
, id: "id_email"
emailInputCpt = here.component "emailInput" cpt where
, placeholder: "email"
cpt { email, disabled } _ = do
, name: "email"
disabled' <- T.useLive T.unequal disabled
, maxLength: "254" }
pure $ F.bindInput { value: email
, type: "email"
, className: "form-control"
, id: "id_email"
, placeholder: "email"
, name: "email"
, maxLength: "254"
, disabled: disabled' }
type SubmitButtonProps =
type SubmitButtonProps =
( email :: T.Box Email
( email :: T.Box Email
, message :: T.Box String
, message :: T.Box String
, disabled :: T.Box Boolean
| 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, message} _ = do
cpt { backend, email, sessions, message
, disabled
} _ = do
email' <- T.useLive T.unequal email
email' <- T.useLive T.unequal email
disabled' <- T.useLive T.unequal disabled
pure $ H.div {className: "form-group text-center"}
pure $ H.div {className: "form-group text-center"}
[ H.button { className: "btn btn-primary"
[ H.button { className: "btn btn-primary"
, disabled: disabled'
, on: { click: click email' }}
, on: { click: click email' }}
[ H.text "Submit" ]
[ H.text "Submit" ]
]
]
where
where
click :: Email -> R.SyntheticEvent DE.MouseEvent -> Effect Unit
click :: Email -> R.SyntheticEvent DE.MouseEvent -> Effect Unit
click email' e = do
click email' e = do
liftEffect $ T.write_ true disabled
E.preventDefault e
E.preventDefault e
here.log2 "email" email'
here.log2 "email" email'
here.log2 "backend" backend
here.log2 "backend" backend
...
@@ -81,7 +93,9 @@ submitButtonCpt = here.component "submitButton" cpt where
...
@@ -81,7 +93,9 @@ submitButtonCpt = here.component "submitButton" cpt where
res <- postForgotPasswordRequest backend email'
res <- postForgotPasswordRequest backend email'
liftEffect $ here.log2 "res" res
liftEffect $ here.log2 "res" res
liftEffect $ case res of
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
Right _ -> T.write_ "Request sent!" message
messageDisplay :: R2.Leaf (message :: T.Box String)
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