-
-
Notifications
You must be signed in to change notification settings - Fork 468
/
TaskListItem.tsx
106 lines (102 loc) · 2.92 KB
/
TaskListItem.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import React, { useState } from 'react';
import ListItem from '@mui/material/ListItem';
import Divider from '@mui/material/Divider';
import ListItemText from '@mui/material/ListItemText';
import Chip from '@mui/material/Chip';
import Typography from '@mui/material/Typography';
import ListItemAvatar from '@mui/material/ListItemAvatar';
import Avatar from '@mui/material/Avatar';
import EditOutlinedIcon from '@mui/icons-material/EditOutlined';
import { common } from '@mui/material/colors';
import AssignmentIcon from '@mui/icons-material/Assignment';
import AssignmentTurnedInIcon from '@mui/icons-material/AssignmentTurnedIn';
import { UpdateTaskModal } from 'components/TaskModals/UpdateTaskModal';
interface InterfaceUser {
_id: string;
firstName: string;
lastName: string;
}
interface InterfaceTask {
_id: string;
title: string;
deadline: string;
description: string;
completed: boolean;
volunteers: InterfaceUser[];
}
type PropType = {
task: InterfaceTask;
refetchData: () => void;
organization: {
_id: string;
members: InterfaceUser[];
};
};
export const TaskListItem = ({
task,
refetchData,
organization: organizationData,
}: PropType): JSX.Element => {
const [showUpdateTaskModal, setShowUpdateTaskModal] = useState(false);
return (
<>
<div>
<ListItem alignItems="flex-start">
<ListItemAvatar>
<Avatar
sx={{
bgcolor: common['white'],
width: 36,
height: 36,
}}
variant="rounded"
>
{' '}
{task.completed ? (
<AssignmentTurnedInIcon color="success" fontSize="large" />
) : (
<AssignmentIcon color="primary" fontSize="large" />
)}
</Avatar>
</ListItemAvatar>
<ListItemText
primary={task.title}
secondary={
<React.Fragment>
<Typography
sx={{ display: 'inline' }}
component="span"
variant="body2"
color="text.primary"
>
{task.description}
</Typography>
</React.Fragment>
}
/>
<Chip
icon={<EditOutlinedIcon fontSize="small" />}
label="View"
variant="outlined"
onClick={(): void => {
setShowUpdateTaskModal(true);
}}
/>
</ListItem>
<Divider component="li" />
<div>
{/* Wrapper Div for all the relevant modals */}
<UpdateTaskModal
show={showUpdateTaskModal}
handleClose={(): void => {
setShowUpdateTaskModal(false);
}}
task={task}
refetchData={refetchData}
organization={organizationData}
/>
</div>
</div>
</>
);
};