From 66b233159a00eb112502aa056d954d6c7e07ac6d Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Tue, 14 Apr 2026 07:54:25 +0530 Subject: [PATCH] feat: add agency information section and dynamic field labels to profile experience data --- src/app/(agent)/agent/dashboard/page.tsx | 9 +++++ src/app/(user)/user/profile/[id]/page.tsx | 9 +++++ src/components/profile/ExperienceSection.tsx | 40 +++++++++++++------- src/utils/profileDataMapper.ts | 32 +++++++++++++++- 4 files changed, 76 insertions(+), 14 deletions(-) diff --git a/src/app/(agent)/agent/dashboard/page.tsx b/src/app/(agent)/agent/dashboard/page.tsx index 03292b1..3624fae 100644 --- a/src/app/(agent)/agent/dashboard/page.tsx +++ b/src/app/(agent)/agent/dashboard/page.tsx @@ -31,10 +31,19 @@ const mockData = { // Default experience data when no field values are available const defaultExperience: ExperienceData = { years: '-', + yearsLabel: 'Years in Experience', contracts: '-', + contractsLabel: 'Number of contracts closed', licensingAreas: [], + licensingAreasLabel: 'Licensing & Areas', expertiseYears: [], + expertiseYearsLabel: 'Areas in expertise & Years', certifications: [], + certificationsLabel: 'Certifications', + agencyName: '', + agencyDesignation: '', + agencyShowDesignation: false, + agencySectionLabel: 'Real Estate Agency & Designation', }; // Default profile card data when no field values are available diff --git a/src/app/(user)/user/profile/[id]/page.tsx b/src/app/(user)/user/profile/[id]/page.tsx index a27964a..a385cc4 100644 --- a/src/app/(user)/user/profile/[id]/page.tsx +++ b/src/app/(user)/user/profile/[id]/page.tsx @@ -31,10 +31,19 @@ const mockData = { // Default experience data when no field values are available const defaultExperience: ExperienceData = { years: '-', + yearsLabel: 'Years in Experience', contracts: '-', + contractsLabel: 'Number of contracts closed', licensingAreas: [], + licensingAreasLabel: 'Licensing & Areas', expertiseYears: [], + expertiseYearsLabel: 'Areas in expertise & Years', certifications: [], + certificationsLabel: 'Certifications', + agencyName: '', + agencyDesignation: '', + agencyShowDesignation: false, + agencySectionLabel: 'Real Estate Agency & Designation', }; // Default specialization fields data when no field values are available diff --git a/src/components/profile/ExperienceSection.tsx b/src/components/profile/ExperienceSection.tsx index af6e716..27a9a8e 100644 --- a/src/components/profile/ExperienceSection.tsx +++ b/src/components/profile/ExperienceSection.tsx @@ -2,14 +2,7 @@ import { useState } from 'react'; import { Tag } from './Tag'; - -interface ExperienceData { - years: string; - contracts: string; - licensingAreas: string[]; - expertiseYears: { area: string; years: string }[]; - certifications: { name: string; org: string }[]; -} +import type { ExperienceData } from '@/utils/profileDataMapper'; interface ExperienceSectionProps { experience: ExperienceData; @@ -24,6 +17,13 @@ export function ExperienceSection({ experience }: ExperienceSectionProps) { const [showAllExpertise, setShowAllExpertise] = useState(false); const [showAllCertifications, setShowAllCertifications] = useState(false); + // Build agency display — append designation if flag is set + const agencyDisplay = experience.agencyName + ? (experience.agencyShowDesignation && experience.agencyDesignation + ? `${experience.agencyName} - ${experience.agencyDesignation}` + : experience.agencyName) + : ''; + // Calculate how many more items are hidden const licensingRemaining = experience.licensingAreas.length - INITIAL_DISPLAY_COUNT; const expertiseRemaining = experience.expertiseYears.length - EXPERTISE_INITIAL_COUNT; @@ -46,8 +46,22 @@ export function ExperienceSection({ experience }: ExperienceSectionProps) {
{/* Left Column */}
+ {agencyDisplay && ( + <> +
+

{experience.agencySectionLabel}

+
    +
  • + {agencyDisplay} +
  • +
+
+ {/* Horizontal divider */} +
+ + )}
-

Years in Experience

+

{experience.yearsLabel}

  • {experience.years !== '-' ? experience.years : Not specified} @@ -57,7 +71,7 @@ export function ExperienceSection({ experience }: ExperienceSectionProps) { {/* Horizontal divider */}
    -

    Number of contracts closed

    +

    {experience.contractsLabel}

    • {experience.contracts !== '-' ? experience.contracts : Not specified} @@ -65,7 +79,7 @@ export function ExperienceSection({ experience }: ExperienceSectionProps) {
    -

    Licensing & Areas

    +

    {experience.licensingAreasLabel}

    {experience.licensingAreas.length > 0 ? ( <> @@ -105,7 +119,7 @@ export function ExperienceSection({ experience }: ExperienceSectionProps) { {/* Right Column */}
    -

    Areas in expertise & Years

    +

    {experience.expertiseYearsLabel}

    {experience.expertiseYears.length > 0 ? ( <> @@ -137,7 +151,7 @@ export function ExperienceSection({ experience }: ExperienceSectionProps) {
    -

    Certifications

    +

    {experience.certificationsLabel}

    {experience.certifications.length > 0 ? (
      diff --git a/src/utils/profileDataMapper.ts b/src/utils/profileDataMapper.ts index b3aac29..ca73f87 100644 --- a/src/utils/profileDataMapper.ts +++ b/src/utils/profileDataMapper.ts @@ -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 ); }