2023-03-28 23:24:57 +00:00
|
|
|
import { Title } from "@tremor/react";
|
2023-03-23 22:10:01 +00:00
|
|
|
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
|
|
import { trpc } from "@calcom/trpc";
|
|
|
|
|
|
|
|
import { useFilterContext } from "../context/provider";
|
2023-03-28 23:24:57 +00:00
|
|
|
import { CardInsights } from "./Card";
|
2023-03-23 22:10:01 +00:00
|
|
|
import { TotalBookingUsersTable } from "./TotalBookingUsersTable";
|
|
|
|
|
|
|
|
export const MostBookedTeamMembersTable = () => {
|
|
|
|
const { t } = useLocale();
|
|
|
|
const { filter } = useFilterContext();
|
|
|
|
const { dateRange, selectedEventTypeId } = filter;
|
|
|
|
const [startDate, endDate] = dateRange;
|
|
|
|
const { selectedTeamId: teamId } = filter;
|
|
|
|
|
|
|
|
const { data, isSuccess } = trpc.viewer.insights.membersWithMostBookings.useQuery({
|
|
|
|
startDate: startDate.toISOString(),
|
|
|
|
endDate: endDate.toISOString(),
|
|
|
|
teamId,
|
|
|
|
eventTypeId: selectedEventTypeId ?? undefined,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!isSuccess || !startDate || !endDate || !teamId) return null;
|
|
|
|
|
|
|
|
return (
|
2023-03-28 23:24:57 +00:00
|
|
|
<CardInsights className="shadow-none">
|
2023-03-23 22:10:01 +00:00
|
|
|
<Title>{t("most_booked_members")}</Title>
|
|
|
|
<TotalBookingUsersTable data={data} />
|
2023-03-28 23:24:57 +00:00
|
|
|
</CardInsights>
|
2023-03-23 22:10:01 +00:00
|
|
|
);
|
|
|
|
};
|