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