Commit Graph

1401 Commits

Author SHA1 Message Date
natib21
558f7f38cd feat: add fleet-wide fuel and maintenance stats endpoints
Backend:
FuelService + FuelController:
- Added getFleetFuelStats() aggregating all vehicles
- Route: GET /api/fuel/stats (before :vehicleId route)
- Returns: totalCost, totalLiters, totalPurchases, averagePricePerLiter

MaintenanceService + MaintenanceController:
- Added getFleetMaintenanceStats() aggregating all vehicles
- Route: GET /api/maintenance/stats (before :vehicleId route)
- Returns: totalCost, numberOfMaintenanceItems, averageCostPerMaintenance, costByType

Both endpoints aggregate over past 12 months (customizable via query param).

Enables dashboard to show fleet-wide operating costs.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:32:12 +00:00
natib21
17a6d846a4 fix: show multiple vehicles on tracking map for demo
Changed from filtering by ACTIVE status to showing first 10 vehicles.
Ensures at least 2+ car icons visible on map for testing.

Changes:
- trackableVehicles: first 10 vehicles instead of ACTIVE filter
- Map markers: shows all trackable vehicles
- Badge: "Tracked" count instead of "Active"
- Vehicle list: "Tracked Vehicles (count)" instead of "Active Vehicles"

Enables demo of map functionality with actual fleet data.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:28:44 +00:00
natib21
8be47f98a9 feat: show only active vehicles on tracking map
Filter vehicles to status === 'ACTIVE':
- Map markers: only active vehicles displayed
- Vehicle dropdown: only active vehicles selectable
- All vehicles list: renamed to "Active Vehicles (count)"
- All use activeVehicles useMemo computed from vehiclesWithGPS

Inactive vehicles (maintenance, idle, etc.) hidden from tracking view.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:26:35 +00:00
natib21
fea869a19c feat: display vehicle name instead of ID in fuel purchases table
Backend:
- FuelService.getAllFuelPurchases() now loads vehicle relationship
- Uses leftJoinAndSelect to eagerly load Vehicle data
- Returns complete FuelPurchase with nested vehicle object

Frontend:
- Table displays vehicle.registrationNumber (primary)
- Falls back to vehicle.plateNumber if registration unavailable
- Falls back to vehicleId as last resort

Better UX: shows human-readable vehicle info instead of UUID.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:23:54 +00:00
natib21
67ba168a22 fix: convert numeric strings to numbers in fuel calculations
Problem:
- purchasesData from API returns numeric columns as strings
- Calling .toFixed() on strings throws "toFixed is not a function"
- Occurs in stats cards and table rows

Solution:
- Wrap p.liters, p.costPerLiter, p.totalCost in Number() before calculations
- Total Liters stat card: sum + Number(p.liters)
- Total Cost stat card: sum + Number(p.totalCost)
- Avg Price/L stat card: use Number() on both divisor and dividend
- Table rows: Number(purchase.liters).toFixed(2), etc.

Fixes render error in FuelPurchasePage when loading fuel purchases list.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:21:16 +00:00
natib21
796e63cc59 fix: add missing GET /api/fuel/purchases endpoint
Problem:
- Frontend calls GET /fuel/purchases (all purchases)
- Backend only had GET /fuel/purchases/:vehicleId (specific vehicle)
- Result: 404 when loading fuel purchases list

Solution:
- Added getAllFuelPurchases() to FuelService
- Added GET /fuel/purchases route to FuelController
- Route placed before parameterized route so it gets matched first
- Returns all fuel purchases ordered by date DESC

Endpoints:
- GET /api/fuel/purchases → all purchases
- GET /api/fuel/purchases/:vehicleId → specific vehicle
- POST /api/fuel/purchases → record purchase

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:18:26 +00:00
natib21
ea8198f8a8 style: reduce horizontal padding on fleet dashboards
Add px="lg" (24px) to all Container components:
- FleetDashboard
- FuelPurchasePage
- FuelStatsPage
- MaintenancePage
- FinancialReportsPage
- TrackingPage

