vineroute// field manual
Rider
Driver
Dispatch
Systems
The Dispatch/Assignments
06 / 10

Assignments

Route + vehicle + driver + date

SchedulingOperations

Overview

Page header SCHEDULING / Assignments, with a date picker and +ASSIGNMENT button. The DataTable has DATE, STARTS, ROUTE, VEHICLE, DRIVER, STATUS (PLANNED / IN PROGRESS / COMPLETED / CANCELLED), and a CANCEL link. The modal lets the dispatcher pick a route from a dropdown of active routes, a vehicle from active vehicles, a driver from active drivers, and a date plus start time.

How it works

1

`GET /admin/assignments?date=YYYY-MM-DD` filters server-side by the picked date. The default is today, in the dispatcher's local timezone.

2

Status is computed server-side at read time — planned if start is in the future, in_progress if start <= now <= end, completed if end < now, cancelled if the cancelled-at field is set.

3

Creating an assignment validates that the driver isn't double-booked on that date (no overlapping assignments) and that the vehicle isn't either. Conflicts raise a 409 Conflict with a JSON body the modal renders as an inline error.

4

Cancellation: `PATCH /admin/assignments/[id]` with status='cancelled' stamps cancelledAt and emits a push notification to the driver (if registered) plus an announcement to confirmed passengers.

5

The driver dropdown only shows drivers with isActive=true AND who don't have a conflicting assignment on the picked date — server-side filtered.

Key decisions

Cancel, never delete

Assignments tie reservations to a specific shift. Deleting one would either orphan the reservations or force cascading deletes we'd later regret. Cancellation keeps the row, signals the new state, and lets us notify everyone affected.

Conflict checking on the server

The client could check before submit, but the source of truth is the database. We do the check there, raise a 409, and let the modal show the conflict inline. The two-second round trip is invisible to the dispatcher and the truth never drifts.

Assignments

Quick Reference

Routeapps/admin/src/app/(dash)/assignments/page.tsx
StoreReact Query + date picker state + modal state
APIsGET/POST/PATCH /admin/assignments
Components
PageHeaderDatePickerDataTableModalStatusPill
PreviousPeopleNextReservations