Conversation
…ges and add dashboard/profile - Add centralized axios client with runtime base URL setter (`src/lib/apiClient.ts`) - Implement auth service with login/register, create admin/employee, health/test endpoints and token management (`src/services/authService.ts`) - Implement user service covering all user controller endpoints (`src/services/userService.ts`) - Add dashboard and profile pages (`src/app/dashboard/page.tsx`, `src/app/profile/page.tsx`) - Wire login and register pages to authService and show loading/error UI (`src/app/auth/login/page.tsx`, `src/app/auth/register/page.tsx`) - Add TypeScript API types generated from OpenAPI (`src/types/api.ts`) - Add `.env.local.example` and `integration-report.md` with verification summary This commit integrates frontend pages with backend OpenAPI endpoints, centralizes API configuration for future gateway/Docker changes, and adds initial UI feedback for auth flows.
…rmation feat: Enhance dashboard page to render role-specific dashboards and improve loading states fix: Add request and response interceptors to apiClient for token management and error handling feat: Implement authService to manage login and token storage with logging feat: Create AdminDashboard component with management features and performance metrics feat: Create CustomerDashboard component for vehicle management and service history feat: Create EmployeeDashboard component with schedule and task management feat: Create SuperAdminDashboard component for system management and analytics
Implement comprehensive theme system and enhance authentication pages
There was a problem hiding this comment.
Pull Request Overview
This pull request implements a full-stack authentication and dashboard system for a TechTorque automotive service application. The changes establish API integration, user management services, and role-based dashboard components.
- Adds comprehensive TypeScript API types and service layers for authentication and user management
- Implements role-based dashboard components (SuperAdmin, Admin, Employee, Customer)
- Creates functional login/register pages with backend integration and error handling
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/api.ts | Defines TypeScript interfaces for API requests, responses, and user data models |
| src/services/userService.ts | Implements user management service with CRUD operations and role management |
| src/services/authService.ts | Provides authentication service with login, registration, and token management |
| src/lib/apiClient.ts | Creates Axios HTTP client with authentication interceptors and error handling |
| src/app/profile/page.tsx | Basic profile page displaying current user information |
| src/app/dashboard/page.tsx | Main dashboard with role-based component rendering and navigation |
| src/app/components/dashboards/*.tsx | Role-specific dashboard components with tailored UI and functionality |
| src/app/auth/login/page.tsx | Enhanced login page with backend integration and demo user credentials |
| src/app/auth/register/page.tsx | Enhanced registration page with form validation and error handling |
| package.json | Updates dependencies to include axios and js-cookie for API integration |
| .github/workflows/buildtest.yaml | Adds CI/CD workflow for automated building and testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Request interceptor to attach token | ||
| api.interceptors.request.use((config) => { | ||
| try { | ||
| const token = Cookies.get(TOKEN_COOKIE); | ||
| if (token && config.headers) { | ||
| config.headers['Authorization'] = `Bearer ${token}`; | ||
| } | ||
| } catch (err) { | ||
| // log to help debugging in production builds | ||
| console.warn('auth interceptor error', err); | ||
| } | ||
| return config; | ||
| }); | ||
|
|
There was a problem hiding this comment.
There is duplicate request interceptor logic between authService.ts and apiClient.ts. The token attachment logic should be centralized in one place to avoid maintenance issues and potential inconsistencies.
| // Request interceptor to attach token | |
| api.interceptors.request.use((config) => { | |
| try { | |
| const token = Cookies.get(TOKEN_COOKIE); | |
| if (token && config.headers) { | |
| config.headers['Authorization'] = `Bearer ${token}`; | |
| } | |
| } catch (err) { | |
| // log to help debugging in production builds | |
| console.warn('auth interceptor error', err); | |
| } | |
| return config; | |
| }); |
| // Add a request interceptor to include the auth token | ||
| client.interceptors.request.use( | ||
| (config) => { | ||
| const token = Cookies.get('tt_access_token'); |
There was a problem hiding this comment.
The token cookie name is hardcoded as 'tt_access_token' here but defined as TOKEN_COOKIE constant in authService.ts. This should use the same constant to avoid inconsistencies.
| (error) => { | ||
| if (error.response?.status === 401) { | ||
| // Clear token and redirect to login | ||
| Cookies.remove('tt_access_token'); |
There was a problem hiding this comment.
The token cookie name is hardcoded again. This should reference the same TOKEN_COOKIE constant used in authService.ts to maintain consistency.
No description provided.