"use client";
import { motion } from "framer-motion";
import Link from "next/link";
import type { ReactNode } from "react";
import ServerTrans from "@calcom/lib/components/ServerTrans";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Badge } from "@calcom/ui/components/badge";
import type { IconName } from "@calcom/ui/components/icon";
import { Icon } from "@calcom/ui/components/icon";
import type { NonRouterRoute } from "../../types/types";
import type { MembersMatchResultType } from "./TeamMembersMatchResult";
export const ResultsSection = ({
title,
children,
icon,
hint,
...props
}: {
title?: string;
children: ReactNode;
icon?: IconName;
hint?: ReactNode;
[key: string]: any;
}) => (
{(title || icon) && (
)}
{children}
{hint && hint}
);
export const TeamMember = ({ name, email, score }: { name: string | null; email: string; score: number }) => (
{name || "Nameless User"}
{email}
0 ? "text-green-600" : score < 0 ? "text-red-600" : "text-gray-600"
}`}>
{score > 0 ? "+" : ""}
{score}
);
interface ResultsViewProps {
chosenRoute: NonRouterRoute | null;
supportsTeamMembersMatchingLogic?: boolean;
membersMatchResult?: MembersMatchResultType | null;
isPending?: boolean;
}
export const ResultsView = ({
chosenRoute,
supportsTeamMembersMatchingLogic = false,
membersMatchResult = null,
isPending = false,
}: ResultsViewProps) => {
const { t } = useLocale();
if (!chosenRoute) return null;
if (isPending) {
return (
{supportsTeamMembersMatchingLogic && (
<>
{[1, 2, 3].map((i) => (
))}
{[1, 2, 3].map((i) => (
))}
>
)}
);
}
const notSupportingMembersMatching = ["customPageMessage", "externalRedirectUrl"];
return (
{chosenRoute.action.type === "externalRedirectUrl" && (
{chosenRoute.action.value}
)}
{chosenRoute.action.type === "eventTypeRedirectUrl" && (
{chosenRoute.action.value}
)}
{chosenRoute.action.type === "customPageMessage" && (
{chosenRoute.action.value}
)}
{supportsTeamMembersMatchingLogic &&
membersMatchResult &&
!notSupportingMembersMatching.includes(chosenRoute.action.type) && (
<>
{/* Seperator */}
{membersMatchResult.checkedFallback ? "No" : "Yes"}
{membersMatchResult.checkedFallback ? "Yes" : "Not needed"}
{membersMatchResult.contactOwnerEmail || "Not found"}
{membersMatchResult.teamMembersMatchingAttributeLogic && (
Routing Insights
,
]}
/>
}>
{membersMatchResult.teamMembersMatchingAttributeLogic.map((member, index) => (
))}
)}
{membersMatchResult.mainWarnings && membersMatchResult.mainWarnings.length > 0 && (
{membersMatchResult.mainWarnings.map((warning, index) => (
{warning}
))}
)}
{membersMatchResult.fallbackWarnings && membersMatchResult.fallbackWarnings.length > 0 && (
{membersMatchResult.fallbackWarnings.map((warning, index) => (
{warning}
))}
)}
>
)}
);
};