fix: hide the team member progress (#7077)

* fix: hide the team member progress

* Refactor member progress

---------

Co-authored-by: Kamran Ahmed <kamranahmed.se@gmail.com>
pull/7082/head
Arik Chakma 2 months ago committed by GitHub
parent 537bbc2ceb
commit cf5301030f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      src/components/TeamMembers/TeamMemberItem.tsx
  2. 27
      src/components/TeamMembers/TeamMembersPage.tsx
  3. 44
      src/components/TeamProgress/TeamProgressPage.tsx

@ -12,6 +12,7 @@ type TeamMemberProps = {
userId: string; userId: string;
index: number; index: number;
teamId: string; teamId: string;
canViewProgress: boolean;
canManageCurrentTeam: boolean; canManageCurrentTeam: boolean;
onDeleteMember: () => void; onDeleteMember: () => void;
onUpdateMember: () => void; onUpdateMember: () => void;
@ -29,11 +30,12 @@ export function TeamMemberItem(props: TeamMemberProps) {
userId, userId,
onDeleteMember, onDeleteMember,
onSendProgressReminder, onSendProgressReminder,
canViewProgress = true,
} = props; } = props;
const currentTeam = useStore($currentTeam); const currentTeam = useStore($currentTeam);
const canManageTeam = useStore($canManageCurrentTeam); const canManageTeam = useStore($canManageCurrentTeam);
const showNoProgressBadge = !member.hasProgress && member.status === 'joined'; const showNoProgressBadge = canViewProgress && !member.hasProgress && member.status === 'joined';
const allowProgressReminder = const allowProgressReminder =
canManageTeam && canManageTeam &&
!member.hasProgress && !member.hasProgress &&

@ -61,7 +61,7 @@ export function TeamMembersPage() {
async function loadTeam() { async function loadTeam() {
const { response, error } = await httpGet<TeamDocument>( const { response, error } = await httpGet<TeamDocument>(
`${import.meta.env.PUBLIC_API_URL}/v1-get-team/${teamId}` `${import.meta.env.PUBLIC_API_URL}/v1-get-team/${teamId}`,
); );
if (error || !response) { if (error || !response) {
toast.error(error?.message || 'Something went wrong'); toast.error(error?.message || 'Something went wrong');
@ -75,7 +75,7 @@ export function TeamMembersPage() {
async function getTeamMemberList() { async function getTeamMemberList() {
const { response, error } = await httpGet<TeamMemberItem[]>( const { response, error } = await httpGet<TeamMemberItem[]>(
`${import.meta.env.PUBLIC_API_URL}/v1-get-team-member-list/${teamId}` `${import.meta.env.PUBLIC_API_URL}/v1-get-team-member-list/${teamId}`,
); );
if (error || !response) { if (error || !response) {
toast.error(error?.message || 'Failed to load team member list'); toast.error(error?.message || 'Failed to load team member list');
@ -100,7 +100,7 @@ export function TeamMembersPage() {
`${ `${
import.meta.env.PUBLIC_API_URL import.meta.env.PUBLIC_API_URL
}/v1-delete-member/${teamId}/${memberId}`, }/v1-delete-member/${teamId}/${memberId}`,
{} {},
); );
if (error || !response) { if (error || !response) {
@ -118,7 +118,7 @@ export function TeamMembersPage() {
`${ `${
import.meta.env.PUBLIC_API_URL import.meta.env.PUBLIC_API_URL
}/v1-resend-invite/${teamId}/${memberId}`, }/v1-resend-invite/${teamId}/${memberId}`,
{} {},
); );
if (error || !response) { if (error || !response) {
@ -135,7 +135,7 @@ export function TeamMembersPage() {
`${ `${
import.meta.env.PUBLIC_API_URL import.meta.env.PUBLIC_API_URL
}/v1-send-progress-reminder/${teamId}/${memberId}`, }/v1-send-progress-reminder/${teamId}/${memberId}`,
{} {},
); );
if (error || !response) { if (error || !response) {
@ -147,13 +147,13 @@ export function TeamMembersPage() {
} }
const joinedMembers = teamMembers.filter( const joinedMembers = teamMembers.filter(
(member) => member.status === 'joined' (member) => member.status === 'joined',
); );
const invitedMembers = teamMembers.filter( const invitedMembers = teamMembers.filter(
(member) => member.status === 'invited' (member) => member.status === 'invited',
); );
const rejectedMembers = teamMembers.filter( const rejectedMembers = teamMembers.filter(
(member) => member.status === 'rejected' (member) => member.status === 'rejected',
); );
return ( return (
@ -205,6 +205,11 @@ export function TeamMembersPage() {
index={index} index={index}
teamId={teamId} teamId={teamId}
userId={user?.id!} userId={user?.id!}
canViewProgress={
canManageCurrentTeam ||
!team?.personalProgressOnly ||
String(member.userId) === user?.id
}
onResendInvite={() => { onResendInvite={() => {
resendInvite(teamId, member._id!).finally(() => { resendInvite(teamId, member._id!).finally(() => {
pageProgressMessage.set(''); pageProgressMessage.set('');
@ -241,6 +246,7 @@ export function TeamMembersPage() {
index={index} index={index}
teamId={teamId} teamId={teamId}
userId={user?.id!} userId={user?.id!}
canViewProgress={false}
onResendInvite={() => { onResendInvite={() => {
resendInvite(teamId, member._id!).finally(() => { resendInvite(teamId, member._id!).finally(() => {
pageProgressMessage.set(''); pageProgressMessage.set('');
@ -269,7 +275,9 @@ export function TeamMembersPage() {
{rejectedMembers.length > 0 && ( {rejectedMembers.length > 0 && (
<div className="mt-6"> <div className="mt-6">
<h3 className="text-xs uppercase text-gray-400">Rejected Invites</h3> <h3 className="text-xs uppercase text-gray-400">
Rejected Invites
</h3>
<div className="mt-2 rounded-b-sm rounded-t-md border"> <div className="mt-2 rounded-b-sm rounded-t-md border">
{rejectedMembers.map((member, index) => { {rejectedMembers.map((member, index) => {
return ( return (
@ -278,6 +286,7 @@ export function TeamMembersPage() {
member={member} member={member}
index={index} index={index}
teamId={teamId} teamId={teamId}
canViewProgress={false}
userId={user?.id!} userId={user?.id!}
onResendInvite={() => { onResendInvite={() => {
resendInvite(teamId, member._id!).finally(() => { resendInvite(teamId, member._id!).finally(() => {

@ -10,6 +10,7 @@ import { getUrlParams, setUrlParams } from '../../lib/browser';
import { useAuth } from '../../hooks/use-auth'; import { useAuth } from '../../hooks/use-auth';
import { MemberProgressModal } from './MemberProgressModal'; import { MemberProgressModal } from './MemberProgressModal';
import { MemberCustomProgressModal } from './MemberCustomProgressModal'; import { MemberCustomProgressModal } from './MemberCustomProgressModal';
import { canManageCurrentRoadmap } from '../../stores/roadmap.ts';
export type UserProgress = { export type UserProgress = {
resourceTitle: string; resourceTitle: string;
@ -191,7 +192,7 @@ export function TeamProgressPage() {
key={grouping.value} key={grouping.value}
className={`rounded-md border p-1 px-2 text-sm ${ className={`rounded-md border p-1 px-2 text-sm ${
selectedGrouping === grouping.value selectedGrouping === grouping.value
? ' border-gray-400 bg-gray-200 ' ? 'border-gray-400 bg-gray-200'
: '' : ''
}`} }`}
onClick={() => setSelectedGrouping(grouping.value)} onClick={() => setSelectedGrouping(grouping.value)}
@ -223,21 +224,32 @@ export function TeamProgressPage() {
)} )}
{selectedGrouping === 'member' && ( {selectedGrouping === 'member' && (
<div className="grid gap-4 sm:grid-cols-2"> <div className="grid gap-4 sm:grid-cols-2">
{teamMembers.map((member) => ( {teamMembers.map((member) => {
<MemberProgressItem const canViewMemberProgress =
key={member._id} currentTeam?.role !== 'member' ||
member={member} !currentTeam?.personalProgressOnly ||
teamId={teamId} member.email === user?.email;
isMyProgress={member?.email === user?.email}
onShowResourceProgress={(resourceId, isCustomResource) => { if (!canViewMemberProgress) {
setShowMemberProgress({ return null;
resourceId, }
member,
isCustomResource, return (
}); <MemberProgressItem
}} key={member._id}
/> member={member}
))} teamId={teamId}
isMyProgress={member?.email === user?.email}
onShowResourceProgress={(resourceId, isCustomResource) => {
setShowMemberProgress({
resourceId,
member,
isCustomResource,
});
}}
/>
);
})}
</div> </div>
)} )}
</div> </div>

Loading…
Cancel
Save