Commit graph

7 commits

Author SHA1 Message Date
DEls
c5b1acfc7f Update package dependencies and remove unused API routes
- Added `pocketbase` as a dependency in `package.json` and `package-lock.json`.
- Updated the `dev` script in `package.json` to run on port 6004 instead of 3000.
- Removed unused API routes: `src/app/api/health/route.ts`, `src/app/api/mcp/route.ts`, `src/app/api/upload/route.ts`, and their associated logic to streamline the codebase.
- Cleaned up `package-lock.json` by removing unnecessary peer dependencies and ensuring consistency in the dependency tree.
2026-08-19 00:14:47 +02:00
DEls
8aca2aed20 Clear all placeholder data while PocketBase is sorted out
The previous commit dropped real data for The Hills ext 12
(sites, vehicles, employees, orders, plant hire rates, P&G
expenses) so the dashboard had something to render during design
iteration. With PB about to be wired, that data now belongs in
PocketBase rather than in the source tree.

This commit empties the data layer back to zero so the dashboard
falls into its empty-state UI on every page:

  - src/lib/mock-data.ts    SITES_DATA, SITES, SUPPLIERS, VEHICLES,
                            EMPLOYEES, ORDERS, FUEL_READINGS,
                            PLANT_HIRE_RATES, PG_EXPENSES → []
                            Header comment updated to point future
                            contributors at lib/pb.ts as the next
                            step.
  - src/lib/uploads.ts      UPLOAD_HISTORY → []. Acceptance rules
                            (mime / extensions / size limits) kept so
                            the Uploads page still shows format hints.

Type definitions, helper functions and date utilities are untouched
so all routes continue to render (HTTP 200 across the board). The
sidebar, dashboard, fuel, orders, employees, sites and uploads pages
all gracefully render their empty states.

When PocketBase is wired:
  1. Install 'pocketbase' (npm)
  2. Build src/lib/pb.ts with admin-authed server client + public
     client
  3. Replace the imports in pages like
        import { SITES_DATA, VEHICLES, ... } from '@/lib/mock-data';
     with calls like
        import { getServerPB } from '@/lib/pb';
        const records = await getServerPB().collection('sites').getList();
  4. Keep the empty exports here as a final fallback so the dashboard
     still works if PB is ever unreachable.
