-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: run
eslint --fix
removing all prettier error from web/ folder (#…
- Loading branch information
Showing
9 changed files
with
588 additions
and
529 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,56 @@ | ||
import React, { useEffect } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import React, { useEffect } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { close, checkmark } from 'ionicons/icons' | ||
import { IonIcon } from '@ionic/react' | ||
|
||
const PasswordRequirements = ({ password, onRequirementsMet}) => { | ||
const PasswordRequirements = ({ password, onRequirementsMet }) => { | ||
const requirements = [ | ||
{ label: 'At least 8 characters', test: password.length >= 8 }, | ||
{ label: 'Contains a number', test: /\d/.test(password) }, | ||
{ label: 'Contains a special character', test: /[!@#$%^&*(),.?":{}|<>[\]\\\/_+=-]/.test(password) }, | ||
{ | ||
label: 'Contains a special character', | ||
test: /[!@#$%^&*(),.?":{}|<>[\]\\\/_+=-]/.test(password), | ||
}, | ||
{ label: 'Contains an uppercase letter', test: /[A-Z]/.test(password) }, | ||
{ label: 'Contains a lowercase letter', test: /[a-z]/.test(password) }, | ||
]; | ||
] | ||
|
||
const allRequirementsMet = requirements.every(req => req.test); | ||
const allRequirementsMet = requirements.every((req) => req.test) | ||
|
||
useEffect(() => { | ||
onRequirementsMet(allRequirementsMet); | ||
}, [allRequirementsMet, onRequirementsMet]); | ||
onRequirementsMet(allRequirementsMet) | ||
}, [allRequirementsMet, onRequirementsMet]) | ||
|
||
return ( | ||
<div> | ||
<ul className="password-requirements" style={{ listStyleType: 'none', padding: 0 }}> | ||
<ul | ||
className='password-requirements' | ||
style={{ listStyleType: 'none', padding: 0 }} | ||
> | ||
{requirements.map((req, index) => ( | ||
<p key={index} style={{ color: req.test ? 'green' : 'red', fontSize: '12px', margin: '4px 0' }}> | ||
<IonIcon style={{ marginRight: '4px', verticalAlign: 'middle'}} icon={req.test ? checkmark : close} />{req.label} | ||
<p | ||
key={index} | ||
style={{ | ||
color: req.test ? 'green' : 'red', | ||
fontSize: '12px', | ||
margin: '4px 0', | ||
}} | ||
> | ||
<IonIcon | ||
style={{ marginRight: '4px', verticalAlign: 'middle' }} | ||
icon={req.test ? checkmark : close} | ||
/> | ||
{req.label} | ||
</p> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
) | ||
} | ||
|
||
PasswordRequirements.propTypes = { | ||
password: PropTypes.string.isRequired, | ||
onRequirementsMet: PropTypes.func.isRequired, | ||
}; | ||
password: PropTypes.string.isRequired, | ||
onRequirementsMet: PropTypes.func.isRequired, | ||
} | ||
|
||
export default PasswordRequirements; | ||
export default PasswordRequirements |
Oops, something went wrong.