Admin Dashboard Components
Reusable components used throughout the admin dashboard.
Layout
Location: src/components/Layout.tsx
Main layout wrapper providing:
- Navigation sidebar
- Header with user info
- Content area
- Responsive design
Loader
Location: src/components/Loader.tsx
Loading indicator component.
Props:
size?: 'small' | 'medium' | 'large'fullScreen?: booleanmessage?: string
Usage:
<Loader fullScreen message="Loading..." />
<Loader size="small" />
ProtectedRoute
Location: src/components/ProtectedRoute.tsx
Route wrapper that requires authentication.
Common UI Elements
Buttons
btn-primary- Primary action buttonbtn-edit- Edit buttonbtn-cancel- Cancel buttonbtn-verify- Verify buttonbtn-unverify- Unverify button
Status Badges
status-badge- General status badgeactive/inactive- Status classesverified/unverified- Verification status
Form Elements
form-group- Form field wrapperform-row- Horizontal form rowsearch-input- Search input fieldfilter-select- Filter dropdown
Modals
modal-overlay- Modal backgroundmodal-content- Modal content containermodal-actions- Modal button container
Component Patterns
Loading States
All pages show loaders during data fetching:
if (loading) {
return <Loader fullScreen message="Loading..." />;
}
Error Handling
Errors are displayed using toast notifications:
toast.error(errorMessage);
toast.success('Operation successful');
Update Operations
All update operations now:
- Show loading indicators during the operation
- Disable buttons during processing
- Refresh data after successful updates
- Display success/error messages
Best Practices
- Reusable Components: Extract common UI into reusable components
- Loading States: Always show loading indicators
- Error Handling: Handle errors gracefully with user-friendly messages
- Consistent Styling: Use CSS classes for consistent styling
- Accessibility: Ensure proper ARIA labels and keyboard navigation