Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
natalia646 committed Dec 23, 2024
1 parent 015c0e7 commit 41358e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
25 changes: 2 additions & 23 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const App: React.FC = () => {
);
const isToogleAll = completedTodos.length === todos.length;

const onAddTodo = async (title: string) => {
const onAddTodo = (title: string) => {
setTempTodo({
id: 0,
title,
Expand All @@ -61,7 +61,7 @@ export const App: React.FC = () => {
.finally(() => setTempTodo(null));
};

const onUpdateTodo = async (todoToUpdate: Todo) => {
const onUpdateTodo = (todoToUpdate: Todo) => {
setLoadingTodos(prevTodos => [...prevTodos, todoToUpdate.id]);

return clientTodo
Expand All @@ -85,27 +85,6 @@ export const App: React.FC = () => {
prevTodos.filter(id => todoToUpdate.id !== id),
);
});

// try {
// const updatedTodo = await clientTodo.updateTodo(todoToUpdate);

// setTodos(currentTodos => {
// const newTodos = [...currentTodos];
// const index = newTodos.findIndex(todo => todo.id === updatedTodo.id);

// newTodos.splice(index, 1, updatedTodo);

// return newTodos;
// });
// } catch (error) {
// setErrorMessage(ErrorMessage.UnableToUpdate);

// throw error;
// } finally {
// setLoadingTodos(prevTodos =>
// prevTodos.filter(id => todoToUpdate.id !== id),
// );
// }
};

const onDeleteTodo = (todoId: number) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TodoItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const TodoItem: React.FC<Props> = props => {

const updateRef = useRef<HTMLInputElement>(null);

const handleUpdate = async () => {
const handleUpdate = () => {
const normaliseTitle = updateTitle.trim();

if (todo.title === updateTitle) {
Expand Down

0 comments on commit 41358e7

Please sign in to comment.