Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions Todo/src/components/FilterButtons.jsx
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -19,12 +19,12 @@ const FilterButtons = () => {
onChange={(e) => handleFilter(e.target.value)}
>
<option value="ALL">Default</option>

<option value="COMPLETED">Completed</option>
<option value="INCOMPLETE">Incomplete</option>
</select>

<button
className="text-sm px-2 py-1 bg-purple-500 text-white rounded ml-2"
onClick={() => {}}
onClick={() => dispatch(markAllCompleted())}
>
Mark All Completed
</button>
Expand Down
5 changes: 3 additions & 2 deletions Todo/src/components/Todo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const Todo = () => {
};

const handleSearchChange = (value) => {

setSearchTerm(value);
dispatch(updateSearchTerm(value));
};

return (
Expand Down Expand Up @@ -56,7 +57,7 @@ const Todo = () => {
type="text"
placeholder="Search Todos"
value={searchTerm}
onChange={(e) => handleSearchChange()}
onChange={(e) => handleSearchChange(e.target.value)}
/>
<button className="ml-4 p-2 bg-blue-500 text-white rounded hover:bg-blue-600 focus:outline-none">
<BsSearch size={20} />
Expand Down
8 changes: 4 additions & 4 deletions Todo/src/components/TodoItem.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useDispatch } from 'react-redux';
import {

toggleTodo,
removeTodo,

markCompleted,
markIncomplete,
} from '../redux/actions';
import { FaToggleOn, FaToggleOff, FaTrash, FaCheck, FaTimes } from 'react-icons/fa';
Expand All @@ -23,7 +23,7 @@ const TodoItem = ({ todo, index }) => {
<div className='space-x-3 ml-8'>
<button
className="mr-2 text-sm bg-blue-500 text-white sm:px-2 px-1 py-1 rounded"
onClick={() => {}}
onClick={() => dispatch(toggleTodo(index))}
>
{todo.completed ? <FaToggleOff /> : <FaToggleOn />}
</button>
Expand All @@ -36,7 +36,7 @@ const TodoItem = ({ todo, index }) => {
{!todo.completed && (
<button
className="text-sm bg-green-500 text-white sm:px-2 px-1 py-1 rounded"
onClick={() => {}}
onClick={() => dispatch(markCompleted(index))}
>
<FaCheck />
</button>
Expand Down
4 changes: 2 additions & 2 deletions Todo/src/redux/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down