import React from 'react'; import { useTheme } from 'styled-components'; import { WarningIcon } from '../../icons'; import FilledArrowCircleRight from '../../icons/FilledArrowCircleRight'; import FilledCloseIcon from '../../icons/FilledCloseIcon'; import Typography from '../Typography'; import { ErrorWrapper, IconWrapper, InputField, InputWrapper } from './styles'; export type InputIconState = 'CLEARABLE' | 'SUBMITABLE' | 'ERROR'; type RoundedInputProps = { errorMessage?: string; inputIconState: InputIconState; onClear?: () => void; onEnter?: () => void; onValueChange: (value: string) => void; isError: boolean; value: string; placeholder?: string; }; const RoundedInput: React.FC = ({ placeholder, errorMessage, inputIconState, onClear, onEnter, onValueChange, isError, value, }) => { const { colors } = useTheme(); const onInputChange = (e: React.ChangeEvent) => { onValueChange(e.target.value); }; const onInputKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { handleIconClick(); } }; const handleIconClick = () => { if (inputIconState === 'CLEARABLE') { onClear?.(); } else if (inputIconState === 'SUBMITABLE') { onEnter?.(); } }; return ( <> {inputIconState === 'CLEARABLE' && ( )} {inputIconState === 'SUBMITABLE' && ( )} {isError && errorMessage && ( {errorMessage} )} ); }; export default RoundedInput;