A comprehensive React TypeScript frontend for managing employees, departments, roles, and permissions with advanced role-based access control.
Didi is a feature-rich Employee Management System frontend built with React, TypeScript, and Tailwind CSS. It provides complete role-based access control with three user types (ADMIN, MANAGER, USER) and integrates seamlessly with a Spring Boot backend using comprehensive REST APIs.
- JWT-based authentication with secure token management
- Role-based access control (ADMIN, MANAGER, USER)
- Secure login and registration with validation
- Password change functionality
- Automatic token refresh handling
- Server-side logout integration
- ADMIN: Full CRUD operations on employees
- MANAGER: Read-only access to all employees
- USER: View and edit own profile only
- Advanced employee search and filtering
- Pagination with customizable page sizes
- Department-based filtering
- Detailed employee profiles with comprehensive information
- Employee creation and editing forms with validation
- Salary management and hire date tracking
- ADMIN: Full CRUD operations on departments
- MANAGER: Read-only access to departments
- Department listing with inline editing
- Department creation with code validation
- Real-time validation and error handling
- Comprehensive user profile editing
- Employee information integration
- Password change functionality
- Role-specific field access
- Real-time form validation
- Role Management: Create, edit, delete system roles
- Permission Management: Manage fine-grained permissions
- Role-Permission Assignment: Flexible permission assignment
- Advanced admin controls
- System administration tools
- Admin Dashboard: System statistics, recent hires, employee counts, admin tools
- Manager Dashboard: Team overview, department statistics, employee metrics
- User Dashboard: Personal profile, quick actions, employee information
- Frontend: React 19.1.0 with TypeScript
- Routing: React Router DOM 7.6.3 with protected routes
- Styling: Tailwind CSS 3.3.5 with custom components
- Forms: React Hook Form 7.53.0 with advanced validation
- HTTP Client: Axios 1.10.0 with interceptors
- Notifications: React Hot Toast 2.4.1
- Icons: Heroicons React 2.1.1
- UI Components: Headless UI 2.1.0
- State Management: React Context with role-based permissions
src/
βββ components/
β βββ auth/ # Authentication components
β β βββ LoginForm.tsx
β β βββ SignupForm.tsx
β βββ common/ # Shared components
β β βββ ProtectedRoute.tsx
β β βββ ToastProvider.tsx
β βββ layout/ # Layout components
β βββ DashboardLayout.tsx
β βββ Sidebar.tsx
βββ context/
β βββ AuthContext.tsx # Advanced authentication context
βββ pages/ # Complete page components
β βββ AdminPanel.tsx # Role & permission management
β βββ DashboardPage.tsx # Role-based dashboards
β βββ DepartmentListPage.tsx
β βββ EmployeeDetailsPage.tsx
β βββ EmployeeFormPage.tsx
β βββ EmployeeListPage.tsx
β βββ LoginPage.tsx
β βββ ProfilePage.tsx
β βββ SignupPage.tsx
βββ services/ # Complete API services
β βββ api.ts # Advanced Axios configuration
β βββ auth.ts # Authentication services
β βββ departmentService.ts
β βββ employeeService.ts
β βββ permissionService.ts
β βββ roleService.ts
β βββ userProfileService.ts
βββ types/ # Comprehensive TypeScript definitions
β βββ index.ts
βββ App.tsx # Advanced routing with role protection
- Node.js 16.x or higher
- npm or yarn
- Spring Boot backend running on
http://localhost:9090
- Clone the repository
git clone <repository-url>
cd didi- Install dependencies
npm install- Configure environment variables (optional)
Create a
.envfile in the root directory:
REACT_APP_API_BASE_URL=http://localhost:9090
REACT_APP_JWT_TOKEN_KEY=employee_management_token
REACT_APP_REFRESH_TOKEN_KEY=employee_management_refresh_token- Start the development server
npm startThe application will open at http://localhost:3000.
Use these credentials to test different user roles:
| Role | Username | Password | Access Level |
|---|---|---|---|
| Admin | admin | admin123 | Full system access + Admin Panel |
| Manager | manager | manager123 | Read-only access to employees/departments |
| User | user | user123 | Personal profile access only |
- Employee Management: Create, read, update, delete all employees
- Department Management: Full CRUD operations on departments
- Role Management: Create and manage system roles
- Permission Management: Assign and manage permissions
- Admin Panel: Access to advanced administration tools
- System Statistics: View comprehensive system analytics
- All Navigation: Access to all application areas
- Employee Viewing: Read-only access to all employee profiles
- Department Viewing: Read-only access to all departments
- Team Statistics: Access to team and department analytics
- Limited Navigation: Employee and department sections only
- No CRUD Operations: Cannot create, edit, or delete records
- Personal Profile: View and update own information
- Limited Editing: Can only edit phone number and basic profile
- Employee Info: View own employee record (if exists)
- Minimal Navigation: Dashboard and profile only
- No System Access: Cannot view other users or system data
- Login Page: JWT authentication with comprehensive validation
- Signup Page: User registration with password requirements and validation
- Admin Dashboard: System overview, employee metrics, recent hires, quick actions
- Manager Dashboard: Team statistics, department breakdown, employee summary
- User Dashboard: Personal information, profile summary, quick actions
- Employee List: Advanced pagination, search, department filtering
- Employee Details: Comprehensive employee information display
- Employee Form: Create/edit forms with extensive validation
- Profile Management: Personal profile editing with role-based permissions
- Department List: Inline editing, modal-based CRUD operations
- Department Forms: Creation and editing with code validation
- Department Assignment: Employee-department relationship management
- Role Management: Create, edit, delete system roles
- Permission Assignment: Flexible permission-role mapping
- System Administration: Advanced admin controls
- User Role Assignment: Manage user role assignments
The frontend integrates with the Spring Boot backend using these endpoint modules:
POST /auth/login // User login with JWT
POST /auth/register // User registration
POST /auth/logout // Server-side logout
POST /auth/refresh-token // Token refresh
POST /auth/change-password // Password changeGET /api/v1/employees // Paginated employee list
GET /api/v1/employees/search // Employee search
GET /api/v1/employees/{id} // Employee details
GET /api/v1/employees/profile // Current user profile
GET /api/v1/employees/department/{id} // Employees by department
POST /api/v1/employees // Create employee (ADMIN)
PUT /api/v1/employees/{id} // Update employee (ADMIN)
PUT /api/v1/employees/profile // Update own profile
DELETE /api/v1/employees/{id} // Delete employee (ADMIN)GET /api/v1/departments // All departments
GET /api/v1/departments/{id} // Department details
POST /api/v1/departments // Create department (ADMIN)
PUT /api/v1/departments/{id} // Update department (ADMIN)
DELETE /api/v1/departments/{id} // Delete department (ADMIN)GET /users/me // Current user profile
PUT /users/me // Update user profileGET /api/roles // All roles
GET /api/roles/{id} // Role details
POST /api/roles // Create role
PUT /api/roles/{id} // Update role
DELETE /api/roles/{id} // Delete roleGET /api/permissions // All permissions
GET /api/permissions/{id} // Permission details
POST /api/permissions // Create permission
PUT /api/permissions/{id} // Update permission
DELETE /api/permissions/{id} // Delete permission- Responsive Design: Mobile-first design with tablet and desktop optimization
- Role-based Navigation: Dynamic sidebar and menu based on user permissions
- Advanced Loading States: Skeleton screens and progress indicators
- Comprehensive Error Handling: Toast notifications and error boundaries
- Real-time Form Validation: Instant feedback with detailed error messages
- Consistent Design System: Tailwind CSS with custom component library
- Accessibility: WCAG 2.1 compliant interface
- Performance Optimized: Code splitting and lazy loading
- Authentication State: Global auth context with role checking
- Permission System: Granular permission checking utilities
- Token Management: Automatic JWT handling with refresh logic
- Error Handling: Centralized error management with user feedback
- Form State: Advanced form management with validation
- API Caching: Intelligent caching for improved performance
- Code Splitting: Optimized bundle sizes with lazy loading
- JWT Security: Secure token storage and automatic refresh
- API Interceptors: Request/response interceptors for error handling
- CSRF Protection: Cross-site request forgery protection
- Input Validation: Client and server-side validation
- Error Boundaries: Graceful error handling and recovery
The project includes comprehensive testing setup:
- React Testing Library: Component testing
- Jest: Unit testing framework
- TypeScript: Type safety and IntelliSense
- ESLint: Code quality and consistency
Run tests:
npm testBuild for production:
npm run build-
API Connection Issues
- Ensure backend is running on
http://localhost:9090 - Check CORS configuration on backend
- Verify API endpoints match documentation
- Check network tab for failed requests
- Ensure backend is running on
-
Authentication Problems
- Clear localStorage:
localStorage.clear() - Check JWT token expiration
- Verify user credentials and roles
- Check browser console for auth errors
- Clear localStorage:
-
Permission Issues
- Verify user roles in JWT token
- Check role-based route protection
- Ensure proper permission assignment
- Review admin panel configuration
-
Build Errors
- Clear
node_modules:rm -rf node_modules && npm install - Check TypeScript configuration
- Verify all imports are correct
- Update dependencies if needed
- Clear
- Real-time notifications with WebSocket
- Advanced analytics and reporting
- Bulk operations for employee management
- CSV/Excel import/export functionality
- Advanced search with filters
- Activity logging and audit trails
- Multi-tenant support
- Advanced dashboard customization
- Email notification system
- Mobile app (React Native)
- PWA capabilities with offline support
- Advanced caching strategies
- Performance monitoring
- E2E testing with Cypress
- Internationalization (i18n)
- Dark mode theme
- Advanced accessibility features
- SEO optimization
For complete API documentation, see API_ENDPOINTS_REFERENCE.md which includes:
- All endpoint specifications
- Request/response examples
- Error handling guidelines
- Authentication requirements
- Role-based access details
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
For support and questions:
- Create an issue in the repository
- Check the API documentation
- Review the troubleshooting guide
- Contact the development team
Built with β€οΈ using React, TypeScript, and Tailwind CSS
A complete, production-ready Employee Management System with advanced role-based access control.