import { ViewIcon, ViewOffIcon } from '@chakra-ui/icons' import { Button, FormControl, FormControlProps, FormErrorMessage, FormLabel, Input, InputGroup, InputLeftElement, InputRightElement, Text, } from '@chakra-ui/react' import Error from 'next/error' import React, { useState } from 'react' import { FieldErrors } from 'react-hook-form' interface ICustomInputProps { name: string id?: string label?: string placeholder?: string type?: string // errors?: FieldErrors errors?: Error | FieldErrors disabled?: boolean register?: any leftElement?: JSX.Element rightElement?: JSX.Element fieldRequired?: boolean } const CustomInput: React.FunctionComponent = (props) => { const { register, errors, label, id, name, type = 'text', placeholder, leftElement, rightElement, disabled = false, fieldRequired = false, ...rest } = props const error = errors[name] const [showPassword, setShowPassword] = useState(false) console.log('🚀 ~ file: index.tsx ~ line 51 ~ showPassword', type) return ( {label} {fieldRequired && *} {leftElement && {leftElement}} {rightElement && {rightElement}} {type === 'password' && ( )} {error && {error?.message}} ) } export default CustomInput