feat: Implement a new testimonial submission page and service, and update related profile and settings components.
This commit is contained in:
@@ -18,35 +18,12 @@ import {
|
||||
import { agentsService, AgentProfile, FieldValueResponse } from '@/services/agents.service';
|
||||
import { connectionRequestsService } from '@/services/connection-requests.service';
|
||||
import { uploadService } from '@/services/upload.service';
|
||||
import { testimonialsService, Testimonial } from '@/services/testimonials.service';
|
||||
import { mapFieldValuesToExperience, mapFieldValuesToProfileCard, mapFieldValuesToAvailability, mapFieldValuesToSpecializationFields, mapFieldValuesToContactInfo, ExperienceData, ProfileCardData, AvailabilityData, SpecializationFieldsData, ContactInfoData } from '@/utils/profileDataMapper';
|
||||
|
||||
// Mock data for sections not yet available from API
|
||||
const mockData = {
|
||||
preferredWorkEnvironment: 'Preferred work environment includes on-site property visits, in-depth market research, client consultations, property tours, and active involvement in negotiations to ensure the best outcomes',
|
||||
testimonialHighlight: "The most amazing experience I've had as a real estate professional is helping a family secure their dream home and seeing their happiness when they received the keys.",
|
||||
testimonials: [
|
||||
{
|
||||
id: 1,
|
||||
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo ligula eget dolor. Sed dignissim, nisl eget tincidunt vulputate, lacus justo bibendum ipsum, vitae tempus risus lorem at nunc. Integer sed arcu vitae risus feugiat vehicula. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
|
||||
author: 'Kenedy Kenney',
|
||||
role: 'Chief Operations Officer',
|
||||
rating: 5,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo ligula eget dolor. Sed dignissim, nisl eget tincidunt vulputate, lacus justo bibendum ipsum, vitae tempus risus lorem at nunc. Integer sed arcu vitae risus feugiat vehicula. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
|
||||
author: 'Kenedy Kenney',
|
||||
role: 'Chief Operations Officer',
|
||||
rating: 5,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo ligula eget dolor. Sed dignissim, nisl eget tincidunt vulputate, lacus justo bibendum ipsum, vitae tempus risus lorem at nunc. Integer sed arcu vitae risus feugiat vehicula. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
|
||||
author: 'Kenedy Kenney',
|
||||
role: 'Chief Operations Officer',
|
||||
rating: 5,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// Default experience data when no field values are available
|
||||
@@ -101,6 +78,7 @@ export default function AgentDashboard() {
|
||||
const [isAvailable, setIsAvailable] = useState(true);
|
||||
const [isTogglingAvailability, setIsTogglingAvailability] = useState(false);
|
||||
const [pendingRequestCount, setPendingRequestCount] = useState(0);
|
||||
const [testimonials, setTestimonials] = useState<{ id: string; text: string; author: string; role: string; rating: number }[]>([]);
|
||||
|
||||
const defaultImage = '/assets/demo_images/8f017153a7b4a239a4f0691234ef97dd55092282.jpg';
|
||||
|
||||
@@ -118,11 +96,12 @@ export default function AgentDashboard() {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
// Fetch profile, field values, and pending request count in parallel
|
||||
const [profile, fieldValuesResponse, requestCounts] = await Promise.all([
|
||||
// Fetch profile, field values, pending request count, and testimonials in parallel
|
||||
const [profile, fieldValuesResponse, requestCounts, testimonialsData] = await Promise.all([
|
||||
agentsService.getMyProfile(),
|
||||
agentsService.getFieldValues(),
|
||||
connectionRequestsService.getRequestCounts().catch(() => null),
|
||||
testimonialsService.getMyTestimonials('latest').catch(() => [] as Testimonial[]),
|
||||
]);
|
||||
|
||||
setAgentProfile(profile);
|
||||
@@ -132,6 +111,17 @@ export default function AgentDashboard() {
|
||||
setPendingRequestCount(requestCounts.pending);
|
||||
}
|
||||
|
||||
// Map testimonials for TestimonialsSection (latest 3)
|
||||
setTestimonials(
|
||||
testimonialsData.slice(0, 3).map((t) => ({
|
||||
id: t.id,
|
||||
text: t.text,
|
||||
author: t.authorName,
|
||||
role: t.authorRole,
|
||||
rating: t.rating,
|
||||
}))
|
||||
);
|
||||
|
||||
// Map field values to experience data structure
|
||||
const mappedExperience = mapFieldValuesToExperience(fieldValuesResponse.fieldValues);
|
||||
setExperienceData(mappedExperience);
|
||||
@@ -404,25 +394,27 @@ export default function AgentDashboard() {
|
||||
}
|
||||
content={<p className="font-serif font-semibold text-[14px] leading-[19px] text-[#00293D]">{mockData.preferredWorkEnvironment}</p>}
|
||||
/>
|
||||
<InfoCard
|
||||
title=""
|
||||
icon={
|
||||
<Image
|
||||
src="/assets/icons/testimonial-star-icon.svg"
|
||||
alt="Testimonial"
|
||||
width={28}
|
||||
height={28}
|
||||
/>
|
||||
}
|
||||
content={<p className="text-[14px] font-semibold font-serif leading-[19px] text-center text-[#00293D]">“{mockData.testimonialHighlight}”</p>}
|
||||
/>
|
||||
{testimonials.length > 0 && (
|
||||
<InfoCard
|
||||
title=""
|
||||
icon={
|
||||
<Image
|
||||
src="/assets/icons/testimonial-star-icon.svg"
|
||||
alt="Testimonial"
|
||||
width={28}
|
||||
height={28}
|
||||
/>
|
||||
}
|
||||
content={<p className="text-[14px] font-semibold font-serif leading-[19px] text-center text-[#00293D]">“{testimonials[0].text.length > 150 ? testimonials[0].text.substring(0, 150) + '...' : testimonials[0].text}”</p>}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Specialization Section */}
|
||||
<SpecializationSection fieldsData={specializationFieldsData} />
|
||||
|
||||
{/* Testimonials Section */}
|
||||
<TestimonialsSection testimonials={mockData.testimonials} />
|
||||
<TestimonialsSection testimonials={testimonials} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user