Skip to content

Commit e909f36

Browse files
authored
Merge pull request #4054 from Northeastern-Electric-Racing/#4023-guests-projects-tasks-tab
#4023 guest projects tasks tab
2 parents 7100fc6 + f14fc2f commit e909f36

3 files changed

Lines changed: 99 additions & 11 deletions

File tree

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/ProjectViewContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { Link, useHistory } from 'react-router-dom';
7-
import { Project, isGuest, isAdmin, isLeadership } from 'shared';
7+
import { Project, isGuest, isAdmin, isLeadership, RoleEnum } from 'shared';
88
import { projectWbsPipe, wbsPipe } from '../../../utils/pipes';
99
import ProjectDetails from './ProjectDetails';
1010
import { routes } from '../../../utils/routes';
@@ -207,7 +207,7 @@ const ProjectViewContainer: React.FC<ProjectViewContainerProps> = ({ project, en
207207
{tab === 0 ? (
208208
<ProjectDetails project={project} />
209209
) : tab === 1 ? (
210-
<TaskList project={project} />
210+
<TaskList project={project} isGuest={user.role === RoleEnum.GUEST} />
211211
) : tab === 2 ? (
212212
<BOMTab project={project} />
213213
) : tab === 3 ? (
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { Typography } from '@mui/material';
2+
import { Box, useTheme } from '@mui/system';
3+
import { Project, TaskPriority, TaskStatus } from 'shared';
4+
5+
const TaskCard = ({ task }: { task: any }) => {
6+
const theme = useTheme();
7+
const getPriorityColor = (priority: TaskPriority) => {
8+
switch (priority) {
9+
case TaskPriority.High:
10+
return '#ff0000';
11+
case TaskPriority.Medium:
12+
return '#ff9800';
13+
default:
14+
return '#4caf50';
15+
}
16+
};
17+
18+
return (
19+
<Box
20+
sx={{
21+
display: 'flex',
22+
alignItems: 'flex-start',
23+
gap: 1,
24+
p: 2,
25+
mb: 1,
26+
backgroundColor: theme.palette.background.paper,
27+
width: '100%',
28+
borderRadius: 1
29+
}}
30+
>
31+
<Typography
32+
sx={{
33+
color: getPriorityColor(task.priority),
34+
fontWeight: 'bold',
35+
flexShrink: 0
36+
}}
37+
>
38+
{task.priority}
39+
</Typography>
40+
<Typography> - {task.title}</Typography>
41+
</Box>
42+
);
43+
};
44+
45+
export const GuestsTasksList = ({ project }: { project: Project }) => {
46+
const backLogTasks = project.tasks.filter((task) => task.status === TaskStatus.IN_BACKLOG);
47+
const inProgressTasks = project.tasks.filter((task) => task.status === TaskStatus.IN_PROGRESS);
48+
const doneTasks = project.tasks.filter((task) => task.status === TaskStatus.DONE);
49+
50+
return (
51+
<Box justifyContent="space-between" mt={3}>
52+
{backLogTasks.length === 0 && inProgressTasks.length === 0 && doneTasks.length === 0 ? (
53+
<Typography variant="body1" sx={{ textAlign: 'center', color: 'text.secondary' }}>
54+
This project has no tasks associated with it
55+
</Typography>
56+
) : (
57+
<>
58+
{backLogTasks.length > 0 && (
59+
<>
60+
<Typography variant="h5" sx={{ cursor: 'pointer', mb: 1 }}>
61+
Back Log
62+
</Typography>
63+
{backLogTasks.map((task) => (
64+
<TaskCard task={task} />
65+
))}
66+
</>
67+
)}
68+
{inProgressTasks.length > 0 && (
69+
<>
70+
<Typography variant="h5" sx={{ cursor: 'pointer', mb: 1 }}>
71+
In Progress
72+
</Typography>
73+
{inProgressTasks.map((task) => (
74+
<TaskCard task={task} />
75+
))}
76+
</>
77+
)}
78+
{doneTasks.length > 0 && (
79+
<>
80+
<Typography variant="h5" sx={{ cursor: 'pointer', mb: 1 }}>
81+
Done
82+
</Typography>
83+
{doneTasks.map((task) => (
84+
<TaskCard task={task} />
85+
))}
86+
</>
87+
)}
88+
</>
89+
)}
90+
</Box>
91+
);
92+
};
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import { useMediaQuery, Typography, Theme } from '@mui/material';
1+
import { useMediaQuery, Theme } from '@mui/material';
22
import { Project } from 'shared';
33
import { TaskListContent } from './TaskListContent';
4+
import { GuestsTasksList } from '../GuestTasksList';
45

5-
export const TaskList = ({ project }: { project: Project }) => {
6+
export const TaskList = ({ project, isGuest }: { project: Project; isGuest: boolean }) => {
67
const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm'));
7-
return isSmall ? <FallbackForMobile /> : <TaskListContent project={project} />;
8-
};
98

10-
const FallbackForMobile = () => (
11-
<Typography mt={3} align="center">
12-
The Kanban board is not available on mobile
13-
</Typography>
14-
);
9+
return isSmall || isGuest ? <GuestsTasksList project={project} /> : <TaskListContent project={project} />;
10+
};

0 commit comments

Comments
 (0)