fix: Use server-provided displayName for beneficiaries list

When customName is NULL, originalName should be shown.
Now uses beneficiary.displayName from server instead of
local computation (customName || name).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Sergei 2026-01-22 13:40:21 -08:00
parent 9e77a8e059
commit f8939a6817

View File

@ -89,8 +89,8 @@ function BeneficiaryCard({ beneficiary, onPress, onActivate }: BeneficiaryCardPr
const statusConfig = equipmentStatus ? equipmentStatusConfig[equipmentStatus as keyof typeof equipmentStatusConfig] : equipmentStatusConfig.none;
// Display name: customName (e.g., "Mom") if set, otherwise full name
const displayName = beneficiary.customName || beneficiary.name;
// Use server-provided displayName (customName || originalName)
const displayName = beneficiary.displayName;
// Check if avatar is valid (not empty, null, or placeholder)
const hasValidAvatar = beneficiary.avatar &&
@ -226,7 +226,6 @@ export default function HomeScreen() {
}
// Show error when API fails
const errorMessage = response.error?.message || 'Failed to load beneficiaries';
console.error('[HomeScreen] Failed to load beneficiaries:', errorMessage);
setError(errorMessage);
setBeneficiaries([]);
}
@ -241,7 +240,6 @@ export default function HomeScreen() {
return;
}
} catch (err) {
console.error('Failed to load beneficiaries:', err);
setError('Failed to load beneficiaries');
setBeneficiaries([]);
} finally {
@ -263,10 +261,9 @@ export default function HomeScreen() {
const handleActivate = (beneficiary: Beneficiary) => {
setCurrentBeneficiary(beneficiary);
const lovedOneName = beneficiary.customName || beneficiary.name;
router.push({
pathname: '/(auth)/activate',
params: { lovedOneName, beneficiaryId: beneficiary.id.toString() },
params: { lovedOneName: beneficiary.displayName, beneficiaryId: beneficiary.id.toString() },
});
};