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