+1








30ba168fc3
Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Benny Joo <sldisek783@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Gergő Móricz <mo.geryy@gmail.com> Co-authored-by: Keith Williams <keithwillcode@gmail.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { Title } from "@tremor/react";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc";
|
|
|
|
import { useFilterContext } from "../context/provider";
|
|
import { CardInsights } from "./Card";
|
|
import { LoadingInsight } from "./LoadingInsights";
|
|
import { TotalBookingUsersTable } from "./TotalBookingUsersTable";
|
|
|
|
export const MostBookedTeamMembersTable = () => {
|
|
const { t } = useLocale();
|
|
const { filter } = useFilterContext();
|
|
const { dateRange, selectedEventTypeId, isAll, initialConfig } = filter;
|
|
const [startDate, endDate] = dateRange;
|
|
const { selectedTeamId: teamId } = filter;
|
|
|
|
const { data, isSuccess, isPending } = trpc.viewer.insights.membersWithMostBookings.useQuery(
|
|
{
|
|
startDate: startDate.toISOString(),
|
|
endDate: endDate.toISOString(),
|
|
teamId,
|
|
eventTypeId: selectedEventTypeId ?? undefined,
|
|
isAll,
|
|
},
|
|
{
|
|
staleTime: 30000,
|
|
trpc: {
|
|
context: { skipBatch: true },
|
|
},
|
|
enabled: !!(initialConfig?.teamId || initialConfig?.userId || initialConfig?.isAll),
|
|
}
|
|
);
|
|
|
|
if (isPending) return <LoadingInsight />;
|
|
|
|
if (!isSuccess || !startDate || !endDate || !teamId) return null;
|
|
|
|
return (
|
|
<CardInsights className="shadow-none">
|
|
<Title className="text-emphasis">{t("most_booked_members")}</Title>
|
|
<TotalBookingUsersTable data={data} />
|
|
</CardInsights>
|
|
);
|
|
};
|