-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Develop #792
base: master
Are you sure you want to change the base?
Develop #792
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything works as expected! great job!
// import USER_ID from '../../helpers/USER_ID'; | ||
// import { getTodos } from '../../api/todos'; | ||
// import { loadTodosAction } from '../actions/actionCreators'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove that if you don't need it anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fixed 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, but there is quite a bit of work to be done.
src/Components/Footer/Footer.tsx
Outdated
|
||
const activeTodosNumber = getActiveTodos(todos).length; | ||
const completedTodos = getCompletedTodos(todos); | ||
const isClearCompletedInvisible = completedTodos.length === 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isClearCompletedInvisible = completedTodos.length === 0; | |
const isClearCompletedInvisible = !completedTodos.length; |
src/Components/Footer/Footer.tsx
Outdated
return ( | ||
<footer className="todoapp__footer" data-cy="Footer"> | ||
<span className="todo-count" data-cy="TodosCounter"> | ||
{`${activeTodosNumber} items left`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is one item, there should not be a plural in the text.
src/Components/Header/Header.tsx
Outdated
const ref = useRef<HTMLInputElement>(null); | ||
const [inputValue, setInputValue] = useState(''); | ||
|
||
const isToggleVisible = todos.length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isToggleVisible = todos.length > 0; | |
const isToggleVisible = !!todos.length; |
src/Components/Header/Header.tsx
Outdated
dispatch(patchAction); | ||
}); | ||
|
||
if (rejected.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (rejected.length > 0) { | |
if (rejected.length) { |
src/Components/Header/Header.tsx
Outdated
|
||
return ( | ||
<header className="todoapp__header"> | ||
{/* eslint-disable jsx-a11y/control-has-associated-label */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to rewrite the code so that it is not necessary to disable the linter
src/Components/UI/ApiError.tsx
Outdated
onClick={() => { | ||
setAddClassName(true); | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onClick={() => { | |
setAddClassName(true); | |
}} | |
onClick={() => setAddClassName(true)} |
// import USER_ID from '../../helpers/USER_ID'; | ||
// import { getTodos } from '../../api/todos'; | ||
// import { loadTodosAction } from '../actions/actionCreators'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fixed 😢
// useEffect(() => { | ||
// getTodos(USER_ID) | ||
// .then((data) => { | ||
// const action = loadTodosAction(data); | ||
|
||
// dispatch(action); | ||
// }) | ||
// .catch(e => setApiError(e)); | ||
// }, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not leave unnecessary comments.
src/Components/Footer/Footer.tsx
Outdated
const url = value === FiltersType.ALL | ||
? '' | ||
: value.toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can change the FiltersType
a little and then you won't need to add an extra check:
export enum FiltersType {
ALL = '',
ACTIVE = 'Active',
COMPLETED = 'Completed',
}
...
const url = value.toLowerCase();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant!
src/helpers/getFilteredTodos.ts
Outdated
switch (filter) { | ||
case FiltersType.ALL: | ||
default: | ||
return todos; | ||
|
||
case FiltersType.ACTIVE: | ||
return getActiveTodos(todos); | ||
|
||
case FiltersType.COMPLETED: | ||
return getCompletedTodos(todos); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch (filter) { | |
case FiltersType.ALL: | |
default: | |
return todos; | |
case FiltersType.ACTIVE: | |
return getActiveTodos(todos); | |
case FiltersType.COMPLETED: | |
return getCompletedTodos(todos); | |
} | |
switch (filter) { | |
case FiltersType.ACTIVE: | |
return getActiveTodos(todos); | |
case FiltersType.COMPLETED: | |
return getCompletedTodos(todos); | |
default: | |
return todos; | |
} |
Hello mentor! There is a component Footer with handleClearCompletedClick - row 31. The handler is ok or not? |
It's ok. You can do it in different ways. You can collect requests and then handle them with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done 🚀
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
Promise.allSettled(toggledTodos) | ||
.then((data: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
If you are interested you can google how to handle type for Promise.allSettled
https://stackoverflow.com/questions/64928212/how-to-use-promise-allsettled-with-typescript
DEMO LINK
This is a new PR. I've closed the previous one because it didn't contain any tests.
Sorry O.Budnik, your great review remain under the old PR
#780