From e234dc29470e0027f766200e6556dd5a1a6844af Mon Sep 17 00:00:00 2001 From: Kelly Date: Wed, 3 Dec 2025 17:28:22 -0700 Subject: [PATCH] feat(frontend): rewire dashboard to use AZ data endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Main dashboard now uses /api/az/dashboard for dispensary, product, and brand counts instead of the legacy /api/dashboard/stats endpoint. This ensures the dashboard displays consistent data with the /az pages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/src/pages/Dashboard.tsx | 69 +++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx index b79bf188..07112b43 100755 --- a/frontend/src/pages/Dashboard.tsx +++ b/frontend/src/pages/Dashboard.tsx @@ -6,8 +6,7 @@ import { Package, Target, Image as ImageIcon, - MousePointer, - Shield, + Tag, TrendingUp, TrendingDown, RefreshCw, @@ -62,12 +61,42 @@ export function Dashboard() { const loadData = async () => { try { - const [statsData, activityData] = await Promise.all([ - api.getDashboardStats(), - api.getDashboardActivity() - ]); - setStats(statsData); - setActivity(activityData); + // Fetch AZ dashboard data (primary data source) + const azDashboard = await api.getDutchieAZDashboard(); + + // Map AZ dashboard data to the expected stats format + setStats({ + products: { + total: azDashboard.productCount, + in_stock: azDashboard.productCount, // All AZ products are in stock by default + with_images: 0 // Not tracked in AZ pipeline + }, + stores: { + total: azDashboard.dispensaryCount, + active: azDashboard.dispensaryCount // All are active in AZ + }, + brands: { + total: azDashboard.brandCount + }, + campaigns: { + active: 0, + total: 0 + }, + clicks: { + clicks_24h: azDashboard.snapshotCount24h // Use snapshots as activity metric + }, + failedJobs: azDashboard.failedJobCount, + lastCrawlTime: azDashboard.lastCrawlTime + }); + + // Try to fetch activity data (may fail if not authenticated) + try { + const activityData = await api.getDashboardActivity(); + setActivity(activityData); + } catch { + // Activity data requires auth, just skip it + setActivity(null); + } } catch (error) { console.error('Failed to load dashboard:', error); } finally { @@ -196,9 +225,9 @@ export function Dashboard() {
-

Active Stores

-

{stats?.stores?.active || 0}

-

{stats?.stores?.total || 0} total stores

+

Total Dispensaries

+

{stats?.stores?.total || 0}

+

{stats?.stores?.active || 0} active (crawlable)

@@ -242,33 +271,33 @@ export function Dashboard() { - {/* Clicks */} + {/* Snapshots (24h) */}
- +
-

Clicks (24h)

+

Snapshots (24h)

{stats?.clicks?.clicks_24h?.toLocaleString() || 0}

-

Last 24 hours

+

Product snapshots created

- {/* Proxies */} + {/* Brands */}
- +
-

Active Proxies

-

{stats?.proxies?.active || 0}

-

{stats?.proxies?.total || 0} total proxies

+

Brands

+

{stats?.brands?.total || stats?.products?.unique_brands || 0}

+

Unique brands tracked