import { useState } from "react"; import toast from "react-hot-toast"; import { ArrowRight, BarChart3, Boxes, CheckCircle2, DoorOpen, Loader2, Sparkles, Table2, TrendingUp, } from "lucide-react"; import { getEquipmentDemandReport, getRoomUtilizationReport } from "../api.js"; export default function ReportsPage() { const [roomReport, setRoomReport] = useState([]); const [equipmentReport, setEquipmentReport] = useState([]); const [activeReport, setActiveReport] = useState(null); const [loadingRoomReport, setLoadingRoomReport] = useState(false); const [loadingEquipmentReport, setLoadingEquipmentReport] = useState(false); async function loadRoomReport() { setLoadingRoomReport(true); try { const data = await getRoomUtilizationReport(); setRoomReport(Array.isArray(data) ? data : []); setActiveReport("rooms"); toast.success("Room utilization report loaded"); } catch (err) { toast.error(err.message || "Room utilization report could not be loaded."); } finally { setLoadingRoomReport(false); } } async function loadEquipmentReport() { setLoadingEquipmentReport(true); try { const data = await getEquipmentDemandReport(); setEquipmentReport(Array.isArray(data) ? data : []); setActiveReport("equipment"); toast.success("Equipment demand report loaded"); } catch (err) { toast.error(err.message || "Equipment demand report could not be loaded."); } finally { setLoadingEquipmentReport(false); } } return (
Analytics center

Reports & Insights

Review room utilization, equipment demand and operational trends using live data from the project database.

2 Advanced reports
Live PostgreSQL data
SQL Grouped analytics
{!activeReport && (

Select a report to view results

Choose one of the analytical reports above. Results will be loaded from the live database and displayed in a structured table.

)} {activeReport === "rooms" && roomReport.length > 0 && ( [ row.quarterStart, row.buildingName, row.roomCode, row.type, row.totalRoomReservations, row.approvedReservations, row.approvedHours, row.utilizationRank, row.utilizationLevel, ])} /> )} {activeReport === "equipment" && equipmentReport.length > 0 && ( [ row.quarterStart, row.equipmentName, row.stockQuantity, row.assignedRoomQuantity, row.totalRegisteredQuantity, row.totalRequestedQuantity, row.demandToRegisteredPercent, row.demandRank, row.demandLevel, ])} /> )} {activeReport === "rooms" && !loadingRoomReport && roomReport.length === 0 && ( )} {activeReport === "equipment" && !loadingEquipmentReport && equipmentReport.length === 0 && ( )}
); } function ReportCard({ icon: Icon, tag, title, description, points, loading, onClick, }) { return ( ); } function PremiumTable({ title, subtitle, columns, rows }) { return (
Report output

{title}

{subtitle}

{rows.length} rows loaded
{columns.map((column) => ( ))} {rows.map((row, index) => ( {row.map((cell, cellIndex) => ( ))} ))}
{column}
{String(cell ?? "")}
); } function EmptyResult({ title }) { return (

{title}

The query executed successfully, but there is no matching data for the current dataset.

); }