import { ArrowDownWideNarrow, Check, ChevronDown } from "lucide-react"; import { TModuleOrderByOptions } from "@plane/types"; // ui import { CustomMenu, getButtonStyling } from "@plane/ui"; // helpers import { MODULE_ORDER_BY_OPTIONS } from "@/constants/module"; import { cn } from "@/helpers/common.helper"; // types // constants type Props = { onChange: (value: TModuleOrderByOptions) => void; value: TModuleOrderByOptions | undefined; }; export const ModuleOrderByDropdown: React.FC = (props) => { const { onChange, value } = props; const orderByDetails = MODULE_ORDER_BY_OPTIONS.find((option) => value?.includes(option.key)); const isDescending = value?.[0] === "-"; return ( {orderByDetails?.label} } placement="bottom-end" maxHeight="lg" closeOnSelect > {MODULE_ORDER_BY_OPTIONS.map((option) => ( { if (isDescending) onChange(`-${option.key}` as TModuleOrderByOptions); else onChange(option.key); }} > {option.label} {value?.includes(option.key) && } ))}
{ if (isDescending) onChange(value.slice(1) as TModuleOrderByOptions); }} > Ascending {!isDescending && } { if (!isDescending) onChange(`-${value}` as TModuleOrderByOptions); }} > Descending {isDescending && }
); };