'use client'; import Link from 'next/link'; import { ArrowRight } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Skeleton } from '@/components/ui/skeleton'; import type { UmamiMetricRow } from '@/lib/services/umami.service'; interface Props { title: string; rows: UmamiMetricRow[] | null; loading: boolean; /** Label substituted when `x` is empty (e.g. direct traffic referrers). */ defaultLabel?: string; /** Optional "View all" link target. When set, renders a link in the * card header that opens a full ranked-list page for this metric. */ viewAllHref?: string; /** Cap for the inline list (default 10). The full page uses no cap. */ limit?: number; /** Optional callback invoked when the empty-state "expand range" CTA is * clicked. When supplied, the empty state shows a nudge button suggesting * the rep try a wider range. */ onExpandRange?: () => void; /** Label for the expand-range button when `onExpandRange` is supplied. */ expandRangeLabel?: string; } /** * Compact "top N" list used for top pages / referrers / countries. * Renders each row as label + numeric count, with a thin progress bar * scaled to the largest count in the set so the visual density tells * the same story at a glance as the numbers. */ export function TopList({ title, rows, loading, defaultLabel = '-', viewAllHref, limit = 10, onExpandRange, expandRangeLabel = 'Try last 30 days', }: Props) { return ( {title} {viewAllHref ? ( View all ) : null} {loading ? (
) : !rows || rows.length === 0 ? (

No data in this range.

{onExpandRange ? ( ) : null}
) : ( )}
); }