Skip to content

Commit 3114863

Browse files
committed
feat: add is_verified field to article and user components for enhanced user verification display
1 parent 6405426 commit 3114863

6 files changed

Lines changed: 32 additions & 16 deletions

File tree

src/app/(home)/_components/ArticleFeed.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const ArticleFeed = () => {
8787
? getFileUrl(article?.user?.profile_photo!)
8888
: "",
8989
username: article?.user?.username ?? "",
90+
is_verified: Boolean(article?.user?.is_verified),
9091
}}
9192
publishedAt={article?.created_at.toDateString() ?? ""}
9293
readingTime={readingTime(article?.body ?? "")}

src/app/[username]/(profile-page)/articles/UserArticleFeed.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const UserArticleFeed: React.FC<UserArticleFeedProps> = ({ userId }) => {
7171
name: article?.user?.name ?? "",
7272
avatar: getFileUrl(article?.user?.profile_photo) ?? "",
7373
username: article?.user?.username ?? "",
74+
is_verified: Boolean(article?.user?.is_verified),
7475
}}
7576
publishedAt={article?.created_at?.toDateString() ?? ""}
7677
readingTime={readingTime(article?.body ?? "")}

src/app/tags/[tag_name]/_components/TagArticleFeed.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const TagArticleFeed: React.FC<TagArticleFeedProps> = ({ tag }) => {
128128
? getFileUrl(article.user.profile_photo)
129129
: "",
130130
username: article?.user?.username ?? "",
131+
is_verified: Boolean(article?.user.is_verified),
131132
}}
132133
publishedAt={article?.created_at?.toDateString() ?? ""}
133134
readingTime={readingTime(article?.body ?? "")}

src/backend/services/article.actions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export async function articleFeed(
340340
foreignField: "id",
341341
localField: "author_id",
342342
},
343-
columns: ["id", "name", "username", "profile_photo"],
343+
columns: ["id", "name", "username", "profile_photo", "is_verified"],
344344
} as sk.Join<Article, User>,
345345
],
346346
});
@@ -385,7 +385,7 @@ export async function userArticleFeed(
385385
foreignField: "id",
386386
localField: "author_id",
387387
},
388-
columns: ["id", "name", "username", "profile_photo"],
388+
columns: ["id", "name", "username", "profile_photo", "is_verified"],
389389
} as sk.Join<Article, User>,
390390
],
391391
});
@@ -432,6 +432,7 @@ export async function articlesByTag(
432432
u.name as user_name,
433433
u.username as user_username,
434434
u.profile_photo as user_profile_photo,
435+
u.is_verified as user_is_verified,
435436
t.name as tag_name,
436437
COUNT(*) OVER() as total_count
437438
FROM articles a
@@ -469,6 +470,7 @@ export async function articlesByTag(
469470
name: row.user_name,
470471
username: row.user_username,
471472
profile_photo: row.user_profile_photo,
473+
is_verified: row.user_is_verified,
472474
},
473475
}));
474476

src/components/ArticleCard.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ResourceBookmark from "./ResourceBookmark";
1111
import ResourceReaction from "./ResourceReaction";
1212
import { HoverCard, HoverCardContent, HoverCardTrigger } from "./ui/hover-card";
1313
import UserInformationCard from "./UserInformationCard";
14+
import { VerifiedIcon } from "lucide-react";
1415

1516
interface ArticleCardProps {
1617
id: string;
@@ -23,6 +24,7 @@ interface ArticleCardProps {
2324
name: string;
2425
avatar: string;
2526
username: string;
27+
is_verified: boolean;
2628
};
2729
publishedAt: string;
2830
readingTime: number;
@@ -39,8 +41,6 @@ const ArticleCard = ({
3941
readingTime,
4042
}: ArticleCardProps) => {
4143
const { lang } = useTranslation();
42-
const session = useSession();
43-
const loginPopup = useLoginPopup();
4444

4545
const articleUrl = useMemo(() => {
4646
return `/@${author.username}/${handle}`;
@@ -67,12 +67,17 @@ const ArticleCard = ({
6767
</HoverCardContent>
6868
</HoverCard>
6969
<div className="ml-2.5">
70-
<Link
71-
href={`/@${author.username}`}
72-
className="text-sm font-medium text-foreground"
73-
>
74-
{author.name}
75-
</Link>
70+
<div className="flex flex-wrap items-center gap-2">
71+
<Link
72+
href={`/@${author.username}`}
73+
className="text-sm font-medium text-foreground"
74+
>
75+
{author.name}
76+
</Link>
77+
{author?.is_verified && (
78+
<VerifiedIcon className="size-4 fill-primary" />
79+
)}
80+
</div>
7681
<div className="flex items-center text-xs text-muted-foreground">
7782
<time dateTime={publishedAt.toString()}>
7883
{formattedTime(new Date(publishedAt), lang)}

src/components/UserInformationCard.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"use client";
22

3-
import { useTranslation } from "@/i18n/use-translation";
4-
import { Button } from "./ui/button";
53
import * as userActions from "@/backend/services/user.action";
6-
import { useQuery } from "@tanstack/react-query";
4+
import { useTranslation } from "@/i18n/use-translation";
75
import { useSession } from "@/store/session.atom";
8-
import Link from "next/link";
9-
import Image from "next/image";
106
import getFileUrl from "@/utils/getFileUrl";
7+
import { useQuery } from "@tanstack/react-query";
8+
import { VerifiedIcon } from "lucide-react";
9+
import Image from "next/image";
10+
import Link from "next/link";
11+
import { Button } from "./ui/button";
1112

1213
interface Props {
1314
userId: string;
@@ -58,7 +59,12 @@ const UserInformationCard: React.FC<Props> = ({ userId }) => {
5859

5960
{/* Name */}
6061
<div>
61-
<h2 className="text-xl font-bold">{query.data?.name}</h2>
62+
<div className="flex flex-wrap items-center gap-2">
63+
<h2 className="text-xl font-bold">{query.data?.name}</h2>
64+
{query.data?.is_verified && (
65+
<VerifiedIcon className="size-5 fill-primary" />
66+
)}
67+
</div>
6268
<p className="text-sm text-muted-foreground">
6369
{query.data?.username}
6470
</p>

0 commit comments

Comments
 (0)