import { Box, Flex } from "@chakra-ui/react"; import { useLingui } from "@lingui/react"; import { components } from "react-select"; import { gear } from "utils/lists/gear"; import GearImage from "./GearImage"; import MySelect from "./MySelect"; interface WeaponSelectorProps { value?: string; setValue: (value: string) => void; slot: "head" | "clothing" | "shoes"; } const SingleValue = (props: any) => { return ( {props.data.label} ); }; const Option = (props: any) => { return ( {props.label} ); }; const customFilterOption = (option: any, rawInput: string) => { const words = rawInput.split(" "); return words.reduce( (acc, cur) => acc && (option.label.toLowerCase().includes(cur.toLowerCase()) || option.data?.data?.toLowerCase() == rawInput.toLocaleLowerCase()), true ); }; const GearSelector: React.FC = ({ value, setValue, slot, }) => { const { i18n } = useLingui(); return ( ({ label: i18n._(category.brand), options: category[slot].map((gear) => ({ value: gear, label: i18n._(gear), data: i18n._(category.brand), })), }))} value={value ? { value, label: i18n._(value) } : undefined} setValue={setValue} isClearable isSearchable components={{ IndicatorSeparator: () => null, Option, SingleValue, }} hideMenuBeforeTyping customFilterOption={customFilterOption} /> ); }; export default GearSelector;