lavoce #2

Merged
yogiedigital merged 118 commits from lavoce into main 2025-10-20 04:06:02 +00:00
Owner

update new

update new
yogiedigital added 118 commits 2025-10-20 04:05:49 +00:00
- Add getAllRole API import to fetch roles dynamically
- Add roleList and loadingRoles state management
- Implement fetchRoles function to get all roles from API
- Update Select component to display roles dynamically from database
- Display role format: Role Name (Level X)
- Add loading indicator while fetching roles
- Fetch roles automatically when modal opens
- Add helper function capitalizeFirstLetter for consistent formatting
- Add helper function getRoleColor to determine tag color by role_level or role_name
- Refactor role_name column render to use dynamic helpers
- Replace 30+ lines of hardcoded conditions with 8 lines of clean code
- Support any role name from database without code changes
- Display role names with first letter capitalized
- Color mapping: Level 1=purple, Level 2=blue, Level 3=cyan, Level 4=green
- Add KeyOutlined icon import for change password feature
- Fix getAllRole endpoint from roles/roles to roles
- Fix getRoleById endpoint from roles/roles/:id to roles/:id
- Fix createRole endpoint from roles/roles to roles
- Fix updateRole endpoint from roles/roles/:id to roles/:id
- Fix deleteRole endpoint from roles/roles/:id to roles/:id
- Add try-catch error handling in getAllRole
- Support both server-side and client-side pagination

This fixes SQL error: Conversion failed when converting the nvarchar value 'roles' to data type int
Backend was interpreting duplicate /roles as an ID parameter
- Add support for server-side pagination from backend
- Maintain client-side pagination as fallback
- Filter out super admin users (is_sa = true or 1) in both paths
- Add comprehensive error handling with try-catch
- Add console logging for debugging
- Return standardized response structure
- Handle both boolean and integer values for is_sa field
- Recalculate pagination info after filtering SA users

API now supports both backend pagination and ensures SA users are always hidden from the list
Add ChangePasswordModal component:
- Create modal with new password and confirmation fields
- Implement password validation (min 8 chars, uppercase, lowercase, number, special char)
- Add real-time error validation and display
- Show password requirements info box
- Display username for confirmation
- Add loading state during password change
- Success/error notifications

Update IndexUser:
- Add state management for change password modal
- Pass props to ListUser and ChangePasswordModal
- Integrate ChangePasswordModal component

Update ListUser:
- Add KeyOutlined icon for change password button
- Add purple change password button in action column
- Implement showChangePasswordModal function
- Update columns to include change password handler
- Increase action column width to 18%

API endpoint: PUT /api/user/change-password/:id
- Add support for backend pagination with current_page, current_limit, total_limit, total_page
- Handle multiple sources for total count (total_data, rows, data.length)
- Transform backend paging structure to frontend format
- Maintain client-side pagination as fallback
- Add comprehensive error handling with try-catch
- Add detailed console logging for debugging
- Map backend fields: current_page->page, current_limit->limit, total_limit->total
- Calculate total_page if not provided by backend

Backend response format: GET /api/device?page=1&limit=10
Supports both server-side and client-side pagination modes
- Update defaultFilter to use criteria instead of search
- Update handleSearch to use criteria parameter
- Update handleSearchClear to use criteria parameter
- Update auto-clear onChange to use criteria parameter

API endpoint now uses: /api/user?page=1&limit=10&criteria=keyword
- Update defaultFilter to use criteria instead of search
- Update handleSearch to use criteria parameter
- Update handleSearchClear to use criteria parameter
- Update auto-clear onChange to use criteria parameter

API endpoint now uses: /api/device?page=1&limit=10&criteria=keyword
- Update defaultFilter to use criteria instead of search
- Update handleSearch to use criteria parameter
- Update handleSearchClear to use criteria parameter
- Update auto-clear onChange to use criteria parameter

API endpoint now uses: /api/roles?page=1&limit=10&criteria=keyword
yogiedigital merged commit 56e3ce78a6 into main 2025-10-20 04:06:02 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: yogiedigital/cod-fe#2
No description provided.