2026-08-18 13:49:28 +02:00
DEls
fa5611cb38 Drop in real data for The Hills ext 12 (C26/09) + Burn panel
Data wired from the site cost sheet, fuel log, wage schedule and two
PO PDFs the user shared:

  - src/lib/types.ts            VehicleType expanded (Roller, TLB,
                                Pickup, Water Truck, Compressor,
                                Mixer) so plant types map cleanly to
                                the source data. Vehicle gains
                                optional kmPerL and expectedLPerHour
                                fields for the mixed L/h + km/L
                                allowance model.
  - src/lib/mock-data.ts       SITES_DATA[0] = The Hills ext 12,
                                contract value R24,988,663, contract
                                code C26/09, 8-month duration.
                                SITES, SUPPLIERS updated.
                                VEHICLES populated with 47 entries
                                covering rollers, TLBs, excavators,
                                graders, loaders, tipper trucks,
                                water trucks, pickups, mixers and
                                auxiliary equipment (compressors,
                                crushing machine).
                                EMPLOYEES populated with 15 permanent
                                + 53 casuals, all at the project's
                                45h/week standard.
                                PLANT_HIRE_RATES populated with 32
                                entries matching the cost sheet
                                (R185–R680/h depending on equipment).
                                PG_EXPENSES populated with all 6 P&G
                                monthly lines (container, security,
                                salaries, overheads, insurance,
                                site facilities = R567,403.50/m).
                                ORDERS populated with MEGCPO9199
                                (PPE, Delivered) and MEGCPO9165
                                (aggregates, Partial).
                                FUEL_READINGS starts empty — drop
                                CSV-imported rows in once the depot
                                system is wired.
  - src/lib/uploads.ts          UPLOAD_HISTORY seeded with the GRN
                                attached to MEGCPO9199.
  - src/lib/burn.ts             New helper. burnBreakdown() joins
                                plant hire rates with the vehicles
                                list, multiplies each hire rate by
                                the standard 45h/week, adds weekly
                                P&G share, and surfaces both weekly
                                and monthly totals.
  - src/lib/sites.ts            summarizeSite + summarizeAllSites
                                now take PlantHireRate[] and
                                PgExpense[] so the site summary
                                exposes weeklyBurn / monthlyBurn /
                                weeklyPlantHire / monthlyPg etc.
  - src/app/dashboard/page.tsx  New 'Burn rate — weekly vs monthly'
                                panel. Two side-by-side cards show
                                weekly + monthly totals with plant
                                hire vs P&G breakdown, plus a
                                'Cost breakdown' card on the right.
  - src/app/dashboard/sites/*  Pass the new hireRates + pgExpenses
                                arrays through to the summary helpers.

Notes:
  - The 'Spent to date' KPI on the Sites list / detail now sums PO
    value (since there are no fuel readings yet). Once depot data is
    ingested, it will pick up the actual R25.65/L burn automatically.
  - Tank capacities + odometer start values are sensible estimates
    for the equipment types — adjust per-unit when you have real
    fleet specs.
  - Weekly hours per employee default to 45h so the workforce
    trends look populated; replace with timesheet imports as soon as
    those land.
2026-08-18 12:35:34 +02:00
DEls
c09094c1dc Clear placeholder data + fix divide-by-zero on Sites page
Wipe all seeded mock data so the user can drop in real numbers:

  - src/lib/mock-data.ts    SITES_DATA, SITES, SUPPLIERS, VEHICLES,
                            EMPLOYEES, ORDERS, FUEL_READINGS → []
                            Type definitions and helper functions
                            preserved; the FUEL_READINGS generator is
                            preserved as a commented block ready to
                            re-enable.
  - src/lib/uploads.ts      UPLOAD_HISTORY → []. Acceptance rules
                            (mime / extensions / size limits per kind)
                            kept so the UI still shows format hints.

While verifying empty states, caught a divide-by-zero on the Sites
list page: 'Workforce this week' KPI rendered as 'NaN% of total
contract value' when there are zero sites. Guard the divide.

All pages now render in their empty-state UI — KPIs show 0, charts
draw empty axes, tables say 'No X match the current filters', upload
history cards say 'No uploads yet'. Typecheck clean, all routes
return 200, no runtime errors.
2026-08-18 12:10:44 +02:00
DEls
c6ac2f06b8 Remove Fuel CSV uploads card + add demo critical anomaly
Two small cleanup changes:

1. Drop the 'CSV uploads' card at the bottom of the Fuel page.
   The Template / Upload CSV buttons in the topbar still let users
   ingest readings, but the recent-uploads mini-list was redundant —
   the Uploads page already shows every upload. The fuelCsvTemplate
   import is still in use by the topbar download button.

   Also clean up the now-unused uploads/setUploads state, the
   FileSpreadsheet icon, and the unused CardDescription / Badge /
   FileSpreadsheet references in the bottom block.

2. Plant a guaranteed critical anomaly on the most recent working
   day so the Anomaly log's first page and the dashboard's 'Needs
   attention' rail show one for demo purposes. The previous random
   spike day often landed too far back to be visible without
   paginating. Now MI-TT-07 (one of the tipper trucks) always has
   a 2.4x-2.8x theft spike on the latest day, while the other
   eight vehicles still get a random earlier spike for variety.

3. Sort the Anomaly log by date desc, then by severity desc
   (critical → alert → watch → ok) so actionable entries surface
   first within each day. The dashboard's 'Needs attention' rail
   also benefits from the more recent critical sitting at the top.

4. Restore the Uploads nav item in the sidebar that was removed
   in the previous commit by mistake.
2026-08-09 20:21:54 +02:00
DEls
3506640e4a Add Uploads page with 4 colored drop zones
New /dashboard/uploads page with a 2x2 grid of drop zones, one per
ingest source:

  - Orders (orange) — CSV / XLS / XLSX, max 10 MB
  - Delivery Notes (teal) — PDF / images, max 20 MB
  - Fuel Logs (yellow-green) — CSV / XLS / XLSX, max 5 MB
  - Time Sheets (green) — CSV / XLS / XLSX, max 5 MB

Each block has:
  - A coloured left stripe + icon disc in the accent colour
  - Title, format-count badge, and a long description of what to upload
  - File-format chips and a max-size hint
  - A drag-and-drop drop zone that also accepts files via click
  - A primary 'Upload X' button in the accent colour
  - A 'Recent' list showing the last 4 uploads with status badges

When files are dropped or picked, the client POSTs to
/api/upload with a 'type' field. The endpoint validates MIME and size
against the kind-specific rules in src/lib/uploads.ts and returns a
JSON descriptor with accepted/rejected entries. New entries are
prepended to the page's recent-uploads list in real time, and a
bottom-right toast shows accepted/rejected counts.

The sidebar gets a new 'Uploads' nav item with the upload icon.

Files:
  - src/lib/types.ts                    type definitions
  - src/lib/uploads.ts                   acceptance rules + mock history
  - src/app/api/upload/route.ts          type-aware upload handler
  - src/app/dashboard/uploads/page.tsx   the new page
  - src/components/layout/sidebar.tsx    Uploads nav entry
2026-08-09 19:30:00 +02:00
SJCoetz
eeea5b7592 Initial commit: MEGA INFRASTRUCTURE dashboard + Coolify Dockerfile 2026-08-09 01:37:40 +02:00