feat: strip state prefixes from city values and format as title case in profile displays
This commit is contained in:
@@ -120,7 +120,13 @@ function ProfileCard({ profile, resolvedAvatarUrl }: ProfileCardProps) {
|
||||
let cityValue: string | null = null;
|
||||
let stateValue: string | null = null;
|
||||
|
||||
// Helper to format snake_case to Title Case, with uppercase for 2-letter state codes
|
||||
// Helper to format snake_case to Title Case, with uppercase for 2-letter state codes.
|
||||
// City values carry a state prefix (e.g. "ne_adams", "co_aetna_estates") — strip it.
|
||||
const formatCity = (v: string) => {
|
||||
const trimmed = v.trim();
|
||||
const stripped = trimmed.replace(/^[a-z]{2}_/i, '');
|
||||
return stripped.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(' ');
|
||||
};
|
||||
const formatValue = (v: string) => {
|
||||
const trimmed = v.trim();
|
||||
if (/^[a-z]{2}$/i.test(trimmed)) return trimmed.toUpperCase();
|
||||
@@ -144,10 +150,10 @@ function ProfileCard({ profile, resolvedAvatarUrl }: ProfileCardProps) {
|
||||
if (cityField && cityField.jsonValue) {
|
||||
const value = cityField.jsonValue;
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
// For multiselect, join all selected values
|
||||
cityValue = value.map(v => formatValue(String(v))).join(', ');
|
||||
// City values carry a state prefix — strip it before joining
|
||||
cityValue = value.map(v => formatCity(String(v))).join(', ');
|
||||
} else if (typeof value === 'string' && value.trim()) {
|
||||
cityValue = formatValue(value);
|
||||
cityValue = formatCity(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user