"use client"; import { ArrowDownWideNarrow, Check, ChevronDown } from "lucide-react"; // types import { TPageFiltersSortBy, TPageFiltersSortKey } from "@plane/types"; // ui import { CustomMenu, getButtonStyling } from "@plane/ui"; // constants import { PAGE_SORTING_KEY_OPTIONS } from "@/constants/page"; // helpers import { cn } from "@/helpers/common.helper"; type Props = { onChange: (value: { key?: TPageFiltersSortKey; order?: TPageFiltersSortBy }) => void; sortBy: TPageFiltersSortBy; sortKey: TPageFiltersSortKey; }; export const PageOrderByDropdown: React.FC = (props) => { const { onChange, sortBy, sortKey } = props; const orderByDetails = PAGE_SORTING_KEY_OPTIONS.find((option) => sortKey === option.key); const isDescending = sortBy === "desc"; return ( {orderByDetails?.label} } placement="bottom-end" maxHeight="lg" closeOnSelect > {PAGE_SORTING_KEY_OPTIONS.map((option) => ( onChange({ key: option.key, }) } > {option.label} {sortKey === option.key && } ))}
{ if (isDescending) onChange({ order: "asc", }); }} > Ascending {!isDescending && } { if (!isDescending) onChange({ order: "desc", }); }} > Descending {isDescending && }
); };