|
|
@ -1,5 +1,5 @@ |
|
|
|
import { useEffect, useState } from 'preact/hooks'; |
|
|
|
import { useEffect, useState } from 'preact/hooks'; |
|
|
|
import { httpDelete, httpGet } from '../../lib/http'; |
|
|
|
import { httpDelete, httpGet, httpPatch } from '../../lib/http'; |
|
|
|
import { MemberActionDropdown } from './MemberActionDropdown'; |
|
|
|
import { MemberActionDropdown } from './MemberActionDropdown'; |
|
|
|
import { useAuth } from '../../hooks/use-auth'; |
|
|
|
import { useAuth } from '../../hooks/use-auth'; |
|
|
|
import { pageProgressMessage } from '../../stores/page'; |
|
|
|
import { pageProgressMessage } from '../../stores/page'; |
|
|
@ -94,11 +94,11 @@ export function TeamMembersPage() { |
|
|
|
pageProgressMessage.set(''); |
|
|
|
pageProgressMessage.set(''); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, [teamId]); |
|
|
|
}, [teamId]); |
|
|
|
|
|
|
|
|
|
|
|
async function deleteMember(teamId: string, memberId: string) { |
|
|
|
async function deleteMember(teamId: string, memberId: string) { |
|
|
|
pageProgressMessage.set('Deleting member'); |
|
|
|
pageProgressMessage.set('Deleting member'); |
|
|
|
const { response, error } = await httpDelete( |
|
|
|
const { response, error } = await httpDelete( |
|
|
|
`${import.meta.env.PUBLIC_API_URL |
|
|
|
`${ |
|
|
|
|
|
|
|
import.meta.env.PUBLIC_API_URL |
|
|
|
}/v1-delete-member/${teamId}/${memberId}`,
|
|
|
|
}/v1-delete-member/${teamId}/${memberId}`,
|
|
|
|
{} |
|
|
|
{} |
|
|
|
); |
|
|
|
); |
|
|
@ -112,6 +112,23 @@ export function TeamMembersPage() { |
|
|
|
await getTeamMemberList(); |
|
|
|
await getTeamMemberList(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function handleSendReminder(teamId: string, memberId: string) { |
|
|
|
|
|
|
|
pageProgressMessage.set('Sending Reminder'); |
|
|
|
|
|
|
|
const { response, error } = await httpPatch( |
|
|
|
|
|
|
|
`${ |
|
|
|
|
|
|
|
import.meta.env.PUBLIC_API_URL |
|
|
|
|
|
|
|
}/v1-send-progress-reminder/${teamId}/${memberId}`,
|
|
|
|
|
|
|
|
{} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (error || !response) { |
|
|
|
|
|
|
|
toast.error(error?.message || 'Something went wrong'); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toast.success('Reminder has been sent'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const joinedMembers = teamMembers.filter( |
|
|
|
const joinedMembers = teamMembers.filter( |
|
|
|
(member) => member.status === 'joined' |
|
|
|
(member) => member.status === 'joined' |
|
|
|
); |
|
|
|
); |
|
|
@ -180,66 +197,81 @@ export function TeamMembersPage() { |
|
|
|
onUpdateMember={() => { |
|
|
|
onUpdateMember={() => { |
|
|
|
setMemberToUpdate(member); |
|
|
|
setMemberToUpdate(member); |
|
|
|
}} |
|
|
|
}} |
|
|
|
|
|
|
|
handleSendReminder={() => { |
|
|
|
|
|
|
|
handleSendReminder(teamId, member._id!).finally(() => { |
|
|
|
|
|
|
|
pageProgressMessage.set(''); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}} |
|
|
|
/> |
|
|
|
/> |
|
|
|
); |
|
|
|
); |
|
|
|
})} |
|
|
|
})} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
{invitedMembers.length > 0 && (<div className="mt-6"> |
|
|
|
{invitedMembers.length > 0 && ( |
|
|
|
<h3 className="font-medium text-xl">Invited Members</h3> |
|
|
|
<div className="mt-6"> |
|
|
|
<div className="rounded-b-sm rounded-t-md border mt-2"> |
|
|
|
<h3 className="text-xl font-medium">Invited Members</h3> |
|
|
|
{invitedMembers.map((member, index) => { |
|
|
|
<div className="mt-2 rounded-b-sm rounded-t-md border"> |
|
|
|
return ( |
|
|
|
{invitedMembers.map((member, index) => { |
|
|
|
<TeamMemberItem |
|
|
|
return ( |
|
|
|
key={index} |
|
|
|
<TeamMemberItem |
|
|
|
member={member} |
|
|
|
key={index} |
|
|
|
index={index} |
|
|
|
member={member} |
|
|
|
teamId={teamId} |
|
|
|
index={index} |
|
|
|
userId={user?.id!} |
|
|
|
teamId={teamId} |
|
|
|
canManageCurrentTeam={canManageCurrentTeam} |
|
|
|
userId={user?.id!} |
|
|
|
handleDeleteMember={() => { |
|
|
|
canManageCurrentTeam={canManageCurrentTeam} |
|
|
|
deleteMember(teamId, member._id!).finally(() => { |
|
|
|
handleDeleteMember={() => { |
|
|
|
pageProgressMessage.set(''); |
|
|
|
deleteMember(teamId, member._id!).finally(() => { |
|
|
|
}); |
|
|
|
pageProgressMessage.set(''); |
|
|
|
}} |
|
|
|
}); |
|
|
|
onUpdateMember={() => { |
|
|
|
}} |
|
|
|
setMemberToUpdate(member); |
|
|
|
onUpdateMember={() => { |
|
|
|
}} |
|
|
|
setMemberToUpdate(member); |
|
|
|
/> |
|
|
|
}} |
|
|
|
); |
|
|
|
handleSendReminder={() => { |
|
|
|
})} |
|
|
|
handleSendReminder(teamId, member._id!).finally(() => { |
|
|
|
|
|
|
|
pageProgressMessage.set(''); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
})} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div>)} |
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{rejectedMembers.length > 0 && ( |
|
|
|
rejectedMembers.length > 0 && ( |
|
|
|
<div className="mt-6"> |
|
|
|
<div className="mt-6"> |
|
|
|
<h3 className="text-xl font-medium">Rejected Members</h3> |
|
|
|
<h3 className="font-medium text-xl">Rejected Members</h3> |
|
|
|
<div className="mt-2 rounded-b-sm rounded-t-md border"> |
|
|
|
<div className="rounded-b-sm rounded-t-md border mt-2"> |
|
|
|
{rejectedMembers.map((member, index) => { |
|
|
|
{rejectedMembers.map((member, index) => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<TeamMemberItem |
|
|
|
<TeamMemberItem |
|
|
|
key={index} |
|
|
|
key={index} |
|
|
|
member={member} |
|
|
|
member={member} |
|
|
|
index={index} |
|
|
|
index={index} |
|
|
|
teamId={teamId} |
|
|
|
teamId={teamId} |
|
|
|
userId={user?.id!} |
|
|
|
userId={user?.id!} |
|
|
|
canManageCurrentTeam={canManageCurrentTeam} |
|
|
|
canManageCurrentTeam={canManageCurrentTeam} |
|
|
|
handleDeleteMember={() => { |
|
|
|
handleDeleteMember={() => { |
|
|
|
deleteMember(teamId, member._id!).finally(() => { |
|
|
|
deleteMember(teamId, member._id!).finally(() => { |
|
|
|
pageProgressMessage.set(''); |
|
|
|
pageProgressMessage.set(''); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}} |
|
|
|
}} |
|
|
|
onUpdateMember={() => { |
|
|
|
onUpdateMember={() => { |
|
|
|
setMemberToUpdate(member); |
|
|
|
setMemberToUpdate(member); |
|
|
|
}} |
|
|
|
}} |
|
|
|
handleSendReminder={() => { |
|
|
|
/> |
|
|
|
handleSendReminder(teamId, member._id!).finally(() => { |
|
|
|
); |
|
|
|
pageProgressMessage.set(''); |
|
|
|
})} |
|
|
|
}); |
|
|
|
</div> |
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
})} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
</div> |
|
|
|
} |
|
|
|
)} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
{canManageCurrentTeam && ( |
|
|
|
{canManageCurrentTeam && ( |
|
|
|