The Admin Panel is a comprehensive administrative interface for managing users and system operations. It features modern UI/UX with animations, responsive design, and full integration with the backend API.
- Secure admin login with JWT tokens
- Protected routes with automatic redirection
- Session management with local storage
- Password validation and error handling
- Real-time statistics and metrics
- Animated counters and progress indicators
- Recent activity monitoring
- Quick action shortcuts
- System status overview
- Comprehensive user listing with filtering
- Search functionality across all user fields
- Status badges for verification and profile completion
- Individual user actions (view, resend email, delete)
- Bulk operations support
- Single user creation with email verification
- Bulk user upload from files or manual entry
- Real-time validation and error feedback
- Success/failure reporting for batch operations
- Email template integration
- Admin profile management
- Password change functionality
- Notification preferences
- System configuration options
- Framer Motion animations - Smooth transitions and micro-interactions
- Lucide React icons - Consistent iconography
- Tailwind CSS - Responsive design with glassmorphism effects
- Dark theme - Professional admin interface
- Loading states - Skeleton loaders and spinners
- TypeScript - Full type safety
- React Hook Form - Efficient form handling
- Zod validation - Runtime type checking
- Custom hooks - Reusable logic separation
- Error boundaries - Graceful error handling
- Mobile-first approach
- Adaptive sidebar navigation
- Touch-friendly interactions
- Flexible grid layouts
- Optimized for all screen sizes
client/
├── app/admin/
│ ├── layout.tsx # Admin layout wrapper
│ ├── page.tsx # Root redirect
│ ├── login/page.tsx # Login form
│ ├── dashboard/page.tsx # Main dashboard
│ ├── users/page.tsx # User management
│ ├── create-user/page.tsx # User creation
│ └── settings/page.tsx # Admin settings
├── components/admin/
│ ├── admin-layout.tsx # Layout components
│ └── animations.tsx # Reusable animations
├── hooks/admin/
│ ├── use-admin-auth.tsx # Authentication context
│ └── use-admin-api.ts # API integration hooks
├── types/admin/
│ └── index.ts # TypeScript definitions
└── api/admin/
└── login/route.ts # API route handlers
POST /api/admin/login- Admin login
GET /api/admin/users- Get all usersPOST /api/admin/create-user- Create single userPOST /api/admin/create-bulk-users- Create multiple usersPOST /api/admin/resend-verification/:userId- Resend verificationDELETE /api/admin/user/:userId- Delete user
NEXT_API_PUBLIC_URL=http://localhost:5000/api
JWT_SECRET=your-jwt-secretCreate an admin account in your database:
const admin = new Admin({
email: 'admin@example.com',
password: 'secure-password',
name: 'Admin User',
role: 'admin'
});
await admin.save();Ensure your server has these dependencies:
bcryptjs- Password hashingjsonwebtoken- JWT token generationjoi- Request validation
- Navigate to
/admin/login - Enter admin credentials
- Access dashboard and features
- Go to "Create User" section
- Choose single or bulk creation
- Enter email addresses
- Users receive verification emails automatically
- View all users in "User Management"
- Use search and filters to find specific users
- Perform actions via dropdown menus
- Monitor user status with visual indicators
- JWT token-based authentication
- Password hashing with bcrypt
- Request validation with Joi schemas
- Protected routes with middleware
- CORS configuration
- Input sanitization
The admin panel uses CSS custom properties for easy theming:
:root {
--admin-primary: #8b5cf6;
--admin-secondary: #06b6d4;
--admin-accent: #10b981;
--admin-bg: #0f172a;
}Customize animations in components/admin/animations.tsx:
export const customAnimation = {
initial: { opacity: 0, scale: 0.9 },
animate: { opacity: 1, scale: 1 },
transition: { duration: 0.3 }
};- Login fails: Check JWT_SECRET and admin credentials
- API errors: Verify NEXT_API_PUBLIC_URL is correct
- Loading issues: Check network connectivity
- Style problems: Ensure Tailwind CSS is properly configured
Set NODE_ENV=development for detailed error messages.
- Follow TypeScript strict mode
- Use provided hooks for API calls
- Implement proper error handling
- Add loading states for all async operations
- Maintain responsive design principles
The admin panel is optimized for:
- Lazy loading of components
- Efficient re-renders with React hooks
- Minimal bundle size
- Fast API responses
- Smooth animations
- Chrome 90+
- Firefox 90+
- Safari 14+
- Edge 90+
Part of the TNP Profile Management System.