Skip to main content

Admin Dashboard

Route: /admin (also /(admin))
Files:

  • ayts-admin/app/(admin)/page.tsx (modern)
  • ayts-admin/app/admin/page.tsx (legacy)

Auth required: Yes — admin role (role: 'admin' in Supabase user metadata)

Purpose

Central overview of platform health. Shows key metrics, recent activity, and quick access to management sections.

Metric Cards

MetricAPI Source
Total StoresGET /api/admin/dashboard
Total ProductsGET /api/admin/dashboard
Total OrdersGET /api/admin/dashboard
Total UsersGET /api/admin/dashboard
Revenue (today / this week / this month)GET /api/admin/analytics
Active StoresGET /api/admin/dashboard
Pending Vendor ApplicationsGET /api/admin/dashboard

Recent Activity Feed

  • Latest 10 orders (store name, amount, time)
  • Recent user registrations
  • New vendor applications

Quick Actions

ActionLinks To
Verify Stores/admin/stores
Review Applications/admin/applications ⚠️ Not yet built
Manage Orders/admin/orders

Auth Flow

The admin panel authenticates via Supabase:

  1. Admin logs in at /auth/login
  2. Supabase returns session token
  3. All API calls include Authorization: Bearer {supabaseToken}
  4. requireAdmin middleware on /api/admin/* validates token + checks role: 'admin'
Admin role required

If the admin user does not have role: 'admin' in Supabase Auth → User Metadata, all /api/admin/* calls return 401 Unauthorized. Set this in Supabase dashboard → Authentication → Users → Edit User Metadata.

Known Issues / Status

ItemStatus
Real data from API✅ Fixed (no more hardcoded stats)
Admin auth token passed✅ Fixed in ayts-admin/lib/api.ts
Dashboard metrics load✅ Working
Pending applications count⚠️ Shows but no link to applications page
Page title⚠️ Generic "AYTS Admin - Dashboard" across all pages

Set dynamic page titles per route. In Next.js app router, add to each page:

export const metadata = { title: 'Dashboard — AYTS Admin' };
// orders: 'Orders — AYTS Admin'
// stores: 'Stores — AYTS Admin'