Reduces left/right padding from default to 24px,
making better use of horizontal screen space.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:13:58 +00:00
natib21
2e1c720b86 feat: add vehicle tracking/GPS map
New TrackingPage with:
- Interactive map grid showing vehicle locations
- Real-time GPS coordinates (mock data)
- Vehicle speed & heading display
- Vehicle selector dropdown
- Live status indicators
- All vehicles list with speed
- Click-to-track functionality
- Location details sidebar:
  * Latitude/Longitude
  * Current speed
  * Heading direction
  * Last update timestamp
  * View history button

Features:
- Grid-based map (no external dependencies)
- Vehicle markers (color-coded selected/inactive)
- SVG grid background (lat/lng lines)
- Responsive layout (map + sidebar)
- Mantine UI + brand colors
- Mock GPS generation per vehicle

Route: /dashboard/tracking
Sidebar: "Track Vehicles" in Fleet Management

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 14:08:21 +00:00
natib21
69d1d3073f style: standardize dashboard padding
All fleet pages now use consistent layout:
- Container size: xl
- Vertical padding: xl

Pages updated:
- FleetDashboard: size="xl" py="xl" (unchanged)
- FuelPurchasePage: lg → xl
- FuelStatsPage: lg → xl
- MaintenancePage: Added Container wrapper (xl, xl)
- FinancialReportsPage: Added Container wrapper (xl, xl)

Uniform spacing across all fleet management dashboards.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 13:59:20 +00:00
natib21
5af7f0606b style: apply consistent branding across fleet pages
Import freightBrand theme from @/theme/freight-brand

Color updates:
- Primary buttons: color="edr-green"
- Stat cards: top border #1B9E7A (freightBrand.primary)
- Status badges:
  * Active/Completed: edr-green
  * In Progress: edr-amber-soft
  * Maintenance: edr-amber-soft
  * Overdue: edr-red
  * Unassigned: edr-slate
