import * as React from "react" import { cn } from "../ui/utils" interface DonutItem { name: string value: number stock?: string | number unit?: string } interface BottomStat { label: string value: string | number subLabel?: string } interface DonutChartCardProps extends React.ComponentProps<"div"> { title: string centerValue?: string | number centerUnit?: string centerLabel?: string items: DonutItem[] selectedItem?: string | null onItemSelect?: (name: string | null) => void bottomStats?: BottomStat[] bottomColumns?: number chartElement: React.ReactNode } function DonutChartCard({ title, centerValue, centerUnit, centerLabel, items, selectedItem, onItemSelect, bottomStats, bottomColumns = 4, chartElement, className, ...props }: DonutChartCardProps) { const grayColors = ["#D4D4D4", "#A8A8A8", "#8B8B8B", "#6B6B6B"] return (

{title}

{chartElement} {(centerValue !== undefined || centerLabel) && (
{centerValue !== undefined && (

{centerValue} {centerUnit && {centerUnit}}

)} {centerLabel && (

{centerLabel}

)}
)}
{items.map((item, index) => (
onItemSelect?.(selectedItem === item.name ? null : item.name)} style={{ opacity: selectedItem === null || selectedItem === undefined || selectedItem === item.name ? 1 : 0.3, }} >
{item.name}
{item.stock !== undefined && ( {item.stock} {item.unit && {item.unit}} )}
))}
{bottomStats && bottomStats.length > 0 && (
{bottomStats.map((stat) => (

{stat.label}

{stat.value}

{stat.subLabel && (

{stat.subLabel}

)}
))}
)}
) } export { DonutChartCard } export type { DonutChartCardProps, DonutItem, BottomStat }