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
| Metric | API Source |
|---|---|
| Total Stores | GET /api/admin/dashboard |
| Total Products | GET /api/admin/dashboard |
| Total Orders | GET /api/admin/dashboard |
| Total Users | GET /api/admin/dashboard |
| Revenue (today / this week / this month) | GET /api/admin/analytics |
| Active Stores | GET /api/admin/dashboard |
| Pending Vendor Applications | GET /api/admin/dashboard |
Recent Activity Feed
- Latest 10 orders (store name, amount, time)
- Recent user registrations
- New vendor applications
Quick Actions
| Action | Links To |
|---|---|
| Verify Stores | /admin/stores |
| Review Applications | /admin/applications ⚠️ Not yet built |
| Manage Orders | /admin/orders |
Auth Flow
The admin panel authenticates via Supabase:
- Admin logs in at
/auth/login - Supabase returns session token
- All API calls include
Authorization: Bearer {supabaseToken} requireAdminmiddleware on/api/admin/*validates token + checksrole: '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
| Item | Status |
|---|---|
| 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 |
Recommended Fix
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'