mega-plant/components/OilsStock.tsx
David df53130861 Add Workforce pages, Plant Clock tab bar and oil & diesel book-out
- Workforce: Employees register, per-employee dashboards, Attendance table
- Plant Clock: scan-only clock, bottom tab bar (Employees / Oil & Diesel / Job cards)
- Oil & Diesel stock: diesel tank (650 L, opening 589 L), level overwrite dialog,
  QR on each card, book-out screen with searchable vehicle picker,
  filterable "Booked out" table (today/week/month/all/range)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-22 11:39:18 +02:00

37 lines
No EOL
1.1 KiB
TypeScript

"use client";
import { useState, useTransition } from "react";
import { useRouter } from "next/navigation";
import { Loader2 } from "lucide-react";
import type { OilStock } from "@/lib/oil";
import { oilQrPayload } from "@/lib/oil";
import { OilsBoard, type OilLogRow } from "@/components/OilsBoard";
import { buildOilLabelsPdf, downloadPdf } from "@/lib/qr-pdf";
export function OilsStock({ stock, log }: { stock: OilStock[]; log: OilLogRow[] }) {
const router = useRouter();
const [, startTransition] = useTransition();
const [building, setBuilding] = useState(false);
async function download() {
setBuilding(true);
try {
const bytes = await buildOilLabelsPdf(
stock.map((s) => ({
name: s.item.name,
code: s.item.code,
colour: s.item.colour,
drum_litres: s.item.drum_litres,
})),
oilQrPayload,
);
downloadPdf(bytes, "mega-plant-oil-diesel-labels.pdf");
} catch {
alert("Could not build the PDF. Please try again.");
} finally {
setBuilding(false);
}
}
return <OilsBoard stock={stock} log={log} onDownload={download} building={building} />;
}