-
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
Solution #1580
base: master
Are you sure you want to change the base?
Solution #1580
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.
Good job 👍
Let's improve your code
src/App.tsx
Outdated
const [filter, setFilter] = useState<'all' | 'active' | 'completed'>( | ||
Filter.All, | ||
); |
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 [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 { |
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.
It is important to follow the same way of creating functions everywhere, fix it everywhere
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, |
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 comments
// userId: USER_ID, |
src/components/Footer.tsx
Outdated
filter: 'all' | 'active' | 'completed'; | ||
setFilter: (filter: 'all' | 'active' | 'completed') => void; |
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.
Use your created enum here for types
src/components/Footer.tsx
Outdated
})} | ||
data-cy={`FilterLink${key}`} | ||
onClick={() => | ||
setFilter(key.toLowerCase() as 'all' | 'active' | 'completed') |
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.
And here
src/components/Header.tsx
Outdated
const allTodoCompleted = todos.every(todo => todo.completed); | ||
|
||
const focus = useRef<HTMLInputElement>(null); | ||
// const [focus, setFocus] = React.useState(''); |
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 [focus, setFocus] = React.useState(''); |
className="todo__title" | ||
onDoubleClick={() => handleDoubleClick({ ...todo })} | ||
> | ||
{todo.title} |
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.
Use destructuring for todo
src/utils/getFilteredItems.ts
Outdated
case 'active': | ||
return items.filter(item => !item.completed); | ||
case 'completed': |
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.
Use enum here
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.
GJ! 👍
DEMO LINK