Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task card icon #302

Merged
merged 18 commits into from
Aug 30, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 54 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,53 @@ 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"
onClick={() => { console.log('edit task', id) }}
PrerakMathur20 marked this conversation as resolved.
Show resolved Hide resolved
className={classes.button}
>
<CreateIcon className={classes.icons} />
</Button>
</Tooltip>
</div>
)
: null
}

Expand Down