fix: use smart default for displayField based on entityType

When displayField is omitted in award definitions, the backend now
selects the appropriate default field based on the entityType:
- dxcc → entity (country name)
- state → state
- grid → grid (4-character)
- callsign → callsign

Previously, it used a fixed fallback order that prioritized entity
over other fields, causing grid-based awards to show DXCC names.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-23 14:14:05 +01:00
parent 2ae47232cb
commit a35731f626
4 changed files with 24 additions and 6 deletions

View File

@@ -896,7 +896,19 @@ export async function getAwardEntityBreakdown(userId, awardId) {
}
displayName = String(rawValue || entity);
} else {
displayName = qso.entity || qso.state || qso.grid || qso.callsign || String(entity);
// Smart default based on entityType when displayField is not specified
const defaultDisplayField = {
'dxcc': 'entity',
'state': 'state',
'grid': 'grid',
'callsign': 'callsign'
}[rules.entityType] || 'entity';
let rawValue = qso[defaultDisplayField];
if (defaultDisplayField === 'grid' && rawValue && rawValue.length > 4) {
rawValue = rawValue.substring(0, 4);
}
displayName = String(rawValue || entity);
}
if (!slotMap.has(slotKey)) {