---
phase: 18-cleanup-consolidamento
plan: "01"
subsystem: ui
tags: [next.js, admin, cleanup, sidebar, server-actions]

requires: []
provides:
  - Forecast route removed (/admin/forecast → 404)
  - Admin sidebar without Forecast entry
  - project-actions.ts without revalidatePath forecast calls
  - Quote builder route removed (/admin/quotes/new → 404)
  - SendQuoteModal without navigation to quotes/new
  - QuoteBuilderForm, OfferSelector, PriceOverrideInput, QuotePreview components deleted
affects: [phase-21-ai-quote-agent, any future admin nav changes]

tech-stack:
  added: []
  patterns:
    - "Dead-code deletion: remove page files + directories + all entry points atomically before Sales Loop phase"

key-files:
  created: []
  modified:
    - src/components/admin/AdminSidebar.tsx
    - src/app/admin/projects/project-actions.ts
    - src/components/admin/leads/SendQuoteModal.tsx
    - src/lib/admin-queries.ts
  deleted:
    - src/app/admin/forecast/page.tsx
    - src/app/admin/quotes/new/page.tsx
    - src/app/admin/quotes/new/actions.ts
    - src/components/admin/quotes/QuoteBuilderForm.tsx
    - src/components/admin/quotes/OfferSelector.tsx
    - src/components/admin/quotes/PriceOverrideInput.tsx
    - src/components/admin/quotes/QuotePreview.tsx

key-decisions:
  - "Kept lib/forecast-queries.ts and lib/quote-actions.ts as tolerable deadweight — no broken imports, no consumer"
  - "SendQuoteModal Tabs UI replaced with flat single-form layout (only 'existing' flow remains)"
  - "quotes/new/actions.ts (re-export shim) deleted along with page since its only consumer was QuoteBuilderForm"
  - "Stale JSDoc comment in admin-queries.ts referencing /admin/quotes/new cleaned up (Rule 1 auto-fix)"

patterns-established:
  - "Cleanup tasks: always grep for all entry points (revalidatePath, navigation, JSDoc) before marking done"

requirements-completed: [CLEAN-01, CLEAN-02]

duration: 12min
completed: 2026-06-19
---

# Phase 18 Plan 01: Cleanup — Remove Forecast and Manual Quote Builder Routes Summary

**Deleted /admin/forecast and /admin/quotes/new routes with all entry points (sidebar, revalidatePath, navigation button, exclusive components) to clear the codebase for the Sales Loop AI phase.**

## Performance

- **Duration:** ~12 min
- **Started:** 2026-06-19T10:04:00Z
- **Completed:** 2026-06-19T10:16:00Z
- **Tasks:** 2
- **Files modified/deleted:** 11

## Accomplishments

- Removed Forecast route: deleted `src/app/admin/forecast/page.tsx`, removed sidebar nav entry and `TrendingUp` import, stripped 3 `revalidatePath("/admin/forecast")` calls from project-actions.ts
- Removed Quote Builder route: deleted `quotes/new/page.tsx`, `quotes/new/actions.ts`, and all 4 exclusive components (QuoteBuilderForm, OfferSelector, PriceOverrideInput, QuotePreview)
- Simplified SendQuoteModal from two-tab layout to single flat form — "Crea Nuovo" tab and `window.location` navigation removed entirely; "existing quote" flow unchanged
- Build passes clean: 0 TypeScript errors, 0 broken imports

## Task Commits

1. **Task 1: Rimuovi rotta Forecast** - `7d88409` (chore)
2. **Task 2: Rimuovi rotta Quote Builder** - `268f56c` (chore)

**Plan metadata:** (see final commit below)

## Files Created/Modified

- `src/components/admin/AdminSidebar.tsx` - Removed Forecast NAV_ITEMS entry and TrendingUp import
- `src/app/admin/projects/project-actions.ts` - Removed 3 revalidatePath("/admin/forecast") calls
- `src/components/admin/leads/SendQuoteModal.tsx` - Removed "Crea Nuovo" tab and quotes/new navigation
- `src/lib/admin-queries.ts` - Removed stale JSDoc comment referencing /admin/quotes/new

