diff --git a/Todo/src/components/FilterButtons.jsx b/Todo/src/components/FilterButtons.jsx index fa3ceca..304c681 100644 --- a/Todo/src/components/FilterButtons.jsx +++ b/Todo/src/components/FilterButtons.jsx @@ -1,7 +1,7 @@ // FilterButtons.jsx import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { filterTodos } from '../redux/actions'; +import { filterTodos , markAllCompleted } from '../redux/actions'; const FilterButtons = () => { const dispatch = useDispatch(); @@ -19,12 +19,12 @@ const FilterButtons = () => { onChange={(e) => handleFilter(e.target.value)} > - + + - diff --git a/Todo/src/components/Todo.jsx b/Todo/src/components/Todo.jsx index e6e9cd1..1969f3b 100644 --- a/Todo/src/components/Todo.jsx +++ b/Todo/src/components/Todo.jsx @@ -25,7 +25,8 @@ const Todo = () => { }; const handleSearchChange = (value) => { - + setSearchTerm(value); + dispatch(updateSearchTerm(value)); }; return ( @@ -56,7 +57,7 @@ const Todo = () => { type="text" placeholder="Search Todos" value={searchTerm} - onChange={(e) => handleSearchChange()} + onChange={(e) => handleSearchChange(e.target.value)} /> @@ -36,7 +36,7 @@ const TodoItem = ({ todo, index }) => { {!todo.completed && ( diff --git a/Todo/src/redux/reducer.js b/Todo/src/redux/reducer.js index e462024..b2976c2 100644 --- a/Todo/src/redux/reducer.js +++ b/Todo/src/redux/reducer.js @@ -35,13 +35,13 @@ const todoReducer = (state = initialState, action) => { todos: state.todos.filter((todo, index) => index !== action.payload.id), filter: state.filter, searchTerm: state.searchTerm, + }; case MARK_COMPLETED: return { todos: state.todos.map((todo, index) => - index === action.payload.id ? { ...todo, completed: true } : todo - ), + index === action.payload.id ? { ...todo, completed: true} : todo ), filter: state.filter, searchTerm: state.searchTerm, };