import React, { useState } from "react"; import { Button } from "@/src/components/ui/button"; import { Badge } from "@/src/components/ui/badge"; import { ChevronRight, ChevronDown } from "lucide-react"; import { cn } from "@/src/utils/tailwind"; interface CollapsibleSectionProps { title: string; badge?: string; count?: number; defaultExpanded?: boolean; actionButton?: React.ReactNode; children: React.ReactNode; isEmpty?: boolean; emptyMessage?: string; className?: string; summaryContent?: string | React.ReactNode; } export const CollapsibleSection: React.FC = ({ title, badge, count, defaultExpanded = false, actionButton, children, isEmpty = false, emptyMessage, className, summaryContent, }) => { const [isExpanded, setIsExpanded] = useState(defaultExpanded); const toggleExpanded = () => { setIsExpanded(!isExpanded); }; const hasContent = count !== undefined ? count > 0 : !isEmpty; return (
{/* Header */}
{actionButton && (
{actionButton}
)}
{/* Content */} {isExpanded && (
{hasContent ? ( children ) : (

{emptyMessage || "No items configured."}

)}
)} {/* Compact summary when collapsed */} {!isExpanded && (hasContent || summaryContent) && (

{summaryContent || (count !== undefined && count > 0 ? `${count} item${count === 1 ? "" : "s"} configured` : "Configured")}

)}
); };