import type { ChangeEvent } from 'react' import { ValidatedErrorIcon, ValidatedErrorMessage, ValidatedSuccessIcon, ValidatingTip, } from './ValidateStatus' import { ValidatedStatus } from './declarations' import type { ValidatedStatusState } from './declarations' type KeyInputProps = { value?: string name: string placeholder: string className?: string onChange: (v: string) => void onFocus?: () => void validating: boolean validatedStatusState: ValidatedStatusState } const KeyInput = ({ value, name, placeholder, className, onChange, onFocus, validating, validatedStatusState, }: KeyInputProps) => { const handleChange = (e: ChangeEvent) => { const inputValue = e.target.value onChange(inputValue) } const getValidatedIcon = () => { if (validatedStatusState.status === ValidatedStatus.Error || validatedStatusState.status === ValidatedStatus.Exceed) return if (validatedStatusState.status === ValidatedStatus.Success) return } const getValidatedTip = () => { if (validating) return if (validatedStatusState.status === ValidatedStatus.Error) return } return (
{name}
{getValidatedIcon()}
{getValidatedTip()}
) } export default KeyInput