Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #1580

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #1580

wants to merge 3 commits into from

Conversation

AndreaTkachuk
Copy link

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍
Let's improve your code

src/App.tsx Outdated
Comment on lines 23 to 25
const [filter, setFilter] = useState<'all' | 'active' | 'completed'>(
Filter.All,
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [filter, setFilter] = useState<'all' | 'active' | 'completed'>(
Filter.All,
);
const [filter, setFilter] = useState<Filter>(Filter.All);

src/App.tsx Outdated
.finally(() => setLoading(0));
};

function updateTodoTitle(id: number, value: string): Promise<void> | void {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is important to follow the same way of creating functions everywhere, fix it everywhere

Suggested change
function updateTodoTitle(id: number, value: string): Promise<void> | void {
const updateTodoTitle = (id: number, value: string): Promise<void> | void => {

src/api/todos.ts Outdated

export const postTodo = (value: string) => {
const newTodo = {
// userId: USER_ID,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments

Suggested change
// userId: USER_ID,

Comment on lines 8 to 9
filter: 'all' | 'active' | 'completed';
setFilter: (filter: 'all' | 'active' | 'completed') => void;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use your created enum here for types

})}
data-cy={`FilterLink${key}`}
onClick={() =>
setFilter(key.toLowerCase() as 'all' | 'active' | 'completed')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

const allTodoCompleted = todos.every(todo => todo.completed);

const focus = useRef<HTMLInputElement>(null);
// const [focus, setFocus] = React.useState('');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// const [focus, setFocus] = React.useState('');

className="todo__title"
onDoubleClick={() => handleDoubleClick({ ...todo })}
>
{todo.title}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use destructuring for todo

Comment on lines 5 to 7
case 'active':
return items.filter(item => !item.completed);
case 'completed':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use enum here

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants