Sort member lists by last name instead of first name
All checks were successful
Build And Push Image / docker (push) Successful in 2m11s

- Updated member-list.vue to sort by last name with new sort options
- Changed default sort to lastname-asc
- Added Last Name and First Name sort options in dropdown
- Updated board/members/index.vue to include name field and sort by last name
- Updated admin/members/index.vue to include name field and sort by last name
- All member lists now consistently sort alphabetically by last name
This commit is contained in:
2025-08-31 18:58:16 +02:00
parent ce7d5af450
commit c9e181e8a8
3 changed files with 57 additions and 8 deletions

View File

@@ -475,6 +475,8 @@ const loadMembers = async () => {
member_id: member.Id || member.id,
first_name: member.first_name,
last_name: member.last_name,
// Add name field for sorting (last name, first name format)
name: `${member.last_name || ''}, ${member.first_name || ''}`.trim(),
email: member.email,
membership_type: member.membership_type || 'Standard',
status: member.membership_status === 'Active' ? 'active' : 'inactive',
@@ -483,6 +485,21 @@ const loadMembers = async () => {
phone: member.phone_number || member.phone || ''
}));
// Sort by last name, then first name by default
members.value.sort((a, b) => {
const aLastName = (a.last_name || '').toLowerCase();
const bLastName = (b.last_name || '').toLowerCase();
const aFirstName = (a.first_name || '').toLowerCase();
const bFirstName = (b.first_name || '').toLowerCase();
// First compare by last name
const lastNameCompare = aLastName.localeCompare(bLastName);
if (lastNameCompare !== 0) return lastNameCompare;
// If last names are the same, compare by first name
return aFirstName.localeCompare(bFirstName);
});
// Calculate stats from real data
const now = new Date();
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);