Member progress item sorting

chore/update-progress^2
Kamran Ahmed 1 year ago
parent 5d3202e065
commit 5bc33cb527
  1. 4
      src/components/TeamDropdown/TeamDropdown.tsx
  2. 4
      src/components/TeamMembers/TeamMembersPage.tsx
  3. 27
      src/components/TeamProgress/MemberProgressItem.tsx
  4. 30
      src/components/TeamProgress/TeamProgressPage.tsx

@ -95,7 +95,7 @@ export function TeamDropdown() {
{pendingTeamIds.length} {pendingTeamIds.length}
</span> </span>
)} )}
<div className="flex items-center gap-2"> <div className="inline-grid grid-cols-[16px_auto] items-center gap-1.5 mr-1.5">
{isLoading && <Spinner className="h-4 w-4" isDualRing={false} />} {isLoading && <Spinner className="h-4 w-4" isDualRing={false} />}
{!isLoading && ( {!isLoading && (
<img <img
@ -149,7 +149,7 @@ export function TeamDropdown() {
className="flex w-full cursor-pointer items-center gap-2 rounded p-2 text-sm font-medium text-slate-100 hover:bg-slate-700" className="flex w-full cursor-pointer items-center gap-2 rounded p-2 text-sm font-medium text-slate-100 hover:bg-slate-700"
href={`${pageLink}`} href={`${pageLink}`}
> >
<span className="flex-grow truncate">{team.name}</span> <span className="flex-grow min-w-0 truncate">{team.name}</span>
{pendingTeamIds.includes(team._id) && ( {pendingTeamIds.includes(team._id) && (
<span className="flex rounded-md bg-red-500 px-2 text-xs text-white"> <span className="flex rounded-md bg-red-500 px-2 text-xs text-white">
Invite Invite

@ -163,8 +163,8 @@ export function TeamMembersPage() {
<MemberRoleBadge role={member.role} /> <MemberRoleBadge role={member.role} />
</span> </span>
<div className="flex items-center"> <div className="flex items-center">
<h3 className="flex items-center font-medium"> <h3 className="inline-grid grid-cols-[auto_auto] items-center font-medium">
{member.name} <span className="truncate">{member.name}</span>
{member.userId === user?.id && ( {member.userId === user?.id && (
<span className="ml-2 hidden text-xs font-normal text-blue-500 sm:inline"> <span className="ml-2 hidden text-xs font-normal text-blue-500 sm:inline">
You You

@ -5,9 +5,10 @@ import { MemberProgressModal } from './MemberProgressModal';
type MemberProgressItemProps = { type MemberProgressItemProps = {
teamId: string; teamId: string;
member: TeamMember; member: TeamMember;
isMyProgress?: boolean;
}; };
export function MemberProgressItem(props: MemberProgressItemProps) { export function MemberProgressItem(props: MemberProgressItemProps) {
const { member, teamId } = props; const { member, teamId, isMyProgress = false } = props;
const memberProgress = member?.progress?.sort((a, b) => { const memberProgress = member?.progress?.sort((a, b) => {
return b.done - a.done; return b.done - a.done;
@ -31,10 +32,10 @@ export function MemberProgressItem(props: MemberProgressItemProps) {
)} )}
<div <div
className="flex h-full min-h-[270px] flex-col rounded-md border" className={`flex h-full min-h-[270px] flex-col overflow-hidden rounded-md border`}
key={member._id} key={member._id}
> >
<div className="flex items-center gap-3 border-b p-3"> <div className={`relative flex items-center gap-3 border-b p-3`}>
<img <img
src={ src={
member.avatar member.avatar
@ -44,8 +45,18 @@ export function MemberProgressItem(props: MemberProgressItemProps) {
alt={member.name || ''} alt={member.name || ''}
className="h-8 w-8 rounded-full" className="h-8 w-8 rounded-full"
/> />
<div className="inline-grid"> <div className="inline-grid w-full">
<h3 className="truncate font-medium">{member.name}</h3> {!isMyProgress && (
<h3 className="truncate font-medium">{member.name}</h3>
)}
{isMyProgress && (
<div className="inline-grid grid-cols-[auto,32px] items-center gap-1.5">
<h3 className="truncate font-medium">{member.name}</h3>
<span className="rounded-md bg-red-500 text-center py-0.5 text-xs text-white">
You
</span>
</div>
)}
<p className="truncate text-sm text-gray-500">{member.email}</p> <p className="truncate text-sm text-gray-500">{member.email}</p>
</div> </div>
</div> </div>
@ -60,9 +71,11 @@ export function MemberProgressItem(props: MemberProgressItemProps) {
> >
<span className="relative z-10 flex items-center justify-between text-sm"> <span className="relative z-10 flex items-center justify-between text-sm">
<span className="inline-grid"> <span className="inline-grid">
<span className={'truncate'}>{progress.resourceTitle}</span> <span className={'truncate'}>
{progress.resourceTitle}
</span>
</span> </span>
<span className="text-xs text-gray-400 shrink-0 ml-1.5"> <span className="ml-1.5 shrink-0 text-xs text-gray-400">
{progress.done} / {progress.total} {progress.done} / {progress.total}
</span> </span>
</span> </span>

@ -72,10 +72,17 @@ export function TeamProgressPage() {
return; return;
} }
const currentUserProgress = response.find((member) => member.email === user?.email) setTeamMembers(
const otherUserProgresses = response.filter(member => member.email !== user?.email); response.sort((a, b) => {
const allUserProgresses = currentUserProgress ? [currentUserProgress, ...otherUserProgresses] : otherUserProgresses; if (a.email === user?.email) {
setTeamMembers(allUserProgresses); return -1;
}
if (b.email === user?.email) {
return 1;
}
return 0;
})
);
} }
useEffect(() => { useEffect(() => {
@ -139,10 +146,11 @@ export function TeamProgressPage() {
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
{groupingTypes.map((grouping) => ( {groupingTypes.map((grouping) => (
<button <button
className={`rounded-md border p-1 px-2 text-sm ${selectedGrouping === grouping.value className={`rounded-md border p-1 px-2 text-sm ${
? ' border-gray-400 bg-gray-200 ' selectedGrouping === grouping.value
: '' ? ' border-gray-400 bg-gray-200 '
}`} : ''
}`}
onClick={() => setSelectedGrouping(grouping.value)} onClick={() => setSelectedGrouping(grouping.value)}
> >
{grouping.label} {grouping.label}
@ -163,7 +171,11 @@ 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 teamId={teamId} member={member} /> <MemberProgressItem
teamId={teamId}
member={member}
isMyProgress={member?.email === user?.email}
/>
))} ))}
</div> </div>
)} )}

Loading…
Cancel
Save