From e8aa1c9fdafffa039a2f5be2ec795743e5dbf35c Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Mon, 31 Oct 2022 18:21:49 +0800 Subject: [PATCH] [portal][feat] custom login page (#485) --- .../portal/src/components/global/AppShell.tsx | 21 +++--- .../src/components/global/HomeNavigation.ts | 31 ++++---- .../offers/profile/ProfileComments.tsx | 3 +- .../comment/ResumeCommentVoteButtons.tsx | 3 +- .../resumes/shared/ResumeSignInButton.tsx | 18 +++-- .../components/shared/icons/GitHubIcon.tsx | 15 ++++ .../src/components/shared/loginPageHref.ts | 8 +++ apps/portal/src/pages/login.tsx | 72 +++++++++++++++++++ apps/portal/src/pages/resumes/[resumeId].tsx | 7 +- apps/portal/src/pages/resumes/index.tsx | 3 +- apps/portal/src/pages/resumes/submit.tsx | 3 +- 11 files changed, 139 insertions(+), 45 deletions(-) create mode 100644 apps/portal/src/components/shared/icons/GitHubIcon.tsx create mode 100644 apps/portal/src/components/shared/loginPageHref.ts create mode 100644 apps/portal/src/pages/login.tsx diff --git a/apps/portal/src/components/global/AppShell.tsx b/apps/portal/src/components/global/AppShell.tsx index 3c36e0d9..a0a44b84 100644 --- a/apps/portal/src/components/global/AppShell.tsx +++ b/apps/portal/src/components/global/AppShell.tsx @@ -1,7 +1,7 @@ import clsx from 'clsx'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import { signIn, signOut, useSession } from 'next-auth/react'; +import { signOut, useSession } from 'next-auth/react'; import type { ReactNode } from 'react'; import { Fragment, useState } from 'react'; import { Menu, Transition } from '@headlessui/react'; @@ -19,12 +19,14 @@ import GoogleAnalytics from './GoogleAnalytics'; import MobileNavigation from './MobileNavigation'; import type { ProductNavigationItems } from './ProductNavigation'; import ProductNavigation from './ProductNavigation'; +import loginPageHref from '../shared/loginPageHref'; type Props = Readonly<{ children: ReactNode; }>; function ProfileJewel() { + const router = useRouter(); const { data: session, status } = useSession(); const isSessionLoading = status === 'loading'; @@ -32,25 +34,20 @@ function ProfileJewel() { return null; } + const loginHref = loginPageHref(); if (session == null) { - return ( - { - event.preventDefault(); - signIn(); - }}> - Sign in + return router.pathname !== loginHref.pathname ? ( + + Log In - ); + ) : null; } const userNavigation = [ { href: '/profile', name: 'Profile' }, { href: '/api/auth/signout', - name: 'Sign out', + name: 'Log out', onClick: (event: MouseEvent) => { event.preventDefault(); signOut(); diff --git a/apps/portal/src/components/global/HomeNavigation.ts b/apps/portal/src/components/global/HomeNavigation.ts index 96739432..d9316ee3 100644 --- a/apps/portal/src/components/global/HomeNavigation.ts +++ b/apps/portal/src/components/global/HomeNavigation.ts @@ -1,22 +1,21 @@ -import type { ProductNavigationItems } from '~/components/global/ProductNavigation'; - -const navigation: ProductNavigationItems = [ - { href: '/offers', name: 'Offers' }, - { href: '/questions', name: 'Question Bank' }, - { - children: [ - { href: '/resumes', name: 'View Resumes' }, - { href: '/resumes/submit', name: 'Submit Resume' }, - ], - href: '#', - name: 'Resumes', - }, -]; +// Not using this for now. +// const navigation: ProductNavigationItems = [ +// { href: '/offers', name: 'Offers' }, +// { href: '/questions', name: 'Question Bank' }, +// { +// children: [ +// { href: '/resumes', name: 'View Resumes' }, +// { href: '/resumes/submit', name: 'Submit Resume' }, +// ], +// href: '#', +// name: 'Resumes', +// }, +// ]; const config = { googleAnalyticsMeasurementID: 'G-DBLZDQ2ZZN', - navigation, - showGlobalNav: true, + navigation: [], + showGlobalNav: false, title: 'Tech Interview Handbook', titleHref: '/', }; diff --git a/apps/portal/src/components/offers/profile/ProfileComments.tsx b/apps/portal/src/components/offers/profile/ProfileComments.tsx index 70e388c7..44181afa 100644 --- a/apps/portal/src/components/offers/profile/ProfileComments.tsx +++ b/apps/portal/src/components/offers/profile/ProfileComments.tsx @@ -12,6 +12,7 @@ import { import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import ExpandableCommentCard from '~/components/offers/profile/comments/ExpandableCommentCard'; import Tooltip from '~/components/offers/util/Tooltip'; +import loginPageHref from '~/components/shared/loginPageHref'; import { copyProfileLink } from '~/utils/offers/link'; import { trpc } from '~/utils/trpc'; @@ -195,7 +196,7 @@ export default function ProfileComments({