* refactor: update PopuplarEvents chart to use InsightsBookingService * use buildHashMapForUsers * refactor least booked * refactor charts * combine methods * refactor booking kpi cards * remove unused code * fix booking kpi cards * restore code that was removed accidentally * Revert "restore code that was removed accidentally" This reverts commit 0c0b444b02498b94fb29ef470da065bad3ad7ece. * Revert "fix booking kpi cards" This reverts commit b1e8e9afbd3632a5239495566551ae12bd926b66. * refactor booking kpi cards * revert method and remove unused code * fix previous period * fix metrics * clean up trpc call params * clean up Download.tsx * split utils * restructure folders for components * clean up imports * rename TotalUserFeedbackTable to UserStatsTable * add guide * use client * add curly braces to case * fix tests
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc";
|
|
|
|
import { useInsightsBookingParameters } from "../../hooks/useInsightsBookingParameters";
|
|
import { ChartCard, ChartCardItem } from "../ChartCard";
|
|
import { LoadingInsight } from "../LoadingInsights";
|
|
|
|
export const PopularEventsTable = () => {
|
|
const { t } = useLocale();
|
|
const insightsBookingParams = useInsightsBookingParameters();
|
|
|
|
const { data, isSuccess, isPending } = trpc.viewer.insights.popularEvents.useQuery(insightsBookingParams, {
|
|
staleTime: 180000,
|
|
refetchOnWindowFocus: false,
|
|
trpc: {
|
|
context: { skipBatch: true },
|
|
},
|
|
});
|
|
|
|
if (isPending) return <LoadingInsight />;
|
|
|
|
if (!isSuccess || !data) return null;
|
|
|
|
return (
|
|
<ChartCard title={t("popular_events")}>
|
|
<div>
|
|
{data
|
|
.filter((item) => item.eventTypeId)
|
|
.map((item) => (
|
|
<ChartCardItem key={item.eventTypeId} count={item.count}>
|
|
<div className="flex">
|
|
<div className="bg-subtle mr-1.5 h-5 w-[2px] shrink-0 rounded-sm" />
|
|
<p>{item.eventTypeName}</p>
|
|
</div>
|
|
</ChartCardItem>
|
|
))}
|
|
</div>
|
|
{data.length === 0 && (
|
|
<div className="flex h-60 text-center">
|
|
<p className="m-auto text-sm font-light">{t("insights_no_data_found_for_filter")}</p>
|
|
</div>
|
|
)}
|
|
</ChartCard>
|
|
);
|
|
};
|