This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeTodo = (i, checked) => { | |
if (checked) { | |
const newCompletedTodos = [...completedTodos]; | |
newCompletedTodos.splice(i, 1); | |
setCompletedTodos(newCompletedTodos); | |
} else { | |
const newTodos = [...todos]; | |
newTodos.splice(i, 1); | |
setTodos(newTodos); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkboxRow = (todo, i, checked = false) => ( | |
<Flex | |
width='100%' | |
justifyContent='space-between' | |
> | |
<Label | |
color='#fff' | |
> | |
<Checkbox | |
checked={checked} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkboxRow = (todo, i, checked = false) => ( | |
<Flex | |
width='100%' | |
justifyContent='space-between' | |
> | |
<Label | |
color='#fff' | |
> | |
<Checkbox | |
checked={checked} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const revertTodo = (i) => { | |
const todo = completedTodos[i]; | |
todos.unshift(todo); | |
setTodos(todos); | |
const newCompletedTodos = [...completedTodos]; | |
newCompletedTodos.splice(i, 1); | |
setCompletedTodos(newCompletedTodos); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<Box width='350px'> | |
{todos.map((todo, i) => checkboxRow(todo, i))} | |
</Box> | |
// add this --> | |
<hr | |
color='#fff' | |
width='350px' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const completeTodo = (i) => { | |
const todo = todos[i]; | |
completedTodos.unshift(todo); | |
setCompletedTodos(completedTodos); | |
const newTodos = [...todos]; | |
newTodos.splice(i, 1); | |
setTodos(newTodos); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const completeTodo = (i) => { | |
const todo = todos[i]; | |
completedTodos.unshift(todo); | |
setCompletedTodos(completedTodos); | |
const newTodos = [...todos]; | |
newTodos.splice(i, 1); | |
setTodos(newTodos); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const App = () => { | |
const [todos, setTodos] = useState([]); | |
const addTodo = (e) => { | |
e.preventDefault(); | |
if (e.target[0].value.length > 0) { | |
const todo = e.target[0].value; | |
const newTodos = [...todos]; | |
newTodos.unshift(todo); | |
setTodos(newTodos); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const App = () => { | |
const [todos, setTodos] = useState([]); | |
const addTodo = (e) => { | |
e.preventDefault(); | |
if (e.target[0].value.length > 0) { | |
const todo = e.target[0].value; | |
const newTodos = [...todos]; | |
newTodos.unshift(todo); | |
setTodos(newTodos); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const App = () => { | |
const [todos, setTodos] = useState([]); | |
const addTodo = (e) => { | |
e.preventDefault(); | |
if (e.target[0].value.length > 0) { | |
const todo = e.target[0].value; | |
const newTodos = [...todos]; | |
newTodos.unshift(todo); | |
setTodos(newTodos); |