"use client"; import { Button } from "@suphark/ui/components/shared/button/button"; import { FormattedNumber } from "@suphark/ui/components/shared/number/formatted-number"; import { PrimarySecondaryText } from "@suphark/ui/components/shared/text/primary-secondary-text"; import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, } from "@suphark/ui/components/ui/attachment"; import { Badge } from "@suphark/ui/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@suphark/ui/components/ui/card"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@suphark/ui/components/ui/dropdown-menu"; import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "@suphark/ui/components/ui/empty"; import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, ItemTitle, } from "@suphark/ui/components/ui/item"; import { RelativeDate } from "@suphark/ui/components/ui/relative-date"; import { Skeleton } from "@suphark/ui/components/ui/skeleton"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@suphark/ui/components/ui/table"; import { DataTable, DataTableColumnHeader } from "@suphark/ui/data-table"; import type { ColumnDef } from "@tanstack/react-table"; import { AlertTriangle, Download, Eye, FileCheck, FileSpreadsheet, FileText, MoreHorizontal, Package, Plus, Trash2, } from "lucide-react"; import * as React from "react"; export function ShowcaseDataDisplay() { const [dataState, setDataState] = React.useState<"ready" | "loading" | "empty">("ready"); const tableRows = [ { code: "PKG-2026-041", name: "งานจัดซื้อคอนกรีตผสมเสร็จ ผสมสารกันซึม", category: "Material / Structural", vendor: "Alpha Cement Co., Ltd.", quantity: "1,200 m³", unitRate: 2450.0, totalAmount: 2940000.0, status: "Approved", badgeVariant: "default", date: new Date(Date.now() - 1000 * 60 * 60 * 2), }, { code: "PKG-2026-042", name: "งานจัดจ้างติดตั้งระบบแจ้งเหตุเพลิงไหม้ (Fire Alarm)", category: "Subcontract / MEP", vendor: "Beta Fire Engineering Ltd.", quantity: "1 Lump Sum", unitRate: 4850000.0, totalAmount: 4850000.0, status: "Under Review", badgeVariant: "secondary", date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2), }, { code: "PKG-2026-043", name: "งานจัดซื้อกระจกลามิเนตกันเสียง Facade", category: "Material / Architectural", vendor: "Gamma Glass Architectural", quantity: "850 m²", unitRate: 3200.0, totalAmount: 2720000.0, status: "Draft", badgeVariant: "outline", date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5), }, { code: "PKG-2026-044", name: "งานจัดจ้างเจาะเสาเข็ม Bored Pile Dia 800mm", category: "Subcontract / Foundation", vendor: "Delta Piling Co., Ltd.", quantity: "140 Piles", unitRate: 18500.0, totalAmount: 2590000.0, status: "Approved", badgeVariant: "default", date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 8), }, ]; type PackageRow = (typeof tableRows)[number]; const packageColumns: ColumnDef[] = [ { accessorKey: "code", header: ({ column }) => , cell: ({ row }) => {row.original.code}, }, { accessorKey: "name", header: ({ column }) => , cell: ({ row }) => ( ), }, { accessorKey: "vendor", header: ({ column }) => , }, { accessorKey: "status", header: ({ column }) => , cell: ({ row }) => {row.original.status}, filterFn: (row, id, value: string[]) => value.includes(row.getValue(id)), }, { accessorKey: "totalAmount", header: ({ column }) => ( ), cell: ({ row }) => (
), }, ]; return (
{/* Section Header */}
Data Presentation Tables, Triple States, Items, Attachments & Formatters

การแสดงผลชุดข้อมูลและสถานะการทำงาน

ตารางข้อมูลที่มีความหนาแน่นสูง (Data-Dense Tables), การสลับ 3 สถานะ (Ready / Loading / Empty), และตัวจัดรูปแบบตัวเลข-วันที่

{/* Triple State Demonstration */}
Data Table & Triple State Lifecycle ทดสอบสลับระหว่าง Ready State, Geometry-Accurate Skeleton, และ Actionable Empty State
{dataState === "ready" && (
รหัส / Package รายการและหมวดหมู่งาน คู่ค้าที่เสนอราคา สถานะ จำนวน ราคาต่อหน่วย มูลค่ารวม (THB) จัดการ {tableRows.map((row) => ( {row.code}
{row.vendor}
{row.status} {row.quantity} } > ตัวเลือกรายการ ดูรายละเอียด ส่งออก BOQ ลบแพ็กเกจ
))}
)} {dataState === "loading" && (
)} {dataState === "empty" && ( ไม่พบรายการแพ็กเกจจัดซื้อ ยังไม่มีการสร้างแพ็กเกจในงวดนี้ หรือคำค้นหาไม่ตรงกับเงื่อนไขการค้นหา )}
{/* DataTable (@suphark/ui/data-table) */} DataTable (tanstack) — @suphark/ui/data-table ตารางมาตรฐานพร้อม global search, faceted filter, เรียงคอลัมน์, ซ่อน/แสดงคอลัมน์ และ pagination — import แยกจาก @suphark/ui/data-table (ต้องมี peer{" "} @tanstack/react-table) {/* Item & Attachment Primitives */}
{/* Item Primitive */} Item & ItemGroup Primitive คอมโพเนนต์สำหรับแสดงแถวรายการที่มี Media, Badge, และ Inline Actions ใบรับรองคุณภาพ มอก. 20-2558 (Alpha Concrete) รับรองมาตรฐานคอนกรีตผสมเสร็จความแข็งแรงสูง • มีผลบังคับใช้ถึง 31 ธ.ค. 2570 หนังสือค้ำประกันผลงาน (Performance Bond) อยู่ระหว่างรอหนังสือค้ำประกันฉบับจริงจากธนาคารกสิกรไทย Pending {/* Attachment Primitive */} Attachment Primitive การ์ดไฟล์แนบพร้อมสถานะการอัปโหลด (Done / Uploading / Error) BOQ_Facade_Rev2.xlsx 2.4 MB • Alpha Approved Tender_Terms_2026.pdf 1.1 MB • Signed
{/* Shared Formatters & Benchmark Analysis */}
{/* Value Formatters */} Shared Value Formatters Formatters เพื่อป้องกัน SSR Hydration Mismatch และคุม Locale ภาษาไทย
FormattedNumber (Currency) ปัดทศนิยม 2 ตำแหน่ง พร้อมลูกน้ำ
฿
PrimarySecondaryText ข้อความหลัก/รองแบบสองชั้น
RelativeDate (Thai relative) แสดงเวลาแบบสัมพัทธ์ภาษาไทย
); }