/** * 倉庫卡片元件 * 顯示單個倉庫的資訊和統計 */ import { useState } from "react"; import { Package, AlertTriangle, MapPin, Edit, Info, FileText, } from "lucide-react"; import { Warehouse, WarehouseStats } from "@/types/warehouse"; import { Button } from "@/Components/ui/button"; import { Badge } from "@/Components/ui/badge"; import { Card, CardContent } from "@/Components/ui/card"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/Components/ui/dialog"; interface WarehouseCardProps { warehouse: Warehouse; stats: WarehouseStats; hasWarning: boolean; onViewInventory: (warehouseId: string) => void; onEdit: (warehouse: Warehouse) => void; } const WAREHOUSE_TYPE_LABELS: Record = { standard: "標準倉", production: "生產倉", retail: "門市倉", vending: "販賣機", transit: "在途倉", quarantine: "瑕疵倉", }; export default function WarehouseCard({ warehouse, stats, hasWarning, onViewInventory, onEdit, }: WarehouseCardProps) { const [showInfoDialog, setShowInfoDialog] = useState(false); return ( {/* 警告橫幅 */} {hasWarning && (
低庫存警告
)} {/* 上半部:資訊區域 */}
{/* 標題區塊 */}

{warehouse.name}

{WAREHOUSE_TYPE_LABELS[warehouse.type || 'standard'] || '標準倉'} {warehouse.type === 'transit' && warehouse.license_plate && ( {warehouse.license_plate} )}
{warehouse.description || "無描述"}
{/* 統計區塊 - 狀態標籤 */}
{/* 銷售狀態與可用性說明 */}
庫存可用性 {warehouse.type === 'quarantine' ? ( 不計入可用 ) : ( 計入可用 )}
{/* 低庫存警告狀態 */}
低庫存警告
{hasWarning ? ( {stats.lowStockCount} 項 ) : ( 正常 )}
{/* 移動倉司機資訊 */} {warehouse.type === 'transit' && warehouse.driver_name && (
司機 {warehouse.driver_name}
)}
{/* 下半部:操作按鈕 */}
{/* 倉庫資訊對話框 */} {warehouse.name} {warehouse.code}

地址

{warehouse.address || "-"}

描述

{warehouse.description || "-"}

); }