import { DropdownItem } from "../Dropdown";

export const filterOptions = (options: DropdownItem[], searchText: string) => {
  return options.filter((item) => {
    //Get value from either string or DropdownOption type
    const value = typeof item === "string" ? item : item.label;

    //Compare both values after lower case.
    return value?.toLowerCase().includes(searchText.toLowerCase());
  });
};
