import { ChevronRight, Loader2, RefreshCw, Search } from "lucide-react"; import { type ReactNode } from "react"; import { cn } from "../lib/utils"; import { Card, CardContent } from "./card"; import { Input } from "./input"; import { Skeleton } from "./skeleton"; export interface SummaryItem { id: string; label: string; subtitle?: string; summaryText: string; summaryValue?: number; onClick: () => void; } interface SummaryListProps { items: T[]; loading: boolean; error: string | null; searchValue: string; onSearchChange: (value: string) => void; onRetry: () => void; hasMore: boolean; onLoadMore: () => void; loadingMore: boolean; renderIcon: (item: T) => ReactNode; emptyMessage?: string; className?: string; } export function SummaryList({ items, loading, error, searchValue, onSearchChange, onRetry, hasMore, onLoadMore, loadingMore, renderIcon, emptyMessage = "No items found", className, }: SummaryListProps) { return (
{/* Search */}
onSearchChange(e.target.value)} className="pl-9 rounded-full" />
{/* Error */} {error && (

{error}

)} {/* Loading skeleton — only on initial load */} {loading && items.length === 0 && !error && (
{Array.from({ length: 6 }).map((_, i) => (
))}
)} {/* Empty */} {!loading && !error && items.length === 0 && (

{emptyMessage}

)} {/* Items */} {!error && items.length > 0 && ( <>
{items.map((item) => ( ))}
{/* Load More */} {hasMore && (
)} )}
); }