import { Grid } from "@tremor/react"; import { Flex, Text, Metric } from "@tremor/react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc"; import { useInsightsParameters } from "../hooks/useInsightsParameters"; import { valueFormatter } from "../lib"; import { CardInsights } from "./Card"; export const RoutingKPICards = () => { const { t } = useLocale(); const { teamId, startDate, endDate, userId, memberUserIds, isAll, routingFormId, columnFilters } = useInsightsParameters(); const { data, isPending } = trpc.viewer.insights.routingFormsByStatus.useQuery( { teamId, startDate, endDate, userId, memberUserIds, isAll, routingFormId, columnFilters, }, { 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 || !data) { return ; } return ( <> {categories.map((item) => ( {item.title} {valueFormatter(data[item.index])} ))} ); }; const LoadingKPICards = (props: { categories: { title: string; index: string }[] }) => { const { categories } = props; return ( {categories.map((item) => (
))} ); };