import { Grid } from "@tremor/react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc"; import { SkeletonContainer, SkeletonText } from "@calcom/ui"; import { useInsightsParameters } from "../hooks/useInsightsParameters"; import { CardInsights } from "./Card"; import { KPICard } from "./KPICard"; export const BookingKPICards = () => { const { t } = useLocale(); const { startDate, endDate, teamId, userId, isAll, memberUserId, eventTypeId } = useInsightsParameters(); const { data, isSuccess, isPending } = trpc.viewer.insights.eventsByStatus.useQuery( { startDate, endDate, teamId, eventTypeId, memberUserId, userId, isAll, }, { staleTime: 30000, trpc: { context: { skipBatch: true }, }, } ); const categories: { title: string; index: | "created" | "completed" | "rescheduled" | "cancelled" | "no_show" | "rating" | "csat" | "no_show_guest"; }[] = [ { title: t("events_created"), index: "created", }, { title: t("events_completed"), index: "completed", }, { title: t("events_rescheduled"), index: "rescheduled", }, { title: t("events_cancelled"), index: "cancelled", }, { 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 ; } if (!isSuccess || !data) return null; return ( <> {categories.map((item) => ( ))} ); }; const LoadingKPICards = (props: { categories: { title: string; index: string }[] }) => { const { categories } = props; return ( {categories.map((item) => ( ))} ); };