feat: Display pending connection request count on the agent dashboard profile card.
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
PhotoUploadModal,
|
||||
} from '@/components/profile';
|
||||
import { agentsService, AgentProfile, FieldValueResponse } from '@/services/agents.service';
|
||||
import { connectionRequestsService } from '@/services/connection-requests.service';
|
||||
import { uploadService } from '@/services/upload.service';
|
||||
import { mapFieldValuesToExperience, mapFieldValuesToProfileCard, mapFieldValuesToAvailability, mapFieldValuesToSpecializationFields, mapFieldValuesToContactInfo, ExperienceData, ProfileCardData, AvailabilityData, SpecializationFieldsData, ContactInfoData } from '@/utils/profileDataMapper';
|
||||
|
||||
@@ -99,6 +100,7 @@ export default function AgentDashboard() {
|
||||
const [avatarUrl, setAvatarUrl] = useState<string | null>(null);
|
||||
const [isAvailable, setIsAvailable] = useState(true);
|
||||
const [isTogglingAvailability, setIsTogglingAvailability] = useState(false);
|
||||
const [pendingRequestCount, setPendingRequestCount] = useState(0);
|
||||
|
||||
const defaultImage = '/assets/demo_images/8f017153a7b4a239a4f0691234ef97dd55092282.jpg';
|
||||
|
||||
@@ -116,15 +118,19 @@ export default function AgentDashboard() {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
// Fetch profile and field values in parallel
|
||||
const [profile, fieldValuesResponse] = await Promise.all([
|
||||
// Fetch profile, field values, and pending request count in parallel
|
||||
const [profile, fieldValuesResponse, requestCounts] = await Promise.all([
|
||||
agentsService.getMyProfile(),
|
||||
agentsService.getFieldValues(),
|
||||
connectionRequestsService.getRequestCounts().catch(() => null),
|
||||
]);
|
||||
|
||||
setAgentProfile(profile);
|
||||
setFieldValues(fieldValuesResponse.fieldValues);
|
||||
setIsAvailable(profile.isAvailable ?? true);
|
||||
if (requestCounts) {
|
||||
setPendingRequestCount(requestCounts.pending);
|
||||
}
|
||||
|
||||
// Map field values to experience data structure
|
||||
const mappedExperience = mapFieldValuesToExperience(fieldValuesResponse.fieldValues);
|
||||
@@ -351,6 +357,7 @@ export default function AgentDashboard() {
|
||||
editHref="/agent/edit"
|
||||
messageHref="/agent/message"
|
||||
requestsHref="/agent/network"
|
||||
pendingRequestCount={pendingRequestCount}
|
||||
/>
|
||||
|
||||
{/* Experience Section - Dynamic data from profile fields */}
|
||||
|
||||
Reference in New Issue
Block a user