import { ChevronDownIcon } from "@chakra-ui/icons"; import { Flex, Text, Menu, MenuButton, MenuList, MenuItem, Button, } from "@chakra-ui/react"; import { FunctionComponent } from "react"; import { SEARCH_ANALYTICS, SORT_RENDER_MAP } from "./constants"; import testIds from "./testIds"; import { useSort } from "./useSearchParam"; import { useUpdateSearchParam } from "./useUpdateSearchParam"; import { CatalogSearchSort } from "../../api/catalog-search/constants"; import { eventName } from "../../contexts/Analytics"; export const SortedBy: FunctionComponent = () => { const sort = useSort(); const updateSearch = useUpdateSearchParam(); const selected = sort ? SORT_RENDER_MAP[sort] : "Relevance"; return ( Sorted by } variant="link" > {selected} updateSearch({ sort: undefined })} > Relevance {Object.entries(SORT_RENDER_MAP).map(([value, display]) => ( updateSearch({ sort: value as CatalogSearchSort })} > {display} ))} ); };