fix: Populate the directionsUrl with a Google Maps link on the contact page.

This commit is contained in:
pradeepkumar
2026-03-19 13:56:09 +05:30
parent ee51f4b554
commit 896f49d1e1
3 changed files with 25 additions and 83 deletions

View File

@@ -10,6 +10,7 @@ import { notificationsApiService } from '@/services/notifications-api.service';
interface HeaderData {
profileImage: string | null;
profileName: string | null;
profileTitle: string | null;
avatarLoaded: boolean;
setAvatarLoaded: (loaded: boolean) => void;
notificationCount: number;
@@ -18,6 +19,7 @@ interface HeaderData {
const HeaderContext = createContext<HeaderData>({
profileImage: null,
profileName: null,
profileTitle: null,
avatarLoaded: false,
setAvatarLoaded: () => {},
notificationCount: 0,
@@ -31,6 +33,7 @@ export function HeaderProvider({ children }: { children: React.ReactNode }) {
const { data: session, status } = useSession();
const [profileImage, setProfileImage] = useState<string | null>(null);
const [profileName, setProfileName] = useState<string | null>(null);
const [profileTitle, setProfileTitle] = useState<string | null>(null);
const [avatarLoaded, setAvatarLoaded] = useState(false);
const [notificationCount, setNotificationCount] = useState(0);
const lastAvatarKeyRef = useRef<string | null>(null);
@@ -41,18 +44,22 @@ export function HeaderProvider({ children }: { children: React.ReactNode }) {
const role = (session?.user as any)?.role;
let avatar: string | null = null;
let name: string | null = null;
let title: string | null = null;
if (role === 'AGENT') {
const profile = await agentsService.getMyProfile();
avatar = profile.avatar;
name = profile.firstName ? `${profile.firstName} ${profile.lastName || ''}`.trim() : null;
title = profile.agentType?.name || 'Real Estate Agent';
} else if (role === 'USER') {
const profile = await usersService.getMyProfile();
avatar = profile.avatar;
name = profile.firstName ? `${profile.firstName} ${profile.lastName || ''}`.trim() : null;
title = 'Member';
}
if (name) setProfileName(name);
if (title) setProfileTitle(title);
if (avatar && (avatar !== lastAvatarKeyRef.current || forceRefresh)) {
lastAvatarKeyRef.current = avatar;
@@ -79,6 +86,7 @@ export function HeaderProvider({ children }: { children: React.ReactNode }) {
hasFetchedRef.current = false;
setProfileImage(null);
setProfileName(null);
setProfileTitle(null);
setAvatarLoaded(false);
lastAvatarKeyRef.current = null;
}
@@ -119,7 +127,7 @@ export function HeaderProvider({ children }: { children: React.ReactNode }) {
}, [status]);
return (
<HeaderContext.Provider value={{ profileImage, profileName, avatarLoaded, setAvatarLoaded, notificationCount }}>
<HeaderContext.Provider value={{ profileImage, profileName, profileTitle, avatarLoaded, setAvatarLoaded, notificationCount }}>
{children}
</HeaderContext.Provider>
);