|
|
@ -1,5 +1,5 @@ |
|
|
|
import React, {useState } from 'react'; |
|
|
|
import { Box, Button, Checkbox, Dialog, DialogActions, DialogContent, DialogTitle, Divider, List, ListItem, TextField, Tooltip, Typography } from '@mui/material'; |
|
|
|
import { Box, Button, Checkbox, Dialog, DialogActions, DialogContent, DialogTitle, Divider, List, ListItem, Switch, TextField, Tooltip, Typography } from '@mui/material'; |
|
|
|
import { DatePicker } from '@mui/x-date-pickers'; |
|
|
|
import DeleteOutlineRoundedIcon from '@mui/icons-material/DeleteOutlineRounded'; |
|
|
|
import EditRoundedIcon from '@mui/icons-material/EditRounded'; |
|
|
@ -228,12 +228,20 @@ const editSubtodo= (todo: Subtodo) => { |
|
|
|
...todos.slice(editI+1)]); |
|
|
|
} |
|
|
|
|
|
|
|
const [showChecked, setShowChecked] = useState(false); |
|
|
|
const handleShowChecked = (event: React.ChangeEvent<HTMLInputElement>) => { |
|
|
|
setShowChecked(event.target.checked); |
|
|
|
}; |
|
|
|
|
|
|
|
return ( |
|
|
|
<div style={{...style, textAlign: "left"}}> |
|
|
|
<Typography variant="h3">ToDo's</Typography> |
|
|
|
<Button onClick={handleClickOpen}>Add Todo</Button> |
|
|
|
{/* This should be done with a FormControlLabel or sth...*/} |
|
|
|
Show Done |
|
|
|
<Switch checked={showChecked} onChange={handleShowChecked}/> |
|
|
|
<List> |
|
|
|
{todos.map((todo, i) => |
|
|
|
{todos.filter((td) => !td.done || showChecked).map((todo, i) => |
|
|
|
<div key={todo.id}> |
|
|
|
<Box sx={{display: "flex", flexDirection: "columns"}}> |
|
|
|
<TodoItem key={todo.id} todo={todo}/> |
|
|
@ -248,10 +256,10 @@ const editSubtodo= (todo: Subtodo) => { |
|
|
|
<Button onClick={() => deleteTodo(i)}><DeleteOutlineRoundedIcon/></Button> |
|
|
|
</Tooltip> |
|
|
|
</Box> |
|
|
|
{(todo.subs && todo.subs.length > 0) && |
|
|
|
{(todo.subs && todo.subs.filter((td) => !td.done || showChecked).length > 0) && |
|
|
|
<List sx={{marginLeft: "20px"}}> |
|
|
|
<Divider/> |
|
|
|
{todo.subs.map((stodo, j) => |
|
|
|
{todo.subs.filter((td) => !td.done || showChecked).map((stodo, j) => |
|
|
|
<div key={stodo.id}> |
|
|
|
<Box sx={{display: "flex", flexDirection: "columns"}}> |
|
|
|
<TodoItem key={todo.id} todo={stodo}/> |
|
|
@ -263,11 +271,11 @@ const editSubtodo= (todo: Subtodo) => { |
|
|
|
<Button onClick={() => deleteSubtodo(i,j)}><DeleteOutlineRoundedIcon/></Button> |
|
|
|
</Tooltip> |
|
|
|
</Box> |
|
|
|
{(j + 1) < todo.subs!.length && <Divider/>} |
|
|
|
{(j + 1) < todo.subs!.filter((td) => !td.done || showChecked).length && <Divider/>} |
|
|
|
</div> |
|
|
|
)} |
|
|
|
</List>} |
|
|
|
{(i + 1) < todos.length && <Divider/>} |
|
|
|
{(i + 1) < todos.filter((td) => !td.done || showChecked).length && <Divider/>} |
|
|
|
</div> |
|
|
|
)} |
|
|
|
</List> |
|
|
|