Skip to content

Commit

Permalink
FIX PAGE
Browse files Browse the repository at this point in the history
  • Loading branch information
vovan4ik1 committed Oct 22, 2024
1 parent aafc647 commit df022c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import React from 'react';
import classNames from 'classnames';
import { Todo } from '../../types/Todo';
import cn from 'classnames';
import { Filter } from '../../types/Filter';
import { Error } from '../../types/Error';
import { deleteTodo } from '../../api/todos';
import { Error } from '../../types/Error';

interface Props {
type Props = {
setTodos: React.Dispatch<React.SetStateAction<Todo[]>>;
activeTodos: Todo[];
completedTodos: Todo[];
filter: Filter;
setErrorMessage: React.Dispatch<React.SetStateAction<Error>>;
setFilter: (filter: Filter) => void;
setDeletingTodoIds: React.Dispatch<React.SetStateAction<number[]>>;
}
};

export const Footer: React.FC<Props> = ({
setTodos,
activeTodos,
completedTodos,
setFilter,
filter,
setTodos,
setErrorMessage,
filter,
setFilter,
setDeletingTodoIds,
}) => {
const handleClearCompleted = async () => {
async function handleClearCompleted() {
const completedTodoIds = completedTodos.map(todo => todo.id);

setDeletingTodoIds(completedTodoIds);
Expand Down Expand Up @@ -55,7 +55,7 @@ export const Footer: React.FC<Props> = ({
}

setDeletingTodoIds([]);
};
}

return (
<footer className="todoapp__footer" data-cy="Footer">
Expand All @@ -70,10 +70,10 @@ export const Footer: React.FC<Props> = ({
key={filterOption}
href={`#/${filterOption.toLowerCase()}`}
onClick={() => setFilter(filterOption)}
className={cn('filter__link', {
className={classNames('filter__link', {
selected: filter === filterOption,
})}
data-cy={`FilterLink${filterOption.charAt(0).toUpperCase() + filterOption.slice(1)}`}
data-cy={`FilterLink${filterOption}`}
>
{filterOption}
</a>
Expand Down
10 changes: 5 additions & 5 deletions src/components/TodoItem/TodoItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const TodoItem: React.FC<Props> = ({
});
};

function handleToggleTodo(updatedTodo: Todo) {
const handleToggleTodo = (updatedTodo: Todo) => {
setIsLoading(true);
updateTodo(updatedTodo)
.then(todo => {
Expand All @@ -81,9 +81,9 @@ export const TodoItem: React.FC<Props> = ({
}, 3000);
})
.finally(() => setIsLoading(false));
}
};

function handleEditTodo(updatedTodo: Todo) {
const handleEditTodo = (updatedTodo: Todo) => {
setIsLoading(true);
if (editedTodoTitle.trim() === title) {
setIsEditing(false);
Expand All @@ -92,7 +92,7 @@ export const TodoItem: React.FC<Props> = ({
return;
}

if (editedTodoTitle.trim() === '') {
if (editedTodoTitle.trim()) {
handleDeleteTodo(id);

return;
Expand All @@ -119,7 +119,7 @@ export const TodoItem: React.FC<Props> = ({
}, 3000);
})
.finally(() => setIsLoading(false));
}
};

return (
<div
Expand Down
2 changes: 1 addition & 1 deletion src/types/Filter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum Filter {
ALL = 'all',
ALL = 'All',
Active = 'Active',
Completed = 'Completed',
}

0 comments on commit df022c7

Please sign in to comment.