This implementation provides different dashboard views based on user roles fetched from the profiles table.
- Full KPI Cards: Total Bookings, Pending Approvals, Occupancy Rate, Completed Bookings
- Advanced Charts: All chart types including trends, pie charts, donut charts
- Detailed Analytics: Recent activity, hall status, utilization metrics
- Additional Stats: Rejected bookings, average utilization, available halls, peak usage hours
- Simplified View: Focus on essential charts and data
- Core Charts: Booking trends, status charts, hall utilization
- Recent Information: Recent bookings and hall status
- No Administrative KPIs: Removes admin-specific metrics for cleaner user experience
src/lib/fetchProfileServer.ts- Server-side profile fetching with rolesrc/components/custom/AdminDashboard.tsx- Full admin dashboard componentsrc/components/custom/UserDashboard.tsx- Simplified user dashboard componentsrc/components/custom/RoleIndicator.tsx- Visual indicator of current role and dashboard typesrc/app/dashboard/page.tsx- Updated main dashboard page with role-based renderingsrc/types/profile.ts- Added ProfileWithRole type
- ADMIN: Gets the full-featured dashboard with all KPI cards and admin features
- USER, GUEST, SYSTEM: Gets the simplified dashboard focused on basic charts and information
- Error Handling: Displays error message if profile cannot be fetched
- Uses existing
profilestable withrolefield - Requires user to be authenticated and have a profile record
- Supports roles:
GUEST,USER,ADMIN,SYSTEM(as defined in database schema)
The dashboard automatically detects the user's role from the database and renders the appropriate view. Users don't need to navigate to different URLs - the same /dashboard route shows different content based on their role.
To test different roles:
- Update a user's role in the
profilestable in your database - Log in as that user
- Navigate to
/dashboard - The role indicator at the top will show which dashboard view is active