feat: strip state prefixes from city values and format as title case in profile displays

This commit is contained in:
pradeepkumar
2026-04-15 23:44:44 +05:30
parent d764fe02c9
commit c60978aea1
2 changed files with 25 additions and 5 deletions

View File

@@ -377,11 +377,25 @@ export function mapFieldValuesToProfileCard(fieldValues: FieldValueResponse[]):
const cityValue = getFieldValue(fieldValues, 'city');
const stateValue = getFieldValue(fieldValues, 'state');
// City values carry a state prefix (e.g. "ne_adams") — strip before formatting
const stripCityPrefix = (value: unknown): string | null => {
const toPretty = (s: string) =>
s.replace(/^[a-z]{2}_/i, '')
.split('_')
.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
.join(' ');
if (Array.isArray(value) && value.length > 0) {
return value.map((v) => toPretty(String(v))).join(', ');
}
if (typeof value === 'string' && value.trim()) return toPretty(value);
return null;
};
return {
bio: description || descrption || biography || bio || '',
expertise: aboutMeExpertise || expertiseAreas || specializations || areasOfExpertise || [],
serviceAreas: serviceAreas || licensedAreas || coverageAreas || [],
city: extractAllValues(cityValue),
city: stripCityPrefix(cityValue),
state: extractAllValues(stateValue),
};
}