"use client";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import classNames from "@calcom/ui/classNames";
import { SkeletonText } from "@calcom/ui/components/skeleton";
import { useInsightsBookingParameters } from "@calcom/web/modules/insights/hooks/useInsightsBookingParameters";
import { ChartCard } from "../ChartCard";
import { KPICard } from "../KPICard";
export const BookingKPICards = () => {
const { t } = useLocale();
const insightsBookingParams = useInsightsBookingParameters();
const { data, isSuccess, isPending, isError } = trpc.viewer.insights.bookingKPIStats.useQuery(
insightsBookingParams,
{
staleTime: 180000,
refetchOnWindowFocus: false,
trpc: {
context: { skipBatch: true },
},
}
);
const eventCategories: {
title: string;
index: "created" | "completed" | "rescheduled" | "cancelled";
}[] = [
{
title: t("events_created"),
index: "created",
},
{
title: t("events_completed"),
index: "completed",
},
{
title: t("events_rescheduled"),
index: "rescheduled",
},
{
title: t("events_cancelled"),
index: "cancelled",
},
];
const performanceCategories: {
title: string;
index: "rating" | "no_show" | "no_show_guest" | "csat";
}[] = [
{
title: t("event_ratings"),
index: "rating",
},
{
title: t("event_no_show"),
index: "no_show",
},
{
title: t("event_no_show_guest"),
index: "no_show_guest",
},
{
title: t("csat_score"),
index: "csat",
},
];
if (isPending) {
return (