"use client"; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from "recharts"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import type { RouterOutputs } from "@calcom/trpc/react"; import { useInsightsBookingParameters } from "@calcom/web/modules/insights/hooks/useInsightsBookingParameters"; import { useToggleableLegend } from "@calcom/web/modules/insights/hooks/useToggleableLegend"; import { valueFormatter } from "@calcom/features/insights/lib/valueFormatter"; import { ChartCard } from "../ChartCard"; const COLOR = { CREATED: "#a855f7", COMPLETED: "#22c55e", RESCHEDULED: "#3b82f6", CANCELLED: "#ef4444", NO_SHOW_HOST: "#64748b", NO_SHOW_GUEST: "#f97316", }; export const legend = [ { label: "Created", color: COLOR.CREATED }, { label: "Completed", color: COLOR.COMPLETED }, { label: "Rescheduled", color: COLOR.RESCHEDULED }, { label: "Cancelled", color: COLOR.CANCELLED }, { label: "No-Show (Host)", color: COLOR.NO_SHOW_HOST }, { label: "No-Show (Guest)", color: COLOR.NO_SHOW_GUEST }, ]; type EventTrendsData = RouterOutputs["viewer"]["insights"]["eventTrends"][number]; // Custom Tooltip component const CustomTooltip = ({ active, payload, label: _label, }: { active?: boolean; payload?: Array<{ value: number; dataKey: string; name: string; color: string; payload: EventTrendsData; }>; label?: string; }) => { if (!active || !payload?.length) { return null; } return (
{payload[0].payload.formattedDateFull}
{payload.map((entry, index: number) => ({entry.name}: {valueFormatter ? valueFormatter(entry.value) : entry.value}
))}