diff --git a/apps/portal/src/pages/offers/profile/[offerProfileId].tsx b/apps/portal/src/pages/offers/profile/[offerProfileId].tsx index 73468325..fe39a45b 100644 --- a/apps/portal/src/pages/offers/profile/[offerProfileId].tsx +++ b/apps/portal/src/pages/offers/profile/[offerProfileId].tsx @@ -6,6 +6,7 @@ import { Spinner, useToast } from '@tih/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { ProfileDetailTab } from '~/components/offers/constants'; +import { HOME_URL } from '~/components/offers/constants'; import ProfileComments from '~/components/offers/profile/ProfileComments'; import ProfileDetails from '~/components/offers/profile/ProfileDetails'; import ProfileHeader from '~/components/offers/profile/ProfileHeader'; @@ -13,7 +14,6 @@ import type { BackgroundDisplayData, OfferDisplayData, } from '~/components/offers/types'; -import { HOME_URL } from '~/components/offers/types'; import type { JobTitleType } from '~/components/shared/JobTitles'; import { getLabelForJobTitleType } from '~/components/shared/JobTitles'; diff --git a/apps/portal/src/pages/offers/submit/result/[offerProfileId].tsx b/apps/portal/src/pages/offers/submit/result/[offerProfileId].tsx index 1eb7b2e6..f507283d 100644 --- a/apps/portal/src/pages/offers/submit/result/[offerProfileId].tsx +++ b/apps/portal/src/pages/offers/submit/result/[offerProfileId].tsx @@ -1,3 +1,4 @@ +import Error from 'next/error'; import { useRouter } from 'next/router'; import { useEffect, useRef, useState } from 'react'; import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/20/solid'; @@ -21,12 +22,21 @@ export default function OffersSubmissionResult() { token = token as string; const [step, setStep] = useState(0); const [analysis, setAnalysis] = useState(null); + const [isValidToken, setIsValidToken] = useState(false); const pageRef = useRef(null); const scrollToTop = () => pageRef.current?.scrollTo({ behavior: 'smooth', top: 0 }); - // TODO: Check if the token is valid before showing this page + const checkToken = trpc.useQuery( + ['offers.profile.isValidToken', { profileId: offerProfileId, token }], + { + onSuccess(data) { + setIsValidToken(data); + }, + }, + ); + const getAnalysis = trpc.useQuery( ['offers.analysis.get', { profileId: offerProfileId }], { @@ -69,7 +79,7 @@ export default function OffersSubmissionResult() { return ( <> - {getAnalysis.isLoading && ( + {(checkToken.isLoading || getAnalysis.isLoading) && (
@@ -77,7 +87,13 @@ export default function OffersSubmissionResult() {
)} - {!getAnalysis.isLoading && ( + {checkToken.isSuccess && !isValidToken && ( + + )} + {getAnalysis.isSuccess && (