fix
This commit is contained in:
@@ -124,3 +124,98 @@ export function hasExperienceData(experience: ExperienceData): boolean {
|
||||
experience.certifications.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
// Profile card data structure
|
||||
export interface ProfileCardData {
|
||||
bio: string;
|
||||
expertise: string[];
|
||||
serviceAreas: string[];
|
||||
}
|
||||
|
||||
// Availability data structure
|
||||
export interface AvailabilityData {
|
||||
type: string;
|
||||
schedule: string[];
|
||||
}
|
||||
|
||||
// Map availability option values to human-readable labels
|
||||
const availabilityLabels: Record<string, string> = {
|
||||
'mf_9_5': 'Monday - Friday, 9 AM - 5 PM',
|
||||
'mf_8_6': 'Monday - Friday, 8 AM - 6 PM',
|
||||
'weekends': 'Weekends',
|
||||
'evenings': 'Evenings',
|
||||
'flexible': 'Flexible Schedule',
|
||||
'full_time': 'Full-time',
|
||||
'part_time': 'Part-time',
|
||||
'24_7': '24/7 Available',
|
||||
'by_appointment': 'By Appointment Only',
|
||||
'monday': 'Monday',
|
||||
'tuesday': 'Tuesday',
|
||||
'wednesday': 'Wednesday',
|
||||
'thursday': 'Thursday',
|
||||
'friday': 'Friday',
|
||||
'saturday': 'Saturday',
|
||||
'sunday': 'Sunday',
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps field values to availability data
|
||||
*/
|
||||
export function mapFieldValuesToAvailability(fieldValues: FieldValueResponse[]): AvailabilityData {
|
||||
const availabilityValues = getFieldValue(fieldValues, 'availability') as string[] | undefined;
|
||||
|
||||
if (!availabilityValues || availabilityValues.length === 0) {
|
||||
return {
|
||||
type: '',
|
||||
schedule: [],
|
||||
};
|
||||
}
|
||||
|
||||
// Map values to human-readable labels
|
||||
const schedule = availabilityValues.map(val =>
|
||||
availabilityLabels[val] || val.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
|
||||
);
|
||||
|
||||
// Determine type based on values
|
||||
let type = 'Available';
|
||||
if (availabilityValues.includes('full_time') || availabilityValues.includes('mf_9_5') || availabilityValues.includes('mf_8_6')) {
|
||||
type = 'Full-time';
|
||||
} else if (availabilityValues.includes('part_time')) {
|
||||
type = 'Part-time';
|
||||
} else if (availabilityValues.includes('flexible')) {
|
||||
type = 'Flexible';
|
||||
}
|
||||
|
||||
return {
|
||||
type,
|
||||
schedule,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps field values to profile card data (bio, expertise, service areas)
|
||||
*/
|
||||
export function mapFieldValuesToProfileCard(fieldValues: FieldValueResponse[]): ProfileCardData {
|
||||
// Get bio/description from various possible fields
|
||||
const description = getFieldValue(fieldValues, 'description') as string | undefined;
|
||||
const descrption = getFieldValue(fieldValues, 'descrption') as string | undefined; // typo in field slug
|
||||
const biography = getFieldValue(fieldValues, 'biography') as string | undefined;
|
||||
const bio = getFieldValue(fieldValues, 'bio') as string | undefined;
|
||||
|
||||
// Get expertise from various possible fields
|
||||
const aboutMeExpertise = getFieldValue(fieldValues, 'about_me_expertise') as string[] | undefined;
|
||||
const expertiseAreas = getFieldValue(fieldValues, 'expertise_areas') as string[] | undefined;
|
||||
const specializations = getFieldValue(fieldValues, 'specializations') as string[] | undefined;
|
||||
const areasOfExpertise = getFieldValue(fieldValues, 'areas_of_expertise') as string[] | undefined;
|
||||
|
||||
// Get service areas from various possible fields
|
||||
const serviceAreas = getFieldValue(fieldValues, 'service_areas') as string[] | undefined;
|
||||
const licensedAreas = getFieldValue(fieldValues, 'licensed_areas') as string[] | undefined;
|
||||
const coverageAreas = getFieldValue(fieldValues, 'coverage_areas') as string[] | undefined;
|
||||
|
||||
return {
|
||||
bio: description || descrption || biography || bio || '',
|
||||
expertise: aboutMeExpertise || expertiseAreas || specializations || areasOfExpertise || [],
|
||||
serviceAreas: serviceAreas || licensedAreas || coverageAreas || [],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user