Skip to content

Commit

Permalink
[frontend] Change to not display the add friend button and confirm bu…
Browse files Browse the repository at this point in the history
…tton while blocking (#295)
  • Loading branch information
lim396 authored Mar 4, 2024
1 parent f606b66 commit f3fb2d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/app/user/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export default async function FindUser({
const hasSentRequest = requests.requesting.some((r) => r.id === userId);
const hasReceivedRequest = requests.requestedBy.some((r) => r.id === userId);
const isFriend = myFriends.some((f) => f.id == userId);
const canAddFriend = !hasSentRequest && !hasReceivedRequest && !isFriend;
const isBlocking = blockingUsers.some((b) => b.id === userId);
const canAddFriend =
!hasSentRequest && !hasReceivedRequest && !isFriend && !isBlocking;
const canAcceptFriend = hasReceivedRequest && !isFriend && !isBlocking;
// TODO: Must consider these situations
// 1. Already friends
// 2. Friend request sent
Expand All @@ -58,7 +60,7 @@ export default async function FindUser({
<>
<div className="flex gap-4">
{hasSentRequest && <CancelFriendRequestButton id={userId} />}
{hasReceivedRequest && <AcceptFriendButton id={userId} />}
{canAcceptFriend && <AcceptFriendButton id={userId} />}
{hasReceivedRequest && <RejectFriendButton id={userId} />}
{isFriend && <RemoveFriendButton id={userId} />}
{canAddFriend && <AddFriendButton id={userId} />}
Expand Down

0 comments on commit f3fb2d3

Please sign in to comment.