[resumes][refactor] redirect user to signin on vote ()

Co-authored-by: Terence Ho <>
pull/444/head
Terence 2 years ago committed by GitHub
parent a12686e37f
commit e3620faafe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,5 @@
import clsx from 'clsx';
import { useRouter } from 'next/router';
import { useState } from 'react';
import {
ArrowDownCircleIcon,
@ -21,6 +22,7 @@ export default function ResumeCommentVoteButtons({
const [downvoteAnimation, setDownvoteAnimation] = useState(false);
const trpcContext = trpc.useContext();
const router = useRouter();
// COMMENT VOTES
const commentVotesQuery = trpc.useQuery([
@ -47,6 +49,11 @@ export default function ResumeCommentVoteButtons({
);
const onVote = async (value: Vote, setAnimation: (_: boolean) => void) => {
if (!userId) {
router.push('/api/auth/signin');
return;
}
setAnimation(true);
if (commentVotesQuery.data?.userVote?.value === value) {
@ -74,7 +81,6 @@ export default function ResumeCommentVoteButtons({
<>
<button
disabled={
!userId ||
commentVotesQuery.isLoading ||
commentVotesUpsertMutation.isLoading ||
commentVotesDeleteMutation.isLoading
@ -103,7 +109,6 @@ export default function ResumeCommentVoteButtons({
<button
disabled={
!userId ||
commentVotesQuery.isLoading ||
commentVotesUpsertMutation.isLoading ||
commentVotesDeleteMutation.isLoading

Loading…
Cancel
Save