import React, {
useState, useEffect, InputHTMLAttributes, SyntheticEvent,
} from 'react';
export interface SubmitInputProps extends InputHTMLAttributes {
type?: 'text' | 'number';
initialValue?: string;
name: string;
onSubmitValue: (value: string) => void;
focus?: boolean;
}
export const SubmitInput = ({
type = 'text',
initialValue = '',
name,
onSubmitValue,
focus,
min,
max,
...rest
}: SubmitInputProps): JSX.Element => {
const [value, setValue] = useState(initialValue);
useEffect(() => {
setValue(initialValue ?? '');
}, [initialValue]);
const onSubmit = (e: SyntheticEvent) => {
e.preventDefault();
onSubmitValue(value);
};
return (
);
};