import React, { useState } from 'react'; import { faCircle, faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import guidGenerator from '../utilities/randomId'; interface InputFieldProps { static?: boolean; label: string; type: string; value: string; placeholder?: string; isRequired: boolean; disabled?: boolean; error?: boolean; text?: string; name?: string; blurred?: boolean; errorText?: string; onChangeHandler: (value: string) => void; } const InputField = ( props: InputFieldProps & Pick ) => { const [passwordVisible, setPasswordVisible] = useState(false); if (props.static === true) { return (

{props.label}

{props.text && (

{props.text}

)} props.onChangeHandler(e.target.value)} type={props.type} placeholder={props.placeholder} value={props.value} required={props.isRequired} className="bg-bunker-800 text-gray-400 border border-gray-600 rounded-md text-md p-2 w-full min-w-16 outline-none" name={props.name} readOnly autoComplete={props.autoComplete} id={props.id} />
); } else { return (

{props.label}

{/* {props.label == "Password" && router.asPath != "/login" && (
The password should contain at least 8 characters including at least 1 lowercase character, uppercase character, number, and a special character.
)} */}
props.onChangeHandler(e.target.value)} type={passwordVisible === false ? props.type : 'text'} placeholder={props.placeholder} value={props.value} required={props.isRequired} className={`${ props.blurred ? 'text-bunker-800 group-hover:text-gray-400 focus:text-gray-400 active:text-gray-400' : '' } ${ props.error ? 'focus:ring-red/50' : 'focus:ring-primary/50' } relative peer bg-bunker-800 rounded-md text-gray-400 text-md p-2 w-full min-w-16 outline-none focus:ring-4 duration-200`} name={props.name} spellCheck="false" autoComplete={props.autoComplete} id={props.id} /> {props.label?.includes('Password') && ( )} {props.blurred && (

{props.value .split('') .slice(0, 54) .map(() => ( ))}
)} {/* {props.error && (
)} */}
{props.error && (

{props.errorText}

)}
); } }; export default React.memo(InputField);