"use client"; import { useInsightsRoutingParameters } from "@calcom/web/modules/insights/hooks/useInsightsRoutingParameters"; 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 { valueFormatter } from "@calcom/features/insights/lib"; import { ChartCard } from "../ChartCard"; export const RoutingKPICards = () => { const { t } = useLocale(); const insightsRoutingParameters = useInsightsRoutingParameters(); const { data, isSuccess, isPending, isError } = trpc.viewer.insights.routingFormsByStatus.useQuery( insightsRoutingParameters, { staleTime: 30000, trpc: { context: { skipBatch: true }, }, } ); const categories: { title: string; index: "total" | "totalWithoutBooking" | "totalWithBooking"; }[] = [ { title: t("routing_forms_total_responses"), index: "total", }, { title: t("routing_forms_total_responses_without_booking"), index: "totalWithoutBooking", }, { title: t("routing_forms_total_responses_with_booking"), index: "totalWithBooking", }, ]; if (isPending) { return ; } return ( {isSuccess && data ? ( {categories.map((item) => ( {item.title} {valueFormatter(data[item.index])} ))} ) : null} ); }; const LoadingKPICards = (props: { categories: { title: string; index: string }[]; isPending: boolean; isError: boolean; }) => { const { t } = useLocale(); const { categories, isPending, isError } = props; return ( {categories.map((item) => ( ))} ); };