# PRP-007 — Dashboard & usage

- **Status:** Done
- **Plan:** Lite
- **Depends on:** PRP-004
- **Estimated effort:** ~0.5 day
- **Pro KB ref:** §20 (Reports & Dashboards)

> **Audience:** junior dev. The dashboard already shows counts, by-status, the quota meter, and an
> upgrade card (scaffold + PRP-001). This PRP adds **locked "advanced reports" preview tiles** and
> tidies the data wiring. Backend endpoints already exist — no new endpoints.

---

## 1. Goal / Why
Give the operator an at-a-glance day view and make the Lite ceiling (and the Pro lift) obvious. The
dashboard nurtures upgrade intent.

## 2. Scope
**In:** order counts (total/active/closed), by-status table, today's usage vs cap (from PRP-001),
upgrade card, **locked report preview tiles**.
**Out (Pro):** profit/financial reports, driver/zone/customer analytics, money-flow, CSV export,
date-range charts.

## 3. Prerequisites
- PRP-004 done. `GET /orders/summary` and `GET /orders/usage/today` working.

## 4. Step-by-step implementation

### Step 1 — Verify data sources (no backend change)
- `GET /api/orders/summary` → `{ total, active, closed, byStatus }`.
- `GET /api/orders/usage/today` → `{ used, cap, remaining, resets_at, plan }`.
Both already implemented. Active/closed come from `ACTIVE_STATUSES`/`TERMINAL_STATUSES`.

### Step 2 — Confirm the quota meter (from PRP-001)
In **`client/src/pages/Dashboard.tsx`** confirm the "Today's orders" card with the progress bar and
reset time is present. If missing, re-add per PRP-001 §6.

### Step 3 — Add locked "Advanced reports" preview tiles
Below the by-status card, add a grid of disabled tiles (Profit & money-flow, Driver performance, Zone
analytics, Customer insights), each with a PRO badge and a short benefit line from
`features.reports.teaser` / `features.drivers.teaser` (fetched via `getFeatures()`), linking to
`upgradeUrl`. Use the existing `.upgrade`/`.card` styles; keep it visual (blurred/disabled look).

### Step 4 — Build & test
```bash
npm run build:client
```
Create a few orders across statuses; confirm counts, by-status, and quota all reflect reality.

---

## 5. API endpoints & Postman documentation
**No new endpoints.** Existing (already in Postman **Orders** folder):
- `GET /api/orders/summary` → `{ total, active, closed, byStatus }`.
- `GET /api/orders/usage/today` → `{ used, cap, remaining, resets_at, plan }`.

No Postman change required.

---

## 6. Manual test / acceptance verification
- Create 3 orders, advance one to `collected` → summary shows `total:3, active:2, closed:1`.
- Quota meter shows `used` matching today's created count; for a Pro company the meter is hidden
  (`cap === null`).

**Acceptance criteria**
- [x] Counts and by-status match DB for the company.
- [x] Quota widget shows correct used/remaining + reset time (Lite); hidden for Pro.
- [x] Locked report tiles render with PRO badges + upgrade links.

---

## 7. Git commits
**Commit 1 — dashboard report teasers**
```bash
git add client/src/pages/Dashboard.tsx
git commit -m "feat(web): PRP-007 locked advanced-report preview tiles

Adds disabled Pro report tiles (profit/money-flow, drivers, zones, customers)
with benefit copy + upgrade links beneath the by-status summary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>"
```

**Commit 2 — PRP status**
```bash
git add PRPs/PRP-007-dashboard.md PRPs/README.md
git commit -m "docs(prp): mark PRP-007 done"
```

---

## 8. Done checklist
- [x] Quota meter verified; report tiles added.
- [x] Build passes; numbers match DB.
- [ ] Commits made; PRP marked Done.
