feat: Display pending connection request count on the agent dashboard profile card.
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
|||||||
PhotoUploadModal,
|
PhotoUploadModal,
|
||||||
} from '@/components/profile';
|
} from '@/components/profile';
|
||||||
import { agentsService, AgentProfile, FieldValueResponse } from '@/services/agents.service';
|
import { agentsService, AgentProfile, FieldValueResponse } from '@/services/agents.service';
|
||||||
|
import { connectionRequestsService } from '@/services/connection-requests.service';
|
||||||
import { uploadService } from '@/services/upload.service';
|
import { uploadService } from '@/services/upload.service';
|
||||||
import { mapFieldValuesToExperience, mapFieldValuesToProfileCard, mapFieldValuesToAvailability, mapFieldValuesToSpecializationFields, mapFieldValuesToContactInfo, ExperienceData, ProfileCardData, AvailabilityData, SpecializationFieldsData, ContactInfoData } from '@/utils/profileDataMapper';
|
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 [avatarUrl, setAvatarUrl] = useState<string | null>(null);
|
||||||
const [isAvailable, setIsAvailable] = useState(true);
|
const [isAvailable, setIsAvailable] = useState(true);
|
||||||
const [isTogglingAvailability, setIsTogglingAvailability] = useState(false);
|
const [isTogglingAvailability, setIsTogglingAvailability] = useState(false);
|
||||||
|
const [pendingRequestCount, setPendingRequestCount] = useState(0);
|
||||||
|
|
||||||
const defaultImage = '/assets/demo_images/8f017153a7b4a239a4f0691234ef97dd55092282.jpg';
|
const defaultImage = '/assets/demo_images/8f017153a7b4a239a4f0691234ef97dd55092282.jpg';
|
||||||
|
|
||||||
@@ -116,15 +118,19 @@ export default function AgentDashboard() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
// Fetch profile and field values in parallel
|
// Fetch profile, field values, and pending request count in parallel
|
||||||
const [profile, fieldValuesResponse] = await Promise.all([
|
const [profile, fieldValuesResponse, requestCounts] = await Promise.all([
|
||||||
agentsService.getMyProfile(),
|
agentsService.getMyProfile(),
|
||||||
agentsService.getFieldValues(),
|
agentsService.getFieldValues(),
|
||||||
|
connectionRequestsService.getRequestCounts().catch(() => null),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
setAgentProfile(profile);
|
setAgentProfile(profile);
|
||||||
setFieldValues(fieldValuesResponse.fieldValues);
|
setFieldValues(fieldValuesResponse.fieldValues);
|
||||||
setIsAvailable(profile.isAvailable ?? true);
|
setIsAvailable(profile.isAvailable ?? true);
|
||||||
|
if (requestCounts) {
|
||||||
|
setPendingRequestCount(requestCounts.pending);
|
||||||
|
}
|
||||||
|
|
||||||
// Map field values to experience data structure
|
// Map field values to experience data structure
|
||||||
const mappedExperience = mapFieldValuesToExperience(fieldValuesResponse.fieldValues);
|
const mappedExperience = mapFieldValuesToExperience(fieldValuesResponse.fieldValues);
|
||||||
@@ -351,6 +357,7 @@ export default function AgentDashboard() {
|
|||||||
editHref="/agent/edit"
|
editHref="/agent/edit"
|
||||||
messageHref="/agent/message"
|
messageHref="/agent/message"
|
||||||
requestsHref="/agent/network"
|
requestsHref="/agent/network"
|
||||||
|
pendingRequestCount={pendingRequestCount}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Experience Section - Dynamic data from profile fields */}
|
{/* Experience Section - Dynamic data from profile fields */}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ interface ProfileCardProps {
|
|||||||
editHref?: string;
|
editHref?: string;
|
||||||
messageHref?: string;
|
messageHref?: string;
|
||||||
requestsHref?: string;
|
requestsHref?: string;
|
||||||
|
pendingRequestCount?: number;
|
||||||
connectionStatus?: ConnectionStatus;
|
connectionStatus?: ConnectionStatus;
|
||||||
onConnectClick?: () => void; // Callback when Connect button is clicked (for opening modal)
|
onConnectClick?: () => void; // Callback when Connect button is clicked (for opening modal)
|
||||||
onUnlinkClick?: () => void; // Callback when Unlink button is clicked
|
onUnlinkClick?: () => void; // Callback when Unlink button is clicked
|
||||||
@@ -40,6 +41,7 @@ export function ProfileCard({
|
|||||||
editHref = '/agent/edit',
|
editHref = '/agent/edit',
|
||||||
messageHref,
|
messageHref,
|
||||||
requestsHref,
|
requestsHref,
|
||||||
|
pendingRequestCount = 0,
|
||||||
connectionStatus,
|
connectionStatus,
|
||||||
onConnectClick,
|
onConnectClick,
|
||||||
onUnlinkClick,
|
onUnlinkClick,
|
||||||
@@ -168,11 +170,11 @@ export function ProfileCard({
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{showEditButton && requestsHref ? (
|
{showEditButton && requestsHref ? (
|
||||||
// Agent's own profile - show Requests link
|
// Agent's own profile - show Requests link with badge
|
||||||
<Link
|
<Link
|
||||||
href={requestsHref}
|
href={requestsHref}
|
||||||
onClick={(e) => handleActionClick(e, requestsHref)}
|
onClick={(e) => handleActionClick(e, requestsHref)}
|
||||||
className="flex items-center gap-2 px-4 py-1.5 bg-[#e58625] text-[#00293d] text-sm font-normal rounded-[15px] border border-[#00293d]/10 hover:bg-[#d47720] transition-colors font-serif cursor-pointer"
|
className="relative flex items-center gap-2 px-4 py-1.5 bg-[#e58625] text-[#00293d] text-sm font-normal rounded-[15px] border border-[#00293d]/10 hover:bg-[#d47720] transition-colors font-serif cursor-pointer"
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src="/assets/icons/requests-dark-icon.svg"
|
src="/assets/icons/requests-dark-icon.svg"
|
||||||
@@ -181,6 +183,11 @@ export function ProfileCard({
|
|||||||
height={13}
|
height={13}
|
||||||
/>
|
/>
|
||||||
Requests
|
Requests
|
||||||
|
{pendingRequestCount > 0 && (
|
||||||
|
<span className="absolute -top-2 -right-2 min-w-[20px] h-[20px] flex items-center justify-center px-1 bg-red-500 text-white text-[11px] font-bold rounded-full">
|
||||||
|
{pendingRequestCount > 99 ? '99+' : pendingRequestCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
// Public view - show Connect/Pending/Unlink button based on connection status
|
// Public view - show Connect/Pending/Unlink button based on connection status
|
||||||
|
|||||||
Reference in New Issue
Block a user