- Ring progress:
  * Fuel: edr-accent (#F2A516)
  * Maintenance: edr-red
- Progress bars: edr-green, edr-red, edr-amber-soft
- Icons: Use edr-green, edr-blue, edr-accent, edr-red per metric

Pages updated:
- FleetDashboard: All metrics, progress bars, badges
- FuelPurchasePage: Record button
- MaintenancePage: Schedule button, badges
- FinancialReportsPage: Ring progress colors

Consistent palette across all fleet pages.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 13:52:27 +00:00
natib21
6a4a3d464a improve: fleet dashboard UI + add drivers
UI Improvements:
- Better card design with gradient icons
- Added title + description section
- Improved stat card layout (gradient backgrounds)
- Added change percentage badges
- Better color scheme (blue, cyan, orange, red)
- Striped + highlight on hover for tables
- Tab interface for vehicles/drivers

Driver Management:
- Fetch drivers from /drivers API
- Display driver list in table
- Show driver name, license, contact info
- Display assigned/unassigned status
- Count total drivers + assigned drivers in metrics

Metrics now show:
1. Total Vehicles
2. Total Drivers (NEW)
3. Fuel Spend
4. Maintenance Spend
5. Status breakdowns
6. Cost breakdown pie chart

Tabs show:
- Vehicles with registration, plate, model, status
- Drivers with name, license, contact, assignment

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 13:46:58 +00:00
natib21
814db8a17d feat: fleet dashboard page
Shows fleet overview + key metrics:
- Total vehicles, active count
- Total fuel spending
- Total maintenance spending
- Average fuel efficiency
- Fleet status (active/idle/maintenance)
- Operating cost breakdown (fuel vs maintenance pie chart)
- Fleet vehicle list (first 10)

Route: /dashboard/fleet-dashboard
Sidebar: Added to Fleet Management section

Metrics aggregate from:
- /vehicles (fleet size)
- /fuel/stats (fuel spending + efficiency)
- /maintenance/stats (maintenance spending)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 13:38:35 +00:00
natib21
8e0cc7d5ee fix: vehicles data extraction in maintenance + financial pages
Both MaintenancePage and FinancialReportsPage were calling
vehiclesService.getAll() but not extracting res.data property.
Result was vehicles being undefined, causing .map error.

Fixed to match FuelPurchasePage pattern:
  const res = await vehiclesService.getAll()
  return res.data || []

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 13:10:47 +00:00
natib21
373c0356f2 feat: maintenance + financial reports frontend
MaintenancePage:
- Schedule maintenance (PREVENTIVE/CORRECTIVE/INSPECTION/REPAIR)
- View upcoming by vehicle
- Modal form with date, cost, provider, notes

FinancialReportsPage:
- Aggregate fuel + maintenance costs
- Period selector (3/6/12 months)
- Cost breakdown (percentages, ring progress)
- Operating insights (purchases, efficiency, items, avg cost)
- Cost per month calculation

Routes:
- /dashboard/maintenance
- /dashboard/financial-reports

Sidebar:
- "Maintenance" in Fleet Management
- "Financial Reports" in Fleet Management

QUERY_KEYS:
- FUEL, MAINTENANCE, FINANCIAL_REPORTS cache patterns

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 12:41:23 +00:00
natib21
f436916c42 feat: complete maintenance tracking backend
Service/Controller/Module:
- scheduleMaintenanceAsync: schedule work
- recordMaintenanceCost: log expenses
- getUpcomingMaintenance: due items
- getVehicleMaintenanceStats: cost aggregation

Endpoints:
- POST /maintenance/schedules
- POST /maintenance/costs
- PATCH /maintenance/schedules/:id
- GET /maintenance/upcoming/:vehicleId
- GET /maintenance/history/:vehicleId
- GET /maintenance/stats/:vehicleId

Migration: idempotent maintenance tables creation

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 12:33:29 +00:00
natib21
e59a77b859 feat: add maintenance tracking module foundation
Entities:
- MaintenanceSchedule: track preventive/corrective maintenance
- MaintenanceCost: record actual maintenance expenses

DTOs:
- CreateMaintenanceScheduleDto: schedule maintenance
- CreateMaintenanceCostDto: log costs
- UpdateMaintenanceScheduleDto: mark complete/adjust cost

Repository:
- getUpcomingMaintenance(): find due maintenance
- getMaintenanceCosts(): historical costs by date
- getTotalMaintenanceCost(): aggregate spending

Also fixed fuel-consumption.entity.ts: totalDistanceKm default 0

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 12:28:00 +00:00
natib21
5d70c3b557 fix 2026-06-30 12:13:48 +00:00
natib21
f27f00d480 fix: use vehiclesService and add VEHICLES QUERY_KEYS
- Add VEHICLES to QUERY_KEYS constant
- Use vehiclesService.getAll() instead of direct API call
- Remove duplicate Vehicle type definitions
- Fix TypeScript type references

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 10:15:43 +00:00
natib21
3f81bb77ad feat: add fuel management frontend pages
- FuelPurchasePage: Record fuel purchases, calculate total costs
- FuelStatsPage: View fuel consumption stats, efficiency metrics
- Routes: /dashboard/fuel-purchases and /dashboard/fuel-stats
- Sidebar menu items in Fleet Management section

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 10:11:13 +00:00
natib21
7b9cd88712 fix: correct fuel module TypeScript errors
- Use @InjectRepository decorators for proper dependency injection
- Fix BaseRepository initialization with Repository instance
- Remove unnecessary DataSource references
- Add proper type annotations to reduce handlers

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 10:08:56 +00:00
natib21
df6e417a56 feat: add fuel management system backend
- FuelPurchase entity: record fuel purchases with cost tracking
- FuelConsumption entity: monthly aggregation of fuel metrics
- FuelService: record purchases, calculate stats, efficiency
- FuelController: REST API for fuel operations
- FuelModule: integrated into app
- Migration: create fuel_purchases and fuel_consumption tables

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 10:07:13 +00:00
natib21
360e61ac15 fix: use byId() instead of detail() in QUERY_KEYS
QUERY_KEYS.FIRST_MILE and QUERY_KEYS.LAST_MILE have byId() not detail().

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 04:04:56 +00:00
natib21
0bc9534172 fix: replace apiClient with api in FirstMilePage
Use correct import 'api' from '@/auth/http' instead of undefined 'apiClient'.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 04:03:29 +00:00
natib21
14dde418f7 fix(migrations): check if tables exist before CREATE TABLE
Make invoices migration idempotent - skip table/index creation if they
already exist. Prevents 'relation already exists' errors on redeployment.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 03:55:57 +00:00
natib21
b142552f17 Merge branch 'dev' of github.com:Tria-plc/edr-platform into freight/hot_fix 2026-06-30 03:46:26 +00:00
natib21
25e91c6d93 fix: comment out isPostPaymentCompleted column decorator
Column doesn't exist in DB yet. Commenting out @Column decorator
prevents TypeORM from trying to select non-existent column.
Fixes 500 QueryFailedError on first-mile/last-mile list endpoints.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 03:33:54 +00:00
natib21
b1d9045d0b fix: remove isPostPaymentCompleted filter check
Property removed from entities until migration creates column.
Temporarily skip this filter until feature is fully implemented.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 03:15:58 +00:00
natib21
f9ef473cff fix(migrations): check pg_type before CREATE TYPE enum
PostgreSQL doesn't support IF NOT EXISTS on CREATE TYPE AS ENUM.
Query pg_type table to check if enum exists before creating.
Compatible with all PostgreSQL versions.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 02:45:37 +00:00
natib21
76b25bd214 fix 2026-06-30 02:33:29 +00:00
natib21
1c1e98960e fix 2026-06-30 02:24:52 +00:00
natib21
ec82f8eb9f fix(migrations): use CREATE TYPE IF NOT EXISTS for invoices enum
Allows migration to run when enum already exists in prod DB. Prevents
'type already exists' error on redeployment.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 02:22:09 +00:00
natib21
3ceacbe9a9 fix(migrations): use CREATE TYPE IF NOT EXISTS for invoices enum
Allows migration to run when enum already exists in prod DB. Prevents
'type already exists' error on redeployment.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-30 02:03:20 +00:00
Stephanos A.
9bd7edbd03 Update Dockerfile 2026-06-30 00:42:39 +03:00
Stephanos A.
592efd0bf9 Merge pull request #361 from Tria-plc/alpha
fix(passenger-api): remove trailing backslash in Dockerfile
2026-06-30 00:31:52 +03:00
Stephanos A
bd372cce32 fix(passenger-api): remove trailing backslash in Dockerfile 2026-06-30 00:30:42 +03:00
Stephanos A.
aa974b940c Merge pull request #360 from Tria-plc/alpha
fix(passenger-api): ensure Prisma client is properly copied to runtim…
2026-06-30 00:17:57 +03:00
Stephanos A
0cefd9ffb2 fix(passenger-api): ensure Prisma client is properly copied to runtime container 2026-06-30 00:16:31 +03:00
Stephanos A.
8da6f5c1e1 Merge pull request #359 from Tria-plc/alpha
fix(passenger-api): resolve all pre-init legacy migrations
2026-06-30 00:06:27 +03:00
Stephanos A
44930b5eab fix(passenger-api): resolve all pre-init legacy migrations 2026-06-30 00:03:38 +03:00
Stephanos A.
538b433afb Merge pull request #358 from Tria-plc/alpha
Skip different schema version migrations
2026-06-29 23:56:49 +03:00
Stephanos A
140a989d34 Skip different schema version migrations 2026-06-29 23:55:24 +03:00
Stephanos A.
944bf544c8 Merge pull request #357 from Tria-plc/alpha
Resolve migrations
2026-06-29 23:49:44 +03:00
Stephanos A
f069ee985d Resolve migrations 2026-06-29 23:45:59 +03:00
Stephanos A.
0433285c1c Merge pull request #356 from Tria-plc/alpha
Move the fix before the failing migration
2026-06-29 23:29:19 +03:00
Stephanos A
c52b02ef72 Move the fix before the failing migration 2026-06-29 23:27:36 +03:00
Stephanos A.
43f15426d8 Merge pull request #355 from Tria-plc/alpha
Fix failed migration state
2026-06-29 23:21:00 +03:00
Stephanos A
7d8e19b37d Fix failed migration state 2026-06-29 23:19:10 +03:00
Stephanos A.
8a5b1891ae Merge pull request #354 from Tria-plc/alpha
Migration issue resolution - individual ticket no timezone
2026-06-29 23:09:45 +03:00
Stephanos A
8c2a2e34bf Migration issue resolution - individual ticket no timezone 2026-06-29 23:08:27 +03:00
Nathnael
10cde2b2e3 fix 2026-06-29 19:44:40 +00:00