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 (
{CATEGORY_LABELS[plant.category]} ยท {formatSpacing(plant.spacingCm, unit)} spacing
{(plant.vendor || plant.sourceUrl) && (
{plant.vendor && {plant.vendor}}
{plant.notes}
}