114 lines
5.0 KiB
Markdown
114 lines
5.0 KiB
Markdown
---
|
|
phase: 18-cleanup-consolidamento
|
|
plan: "02"
|
|
subsystem: ui
|
|
tags: [nextjs, analytics, dashboard, react, tailwind]
|
|
|
|
# Dependency graph
|
|
requires:
|
|
- phase: analytics-queries
|
|
provides: getAnalyticsByYear, getMonthlyCollected, getAvailableYears, getTimeByClient, getTotalTrackedHours
|
|
provides:
|
|
- Admin dashboard at /admin integrates annual statistics (MetricCard, MonthlyChart, time tracking per client)
|
|
- /admin/analytics route deleted — returns 404
|
|
- YearSelector navigates to /admin?year=Y
|
|
affects: [18-cleanup-consolidamento, admin-ui, analytics]
|
|
|
|
# Tech tracking
|
|
tech-stack:
|
|
added: []
|
|
patterns:
|
|
- Server page accepts searchParams for year filtering
|
|
- Analytics queries co-located with dashboard queries in same async page
|
|
|
|
key-files:
|
|
created: []
|
|
modified:
|
|
- src/app/admin/page.tsx
|
|
- src/components/admin/YearSelector.tsx
|
|
deleted:
|
|
- src/app/admin/analytics/page.tsx
|
|
|
|
key-decisions:
|
|
- "Unified fmtEur to accept number (analytics version); KPI card callers wrapped with parseFloat() for string DB values"
|
|
- "Two separate awaits in AdminDashboard: getDashboardStats() first, then analytics Promise.all — acceptable for clarity"
|
|
- "Stale .next cache (OfferSelector.tsx reference) cleared before final build — pre-existing issue, not introduced by this plan"
|
|
|
|
patterns-established:
|
|
- "Statistics section appended after activity feed — existing dashboard structure preserved above new section"
|
|
|
|
requirements-completed:
|
|
- CLEAN-03
|
|
|
|
# Metrics
|
|
duration: 15min
|
|
completed: 2026-06-19
|
|
---
|
|
|
|
# Phase 18 Plan 02: Consolidate Analytics Dashboard Summary
|
|
|
|
**Merged /admin/analytics statistics (MetricCard, MonthlyChart, per-client time tracking) into /admin dashboard and deleted the duplicate route**
|
|
|
|
## Performance
|
|
|
|
- **Duration:** ~15 min
|
|
- **Started:** 2026-06-19T10:04:00Z
|
|
- **Completed:** 2026-06-19T10:19:00Z
|
|
- **Tasks:** 2
|
|
- **Files modified:** 3 (2 modified, 1 deleted)
|
|
|
|
## Accomplishments
|
|
- AdminDashboard now shows annual statistics section below activity feed: MetricCard economic metrics, MonthlyChart, and per-client time tracking bars
|
|
- /admin/analytics route deleted — navigating there returns 404
|
|
- YearSelector updated to navigate to /admin?year=Y instead of /admin/analytics?year=Y
|
|
- fmtEur unified to number-accepting version (more robust); existing KPI card string values wrapped with parseFloat()
|
|
|
|
## Task Commits
|
|
|
|
1. **Task 1: Integra statistiche annuali nella Dashboard** — included in `14bdbab` (feat)
|
|
2. **Task 2: Elimina rotta /admin/analytics** — included in `14bdbab` (feat)
|
|
|
|
**Plan metadata:** (docs commit below)
|
|
|
|
## Files Created/Modified
|
|
- `src/app/admin/page.tsx` — Added analytics imports, searchParams, analytics queries, MetricCard, fmtSeconds, fmtEur(number), statistics section
|
|
- `src/components/admin/YearSelector.tsx` — Updated router.push from /admin/analytics to /admin
|
|
- `src/app/admin/analytics/page.tsx` — Deleted
|
|
|
|
## Decisions Made
|
|
- Unified `fmtEur` to the `number` version from analytics (cleaner, no `parseFloat` internally). Updated the two KPI card callers that received string values from DB to pass `parseFloat(kpi.revenueTotale)` and `parseFloat(kpi.pagamentiInSospeso)`.
|
|
- Used two sequential awaits (getDashboardStats first, then analytics Promise.all) rather than one large combined Promise.all — avoids mixing query concerns and follows plan guidance for acceptable two-await pattern.
|
|
- Preserved all existing dashboard content (FollowUpWidget, KPI cards, activity feed) exactly; statistics section appended at the bottom with `mt-10`.
|
|
|
|
## Deviations from Plan
|
|
|
|
### Auto-fixed Issues
|
|
|
|
**1. [Rule 3 - Blocking] Cleared stale .next cache referencing deleted OfferSelector.tsx**
|
|
- **Found during:** Build verification after Task 2
|
|
- **Issue:** Stale `.next/tsconfig.tsbuildinfo` incremental cache listed `src/components/admin/quotes/OfferSelector.tsx` as a root file. That file had been deleted in a prior session. TypeScript errored with "File not found — root file specified for compilation." The pre-existing cache was masking this because prior builds hit cached output.
|
|
- **Fix:** Ran `rm -rf .next` to clear the stale incremental cache, then rebuilt clean.
|
|
- **Files modified:** .next/ (cache only — not tracked in git)
|
|
- **Verification:** Clean build passes with TypeScript check and all routes compiled correctly.
|
|
- **Committed in:** n/a (cache not committed)
|
|
|
|
---
|
|
|
|
**Total deviations:** 1 auto-fixed (Rule 3 - blocking)
|
|
**Impact on plan:** Required to get a clean build. Pre-existing issue unrelated to this plan's scope. .next/ is gitignored so no source changes.
|
|
|
|
## Issues Encountered
|
|
- Stale `.next` incremental TypeScript cache referenced `OfferSelector.tsx` (deleted in a prior session). Cleared cache, rebuilt clean. Build passes correctly.
|
|
|
|
## User Setup Required
|
|
None - no external service configuration required.
|
|
|
|
## Next Phase Readiness
|
|
- /admin is the single analytics entry point — ready for 18-03 and any future admin UI work
|
|
- No stale routes remain in the analytics path
|
|
- Build is clean
|
|
|
|
---
|
|
*Phase: 18-cleanup-consolidamento*
|
|
*Completed: 2026-06-19*
|