diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index 3b35c3ec..8aef57ac 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -10,9 +10,10 @@ export const useAuth = (contactPersonId?: Id) => { useEffect(() => { const userIsAuthorized = user?.role === UserRole.ADMIN || user?.role === UserRole.COORDINATOR; - const personId = user?.personId; if (userIsAuthorized) setIsAuthorized(true); - if (contactPersonId && personId === contactPersonId) { + if (user?.role === UserRole.VOLUNTEER && user.id === contactPersonId) { + setIsOwnProfile(true); + } else if (user?.role === UserRole.AGENT && user.personId === contactPersonId) { setIsOwnProfile(true); } else { setIsOwnProfile(false); diff --git a/src/hooks/useVolunteerProfileSections.tsx b/src/hooks/useVolunteerProfileSections.tsx index 46457fe1..5783cb03 100644 --- a/src/hooks/useVolunteerProfileSections.tsx +++ b/src/hooks/useVolunteerProfileSections.tsx @@ -25,7 +25,7 @@ export const useVolunteerProfileSections = (volunteer: ApiVolunteerGet | undefin const { t, i18n } = useTranslation(); const router = useRouter(); const searchParams = useSearchParams(); - const { isAuthorized, isOwnProfile } = useAuth(volunteer?.person.id); + const { isAuthorized, isOwnProfile } = useAuth(volunteer?.id); const hasEditingRights = isAuthorized || isOwnProfile; const contactDetailsRef = useRef(null); @@ -142,21 +142,19 @@ export const useVolunteerProfileSections = (volunteer: ApiVolunteerGet | undefin ), }); + sections.push({ + iconName: IconName.ClipboardText, + title: t("dashboard.volunteerProfile.documents"), + subComponent: , + }); } if (isAuthorized) { - sections.push( - { - iconName: IconName.ClipboardText, - title: t("dashboard.volunteerProfile.documents"), - subComponent: , - }, - { - iconName: IconName.ChatCircleDots, - title: `${t("dashboard.volunteerProfile.coordinatorComments")} • ${volunteer.comments?.length ?? 0}`, - subComponent: , - }, - ); + sections.push({ + iconName: IconName.ChatCircleDots, + title: `${t("dashboard.volunteerProfile.coordinatorComments")} • ${volunteer.comments?.length ?? 0}`, + subComponent: , + }); } return {