The frontend was calling:
/api/admin/get-institution?institutionId=NRQywtfXzohZEl6rvT5B2jFb8oz2
But should have been calling:
/api/admin/get-institution?adminUserId=NRQywtfXzohZEl6rvT5B2jFb8oz2
The API expects adminUserId to look up which institution the admin owns!
- ✅ Changed API call to use
adminUserIdparameter - ✅ Handle 404 response gracefully (means no institution created yet)
- ✅ Fall back to personal stats if no institution exists
- ✅ Updated response parsing to match API structure
- Hard refresh (Ctrl + F5) on https://rretoriq25.web.app
- Navigate to Dashboard
FIRST TIME (No Institution Yet):
- Dashboard shows your personal stats (0 sessions, 0%, etc.)
- No institution banner appears
- Console shows:
⚠️ No institution found - admin needs to create institution first
AFTER Creating Institution:
- Go to
/admin/dashboard - Fill in:
- Institution Name: "MUJ"
- Seats Purchased: 100
- Click "Update Institution"
- Go back to
/dashboard - NOW you'll see:
- 🏢 Blue institution banner with "MUJ"
- Total Students count
- Aggregated stats from all students
You MUST create the institution first!
Steps:
- Click "Dashboard" in sidebar (to verify no errors)
- Click to
/admin/dashboardin the URL or from the admin portal - Fill in institution details
- Click "Update Institution"
- Return to
/dashboardto see the institution view
Try it now and let me know if the errors are gone! ✅