Skip to content

Commit

Permalink
Merge pull request #302 from PrerakMathur20/TaskCardIcon
Browse files Browse the repository at this point in the history
Task card icon
  • Loading branch information
swapnalshahil authored Aug 30, 2022
2 parents a329041 + 975e7ba commit 1b8410f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
66 changes: 53 additions & 13 deletions React-frontend/src/components/Admin/TaskCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import {
Container,
Typography,
Button

} from '@material-ui/core';
import Tooltip from '@mui/material/Tooltip';
import CreateIcon from '@material-ui/icons/Create';
import CheckCircleIcon from '@material-ui/icons/CheckCircle';
import CheckCircleOutlineIcon from '@material-ui/icons/CheckCircleOutline';
import { useHistory } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import { updateTask } from '../../store/actions/admin';



// Custom styles
const useStyles = makeStyles((theme) => ({
root: {
Expand Down Expand Up @@ -45,19 +47,22 @@ const useStyles = makeStyles((theme) => ({
bodyText: {
fontSize: theme.spacing(1.4),
fontWeight: '400',
marginBottom: theme.spacing(.3)
marginBottom: theme.spacing(1)
},
icons: {
fontSize: '2.3vh'
},
button: {
marginLeft: theme.spacing(1)
}
}))



function TaskCard({ id, title, description, due_on, is_completed }) {
const classes = useStyles()
const auth = useSelector(state => state.auth)
const dispatch = useDispatch()
const history = useHistory()


// toggle is_completed true of false function
function toggleComplete(id, is_completed) {
dispatch(updateTask(id, is_completed, history))
Expand Down Expand Up @@ -93,17 +98,52 @@ function TaskCard({ id, title, description, due_on, is_completed }) {
}
</Typography>

{/* Button to mask task completed */}
{
(auth.user.role === "admin") ?
(<Button
variant="contained"
color="primary"
onClick={() => toggleComplete(id, is_completed)}>
(<div>
{/* Task Completed status Button */}
{
(is_completed) ? (<span>Mark Incomplete</span>) : (<span>Mark Complete</span>)
(is_completed) ? (
<Tooltip title="Mark as Not Completed" placement="bottom-start">
<Button
variant="contained"
color="primary"
onClick={() => toggleComplete(id, is_completed)}
className={classes.button}
>
<CheckCircleIcon
className={classes.icons}
/>
</Button>
</Tooltip>
) : (
<Tooltip title="Mark as Completed" placement="bottom-start">
<Button
variant="contained"
color="primary"
onClick={() => toggleComplete(id, is_completed)}
className={classes.button}
>
<CheckCircleOutlineIcon
className={classes.icons}
/>
</Button>
</Tooltip>
)
}
</Button>)
{/* Task Edit Button */}
<Tooltip title="Edit" placement="bottom-end">

<Button
variant="contained"
color="primary"
className={classes.button}
>
<CreateIcon className={classes.icons} />
</Button>
</Tooltip>
</div>
)
: null
}

Expand Down
2 changes: 1 addition & 1 deletion React-frontend/src/pages/dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Box,
Grid
} from '@material-ui/core';
import { useDispatch, useSelector } from 'react-redux';
import { useSelector } from 'react-redux';
import TaskCard from '../../components/Admin/TaskCard';


Expand Down

0 comments on commit 1b8410f

Please sign in to comment.