import { ActionButton } from "@/components/ui/action-button"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { toast } from "@/components/ui/use-toast"; import { useTranslation } from "@/lib/i18n/client"; import { api } from "@/lib/trpc"; import { cn } from "@/lib/utils"; import { Separator } from "@radix-ui/react-dropdown-menu"; import { ChevronsDownUp, Trash2 } from "lucide-react"; import { useDeleteHighlight } from "@hoarder/shared-react/hooks/highlights"; import { ZHighlight } from "@hoarder/shared/types/highlights"; import { HIGHLIGHT_COLOR_MAP } from "./highlights"; function HighlightCard({ highlight }: { highlight: ZHighlight }) { const { mutate: deleteHighlight, isPending: isDeleting } = useDeleteHighlight( { onSuccess: () => { toast({ description: "Highlight has been deleted!", }); }, onError: () => { toast({ description: "Something went wrong", variant: "destructive", }); }, }, ); const onBookmarkClick = () => { document .querySelector(`[data-highlight-id="${highlight.id}"]`) ?.scrollIntoView({ behavior: "smooth", block: "center", }); }; return (
deleteHighlight({ highlightId: highlight.id })} >
); } export default function HighlightsBox({ bookmarkId }: { bookmarkId: string }) { const { t } = useTranslation(); const { data: highlights, isPending: isLoading } = api.highlights.getForBookmark.useQuery({ bookmarkId }); if (isLoading || !highlights || highlights?.highlights.length === 0) { return null; } return ( {t("common.highlights")} {highlights.highlights.map((highlight) => ( <> ))} ); }