Skip to content

Commit

Permalink
Merge pull request #86 from WilliamTuominiemi/feat/admin
Browse files Browse the repository at this point in the history
feat: allows admins to delete all posts
  • Loading branch information
MaximilianHagelstam authored Aug 11, 2024
2 parents fd1b7e5 + 0e46de9 commit eb54caa
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/post/post-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ export const PostCard = ({ post, showPinned = false }: PostCardProps) => {
const { t } = useTranslation();
const { data: session } = useSession();

const adminUserIds = [
"clzo1nl2e0005137e1z9cnajv",
"clzlkp5j40000ibxoiwtfhtv4",
];

const userId = session?.user.id ?? "";
const isOwner = userId === post.user.id;
const isAdmin = adminUserIds.includes(userId);

return (
<>
<Dialog open={isOpen} onOpenChange={setIsOpen}>
Expand Down Expand Up @@ -67,10 +76,7 @@ export const PostCard = ({ post, showPinned = false }: PostCardProps) => {
{`${"·"} ${dayjs(post.createdAt).fromNow()}`}
</p>
</div>
<MoreButton
post={post}
isOwner={!!session?.user && session.user.id === post.user.id}
/>
<MoreButton post={post} isOwner={isOwner || isAdmin} />
</div>
<div className="flex flex-row justify-between">
<LikeButton post={post} />
Expand Down

0 comments on commit eb54caa

Please sign in to comment.