"use client"; import { ActionButtonWithTooltip } from "@/components/ui/action-button"; import { ButtonWithTooltip } from "@/components/ui/button"; import LoadingSpinner from "@/components/ui/spinner"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { toast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; import { Check, KeyRound, Pencil, Trash, FilePlus, X } from "lucide-react"; import { useSession } from "next-auth/react"; import AddLabelDialog from "./AddLabelDialog"; import EditLabelDialog from "./EditLabelDialog"; import DeleteLabelConfirmationDialog from "./DeleteLabelConfirmationDialog"; export default function LabelsView() { const { data: session } = useSession(); const { data: labels } = api.labels.list.useQuery(); const { data: labelStats } = api.labels.labelStats.useQuery(); const invalidateLabelList = api.useUtils().labels.list.invalidate; const { mutate: deleteLabel, isPending: isDeletionPending } = api.labels.delete.useMutation({ onSuccess: () => { toast({ description: "Label deleted", }); invalidateLabelList(); }, onError: (e) => { toast({ variant: "destructive", description: `Something went wrong: ${e.message}`, }); }, }); const LabelsTable = ({ labels }) => (