import clsx from "clsx";
import { ChangeEvent, FC, HTMLAttributes } from "react";
import { v4 as uuid4 } from "uuid";

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

export interface SearchProps extends HTMLAttributes<HTMLInputElement> {
  placeholder?: string;
  value: string;
  onChange: (e: ChangeEvent<HTMLInputElement>) => void;
}

export const Search: FC<SearchProps> = ({
  className,
  placeholder = "Search...",
  value,
  onChange,
  ...props
}) => (
  <input
    id={`search-input-${uuid4()}`}
    type="search"
    className={clsx([styles.search, className])}
    value={value}
    onChange={onChange}
    placeholder={placeholder}
    spellCheck={false}
    autoComplete={"off"}
    {...props}
  />
);
{
  /* {showAddAmountControls ? this.renderAmountControls() : null} */
}
