Skip to content

Commit 28c34f9

Browse files
committed
Setting state for the error
1 parent fc60493 commit 28c34f9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/App.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,23 @@ const App: FC = () => {
1010
const [todos, setTodos] = useState<string[]>([]);
1111
const [toDoPosition, setToDoPosition] = useState<string>('all');
1212
const [toDoFilter, setToDoFilter] = useState<string[]>([]);
13+
const [hasError, setHasError] = useState(false);
1314

1415
const ToDoFilterHandler = function (): void {
1516

17+
switch (toDoPosition) {
1618

19+
case 'completed':
20+
setToDoFilter(todos.filter((todo: any) => todo.completed === true));
21+
break;
22+
23+
case 'incomplete':
24+
setToDoFilter(todos.filter((todo: any) => todo.completed === false));
25+
26+
default:
27+
setToDoFilter(todos);
28+
29+
}
1730

1831
}
1932

@@ -25,7 +38,7 @@ const App: FC = () => {
2538
<h3 style={{ fontSize: '2.5rem', fontFamily: 'Gloria Hallelujah', color: '#F7F9F9',}}>Your To Do List</h3>
2639
</header>
2740

28-
<AddTaskForm setToDoInput = {setToDoInput} todos = {todos} setTodos = {setTodos} toDoInput = {toDoInput} toDoPosition = {toDoPosition} setToDoPosition = {setToDoPosition} />
41+
<AddTaskForm setToDoInput = {setToDoInput} todos = {todos} setTodos = {setTodos} toDoInput = {toDoInput} toDoPosition = {toDoPosition} setToDoPosition = {setToDoPosition} hasError = {hasError} setHasError = {setHasError} />
2942
<ToDoList todos = {todos} setTodos = {setTodos} />
3043

3144
</div>

0 commit comments

Comments
 (0)