* init page * init insights frontend * nit * nit * nit * merge * fixed icons * i18n, needs features * Init insights trpc * Using trpc on client * Added events timeline * Seed analytics script * connect ui with trpc * Added and fixed event time lines * WIP popular days and avg time duration event type * added new metric graphs * improved upgrade tip * always show upgrade screen * upgrade tremor.so and select inputs for page * Remove log * Move everything to components and add context * Fix select types using calcom ui one * Adding translations * Add missing translations * Add more translations * min fix * Fixes for date select * Prefer early return and mobile design fixes * Fix style for mobile * Fix data with userId filter from popular events * add user id to average time duration * Removed submodules * Delete website * Update yarn.lock * Code organization and type fixes * trpc fixes * Builds are now passing * Relocates server code * Cleanup * Medium size screen fixes * Added TODO --------- Co-authored-by: Alan <alannnc@gmail.com> Co-authored-by: zomars <zomars@me.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { Card, LineChart, Title } from "@tremor/react";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc";
|
|
|
|
import { useFilterContext } from "../context/provider";
|
|
import { valueFormatter } from "../lib/valueFormatter";
|
|
|
|
export const BookingStatusLineChart = () => {
|
|
const { t } = useLocale();
|
|
const { filter } = useFilterContext();
|
|
const { selectedTeamId, selectedTimeView = "week", dateRange, selectedEventTypeId } = filter;
|
|
const [startDate, endDate] = dateRange;
|
|
|
|
if (!startDate || !endDate) return null;
|
|
|
|
const { data: eventsTimeLine, isSuccess } = trpc.viewer.insights.eventsTimeline.useQuery({
|
|
timeView: selectedTimeView,
|
|
startDate: startDate.toISOString(),
|
|
endDate: endDate.toISOString(),
|
|
teamId: selectedTeamId || -1,
|
|
eventTypeId: selectedEventTypeId ?? undefined,
|
|
});
|
|
|
|
if (!isSuccess) return null;
|
|
|
|
return (
|
|
<Card>
|
|
<Title>{t("event_trends")}</Title>
|
|
<LineChart
|
|
className="mt-4 h-80"
|
|
data={eventsTimeLine ?? []}
|
|
categories={["Created", "Completed", "Rescheduled", "Cancelled"]}
|
|
index="Month"
|
|
colors={["gray", "green", "blue", "red"]}
|
|
valueFormatter={valueFormatter}
|
|
/>
|
|
</Card>
|
|
);
|
|
};
|