/** * 倉庫卡片元件 * 顯示單個倉庫的資訊和統計 */ import { useState } from "react"; import { Package, AlertTriangle, MapPin, Edit, Info, FileText, CupSoda, QrCode, Milk, } from "lucide-react"; import { Warehouse, WarehouseStats } from "@/types/warehouse"; import { Button } from "@/Components/ui/button"; import { StatusBadge } from "@/Components/shared/StatusBadge"; import { Card, CardContent } from "@/Components/ui/card"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/Components/ui/dialog"; import { Can } from "@/Components/Permission/Can"; 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); const isVending = warehouse.type === 'vending'; return ( {/* 裝飾性背景元素 (僅限販賣機) */} {isVending && ( <> {/* LED 裝飾線條 - 保持主色調 */}
)} {/* 警告橫幅 */} {hasWarning && (
低庫存警告
{stats.lowStockCount} 項
)} {/* 上半部:資訊區域 */}
{/* 標題區塊 */}

{warehouse.name}

{WAREHOUSE_TYPE_LABELS[warehouse.type || 'standard'] || '標準倉'} {warehouse.type === 'quarantine' ? ' (不計入可用)' : ' (計入可用)'}
{warehouse.description || (isVending ? "管理此機台的商品配貨與補貨狀況" : "無描述")}
{/* 統計區塊 */}
{warehouse.type !== 'quarantine' && (
帳面庫存估值
${Number(stats.totalValue || 0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
)}
{Number(stats.abnormalValue || 0) > 0 && (
{warehouse.type === 'quarantine' ? '瑕疵總計' : '過期統計'}
${Number(stats.abnormalValue || 0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
)}
{/* 販賣機特色視覺:投幣、取物口裝飾 (移動至帳面庫存下方,顏色更顯眼) */} {isVending && (
)}
{/* 下半部:操作按鈕 */}
{/* 倉庫資訊對話框 */} {warehouse.name} {warehouse.code}

地址

{warehouse.address || "-"}

描述

{warehouse.description || "-"}

); }