"use client"; import { memo } from "react"; import { formatNumber } from "./utils"; interface CustomTooltipProps { active?: boolean; payload?: Array<{ value: number; color: string; }>; label?: number; metricLabel?: string; isPercentage?: boolean; totalItems: number; } const CustomTooltip = memo( ({ active, payload, label = 0, metricLabel = "Value", isPercentage = false, totalItems, }: CustomTooltipProps) => { if (active && payload && payload.length) { const value = isPercentage ? `${payload[0].value}%` : formatNumber(payload[0].value); const today = new Date(); const daysAgo = totalItems - 1 - label; const date = new Date(today); date.setDate(today.getDate() - daysAgo); return (

{date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", })}

{metricLabel}: {value}
); } return null; } ); CustomTooltip.displayName = "CustomTooltip"; export default CustomTooltip;