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

v1.0 #672

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

v1.0 #672

wants to merge 14 commits into from

Conversation

JOWISSA
Copy link

@JOWISSA JOWISSA commented Sep 5, 2023

Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

1 item left
image

should still be 1 item left
image

you should rewrite you work using context
image

@JOWISSA JOWISSA requested a review from etojeDenys September 6, 2023 23:51
Comment on lines 36 to 41
if (todo.id === todoId) {
return { ...todo, title };
// eslint-disable-next-line no-else-return
} else {
return todo;
}

Choose a reason for hiding this comment

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

Suggested change
if (todo.id === todoId) {
return { ...todo, title };
// eslint-disable-next-line no-else-return
} else {
return todo;
}
if (todo.id === todoId) {
return { ...todo, title };
}
return todo;

Comment on lines 16 to 20
useEffect(() => {
const savedTodos = JSON.parse(localStorage.getItem('todos') || '[]');

setTodos(savedTodos);
}, []);

Choose a reason for hiding this comment

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

looks redundant cause you have your custom hook for localStorage

@etojeDenys
Copy link

1 item left image

should still be 1 item left image

you should rewrite you work using context image

i can still reproduce the issue
image

@JOWISSA JOWISSA requested a review from etojeDenys September 11, 2023 11:56
Copy link

@Anastasiia-Svintsova Anastasiia-Svintsova left a comment

Choose a reason for hiding this comment

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

  • Hey! Please, make sure you don't have type errors in the project
    image

  • The number of active todos in the footer shouldn't depend on the active filter
    image
    image

const [isLoading, setIsLoading] = useState(false);
const [todos, setTodos] = useLocalStorage('todos', []);

const addNewTodo = async () => {

Choose a reason for hiding this comment

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

Do you really need an async function here? Seems that you await nothing here 🤔

</form>
</header>

{todos.length > 0 && (

Choose a reason for hiding this comment

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

You can use logical operators as well

Suggested change
{todos.length > 0 && (
{!!todos.length && (

const updatedTodos = todos.map((todo) => {
if (todo.id === todoId) {
return { ...todo, title };
// eslint-disable-next-line no-else-return

Choose a reason for hiding this comment

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

Remove this disabling

const updatedTodos = todos.map((todo) => {
if (todo.id === id) {
return { ...todo, completed: !completed };
// eslint-disable-next-line no-else-return

Choose a reason for hiding this comment

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

Same


import { TodoList } from './Components/TodoList';
import { Footer } from './Components/Footer';
import { Header } from './Components/Header';

Choose a reason for hiding this comment

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

Rename the header.tsx to Header.tsx to fix linter errors
image

Choose a reason for hiding this comment

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

image image still not fixed


import { TodoList } from './Components/TodoList';
import { Footer } from './Components/Footer';
import { Header } from './Components/Header';

Choose a reason for hiding this comment

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

image image still not fixed

@JOWISSA JOWISSA requested a review from etojeDenys September 12, 2023 08:16
Copy link

@IvanFesenko IvanFesenko left a comment

Choose a reason for hiding this comment

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

Pay attention on my comments - it's bad practice use anonymous function in JSX - try to refactor

Comment on lines +54 to +64
onChange={() => {
const updatedTodos = todos.map((todo) => {
if (todo.id === id) {
return { ...todo, completed: !completed };
}

return todo;
});

setTodos(updatedTodos);
}}

Choose a reason for hiding this comment

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

logic should be moved into separate handler instead on anonymous function in jsx.
Fix all similar cases

Comment on lines +28 to +51
};

return (
<footer className="todoapp__footer">
<span className="todo-count">
{itemsLeftLength === 1
? '1 item left'
: `${itemsLeftLength} items left`}
</span>

<nav className="filter">
{filterOptions.map((option) => {
return (
<a
key={option}
href={`#/${option}`}
className={classNames(
'filter__link',
{ selected: filterBy === option },
)}
onClick={() => setFilterBy(option)}
>
{option}
</a>

Choose a reason for hiding this comment

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

Suggested change
};
return (
<footer className="todoapp__footer">
<span className="todo-count">
{itemsLeftLength === 1
? '1 item left'
: `${itemsLeftLength} items left`}
</span>
<nav className="filter">
{filterOptions.map((option) => {
return (
<a
key={option}
href={`#/${option}`}
className={classNames(
'filter__link',
{ selected: filterBy === option },
)}
onClick={() => setFilterBy(option)}
>
{option}
</a>
};
const onFilterSelect = (filter: FilterType) => () => {
setFilterBy(filter)
}
return (
<footer className="todoapp__footer">
<span className="todo-count">
{itemsLeftLength === 1
? '1 item left'
: `${itemsLeftLength} items left`}
</span>
<nav className="filter">
{filterOptions.map((option) => {
return (
<a
key={option}
href={`#/${option}`}
className={classNames(
'filter__link',
{ selected: filterBy === option },
)}
onClick={onFilterSelect(option)}
>
{option}
</a>

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.

4 participants