Skip to content

Commit

Permalink
task solution_v3
Browse files Browse the repository at this point in the history
  • Loading branch information
inesshtepa committed Dec 9, 2024
1 parent 13b7553 commit 97334d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Todo } from './types/Todo';
import * as todoService from './api/todos';
import { FilterOptions } from './types/FilterOptions';
import { Todolist } from './components/TodoList';
import { TodoItem } from './components/TodoItem';
import classNames from 'classnames';

export const App: React.FC = () => {
Expand Down Expand Up @@ -225,18 +224,9 @@ export const App: React.FC = () => {
filteredTodos={filteredTodos}
setErrorMessage={setErrorMessage}
loadingIds={loadingIds}
tempTodo={tempTodo}
/>
{tempTodo && (
<TodoItem
todo={tempTodo}
onDelete={handleDelete}
onUpdate={handleUpdateTodo}
deletingId={deletingId}
filteredTodos={filteredTodos}
setErrorMessage={setErrorMessage}
loadingIds={loadingIds}
/>
)}

{todos.length !== 0 && (
<footer className="todoapp__footer" data-cy="Footer">
<span className="todo-count" data-cy="TodosCounter">
Expand Down
14 changes: 14 additions & 0 deletions src/components/TodoList/TodoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Props = {
filteredTodos: Todo[];
setErrorMessage: (message: string) => void;
loadingIds: number[];
tempTodo: Todo | null;
};

export const Todolist: React.FC<Props> = ({
Expand All @@ -23,6 +24,7 @@ export const Todolist: React.FC<Props> = ({
filteredTodos,
setErrorMessage,
loadingIds,
tempTodo,
}) => {
return (
<section className="todoapp__main" data-cy="TodoList">
Expand All @@ -38,6 +40,18 @@ export const Todolist: React.FC<Props> = ({
key={todo.id}
/>
))}
{tempTodo && (
<TodoItem
todo={tempTodo}
onDelete={onDelete}
onUpdate={onUpdate}
deletingId={deletingId}
filteredTodos={filteredTodos}
setErrorMessage={setErrorMessage}
loadingIds={loadingIds}
key={tempTodo.id}
/>
)}
</section>
);
};

0 comments on commit 97334d4

Please sign in to comment.