phase-0: scaffold backend and frontend shell
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { DataTable } from "@/components/DataTable";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
interface MockAsset {
|
||||
code: string;
|
||||
name: string;
|
||||
department: string;
|
||||
status: string;
|
||||
category: string;
|
||||
}
|
||||
|
||||
const MOCK_DATA: MockAsset[] = [
|
||||
{ code: "PHRC-ICU-0001", name: "Ventilator", department: "ICU", status: "In Service", category: "Life Support" },
|
||||
{ code: "PHRC-ICU-0002", name: "Patient Monitor", department: "ICU", status: "Under Repair", category: "Monitoring" },
|
||||
{ code: "PHRC-OT-0001", name: "Anaesthesia Machine", department: "Operation Theatre", status: "In Service", category: "Life Support" },
|
||||
{ code: "PHRC-RAD-0001", name: "CT Scanner", department: "Radiology", status: "In Service", category: "Imaging" },
|
||||
{ code: "PHRC-RAD-0002", name: "X-Ray Unit", department: "Radiology", status: "Out of Service", category: "Imaging" },
|
||||
{ code: "PHRC-EM-0001", name: "Defibrillator", department: "Emergency", status: "In Service", category: "Life Support" },
|
||||
{ code: "PHRC-PATH-0001", name: "Centrifuge", department: "Pathology", status: "In Service", category: "Laboratory" },
|
||||
{ code: "PHRC-DIAL-0001", name: "Dialysis Machine", department: "Dialysis", status: "In Service", category: "Dialysis" },
|
||||
];
|
||||
|
||||
const STATUS_VARIANTS: Record<string, "success" | "danger" | "warning" | "outline"> = {
|
||||
"In Service": "success",
|
||||
"Under Repair": "danger",
|
||||
"Out of Service": "warning",
|
||||
Condemned: "outline",
|
||||
};
|
||||
|
||||
const columns: ColumnDef<MockAsset, unknown>[] = [
|
||||
{ accessorKey: "code", header: "Asset Code", enableColumnFilter: true },
|
||||
{ accessorKey: "name", header: "Equipment Name", enableColumnFilter: true },
|
||||
{ accessorKey: "category", header: "Category", enableColumnFilter: true },
|
||||
{ accessorKey: "department", header: "Department", enableColumnFilter: true },
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "Status",
|
||||
enableColumnFilter: true,
|
||||
cell: ({ getValue }) => {
|
||||
const v = getValue() as string;
|
||||
return <Badge variant={STATUS_VARIANTS[v] ?? "default"}>{v}</Badge>;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export function DataTableDemoPage() {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900">Phase 0 — DataTable Demo</h1>
|
||||
<p className="text-gray-500 mt-1 text-sm">
|
||||
Mock asset data demonstrating column filters, sort, pagination, column visibility, and CSV export.
|
||||
Every list in the app will use this component.
|
||||
</p>
|
||||
</div>
|
||||
<DataTable
|
||||
data={MOCK_DATA}
|
||||
columns={columns}
|
||||
globalFilterPlaceholder="Search assets..."
|
||||
exportFilename="assets-demo"
|
||||
emptyMessage="No assets found."
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user