diff --git a/src/app/dashboard/plant/page.tsx b/src/app/dashboard/plant/page.tsx
index 0a5b61d..3bbe919 100644
--- a/src/app/dashboard/plant/page.tsx
+++ b/src/app/dashboard/plant/page.tsx
@@ -1,18 +1,20 @@
import { pbAdmin } from "@/lib/pb";
-import { PlantView, type PlantRow } from "./plant-view";
+import { PlantView, type PlantRow, type PlantLogRow } from "./plant-view";
export const dynamic = "force-dynamic";
export default async function PlantPage() {
const pb = await pbAdmin();
- // Plant now lives in the VEHICLES collection — we filter to rated items
- // (cost_per_hour > 0) so the financial view shows the heavy machinery.
- const all = await pb.collection("vehicles").getFullList({
- sort: "description",
- });
+ const [allVehicles, allLogs] = await Promise.all([
+ pb.collection("vehicles").getFullList({ sort: "description", perPage: 5000 }),
+ pb
+ .collection("plant_hours_log")
+ .getFullList({ sort: "-start_date", perPage: 5000 })
+ .catch(() => []),
+ ]);
- const rows: PlantRow[] = all
+ const rows: PlantRow[] = allVehicles
.filter((v) => (v.cost_per_hour ?? 0) > 0)
.map((v) => ({
id: v.id,
@@ -21,13 +23,35 @@ export default async function PlantPage() {
projectCode: v.project_code,
hourMeter: v.standard_work_hours,
costPerHour: v.cost_per_hour,
+ unitType: v.unit_type ?? "fuel",
}));
+ const logs: PlantLogRow[] = allLogs.map((l) => ({
+ id: l.id,
+ vehicleId: l.vehicle,
+ vehicleQr: l.vehicle_qr,
+ vehicleDescription:
+ allVehicles.find((v) => v.id === l.vehicle)?.description ?? "",
+ vehicleUnitType: (allVehicles.find((v) => v.id === l.vehicle)?.unit_type ?? "fuel") as "fuel" | "plant",
+ projectCode: l.project_code,
+ startDate: l.start_date,
+ endDate: l.end_date,
+ startTime: l.start_time ?? "",
+ endTime: l.end_time ?? "",
+ hours: l.hours,
+ hourMeterBudget: l.hour_meter_budget,
+ costPerHour: l.cost_per_hour,
+ value: l.value,
+ overBudget: l.over_budget,
+ notes: l.notes ?? "",
+ }));
+
const projectCodes = Array.from(new Set(rows.map((r) => r.projectCode))).sort();
return (