From 5bc33cb5276b873ae889e168bc5a37935cd61861 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 25 Jul 2023 20:05:47 +0100 Subject: [PATCH] Member progress item sorting --- src/components/TeamDropdown/TeamDropdown.tsx | 4 +-- .../TeamMembers/TeamMembersPage.tsx | 4 +-- .../TeamProgress/MemberProgressItem.tsx | 27 ++++++++++++----- .../TeamProgress/TeamProgressPage.tsx | 30 +++++++++++++------ 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/components/TeamDropdown/TeamDropdown.tsx b/src/components/TeamDropdown/TeamDropdown.tsx index 2fed4df15..bd191db74 100644 --- a/src/components/TeamDropdown/TeamDropdown.tsx +++ b/src/components/TeamDropdown/TeamDropdown.tsx @@ -95,7 +95,7 @@ export function TeamDropdown() { {pendingTeamIds.length} )} -
+
{isLoading && } {!isLoading && ( - {team.name} + {team.name} {pendingTeamIds.includes(team._id) && ( Invite diff --git a/src/components/TeamMembers/TeamMembersPage.tsx b/src/components/TeamMembers/TeamMembersPage.tsx index 67276ba88..9133de018 100644 --- a/src/components/TeamMembers/TeamMembersPage.tsx +++ b/src/components/TeamMembers/TeamMembersPage.tsx @@ -163,8 +163,8 @@ export function TeamMembersPage() {
-

- {member.name} +

+ {member.name} {member.userId === user?.id && ( You diff --git a/src/components/TeamProgress/MemberProgressItem.tsx b/src/components/TeamProgress/MemberProgressItem.tsx index 4c65f7703..9942fca23 100644 --- a/src/components/TeamProgress/MemberProgressItem.tsx +++ b/src/components/TeamProgress/MemberProgressItem.tsx @@ -5,9 +5,10 @@ import { MemberProgressModal } from './MemberProgressModal'; type MemberProgressItemProps = { teamId: string; member: TeamMember; + isMyProgress?: boolean; }; export function MemberProgressItem(props: MemberProgressItemProps) { - const { member, teamId } = props; + const { member, teamId, isMyProgress = false } = props; const memberProgress = member?.progress?.sort((a, b) => { return b.done - a.done; @@ -31,10 +32,10 @@ export function MemberProgressItem(props: MemberProgressItemProps) { )}
-
+
{member.name -
-

{member.name}

+
+ {!isMyProgress && ( +

{member.name}

+ )} + {isMyProgress && ( +
+

{member.name}

+ + You + +
+ )}

{member.email}

@@ -60,9 +71,11 @@ export function MemberProgressItem(props: MemberProgressItemProps) { > - {progress.resourceTitle} + + {progress.resourceTitle} + - + {progress.done} / {progress.total} diff --git a/src/components/TeamProgress/TeamProgressPage.tsx b/src/components/TeamProgress/TeamProgressPage.tsx index 0ab12507a..14aa1a69f 100644 --- a/src/components/TeamProgress/TeamProgressPage.tsx +++ b/src/components/TeamProgress/TeamProgressPage.tsx @@ -72,10 +72,17 @@ export function TeamProgressPage() { return; } - const currentUserProgress = response.find((member) => member.email === user?.email) - const otherUserProgresses = response.filter(member => member.email !== user?.email); - const allUserProgresses = currentUserProgress ? [currentUserProgress, ...otherUserProgresses] : otherUserProgresses; - setTeamMembers(allUserProgresses); + setTeamMembers( + response.sort((a, b) => { + if (a.email === user?.email) { + return -1; + } + if (b.email === user?.email) { + return 1; + } + return 0; + }) + ); } useEffect(() => { @@ -139,10 +146,11 @@ export function TeamProgressPage() {
{groupingTypes.map((grouping) => (