diff --git a/src/components/TeamMembers/TeamMemberItem.tsx b/src/components/TeamMembers/TeamMemberItem.tsx index 4442d3da2..7282aadf8 100644 --- a/src/components/TeamMembers/TeamMemberItem.tsx +++ b/src/components/TeamMembers/TeamMemberItem.tsx @@ -12,6 +12,7 @@ type TeamMemberProps = { userId: string; index: number; teamId: string; + canViewProgress: boolean; canManageCurrentTeam: boolean; onDeleteMember: () => void; onUpdateMember: () => void; @@ -29,11 +30,12 @@ export function TeamMemberItem(props: TeamMemberProps) { userId, onDeleteMember, onSendProgressReminder, + canViewProgress = true, } = props; const currentTeam = useStore($currentTeam); const canManageTeam = useStore($canManageCurrentTeam); - const showNoProgressBadge = !member.hasProgress && member.status === 'joined'; + const showNoProgressBadge = canViewProgress && !member.hasProgress && member.status === 'joined'; const allowProgressReminder = canManageTeam && !member.hasProgress && diff --git a/src/components/TeamMembers/TeamMembersPage.tsx b/src/components/TeamMembers/TeamMembersPage.tsx index e6ce94cd2..a568170bd 100644 --- a/src/components/TeamMembers/TeamMembersPage.tsx +++ b/src/components/TeamMembers/TeamMembersPage.tsx @@ -146,25 +146,13 @@ export function TeamMembersPage() { toast.success('Reminder has been sent'); } - const enrichedMembers = teamMembers.map((member) => { - const shouldNotShowProgressWarning = - team?.personalProgressOnly && - !canManageCurrentTeam && - member.userId !== user?.id; - - return { - ...member, - ...(shouldNotShowProgressWarning ? { hasProgress: true } : {}), - }; - }); - - const joinedMembers = enrichedMembers.filter( + const joinedMembers = teamMembers.filter( (member) => member.status === 'joined', ); - const invitedMembers = enrichedMembers.filter( + const invitedMembers = teamMembers.filter( (member) => member.status === 'invited', ); - const rejectedMembers = enrichedMembers.filter( + const rejectedMembers = teamMembers.filter( (member) => member.status === 'rejected', ); @@ -217,6 +205,11 @@ export function TeamMembersPage() { index={index} teamId={teamId} userId={user?.id!} + canViewProgress={ + canManageCurrentTeam || + !team?.personalProgressOnly || + String(member.userId) === user?.id + } onResendInvite={() => { resendInvite(teamId, member._id!).finally(() => { pageProgressMessage.set(''); @@ -253,6 +246,7 @@ export function TeamMembersPage() { index={index} teamId={teamId} userId={user?.id!} + canViewProgress={false} onResendInvite={() => { resendInvite(teamId, member._id!).finally(() => { pageProgressMessage.set(''); @@ -292,6 +286,7 @@ export function TeamMembersPage() { member={member} index={index} teamId={teamId} + canViewProgress={false} userId={user?.id!} onResendInvite={() => { resendInvite(teamId, member._id!).finally(() => { diff --git a/src/components/TeamProgress/TeamProgressPage.tsx b/src/components/TeamProgress/TeamProgressPage.tsx index 70d4f096d..747465465 100644 --- a/src/components/TeamProgress/TeamProgressPage.tsx +++ b/src/components/TeamProgress/TeamProgressPage.tsx @@ -10,6 +10,7 @@ import { getUrlParams, setUrlParams } from '../../lib/browser'; import { useAuth } from '../../hooks/use-auth'; import { MemberProgressModal } from './MemberProgressModal'; import { MemberCustomProgressModal } from './MemberCustomProgressModal'; +import { canManageCurrentRoadmap } from '../../stores/roadmap.ts'; export type UserProgress = { resourceTitle: string; @@ -81,28 +82,15 @@ export function TeamProgressPage() { } setTeamMembers( - response - .filter((member) => { - // If personal progress only is enabled, only show the current user's progress - // and only if the user is a member - if ( - currentTeam?.personalProgressOnly && - currentTeam?.role === 'member' - ) { - return member.email === user?.email; - } - - return true; - }) - .sort((a, b) => { - if (a.email === user?.email) { - return -1; - } - if (b.email === user?.email) { - return 1; - } - return 0; - }), + response.sort((a, b) => { + if (a.email === user?.email) { + return -1; + } + if (b.email === user?.email) { + return 1; + } + return 0; + }), ); } @@ -236,21 +224,32 @@ export function TeamProgressPage() { )} {selectedGrouping === 'member' && (