From b8e8328b1ffffb80bf4ebb776a4a24e5680fc5bc Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 28 Mar 2025 00:42:08 +0000 Subject: 테이블 칼럼 리사이즈 및 핀 충돌 해결 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/po/table/item-dialog.tsx | 173 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 lib/po/table/item-dialog.tsx (limited to 'lib/po/table/item-dialog.tsx') diff --git a/lib/po/table/item-dialog.tsx b/lib/po/table/item-dialog.tsx new file mode 100644 index 00000000..a6690e75 --- /dev/null +++ b/lib/po/table/item-dialog.tsx @@ -0,0 +1,173 @@ +"use client" + +import * as React from "react" +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from "@/components/ui/dialog" +import { Button } from "@/components/ui/button" +import { ScrollArea } from "@/components/ui/scroll-area" +import { Separator } from "@/components/ui/separator" +import { Badge } from "@/components/ui/badge" +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" +import { Package, Info, DollarSign, Tag, Clock, Hash } from "lucide-react" + +import type { ContractDetailParsed } from "@/db/schema/contract" + +interface ItemsDialogProps { + open: boolean + onOpenChange: (open: boolean) => void + po: ContractDetailParsed | null +} + +export function ItemsDialog({ open, onOpenChange, po }: ItemsDialogProps) { + console.log(po) + + // Format currency with appropriate symbol + const formatCurrency = (value: number | null, currency?: string) => { + if (value === null) return '-'; + const currencySymbol = currency === 'USD' ? '$' : currency || ''; + return `${currencySymbol}${value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; + }; + + // Format date to a readable format + const formatDate = (dateString: string) => { + const date = new Date(dateString); + return date.toLocaleString(); + }; + + return ( + + + + + + Contract Items + + + {po + ? `Item list for contract #${po.contractNo} - ${po.contractName}` + : "No contract selected." + } + + + + {/* Main content */} + {po ? ( + po.items.length === 0 ? ( +
+ + No items found for this contract. +
+ ) : ( +
+
+
+ Total Items: {po.items.length} +
+
+ Currency: {po.currency || "Default"} +
+
+ + +
+ {po.items.map((item) => ( + + +
+ + + Item #{item.itemId} + + {item.quantity > 1 && ( + + Qty: {item.quantity} + + )} +
+
+ + {item.description && ( +
+
+ + Description +
+
{item.description}
+
+ )} + + + + + Unit Price + + {item.unitPrice !== null ? ( +
+ + {formatCurrency(item.unitPrice, po.currency??"KRW")} +
+ ) : "-"} +
+
+ + {item.taxRate !== null && ( + + Tax Rate + {item.taxRate}% + + )} + + {item.taxAmount !== null && ( + + Tax Amount + {formatCurrency(item.taxAmount, po.currency??"KRW")} + + )} + + {item.totalLineAmount !== null && ( + + Total Amount + + {formatCurrency(item.totalLineAmount, po.currency??"KRW")} + + + )} +
+
+ + {item.remark && ( +
+
+ + Remark +
+
{item.remark}
+
+ )} + +
+ + Updated: {formatDate(item.updatedAt)} +
+
+
+ ))} +
+
+
+ ) + ) : ( +
+ Please select a contract to see its items. +
+ )} + + + + +
+
+ ) +} \ No newline at end of file -- cgit v1.2.3