import styles from "./styles.module.css";

interface IPlacePickerProps {
  name: string;
  value: string;
  maxLength: number;
  onChange: (value: string) => void;
}

function PlacePicker({ name, value, maxLength, onChange }: IPlacePickerProps) {
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    const place = e.target.value;
    onChange(place);
  };

  return (
    <div className={styles.container}>
      <input
        className={styles["full-address"]}
        name={name}
        type="text"
        placeholder="Enter city of birth"
        maxLength={maxLength}
        value={value}
        onChange={handleChange}
      />
    </div>
  );
}

export default PlacePicker;
