Skip to content

Commit

Permalink
fix(access): 🐛 show edit option only for members #9
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnaveen authored Oct 2, 2024
2 parents 46b01a7 + 7421e86 commit 69ab161
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/[slug]/[board]/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default async function BoardLayout({
placeholder="Search Posts (Coming Soon)"
/>
<BoardView />
<BoardOptions />
{hasAccess && <BoardOptions />}
{session ? (
<CreatePost
boardId={board.id as string}
Expand Down
26 changes: 16 additions & 10 deletions components/posts/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ interface PostsCardProps {
layout: "compact" | "list" | "grid";
user: User;
currentUserId: string;
hasAccess: boolean;
}

export const PostsCard: React.FC<PostsCardProps> = ({
post,
layout = "compact",
currentUserId,
hasAccess,
}) => {
const upvoteCount = post?.upvoteCount ? post.upvoteCount : 0;
const isUpvoted = post?.upvotes.some(
Expand Down Expand Up @@ -93,11 +95,13 @@ export const PostsCard: React.FC<PostsCardProps> = ({
</div>
</div>
<div className="ml-2 flex-shrink-0">
<Options
currentUserId={currentUserId}
hasAccess={true}
post={post}
/>
{hasAccess && (
<Options
currentUserId={currentUserId}
hasAccess={true}
post={post}
/>
)}
</div>
</div>
</CardHeader>
Expand Down Expand Up @@ -159,11 +163,13 @@ export const PostsCard: React.FC<PostsCardProps> = ({
>
{formatPostStatus(post.status as string)}
</Badge>
<Options
currentUserId={currentUserId}
hasAccess={true}
post={post}
/>
{hasAccess && (
<Options
currentUserId={currentUserId}
hasAccess={true}
post={post}
/>
)}
</div>
</div>
</CardFooter>
Expand Down

0 comments on commit 69ab161

Please sign in to comment.