feat: add personal tagline support and improve snake_case string formatting in profile data mapping
This commit is contained in:
@@ -239,6 +239,23 @@ export function mapFieldValuesToWorkEnvironment(fieldValues: FieldValueResponse[
|
||||
};
|
||||
}
|
||||
|
||||
// Personal tagline data structure
|
||||
export interface PersonalTaglineData {
|
||||
label: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps field values to personal tagline data (label + content)
|
||||
*/
|
||||
export function mapFieldValuesToPersonalTagline(fieldValues: FieldValueResponse[]): PersonalTaglineData {
|
||||
const field = fieldValues.find(f => f.fieldSlug === 'personal_tagline');
|
||||
return {
|
||||
label: field?.fieldName || 'Personal Tagline',
|
||||
content: (field?.value as string | undefined)?.trim() || '',
|
||||
};
|
||||
}
|
||||
|
||||
// Type-determining values (business hours → Full-time, etc.)
|
||||
const fullTimeKeywords = ['full_time', 'mf_9_5', 'mf_8_6', 'full time', '9-5', '9 am', '9am'];
|
||||
const partTimeKeywords = ['part_time', 'part time'];
|
||||
@@ -264,13 +281,23 @@ export function mapFieldValuesToAvailability(fieldValues: FieldValueResponse[]):
|
||||
return { type: '', schedule: [], label };
|
||||
}
|
||||
|
||||
// Helper to format snake_case strings to Title Case (for unresolved raw values)
|
||||
const formatIfSnakeCase = (s: string): string => {
|
||||
const trimmed = s.trim();
|
||||
// If it looks like a snake_case key (e.g. "mf_9_5"), format it
|
||||
if (/^[a-z0-9]+(_[a-z0-9]+)+$/i.test(trimmed)) {
|
||||
return trimmed.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
|
||||
}
|
||||
return trimmed;
|
||||
};
|
||||
|
||||
// Prefer backend-resolved labels, fall back to raw value with snake_case formatting
|
||||
const resolvedLabels = rawValues.map((val, i) => {
|
||||
const fromBackend = labelValues[i];
|
||||
if (fromBackend && typeof fromBackend === 'string' && fromBackend.trim()) {
|
||||
return fromBackend.trim();
|
||||
return formatIfSnakeCase(fromBackend);
|
||||
}
|
||||
return val.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
|
||||
return formatIfSnakeCase(val);
|
||||
});
|
||||
|
||||
// Deduplicate by normalized comparison (case/whitespace insensitive)
|
||||
|
||||
Reference in New Issue
Block a user