Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/shared/FollowButton.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -22,6 +23,7 @@ export const BaseFollowButton = ({

const { user } = useAuth()
const uid = user?.uid
const router = useRouter()

const { followStatus, setFollowStatus } = useContext(FollowContext)

Expand Down Expand Up @@ -52,6 +54,11 @@ export const BaseFollowButton = ({
) : null
const handleClick = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
if (!uid) {
const currentPath = router.asPath
router.push(`/login?redirect=${encodeURIComponent(currentPath)}`)
return
}
isFollowing ? UnfollowClick() : FollowClick()
}

Expand Down
7 changes: 7 additions & 0 deletions components/testimony/TestimonyDetailPage/PolicyActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { formUrl } from "components/publish"
import { FC, ReactElement, useContext, useEffect } from "react"
import { useCurrentTestimonyDetails } from "./testimonyDetailSlice"
import { useTranslation } from "next-i18next"
import { useRouter } from "next/router"
import { useAuth } from "components/auth"
import { TopicQuery } from "components/shared/FollowingQueries"
import { StyledImage } from "components/ProfilePage/StyledProfileComponents"
Expand Down Expand Up @@ -39,6 +40,7 @@ export const PolicyActions: FC<React.PropsWithChildren<PolicyActionsProps>> = ({

const { user } = useAuth()
const uid = user?.uid
const router = useRouter()

const { followStatus, setFollowStatus } = useContext(FollowContext)

Expand Down Expand Up @@ -69,6 +71,11 @@ export const PolicyActions: FC<React.PropsWithChildren<PolicyActionsProps>> = ({
) : null
const handleClick = (event: React.MouseEvent<Element, MouseEvent>) => {
event.preventDefault()
if (!uid) {
const currentPath = router.asPath
router.push(`/login?redirect=${encodeURIComponent(currentPath)}`)
return
}
isFollowing ? UnfollowClick() : FollowClick()
}

Expand Down