"use client"; import type { ColumnDef } from "@tanstack/react-table"; import { useMemo } from "react"; import { Badge } from "@calcom/ui/components/badge"; import { Button } from "@calcom/ui/components/button"; import { Dropdown, DropdownItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@calcom/ui/components/dropdown"; import { Checkbox } from "@calcom/ui/components/form"; import type { GroupedBookingReport, BlocklistScope } from "@calcom/features/blocklist/types"; interface UsePendingReportsColumnsProps { t: (key: string) => string; scope: BlocklistScope; enableRowSelection?: boolean; onViewDetails: (entry: T) => void; } export function usePendingReportsColumns({ t, scope, enableRowSelection = false, onViewDetails, }: UsePendingReportsColumnsProps) { const isSystem = scope === "system"; return useMemo[]>(() => { const columns: ColumnDef[] = []; if (enableRowSelection) { columns.push({ id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" /> ), enableSorting: false, enableHiding: false, size: 24, minSize: 24, maxSize: 24, }); } columns.push({ id: "emailOrDomain", header: t("email_slash_domain"), accessorKey: "bookerEmail", enableHiding: false, size: isSystem ? 200 : 250, cell: ({ row }) => { const { bookerEmail, reportCount } = row.original; return (
{bookerEmail} {reportCount > 1 && ( {reportCount} )}
); }, }); if (isSystem) { columns.push({ id: "organization", header: t("org"), size: 140, cell: ({ row }) => { const org = row.original.organization; if (!org) { return {t("individual")}; } return {org.name}; }, }); } columns.push({ id: "reportedBy", header: t("reported_by"), accessorFn: (row) => row.reporter?.email ?? "-", size: isSystem ? 180 : 250, cell: ({ row }) => ( {row.original.reporter?.email ?? "-"} ), }); columns.push({ id: "reason", header: t("reason"), size: isSystem ? 120 : 150, cell: ({ row }) => { const reason = t(row.original.reason.toLowerCase()); const capitalizedReason = reason.charAt(0).toUpperCase() + reason.slice(1); return ( {capitalizedReason} ); }, }); columns.push({ id: "actions", header: "", size: isSystem ? 60 : 90, minSize: isSystem ? 60 : 90, maxSize: isSystem ? 60 : 90, enableHiding: false, enableSorting: false, enableResizing: false, cell: ({ row }) => { const entry = row.original; return (
); }, }); return columns; }, [t, scope, isSystem, enableRowSelection, onViewDetails]); }