This commit is contained in:
Payam 2018-10-24 22:52:23 +11:00
parent 5ce74ff17c
commit 89418c2757
2 changed files with 3 additions and 5 deletions

View file

@ -59,7 +59,7 @@ input[placeholder] {
.container {
width: 40%;
height: 400px;
height: 600px;
position: relative;
margin: 0 auto;
border-radius: 5px;

View file

@ -27,8 +27,7 @@ class TodosContainer extends Component {
updateTodo = (e, id) => {
axios.put(`/api/v1/todos/${id}`, {todo: {done: e.target.checked}})
.then(response => {
const todoIndex = this.props.todos.findIndex(x => x.id === response.data.id)
this.props.dispatch(toggleTodo(todoIndex))
this.props.dispatch(toggleTodo(id))
})
.catch(error => console.log(error))
}
@ -36,8 +35,7 @@ class TodosContainer extends Component {
deleteTodo = (id) => {
axios.delete(`/api/v1/todos/${id}`)
.then(response => {
const todoIndex = this.props.todos.findIndex(x => x.id === id)
this.props.dispatch(deleteTodo(todoIndex))
this.props.dispatch(deleteTodo(id))
})
.catch(error => console.log(error))
}