/** * 倉庫卡片元件 * 顯示單個倉庫的資訊和統計 */ 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"; 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); return ( {/* 警告橫幅 */} {hasWarning && (
低庫存警告
{stats.lowStockCount} 項
)} {/* 上半部:資訊區域 */}
{/* 標題區塊 */}

{warehouse.name}

{WAREHOUSE_TYPE_LABELS[warehouse.type || 'standard'] || '標準倉'} {warehouse.type === 'quarantine' ? ' (不計入可用)' : ' (計入可用)'} {warehouse.type === 'transit' && warehouse.license_plate && ( {warehouse.license_plate} {warehouse.driver_name && `(${warehouse.driver_name})`} )}
{warehouse.description || "無描述"}
{/* 統計區塊 - 狀態標籤 */}
{/* 帳面庫存總計 (金額) - 瑕疵倉隱藏此項以減少重複 */} {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 })}
)}
{/* 下半部:操作按鈕 */}
{/* 倉庫資訊對話框 */} {warehouse.name} {warehouse.code}

地址

{warehouse.address || "-"}

描述

{warehouse.description || "-"}

); }