diff --git a/src/App.tsx b/src/App.tsx index 44a9aa701c..7b8f8e2a53 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,3 @@ -/* eslint-disable max-len */ -/* eslint-disable jsx-a11y/control-has-associated-label */ import React, { useEffect, useMemo, @@ -53,19 +51,19 @@ export const App: React.FC = () => { }); }, []); - const idTimer = useRef(0); + const idTimerRef = useRef(0); useEffect(() => { - if (idTimer.current) { - window.clearTimeout(idTimer.current); + if (idTimerRef.current) { + window.clearTimeout(idTimerRef.current); } - idTimer.current = window.setTimeout(() => { + idTimerRef.current = window.setTimeout(() => { setErrorMessage(''); }, 3000); }, [setErrorMessage]); - function handleAddTodos(newTodo: Omit) { + const handleAddTodos = (newTodo: Omit) => { setLoadingId([0]); setIsLoading(true); setRequest(true); @@ -87,9 +85,9 @@ export const App: React.FC = () => { const temp: Todo = Object.assign(newTodo, { id: 0 }); setTempTodo(temp); - } + }; - function handleDelete(todoId: number) { + const handleDelete = (todoId: number) => { setLoadingId([todoId]); setIsLoaderActive(true); deleteTodos(todoId) @@ -105,7 +103,7 @@ export const App: React.FC = () => { setIsLoading(false); setIsLoaderActive(false); }); - } + }; const handleClearCompleted = () => { const deletePromises = todos @@ -126,8 +124,6 @@ export const App: React.FC = () => { }; const handleDeleteUpdate = (todo: Todo, newTodoTitle: string) => { - // setLoadingId([todo.id]); - // setIsLoaderActive(true); updateTodo({ id: todo.id, title: newTodoTitle, @@ -196,11 +192,9 @@ export const App: React.FC = () => {
0 ? filteredTodos[0] : null} + todo={filteredTodos.length ? filteredTodos[0] : null} userId={USER_ID} - // tempTodo={tempTodo} isLoading={isLoading} errorMessage={errorMessage} setErrorMessage={setErrorMessage} @@ -212,12 +206,11 @@ export const App: React.FC = () => { />
- {filteredTodos.length > 0 ? ( + {filteredTodos.length && ( filteredTodos.map((todo) => ( { onTodoToggle={() => handleToggleTodo(todo)} /> )) - ) : ( -

No todos to display.

)}
@@ -236,7 +227,7 @@ export const App: React.FC = () => { )} - {todos.length !== 0 && ( + {!!todos.length && ( { )}
- {/* Notification is shown in case of any error */} - {/* Add the 'hidden' class to hide the message smoothly */} void; - // isModalVisible: boolean; loadingId: number[], isLoaderActive: boolean, onTodoUpdate: (todoTitle: string) => void @@ -102,9 +101,7 @@ export const TodoApp: React.FC = ({ placeholder="Empty todo will be deleted" value={todosTitle} onChange={handleTodoTitleChange} - onKeyUp={(event) => { - handleOnKeyup(event); - }} + onKeyUp={(event) => handleOnKeyup(event)} /> ) @@ -130,23 +127,6 @@ export const TodoApp: React.FC = ({ )} - {/* - {title} - - - */} -
= ({
- - {/* {false && ( -
- -
- )} */}
); }; diff --git a/src/components/TodoFilter/TodoFilter.tsx b/src/components/TodoFilter/TodoFilter.tsx index b3306f95b1..7768e81dc7 100644 --- a/src/components/TodoFilter/TodoFilter.tsx +++ b/src/components/TodoFilter/TodoFilter.tsx @@ -22,7 +22,6 @@ export const TodoFilter: React.FC = ({ {`${activeTodosCount} items left`} - {/* Active filter should have a 'selected' class */} - {/* don't show this button if there are no completed todos */}