[resumes][feat] re-route to sign-in page + prefix resume for components (#370)

pull/371/head
Keane Chan 2 years ago committed by GitHub
parent 9787ff8f34
commit 596a555d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,7 +3,7 @@ type Props = Readonly<{
title: string; title: string;
}>; }>;
export default function FilterPill({ title, onClick }: Props) { export default function ResumeFilterPill({ title, onClick }: Props) {
return ( return (
<button <button
className="rounded-xl border border-indigo-500 border-transparent bg-white px-2 py-1 text-xs font-medium text-indigo-500 focus:bg-indigo-500 focus:text-white" className="rounded-xl border border-indigo-500 border-transparent bg-white px-2 py-1 text-xs font-medium text-indigo-500 focus:bg-indigo-500 focus:text-white"

@ -7,7 +7,7 @@ import { trpc } from '~/utils/trpc';
import CommentListItems from './CommentListItems'; import CommentListItems from './CommentListItems';
import { COMMENTS_SECTIONS } from './constants'; import { COMMENTS_SECTIONS } from './constants';
import SignInButton from '../SignInButton'; import ResumeSignInButton from '../shared/ResumeSignInButton';
type CommentsListProps = Readonly<{ type CommentsListProps = Readonly<{
resumeId: string; resumeId: string;
@ -24,7 +24,7 @@ export default function CommentsList({
const commentsQuery = trpc.useQuery(['resumes.reviews.list', { resumeId }]); const commentsQuery = trpc.useQuery(['resumes.reviews.list', { resumeId }]);
const renderButton = () => { const renderButton = () => {
if (sessionData === null) { if (sessionData === null) {
return <SignInButton text="to join discussion" />; return <ResumeSignInButton text="to join discussion" />;
} }
return ( return (
<Button <Button

@ -4,7 +4,7 @@ type Props = Readonly<{
text: string; text: string;
}>; }>;
export default function SignInButton({ text }: Props) { export default function ResumeSignInButton({ text }: Props) {
return ( return (
<div className="flex justify-center pt-4"> <div className="flex justify-center pt-4">
<p> <p>

@ -35,18 +35,18 @@ export default function ResumeReviewPage() {
}, },
); );
const starMutation = trpc.useMutation('resumes.resume.star', { const starMutation = trpc.useMutation('resumes.resume.star', {
onError() { onSuccess() {
setStarDetails({ setStarDetails({
isStarred: false, isStarred: true,
numStars: starDetails.numStars - 1, numStars: starDetails.numStars + 1,
}); });
}, },
}); });
const unstarMutation = trpc.useMutation('resumes.resume.unstar', { const unstarMutation = trpc.useMutation('resumes.resume.unstar', {
onError() { onSuccess() {
setStarDetails({ setStarDetails({
isStarred: true, isStarred: false,
numStars: starDetails.numStars + 1, numStars: starDetails.numStars - 1,
}); });
}, },
}); });
@ -65,12 +65,11 @@ export default function ResumeReviewPage() {
}, [detailsQuery.data]); }, [detailsQuery.data]);
const onStarButtonClick = () => { const onStarButtonClick = () => {
setStarDetails({ if (session?.user?.id == null) {
isStarred: !starDetails.isStarred, router.push('/api/auth/signin');
numStars: starDetails.isStarred return;
? starDetails.numStars - 1 }
: starDetails.numStars + 1,
});
// Star button only rendered if resume exists // Star button only rendered if resume exists
// Star button only clickable if user exists // Star button only clickable if user exists
if (starDetails.isStarred) { if (starDetails.isStarred) {
@ -110,7 +109,7 @@ export default function ResumeReviewPage() {
: '', : '',
'isolate inline-flex max-h-10 items-center space-x-4 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 disabled:hover:bg-white', 'isolate inline-flex max-h-10 items-center space-x-4 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 disabled:hover:bg-white',
)} )}
disabled={session?.user === undefined} disabled={starMutation.isLoading || unstarMutation.isLoading}
id="star-button" id="star-button"
type="button" type="button"
onClick={onStarButtonClick}> onClick={onStarButtonClick}>
@ -166,7 +165,7 @@ export default function ResumeReviewPage() {
</div> </div>
</div> </div>
{detailsQuery.data.additionalInfo && ( {detailsQuery.data.additionalInfo && (
<div className="flex items-center pt-2 text-sm text-gray-500"> <div className="flex items-start whitespace-pre-wrap pt-2 text-sm text-gray-500">
<InformationCircleIcon <InformationCircleIcon
aria-hidden="true" aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-gray-400" className="mr-1.5 h-5 w-5 flex-shrink-0 text-gray-400"

@ -19,11 +19,11 @@ import {
ROLES, ROLES,
SORT_OPTIONS, SORT_OPTIONS,
TOP_HITS, TOP_HITS,
} from '~/components/resumes/browse/constants'; } from '~/components/resumes/browse/resumeConstants';
import FilterPill from '~/components/resumes/browse/FilterPill'; import ResumeFilterPill from '~/components/resumes/browse/ResumeFilterPill';
import ResumeListItems from '~/components/resumes/browse/ResumeListItems'; import ResumeListItems from '~/components/resumes/browse/ResumeListItems';
import ResumeReviewsTitle from '~/components/resumes/ResumeReviewsTitle'; import ResumeReviewsTitle from '~/components/resumes/ResumeReviewsTitle';
import SignInButton from '~/components/resumes/SignInButton'; import ResumeSignInButton from '~/components/resumes/shared/ResumeSignInButton';
import { trpc } from '~/utils/trpc'; import { trpc } from '~/utils/trpc';
@ -98,7 +98,7 @@ export default function ResumeHomePage() {
if (sessionData?.user?.id) { if (sessionData?.user?.id) {
router.push('/resumes/submit'); router.push('/resumes/submit');
} else { } else {
// TODO: Handle non-logged in user behaviour router.push('/api/auth/signin');
} }
}; };
@ -221,7 +221,7 @@ export default function ResumeHomePage() {
{TOP_HITS.map((category) => ( {TOP_HITS.map((category) => (
<li key={category.name}> <li key={category.name}>
{/* TODO: Replace onClick with filtering function */} {/* TODO: Replace onClick with filtering function */}
<FilterPill <ResumeFilterPill
title={category.name} title={category.name}
onClick={() => true} onClick={() => true}
/> />
@ -287,7 +287,9 @@ export default function ResumeHomePage() {
</div> </div>
</div> </div>
<div className="col-span-10 pr-8"> <div className="col-span-10 pr-8">
{renderSignInButton && <SignInButton text={signInButtonText} />} {renderSignInButton && (
<ResumeSignInButton text={signInButtonText} />
)}
<ResumeListItems <ResumeListItems
isLoading={ isLoading={
allResumesQuery.isFetching || allResumesQuery.isFetching ||

@ -12,7 +12,7 @@ import {
EXPERIENCE, EXPERIENCE,
LOCATION, LOCATION,
ROLES, ROLES,
} from '~/components/resumes/browse/constants'; } from '~/components/resumes/browse/resumeConstants';
import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys'; import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys';
import { trpc } from '~/utils/trpc'; import { trpc } from '~/utils/trpc';

Loading…
Cancel
Save