The Customers Management Tab provides administrators with a comprehensive interface to view and manage user accounts in the Liyo Salon booking system. It displays all registered users (both customers and admin accounts) with filtering and pagination capabilities.
- User List View: Display all registered users in a responsive table
- Search & Filter: Search by username, email, or name; filter by user type
- User Creation: Admin-only capability to create new user accounts
- Status Visibility: View active/inactive status of each user
- Pagination: Handle large user lists efficiently
- Responsive Design: Works on desktop and mobile devices
CustomersManagementTab.tsx # Main container component
├── CustomersManagement/
│ ├── index.ts # Barrel exports
│ ├── CustomersTable.tsx # User list table with pagination
│ ├── CustomersFilters.tsx # Search and filter controls
│ └── CustomerModal.tsx # New user creation modal
import CustomersManagementTab from './CustomersManagementTab'
// In your tab content
{activeTab === 'customers' && <CustomersManagementTab />}import CustomersManagementTab from '@/components/AdminComponents/CustomersManagementTab'
export default function CustomersPage() {
return <CustomersManagementTab />
}The component integrates with the User Service backend:
| Endpoint | Method | Description |
|---|---|---|
/api/v1/users |
GET | List all users (paginated) |
/api/v1/users |
POST | Create new user |
# .env.local
NEXT_PUBLIC_USER_SERVICE_URL=https://user-service-salon.azurewebsites.netinterface UserListResponse {
id: string
username: string
email: string
full_name?: string
phone?: string
user_type: 'user' | 'admin'
is_active: boolean
created_at: string
}interface PaginatedResponse {
users: UserListResponse[]
total: number
page: number
limit: number
total_pages: number
}interface UserCreateRequest {
username: string
email: string
password: string
full_name?: string
phone?: string
user_type: 'user' | 'admin'
}Provides search and filter capabilities:
- Search: Filter by username, email, or full name
- User Type: Filter by "All Users", "Customers Only", or "Admins Only"
- Refresh: Manual data refresh button
Displays user data in a responsive table:
- User avatar with icon (purple for admin, blue for customer)
- Username and display name
- Email with mail icon
- User type badge
- Active/Inactive status badge
- Join date
- Pagination controls
Form for creating new users with validation:
- Username (required, 3+ characters, alphanumeric)
- Email (required, valid format)
- Full name (optional)
- Phone (optional)
- User type selection (customer/admin)
- Password (required, 8+ chars, uppercase, lowercase, digit)
- Password confirmation
All API calls require admin authentication:
const token = localStorage.getItem('admin_token')
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}The component handles:
- API errors with user-friendly messages
- Network failures with retry capability
- Form validation errors with inline feedback
- Loading states during data fetch
When the API is unavailable, the component falls back to mock data for development:
const MOCK_USERS: UserListResponse[] = [
{
id: 'mock-1',
username: 'john_doe',
email: 'john@example.com',
full_name: 'John Doe',
user_type: 'user',
is_active: true,
created_at: '2024-01-15T08:00:00Z'
},
// ... more mock users
]