-
- {deltaLabel}
- vs Last Month
-
+
+ {resolvedTrend === "up" && }
+ {resolvedTrend === "down" && }
+ {deltaLabel}
)
}
-
-
diff --git a/src/pages/DashboardPage.tsx b/src/pages/DashboardPage.tsx
index d44449b..b0ec911 100644
--- a/src/pages/DashboardPage.tsx
+++ b/src/pages/DashboardPage.tsx
@@ -20,9 +20,6 @@ import {
Area,
AreaChart,
CartesianGrid,
- Cell,
- Pie,
- PieChart,
ResponsiveContainer,
Tooltip,
XAxis,
@@ -30,6 +27,14 @@ import {
} from "recharts"
import { RevenueTrendCard } from "../components/dashboard/RevenueTrendCard"
import { StatCard } from "../components/dashboard/StatCard"
+import {
+ ActivePlansBreakdownCard,
+ RenewalRateCard,
+ DonutBreakdownCard,
+ analyticsSoftCardClass,
+ labelCountsToPieSlices,
+ SUBSCRIPTION_CHART_COLORS,
+} from "../components/analytics/SubscriptionRevenueVisuals"
import alertSrc from "../assets/Alert.svg"
import { Badge } from "../components/ui/badge"
import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"
@@ -39,9 +44,9 @@ import { getTeamMemberById } from "../api/team.api"
import { getDashboard } from "../api/analytics.api"
import { getSubscriptionPlans } from "../api/subscription-plans.api"
import { getRatingSummary, listRatingsByTarget } from "../api/ratings.api"
-import { useEffect, useState } from "react"
+import { useEffect, useState, type ReactNode } from "react"
import { Link } from "react-router-dom"
-import { AnalyticsTimeRangeFilter } from "../components/analytics/AnalyticsTimeRangeFilter"
+import { AnalyticsTimeRangeFilter, getDashboardFilterLabel } from "../components/analytics/AnalyticsTimeRangeFilter"
import {
getPrimaryQuestionTypeSummary,
getSeriesPeriodLabel,
@@ -55,7 +60,20 @@ import { formatPlanDuration } from "../lib/subscriptionPlans"
import type { SubscriptionPlan } from "../types/subscription.types"
import type { Rating, RatingSummary } from "../types/ratings.types"
-const PIE_COLORS = ["#9E2891", "#FFD23F", "#1DE9B6", "#C26FC0", "#6366F1", "#F97316", "#14B8A6", "#EF4444"]
+const PIE_COLORS = SUBSCRIPTION_CHART_COLORS
+const CHART_BRAND = SUBSCRIPTION_CHART_COLORS[0]
+const chartTooltipStyle = {
+ borderRadius: 10,
+ border: "1px solid #E8E8E8",
+ boxShadow: "0 8px 24px rgba(0,0,0,0.08)",
+ fontSize: 12,
+}
+
+function DashboardSectionTitle({ children }: { children: ReactNode }) {
+ return (
+
{children}
+ )
+}
function formatDate(dateStr: string) {
const d = new Date(dateStr)
@@ -173,31 +191,59 @@ export function DashboardPage() {
? getSubscriptionMetrics(dashboard.subscriptions)
: null
+ const generatedAt = dashboard
+ ? new Date(dashboard.generated_at).toLocaleString("en-US", {
+ month: "short",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ })
+ : ""
+
+ const registrationPeakIndex = registrationData.reduce((best, row, idx) => {
+ return row.count > (registrationData[best]?.count ?? 0) ? idx : best
+ }, 0)
+
return (
-
-
-
- Welcome, {userFirstName || localStorage.getItem("user_first_name")}
+
+
+
+
+ Dashboard
+
+
+ Welcome back, {userFirstName || localStorage.getItem("user_first_name") || "there"}
+
+
+ Snapshot for {getDashboardFilterLabel(filters)}
+ {dashboard ? ` · Updated ${generatedAt}` : ""}
+
+
+
+
+ Full analytics →
+
+
+
{loading ? (
-
+
Loading dashboard…
) : !dashboard ? (
-
+
Failed to load dashboard data.
) : (
<>
- {/* Stat tabs */}
-
+