import { Dialog } from "@calcom/features/components/controlled-dialog"; import { useCopy } from "@calcom/lib/hooks/useCopy"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { AssignmentReasonEnum } from "@calcom/prisma/enums"; import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/components/alert"; import { Badge } from "@calcom/ui/components/badge"; import { Button } from "@calcom/ui/components/button"; import { DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/components/dialog"; import { Label, Select, TextArea } from "@calcom/ui/components/form"; import { Icon } from "@calcom/ui/components/icon"; import { showToast } from "@calcom/ui/components/toast"; import type { Dispatch, SetStateAction } from "react"; import type { Control, ControllerRenderProps } from "react-hook-form"; import { Controller, useForm } from "react-hook-form"; import assignmentReasonBadgeTitleMap from "@lib/booking/assignmentReasonBadgeTitleMap"; interface BookingData { uid: string; eventType?: { team?: { id: number; } | null; } | null; user?: { email: string; name: string | null; } | null; assignmentReasonSortedByCreatedAt: Array<{ reasonString: string | null; reasonEnum: AssignmentReasonEnum | null; }>; attendees: Array<{ email: string; }>; } interface IWrongAssignmentDialog { isOpenDialog: boolean; setIsOpenDialog: Dispatch>; booking: BookingData; } interface FormValues { correctAssignee: string; additionalNotes: string; } interface TeamMemberOption { label: string; value: string; email: string; } interface RoutingInfoSectionProps { routingReason: string | null; routingReasonEnum: AssignmentReasonEnum | null; noRoutingReasonText: string; routingReasonLabel: string; guestEmail: string; whoBookedItLabel: string; hostEmail: string; hostName: string | null; whoReceivedItLabel: string; copyToClipboard: (text: string) => void; isCopied: boolean; } function RoutingInfoSection(props: RoutingInfoSectionProps): JSX.Element { const { t } = useLocale(); const { routingReason, routingReasonEnum, noRoutingReasonText, routingReasonLabel, guestEmail, whoBookedItLabel, hostEmail, hostName, whoReceivedItLabel, copyToClipboard, isCopied, } = props; let copyIconName: "check" | "copy" = "copy"; if (isCopied) { copyIconName = "check"; } let hostDisplay = hostEmail; if (hostName) { hostDisplay = `${hostName} (${hostEmail})`; } const handleCopyClick = (): void => { copyToClipboard(guestEmail); }; return (
{routingReasonEnum && ( {t(assignmentReasonBadgeTitleMap(routingReasonEnum))} )} {routingReason || noRoutingReasonText}
{guestEmail}

{hostDisplay}

); } interface AssigneeSectionProps { teamId: number | null; teamMemberOptions: TeamMemberOption[]; control: Control; whoShouldHaveReceivedItLabel: string; optionalLabel: string; selectTeamMemberPlaceholder: string; enterEmailPlaceholder: string; } interface AdditionalNotesSectionProps { control: Control; additionalNotesLabel: string; placeholder: string; fieldRequiredText: string; errorMessage: string | undefined; } function AdditionalNotesSection(props: AdditionalNotesSectionProps): JSX.Element { const { control, additionalNotesLabel, placeholder, fieldRequiredText, errorMessage } = props; const renderTextArea = ({ field, }: { field: ControllerRenderProps; }): JSX.Element =>