import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "@/Components/ui/dialog"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/Components/ui/table"; import { Badge } from "@/Components/ui/badge"; import { Loader2, Package, Calendar, Clock, BookOpen } from "lucide-react"; interface RecipeDetailModalProps { isOpen: boolean; onClose: () => void; recipe: any | null; // Detailed recipe object with items isLoading?: boolean; } export function RecipeDetailModal({ isOpen, onClose, recipe, isLoading }: RecipeDetailModalProps) { if (!isOpen) return null; return (
配方明細 {recipe && ( {recipe.is_active ? "啟用中" : "已停用"} )}
{/* 現代化元數據條 */} {recipe && (
{recipe.code}
建立於 {new Date(recipe.created_at).toLocaleDateString()}
更新於 {new Date(recipe.updated_at).toLocaleDateString()}
)}
{isLoading ? (
) : recipe ? (
{/* 基本資訊區塊 */}
欄位 內容 配方名稱 {recipe.name} 對應成品
{recipe.product?.name || '-'} {recipe.product?.code}
標準產量 {Number(recipe.yield_quantity).toLocaleString()} {recipe.product?.base_unit?.name || '份'} {recipe.description && ( 備註說明 {recipe.description} )}
{/* BOM 表格區塊 */}

原物料清單 (BOM)

原物料名稱 / 料號 標準用量 單位 備註 {recipe.items?.length > 0 ? ( recipe.items.map((item: any, index: number) => (
{item.product?.name || 'Unknown'} {item.product?.code}
{Number(item.quantity).toLocaleString()} {item.unit?.name || '-'} {item.remark || '-'}
)) ) : ( 此配方尚未設定原物料 )}
) : (
無法載入配方資料
)}
); }