**Deleted:**
- `src/app/admin/forecast/page.tsx`
- `src/app/admin/quotes/new/page.tsx`
- `src/app/admin/quotes/new/actions.ts`
- `src/components/admin/quotes/QuoteBuilderForm.tsx`
- `src/components/admin/quotes/OfferSelector.tsx`
- `src/components/admin/quotes/PriceOverrideInput.tsx`
- `src/components/admin/quotes/QuotePreview.tsx`

## Decisions Made

- Kept `lib/forecast-queries.ts` and `lib/quote-actions.ts` intact — they have no broken imports and are tolerable deadweight; removing them was explicitly out of scope per the plan
- Deleted `quotes/new/actions.ts` (not listed in plan) because it was a server re-export shim with `QuoteBuilderForm` as its only consumer — Rule 3 auto-fix (would have blocked clean directory removal)
- Stale JSDoc comment in `admin-queries.ts` updated — Rule 1 auto-fix (stale reference counts as dead code)

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 1 - Bug] Removed stale JSDoc comment referencing deleted route**
- **Found during:** Task 2 (final grep verification)
- **Issue:** `admin-queries.ts` line 862 had a `* Used by: /admin/quotes/new form (OfferSelector dropdown)` comment — the route no longer exists
- **Fix:** Removed the stale line from the JSDoc block
- **Files modified:** src/lib/admin-queries.ts
- **Verification:** `grep -r "quotes/new" src/` → 0 results
- **Committed in:** 268f56c (Task 2 commit)

**2. [Rule 3 - Blocking] Deleted quotes/new/actions.ts (unlisted file)**
- **Found during:** Task 2 — directory was non-empty after deleting page.tsx
- **Issue:** `src/app/admin/quotes/new/actions.ts` was a re-export shim (`export { createQuote } from "@/lib/quote-actions"`) with QuoteBuilderForm as its only consumer. It would leave a broken directory if not removed.
- **Fix:** Confirmed no other consumers via grep, then deleted the file
- **Files modified:** src/app/admin/quotes/new/actions.ts (deleted)
- **Verification:** `grep -r "createQuote" src/` shows only lib/quote-actions.ts (the source) — no broken references
- **Committed in:** 268f56c (Task 2 commit)

---

**Total deviations:** 2 auto-fixed (1 Rule 1 stale comment, 1 Rule 3 blocking unlisted file)
**Impact on plan:** Both auto-fixes necessary for completeness and clean directory state. No scope creep.

## Issues Encountered

- A linter hook reverted `SendQuoteModal.tsx` after the first Write. On re-read, the linter had actually applied the intended changes (removed Tabs imports, removed tab state, flattened to single form). Confirmed the file was correct before staging.

## User Setup Required

None — no external service configuration required.

## Next Phase Readiness

- CLEAN-01 and CLEAN-02 complete: codebase is clear of forecast and manual quote builder dead routes
- Ready for Phase 21 (AI Quote Agent) which will provide the replacement quote creation flow
- `lib/forecast-queries.ts` and `lib/quote-actions.ts` remain as inert deadweight — can be cleaned in a future pass if desired

---
*Phase: 18-cleanup-consolidamento*
*Completed: 2026-06-19*

## Self-Check: PASSED

- `src/components/admin/AdminSidebar.tsx` — FOUND (modified)
- `src/app/admin/projects/project-actions.ts` — FOUND (modified)
- `src/components/admin/leads/SendQuoteModal.tsx` — FOUND (modified)
- `src/lib/admin-queries.ts` — FOUND (modified)
- `src/app/admin/forecast/page.tsx` — MISSING (deleted as intended)
- `src/app/admin/quotes/new/page.tsx` — MISSING (deleted as intended)
- Commit 7d88409 — FOUND
- Commit 268f56c — FOUND
- `grep -r "admin/forecast" src/` → 0 results
- `grep -r "quotes/new" src/` → 0 results
- Build: 0 errors
