feat: add agency information section and dynamic field labels to profile experience data

This commit is contained in:
pradeepkumar
2026-04-14 07:54:25 +05:30
parent 369c7a0ac8
commit 66b233159a
4 changed files with 76 additions and 14 deletions

View File

@@ -3,10 +3,19 @@ import { FieldValueResponse } from '@/services/agents.service';
// Experience data structure expected by ExperienceSection component
export interface ExperienceData {
years: string;
yearsLabel: string;
contracts: string;
contractsLabel: string;
licensingAreas: string[];
licensingAreasLabel: string;
expertiseYears: { area: string; years: string }[];
expertiseYearsLabel: string;
certifications: { name: string; org: string }[];
certificationsLabel: string;
agencyName: string;
agencyDesignation: string;
agencyShowDesignation: boolean;
agencySectionLabel: string;
}
// Certification entry from repeater field
@@ -23,6 +32,12 @@ function getFieldValue(fieldValues: FieldValueResponse[], slug: string): unknown
return field?.value;
}
// Helper to get field label by slug
function getFieldLabel(fieldValues: FieldValueResponse[], slug: string): string | undefined {
const field = fieldValues.find(f => f.fieldSlug === slug);
return field?.fieldName;
}
// Helper to get label from value for select/radio fields
function mapYearsValueToLabel(value: string | undefined): string {
if (!value) return '-';
@@ -115,12 +130,26 @@ export function mapFieldValuesToExperience(fieldValues: FieldValueResponse[]): E
// Get certification entries from repeater
const certificationEntries = getFieldValue(fieldValues, 'certification_entries');
// Agency & Designation fields
const agencyName = getFieldValue(fieldValues, 'agency_name') as string | undefined;
const agencyDesignation = getFieldValue(fieldValues, 'agency_designation') as string | undefined;
const agencyShowDesignation = getFieldValue(fieldValues, 'agency_show_designation');
return {
years: mapYearsValueToLabel(yearsInBusiness),
yearsLabel: getFieldLabel(fieldValues, 'years_in_business') || 'Years in Experience',
contracts: formatContractsCount(contractsCompleted),
contractsLabel: getFieldLabel(fieldValues, 'contracts_completed') || 'Number of contracts closed',
licensingAreas: licensedAreas || [],
licensingAreasLabel: getFieldLabel(fieldValues, 'licensed_areas') || 'Licensing & Areas',
expertiseYears: parseExpertiseAreas(expertiseAreas),
expertiseYearsLabel: getFieldLabel(fieldValues, 'expertise_areas') || 'Areas in expertise & Years',
certifications: parseCertifications(certificationEntries),
certificationsLabel: getFieldLabel(fieldValues, 'certification_entries') || 'Certifications',
agencyName: agencyName?.trim() || '',
agencyDesignation: agencyDesignation?.trim() || '',
agencyShowDesignation: agencyShowDesignation === true || agencyShowDesignation === 'true',
agencySectionLabel: getFieldLabel(fieldValues, 'agency_name') || 'Real Estate Agency & Designation',
};
}
@@ -133,7 +162,8 @@ export function hasExperienceData(experience: ExperienceData): boolean {
experience.contracts !== '-' ||
experience.licensingAreas.length > 0 ||
experience.expertiseYears.length > 0 ||
experience.certifications.length > 0
experience.certifications.length > 0 ||
experience.agencyName.length > 0
);
}