import { Box, InputGroup, InputLeftElement, InputRightElement, Text, Input } from '@chakra-ui/react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { useEffect } from 'react'; import { IInput } from '../../../interfaces/dialog'; interface Props { row: IInput; index: number; handleChange: (value: string, index: number) => void; passwordStates: boolean[]; handlePasswordStates: (index: number) => void; } const InputField: React.FC = (props) => { useEffect(() => { if (props.row.default) props.handleChange(props.row.default, props.index); }, []); return ( <> {props.row.label} {props.row.icon && ( } /> )} ) => props.handleChange(e.target.value, props.index)} placeholder={props.row.placeholder} defaultValue={props.row.default} type={!props.row.password || props.passwordStates[props.index] ? 'text' : 'password'} isDisabled={props.row.disabled} /> {props.row.password && ( props.handlePasswordStates(props.index)} children={ } /> )} ); }; export default InputField;