-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from anct-cnum/Verification_MDP_3_tentatives
Ajout de la vérification de tentative de MDP
- Loading branch information
Showing
6 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { userActions } from '../../actions'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
const ModalVerifyCode = ({ setShowModalVerifyCode, email }) => { | ||
const dispatch = useDispatch(); | ||
const [code, setCode] = useState(''); | ||
const messageCodeVerified = useSelector(state => state.authentication?.messageCodeVerified); | ||
const errorVerifyingCode = useSelector(state => state.authentication?.errorVerifyingCode); | ||
|
||
function handleSendCode() { | ||
dispatch(userActions.verifyCode(code, email)); | ||
} | ||
|
||
function handleChange(e) { | ||
setCode(e.target?.value); | ||
} | ||
|
||
useEffect(() => { | ||
if (messageCodeVerified) { | ||
window.scrollTo({ top: 0, behavior: 'smooth' }); | ||
setShowModalVerifyCode(false); | ||
} | ||
}, [messageCodeVerified]); | ||
|
||
return ( | ||
<dialog aria-labelledby="fr-modal-reset-password" role="dialog" id="fr-modal-reset-password" className="fr-modal modalOpened"> | ||
<div className="fr-container fr-container--fluid fr-container-md"> | ||
<div className="fr-grid-row fr-grid-row--center"> | ||
<div className="fr-col-12 fr-col-md-8 fr-col-lg-6"> | ||
<div className="fr-modal__body"> | ||
<div className="fr-modal__header"> | ||
</div> | ||
<div className="fr-modal__content"> | ||
<h1 id="fr-modal-title-modal-1" className="fr-modal__title"> | ||
<span className="fr-icon-arrow-right-line fr-icon--lg"></span> | ||
Vérification du compte conseiller | ||
</h1> | ||
<p> | ||
Conformément aux règles de sécurité des mots de passe, | ||
un code de vérification vous a été envoyé sur votre | ||
adresse email personnelle. | ||
Merci de le renseigner ici. | ||
</p> | ||
|
||
<div className="fr-grid-row fr-mt-3w"> | ||
<label className={`fr-label code ${errorVerifyingCode ? 'invalid' : ''}`} htmlFor="code"> | ||
Code de vérification | ||
</label> | ||
<input | ||
id="code" | ||
name="code" | ||
type="number" | ||
value={code} | ||
onChange={handleChange} | ||
className={`fr-input fr-input-custom ${errorVerifyingCode ? ' fr-input--error' : ''}`} /> | ||
{errorVerifyingCode && | ||
<div className="invalid">{errorVerifyingCode}</div> | ||
} | ||
</div> | ||
</div> | ||
<div className="fr-modal__footer"> | ||
<button className="fr-btn fr-ml-auto" onClick={handleSendCode}> | ||
Vérifier le code | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</dialog> | ||
); | ||
}; | ||
|
||
ModalVerifyCode.propTypes = { | ||
setShowModalVerifyCode: PropTypes.func, | ||
email: PropTypes.string | ||
}; | ||
|
||
export default ModalVerifyCode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters