|
2 | 2 |
|
3 | 3 | import { useTranslation } from "@/i18n/use-translation"; |
4 | 4 | import { formattedTime } from "@/lib/utils"; |
| 5 | +import clsx from "clsx"; |
5 | 6 | import Image from "next/image"; |
6 | 7 | import Link from "next/link"; |
7 | 8 | import { useMemo } from "react"; |
8 | | -import { HoverCard, HoverCardContent, HoverCardTrigger } from "./ui/hover-card"; |
9 | | -import UserInformationCard from "./UserInformationCard"; |
10 | 9 | import BookmarkStatus from "./render-props/BookmarkStatus"; |
11 | | -import clsx from "clsx"; |
12 | 10 | import ReactionStatus from "./render-props/ReactionStatus"; |
| 11 | +import { HoverCard, HoverCardContent, HoverCardTrigger } from "./ui/hover-card"; |
| 12 | +import UserInformationCard from "./UserInformationCard"; |
| 13 | +import { useLoginPopup } from "./app-login-popup"; |
| 14 | +import { useSession } from "@/store/session.atom"; |
13 | 15 |
|
14 | 16 | interface ArticleCardProps { |
15 | 17 | id: string; |
@@ -42,6 +44,8 @@ const ArticleCard = ({ |
42 | 44 | comments, |
43 | 45 | }: ArticleCardProps) => { |
44 | 46 | const { lang } = useTranslation(); |
| 47 | + const session = useSession(); |
| 48 | + const loginPopup = useLoginPopup(); |
45 | 49 |
|
46 | 50 | const articleUrl = useMemo(() => { |
47 | 51 | return `/@${author.username}/${handle}`; |
@@ -126,7 +130,13 @@ const ArticleCard = ({ |
126 | 130 | "px-2 py-1 flex gap-1 cursor-pointer rounded-sm hover:bg-primary/20", |
127 | 131 | { "bg-primary/20": r.is_reacted } |
128 | 132 | )} |
129 | | - onClick={() => toggle(r.reaction_type!)} |
| 133 | + onClick={() => { |
| 134 | + if (!session?.user) { |
| 135 | + loginPopup.show(); |
| 136 | + return; |
| 137 | + } |
| 138 | + toggle(r.reaction_type!); |
| 139 | + }} |
130 | 140 | > |
131 | 141 | <img |
132 | 142 | src={`/reactions/${r.reaction_type}.svg`} |
|
0 commit comments