todo
27 строк · 696.0 Байт
1import React from 'react';
2import ToDoItem from '../ToDoItem';
3import './ToDoList.css';
4
5interface ToDoListProps {
6tasks: Task[];
7setTasks: React.Dispatch<React.SetStateAction<Task[]>>;
8filter: Filter;
9}
10
11const ToDoList: React.FC<ToDoListProps> = ({ tasks, setTasks, filter }) => {
12const filteredTasks = tasks.filter(task => {
13if (filter === 'Active') return !task.completed;
14if (filter === 'Completed') return task.completed;
15return true;
16});
17
18return (
19<ul>
20{filteredTasks.map(task => (
21<ToDoItem key={task.id} task={task} setTasks={setTasks} />
22))}
23</ul>
24);
25}
26
27export default ToDoList;
28