Dashboard & Navigation
Role-scoped dashboard widgets, realtime reload behavior, sidebar groups, and queue badge semantics.
GET /admin/dashboard renders the React dashboard. GET /api/v1/admin/dashboard/snapshot returns the same role-scoped view as JSON. Both use the shared contract in shared/admin/dashboard.ts.
Time ranges
The dashboard accepts exactly three ranges: 7, 30, or 90 days. The server defaults to 30.
Role sections
Dashboard data is scoped by section, not just by page visibility:
| Role | Sections |
|---|---|
super_admin | users, trucks, jobs, marketplace, reviews, reports, orders, revenue |
admin | users, trucks, jobs, marketplace, reviews, reports, orders, revenue |
content_manager | users, trucks, jobs, marketplace, reviews |
support_agent | users, reports, orders |
moderator | reports, reviews, trucks, jobs, marketplace |
If a section is not in scope, the server does not ship that widget payload. The React page renders widgets only when the prop exists.
Dashboard payload
The snapshot includes:
| Field | Scope |
|---|---|
days, scope, assembledAt | Always present. |
metrics, deltas | Role-scoped overview KPIs. |
userGrowth, recentUsers, activeSessionsCount | Users/system. |
recentTrucks, topTrucks, truckJobActivity | Trucks/jobs. |
recentReports, highPriorityPendingReports | Reports. |
recentReviews, lowRatedReviewsInWindow | Reviews. |
orderVolume, orderStatusMix | Orders. |
revenue, refunds | Revenue. |
marketplaceDistribution, listingActivity | Marketplace. |
jobApplicationStatusMix | Jobs. |
queueHealth | Queue/system health. |
assembledAt tells the UI when the server finished assembling the snapshot. Metrics use a 60-second cache, with targeted invalidation for important admin events.
Realtime reloads
The dashboard subscribes to admin broadcast channels for stats and alerts. Events such as order creation/transition, job activity, review creation, report creation, truck publishing, and payment/refund changes trigger partial Inertia reloads for only the affected props.
The important client rule: treat realtime events as invalidation signals. Re-read the server props; do not apply business-state transitions locally from an event payload.
Sidebar groups
The sidebar is declared in inertia/shell/sidebar-nav-config.ts.
| Group | Items |
|---|---|
| Overview | Dashboard |
| Operate | Users, Trucks, Categories, Jobs, Marketplace |
| Moderate | Reviews, Reports, Menu, Support |
| Commerce | Pricing, Payments, Analytics, Refunds, Webhooks, Orders |
| System | Admins, Announcements, Notifications, Activity, Security, Queue, Legal, FAQs, About, Settings |
An item can be gated by a dashboard section, by an explicit role allow-list, or both. Detail pages inherit their parent nav item, so /admin/users/:id still highlights Users.
Sidebar badges
| Badge | Count semantics |
|---|---|
| Reports | Reports with status in ("pending", "new"). This covers the current mobile contract and legacy reports, and matches the dashboard pending-reports KPI. |
| Support | Support tickets with status in ("open", "pending"). assigned is excluded because someone already owns it. |
Counts are role-scoped. An out-of-scope badge is null, not 0, so the UI can distinguish "no access" from "empty queue".