Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariana-VV committed Oct 24, 2024
1 parent df5c5a8 commit 3385ffa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const App: React.FC = () => {
const filteredTodos = getTodosByStatus(status, todos);

async function addTodo(newTodoTitle: string) {
const editedTitle = newTodoTitle.trim(); //повторение, в онсабмит мі уже єто делали
const editedTitle = newTodoTitle.trim();

if (!editedTitle) {
setTitleError(true);
Expand All @@ -72,11 +72,11 @@ export const App: React.FC = () => {
})
.then(newTodo => {
setTodos(prevTodos => [...prevTodos, newTodo]);
setTempTodo(null); //повторение
setTempTodo(null);
})
.catch(error => {
setAddError(true);
setTempTodo(null); //повторение
setTempTodo(null);
wait(3000).then(() => setAddError(false));
throw error;
});
Expand Down Expand Up @@ -122,7 +122,9 @@ export const App: React.FC = () => {
)
.catch(() => {
setDeleteError(true);
wait(3000).then(() => setDeleteError(false));
wait(3000).then(() => {
setDeleteError(false);
});
});
};

Expand Down
6 changes: 5 additions & 1 deletion src/components/TodoItem/TodoItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const TodoItem: React.FC<Props> = ({
if (!tempTitle) {
setTempArray(todo);
deleteTodo(todo);

return;
}

if (todo.title === tempTitle) {
Expand All @@ -60,7 +62,7 @@ export const TodoItem: React.FC<Props> = ({

const newTodo = { ...todo, title: tempTitle.trim() };

setIsEdited(true);
// setIsEdited(true);

updateTodo(newTodo)
.then(() => {
Expand Down Expand Up @@ -89,6 +91,8 @@ export const TodoItem: React.FC<Props> = ({

if (!tempTitle) {
deleteTodo(todo);

return;
}

if (todo.title !== tempTitle) {
Expand Down

0 comments on commit 3385ffa

Please sign in to comment.