diff --git a/frontend/src/app/my/mentorship/page.tsx b/frontend/src/app/my/mentorship/page.tsx index f622a68a66..b4fd332747 100644 --- a/frontend/src/app/my/mentorship/page.tsx +++ b/frontend/src/app/my/mentorship/page.tsx @@ -20,8 +20,10 @@ import SearchPageLayout from 'components/SearchPageLayout' const MyMentorshipPage: React.FC = () => { const router = useRouter() const searchParams = useSearchParams() + const { data: session } = useSession() - const username = (session as ExtendedSession)?.user?.login + const extendedSession = session as ExtendedSession | null + const userName = extendedSession?.user?.login const initialQuery = searchParams.get('q') || '' const initialPage = Number.parseInt(searchParams.get('page') || '1', 10) @@ -58,7 +60,7 @@ const MyMentorshipPage: React.FC = () => { fetchPolicy: 'cache-and-network', errorPolicy: 'all', }) - const isProjectLeader = (session as ExtendedSession)?.user.isLeader + const isProjectLeader = extendedSession?.user?.isLeader useEffect(() => { if (programData?.myPrograms) { @@ -81,7 +83,7 @@ const MyMentorshipPage: React.FC = () => { const handleCreate = () => router.push('/my/mentorship/programs/create') - if (!username) { + if (!userName) { return } diff --git a/frontend/src/types/auth.ts b/frontend/src/types/auth.ts index 55e9962dc8..03133284e1 100644 --- a/frontend/src/types/auth.ts +++ b/frontend/src/types/auth.ts @@ -8,13 +8,13 @@ export type ExtendedProfile = { export type ExtendedSession = Session & { accessToken?: string user?: Session['user'] & { + email?: string expires?: string + image?: string isLeader?: boolean isMentor?: boolean isOwaspStaff?: boolean login?: string name?: string - email?: string - image?: string } }