import React, { Dispatch, SetStateAction, useEffect } from "react"; import { Sort } from "@linkwarden/types/global"; import { TFunction } from "i18next"; import useLocalSettingsStore from "@/store/localSettings"; import { resetInfiniteQueryPagination } from "@linkwarden/router/lib"; import { useQueryClient } from "@tanstack/react-query"; import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, } from "@/components/ui/dropdown-menu"; import { Button } from "./ui/button"; type Props = { sortBy: Sort; setSort: Dispatch>; t: TFunction<"translation", undefined>; }; export default function SortDropdown({ sortBy, setSort, t }: Props) { const { updateSettings } = useLocalSettingsStore(); const queryClient = useQueryClient(); useEffect(() => { updateSettings({ sortBy }); }, [sortBy]); const handleValueChange = (value: string) => { resetInfiniteQueryPagination(queryClient, ["links"]); setSort(value as unknown as Sort); }; return ( {t("date_newest_first")} {t("date_oldest_first")} {t("name_az")} {t("name_za")} ); }