* Adding skipBatch to trpc calls * Use view in trpc insights * Added performance data creation on seed-insights * fix some scenarios * Fix migration view fields * Prevent revalidating too often --------- Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: zomars <zomars@me.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 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 } = filter;
|
|
const [startDate, endDate] = dateRange;
|
|
const { selectedTeamId: teamId } = filter;
|
|
|
|
const { data, isSuccess, isLoading } = trpc.viewer.insights.membersWithMostBookings.useQuery(
|
|
{
|
|
startDate: startDate.toISOString(),
|
|
endDate: endDate.toISOString(),
|
|
teamId,
|
|
eventTypeId: selectedEventTypeId ?? undefined,
|
|
},
|
|
{
|
|
staleTime: 30000,
|
|
trpc: {
|
|
context: { skipBatch: true },
|
|
},
|
|
}
|
|
);
|
|
|
|
if (isLoading) 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>
|
|
);
|
|
};
|