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:
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user