diff --git a/components/shared/FollowButton.tsx b/components/shared/FollowButton.tsx index 87fa5ec81..505397217 100644 --- a/components/shared/FollowButton.tsx +++ b/components/shared/FollowButton.tsx @@ -1,5 +1,6 @@ import { StyledImage } from "components/ProfilePage/StyledProfileComponents" import { useTranslation } from "next-i18next" +import { useRouter } from "next/router" import { useEffect, useContext } from "react" import { Button } from "react-bootstrap" import { useAuth } from "../auth" @@ -19,6 +20,7 @@ export const BaseFollowButton = ({ hide?: boolean }) => { const { t } = useTranslation(["profile"]) + const router = useRouter() const { user } = useAuth() const uid = user?.uid @@ -50,8 +52,14 @@ export const BaseFollowButton = ({ const checkmark = isFollowing ? ( ) : null - const handleClick = (event: React.FormEvent) => { + const handleClick = (event: React.MouseEvent) => { event.preventDefault() + + if (!uid) { + router.push(`/login?redirect=${encodeURIComponent(router.asPath)}`) + return + } + isFollowing ? UnfollowClick() : FollowClick() }