"use client"; import Link from "next/link"; import { Controller, useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { WatchlistType } from "@calcom/prisma/enums"; import { Button } from "@calcom/ui/components/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/components/dialog"; import { ToggleGroup } from "@calcom/ui/components/form"; import { ExternalLinkIcon, GlobeIcon, MailIcon } from "@coss/ui/icons"; import type { GroupedBookingReport, BlocklistScope } from "@calcom/features/blocklist/types"; interface FormData { blockType: WatchlistType; } export interface BookingReportDetailsModalProps { scope: BlocklistScope; entry: T | null; isOpen: boolean; onClose: () => void; onAddToBlocklist: (email: string, type: WatchlistType) => void; onDismiss: (email: string) => void; isAddingToBlocklist?: boolean; isDismissing?: boolean; } export function BookingReportDetailsModal({ scope, entry, isOpen, onClose, onAddToBlocklist, onDismiss, isAddingToBlocklist = false, isDismissing = false, }: BookingReportDetailsModalProps) { const { t } = useLocale(); const isSystem = scope === "system"; const { control, handleSubmit, reset, formState: { isSubmitting }, } = useForm({ defaultValues: { blockType: WatchlistType.EMAIL, }, }); const onSubmit = (data: FormData) => { if (!entry) return; onAddToBlocklist(entry.bookerEmail, data.blockType); }; const handleDismiss = () => { if (!entry) return; onDismiss(entry.bookerEmail); }; const handleGoBack = () => { onClose(); reset(); }; const reasonMap: Record = { SPAM: t("spam"), DONT_KNOW_PERSON: t("dont_know_person"), OTHER: t("other"), }; if (!entry) return null; return (

{t("details")}

{entry.bookerEmail}

{isSystem && entry.organization && (

{entry.organization.name}

)} {isSystem && !entry.organization && (

{t("individual")}

)}

{reasonMap[entry.reason] || entry.reason}

{entry.reporter?.email || "—"}

{entry.description || t("no_description_provided")}

{entry.reports.map((report) => (
{report.booking.title || t("untitled")}
))}

{t("what_would_you_like_to_block")}

{isSystem &&

{t("system_wide_blocklist_warning")}

} ( { if (value) field.onChange(value); }} options={[ { value: WatchlistType.EMAIL, label: t("block_this_email"), iconLeft: , }, { value: WatchlistType.DOMAIN, label: t("block_all_from_domain"), iconLeft: , }, ]} /> )} />
); }