import { __, sprintf } from '@wordpress/i18n'; import { ChartTooltip } from '@/components/Common/ChartTooltip'; import { formatNumber, formatPercentage } from '@/utils/formatting'; /** * Props interface for the FunnelTooltip component. */ interface FunnelTooltipProps { data: { stepTitle: string; sessionCount: number; sessionPercentage: number; conversionInRate: number; dropoffOutRate: number; lostSessions: number; potentialGainText: string; }; } /** * FunnelTooltip component to display detailed information about a funnel step. * * @param {FunnelTooltipProps} props - The properties for the FunnelTooltip component. * * @return {JSX.Element} The rendered tooltip. */ export const FunnelTooltip: React.FC = ({ data }) => { const { stepTitle, sessionCount, sessionPercentage, conversionInRate, dropoffOutRate, lostSessions, potentialGainText } = data; const sessionPercentageDecimals = 0 < sessionPercentage && 10 > sessionPercentage ? 1 : 0; return (
{/* Header */}

{sprintf( __( '%1$s visitors (%2$s)', 'burst-statistics' ), formatNumber( sessionCount, 0, false ), formatPercentage( sessionPercentage, sessionPercentageDecimals ) )}

{stepTitle}

{/* Transitions Data */}
{sprintf( __( '%s conversion from previous step', 'burst-statistics' ), formatPercentage( conversionInRate, 1 ) )}
{sprintf( __( '%s drop-off to next step', 'burst-statistics' ), formatPercentage( dropoffOutRate, 1 ) )}

{sprintf( __( '%s lost visitors', 'burst-statistics' ), formatNumber( lostSessions, 0, false ) )}

{potentialGainText}

); };