"use client"; import { Pill, Trash2 } from "lucide-react"; import type { ReactNode } from "react"; import { useTranslation } from "react-i18next"; import { Badge } from "@/components/ui/badge"; import { Dialog, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPanel, DialogPopup, DialogTitle, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { type Availability, type InventoryItem, availabilityOf, } from "@/lib/inventory"; const availabilityVariant: Record< Availability, "success" | "warning" | "destructive" > = { "in-stock": "success", low: "warning", out: "destructive", }; function Row({ label, value }: { label: string; value: ReactNode }) { return (
{label} {value}
); } // Read-only detail for a single inventory item, opened by clicking a row on the // inventory list. Editing stock is a later step; this surfaces all the fields a // quick row can't show (reorder threshold, location, expiry, notes). export function InventoryDetailDialog({ item, open, onOpenChange, onDelete, }: { item: InventoryItem | null; open: boolean; onOpenChange: (open: boolean) => void; onDelete?: () => void; }) { const { t } = useTranslation(); if (!item) return null; const availability = availabilityOf(item); return ( {item.name} {t(`inventory.availability.${availability}`)} {[item.strength, item.form].filter(Boolean).join(" · ") || t("inventory.detail.description")}
{item.notes ? (
{t("inventory.detail.notes")} {item.notes}
) : null}
{onDelete && ( )} }> {t("inventory.detail.close")}
); }