feat: wire up real Supabase data to analytics dashboard

- Create src/actions/analytics.ts with real data fetching:
  - getAnalyticsMetrics() - revenue, orders, customers, AOV
  - getRevenueChart() - daily revenue data
  - getTopProducts() - product performance from reports RPC
  - getRecentOrders() - live orders from orders table
  - getCustomerGrowth() - contact growth stats
  - getConversionFunnel() - computed from order data

- Rewrite AnalyticsDashboard.tsx to:
  - Fetch real data from Supabase via brand-scoped RPCs
  - Show loading states and error handling
  - Display actual metrics from the database
  - Remove all mock data

- Add src/app/admin/analytics/page.tsx server component

All analytics now pull from real Supabase data instead of mock values.
This commit is contained in:
2026-06-02 06:38:44 +00:00
parent bcbf7be84f
commit 8dee63fef2
3 changed files with 656 additions and 192 deletions
+19
View File
@@ -0,0 +1,19 @@
import type { Metadata } from "next";
import { getCurrentAdminUser } from "@/actions/admin-user";
import AnalyticsDashboard from "@/components/admin/AnalyticsDashboard";
export const metadata: Metadata = {
title: "Analytics — Route Commerce Admin",
description: "Track your business performance and growth with real-time analytics.",
};
export default async function AnalyticsPage() {
const adminUser = await getCurrentAdminUser();
const effectiveBrandId = adminUser?.brand_id ?? undefined;
return (
<div className="p-6">
<AnalyticsDashboard brandId={effectiveBrandId} />
</div>
);
}