Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[frontend] Change to not display the add friend button and confirm button while blocking #295

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading