import { Table, TableBody, TableCell, TableRow, Text, Title } from "@tremor/react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc"; import { useFilterContext } from "../context/provider"; import { CardInsights } from "./Card"; import { LoadingInsight } from "./LoadingInsights"; export const PopularEventsTable = () => { const { t } = useLocale(); const { filter } = useFilterContext(); const { dateRange, selectedMemberUserId, selectedUserId } = filter; const [startDate, endDate] = dateRange; const { selectedTeamId: teamId } = filter; const { data, isSuccess, isLoading } = trpc.viewer.insights.popularEventTypes.useQuery({ startDate: startDate.toISOString(), endDate: endDate.toISOString(), teamId: teamId ?? undefined, userId: selectedUserId ?? undefined, memberUserId: selectedMemberUserId ?? undefined, }); if (isLoading) return ; if (!isSuccess || !startDate || !endDate || (!teamId && !selectedUserId)) return null; return ( {t("popular_events")} {data.map((item) => ( {item.eventTypeName} {item.count} ))}
{data.length === 0 && (

{t("insights_no_data_found_for_filter")}

)}
); };