import { useState } from 'react' import { PlantIcon } from './PlantIcon' import { LotStateChip, SeedLotList } from './SeedLotList' import { SourceLink } from './SourceLink' import { cardActionClass, cardDangerClass } from '@/components/ui/cardActions' import { CATEGORY_LABELS, isBuiltin, type Plant } from '@/lib/plants' import { formatQuantity, summarizeLots, type SeedLot } from '@/lib/seedLots' import { formatSpacing, type UnitPref } from '@/lib/units' /** * One catalog plant as a card: icon tile tinted with the plant's color, name, * category + mature spacing (unit-aware), and actions. Built-ins are badged and * offer only "Duplicate" (they're read-only); own plants add Edit/Delete. */ export function PlantCard({ plant, unit, lots, onEdit, onDelete, onDuplicate, onAddLot, onEditLot, onDeleteLot, }: { plant: Plant unit: UnitPref /** This plant's purchases. A lot may reference a built-in, so even a built-in * card can carry seed. */ lots: SeedLot[] onEdit: () => void onDelete: () => void onDuplicate: () => void onAddLot: () => void onEditLot: (lot: SeedLot) => void onDeleteLot: (lot: SeedLot) => void }) { const builtin = isBuiltin(plant) const [showLots, setShowLots] = useState(false) const summary = summarizeLots(lots) return (

{plant.name}

{builtin && ( Built-in )}

{CATEGORY_LABELS[plant.category]} ยท {formatSpacing(plant.spacingCm, unit)} spacing

{(plant.vendor || plant.sourceUrl) && (

{plant.vendor && {plant.vendor}}

)} {plant.notes &&

{plant.notes}

}
{showLots && (
)}
{/* The seed count sits with the actions rather than in the body: it's what you scan for down a list of twenty packets, so it wants a fixed place on the card. */} {!builtin && ( )} {!builtin && ( )}
) }