diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/AnalyticsView.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/AnalyticsView.tsx index 8aaf9b9b..bec0cd2a 100644 --- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/AnalyticsView.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/AnalyticsView.tsx @@ -4,10 +4,10 @@ import { useState } from "react"; import { motion } from "framer-motion"; import { Home, AlertTriangle, ToggleLeft, ToggleRight } from "lucide-react"; import { Card, CardContent } from "@/app/shadcn_components/ui/card"; -import ProgressOverview from "./ProgressOverview"; import SurveyedResultsPieChart from "./SurveyedResultsPieChart"; import DampMouldRiskPanel from "./DampMouldRiskPanel"; import CompletionTrendsChart from "./CompletionTrendsChart"; +import SurveyIssuesPanel from "./SurveyIssuesPanel"; import { STAGE_COLORS, STAGE_ORDER } from "./types"; import type { ProjectData, @@ -351,19 +351,6 @@ export default function AnalyticsView({ - {/* Row 3: Progress overview only (no donut chart) */} -
- - - -
- {/* Row 4: Pipeline Funnel */} + + {/* Row 6: Survey Issues */} + ); } diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/CompletionTrendsChart.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/CompletionTrendsChart.tsx index f510ea70..cdcc269d 100644 --- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/CompletionTrendsChart.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/CompletionTrendsChart.tsx @@ -1,7 +1,7 @@ "use client"; import { useState } from "react"; -import { Card, Title, LineChart, Legend } from "@tremor/react"; +import { Card, Title, BarChart, Legend } from "@tremor/react"; import { Button } from "@/app/shadcn_components/ui/button"; import { Input } from "@/app/shadcn_components/ui/input"; import { @@ -56,9 +56,14 @@ function formatMonday(isoDate: string): string { }); } -function aggregateByWeek(deals: ClassifiedDeal[], dateField: string) { +function aggregateByWeek( + deals: ClassifiedDeal[], + dateField: string, + filter?: (deal: ClassifiedDeal) => boolean, +) { const weekCounts: Record = {}; for (const deal of deals) { + if (filter && !filter(deal)) continue; const date = deal[dateField as keyof ClassifiedDeal] as | string | Date @@ -69,9 +74,11 @@ function aggregateByWeek(deals: ClassifiedDeal[], dateField: string) { const key = getMondayOfWeek(d); weekCounts[key] = (weekCounts[key] || 0) + 1; } - return Object.entries(weekCounts) - .sort(([a], [b]) => a.localeCompare(b)) - .map(([isoKey, value]) => ({ week: formatMonday(isoKey), value })); + const allKeys = fillWeekGaps(Object.keys(weekCounts)); + return allKeys.map((isoKey) => ({ + week: formatMonday(isoKey), + value: weekCounts[isoKey] ?? 0, + })); } // Fills all missing Monday ISO-date keys between min and max with 0s @@ -141,11 +148,18 @@ export default function CompletionTrendsChart({ const selectedMetric = METRICS.find((m) => m.key === metric)!; const isCoordination = metric === "coordination"; + const isDesign = metric === "design"; const coordData = isCoordination ? aggregateCoordinationByWeek(deals) : null; const singleData = isCoordination ? null - : aggregateByWeek(deals, selectedMetric.dateField); + : aggregateByWeek( + deals, + selectedMetric.dateField, + isDesign + ? (d) => d.designStatus?.toUpperCase() === "UPLOADED" + : undefined, + ); // Merge targets into non-coordination chart data const chartData = isCoordination @@ -227,7 +241,7 @@ export default function CompletionTrendsChart({ {isCoordination ? ( <> - ) : ( <> -