-
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 #1499
base: master
Are you sure you want to change the base?
Develop #1499
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.
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.
The app always shows an error on deleting the todo (when a user deletes a title during editing) Consider fixing it
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.
- on toggle all, you should show loaders only on todos that you need to update
- show loaders on clear completed all
Screen.Recording.2024-10-24.at.18.15.18.mov
- I can change the edited input (in the todo) to just have some spaces
- error messages have too much spaces
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.
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.
src/App.tsx
Outdated
{loadError && 'Unable to load todos'} | ||
{titleError && 'Title should not be empty'} | ||
{addError && 'Unable to add a todo'} | ||
{deleteError && 'Unable to delete a todo'} | ||
{updateError && 'Unable to update a todo'} |
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.
can we just create only one errorMessage state and save our messages there?
{loadError && 'Unable to load todos'} | |
{titleError && 'Title should not be empty'} | |
{addError && 'Unable to add a todo'} | |
{deleteError && 'Unable to delete a todo'} | |
{updateError && 'Unable to update a todo'} | |
{errorMessage} |
I think it should work
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.
Almost done!
src/App.tsx
Outdated
// const [loadError, setLoadError] = useState(false); | ||
// const [addError, setAddError] = useState(false); | ||
// const [deleteError, setDeleteError] = useState(false); | ||
// const [updateError, setUpdateError] = useState(false); |
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 all comments
// const [loadError, setLoadError] = useState(false); | |
// const [addError, setAddError] = useState(false); | |
// const [deleteError, setDeleteError] = useState(false); | |
// const [updateError, setUpdateError] = useState(false); |
src/App.tsx
Outdated
async function updateTodo( | ||
updatedTodo: Todo, | ||
// successUpdateState?: VoidFunction, | ||
): Promise<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's important to use one way of creating functions, fix it everywhere
async function updateTodo( | |
updatedTodo: Todo, | |
// successUpdateState?: VoidFunction, | |
): Promise<void> { | |
const updateTodo = async ( | |
updatedTodo: Todo, | |
// successUpdateState?: VoidFunction, | |
): Promise<void> => { |
src/App.tsx
Outdated
|
||
async function updateTodo( | ||
updatedTodo: Todo, | ||
// successUpdateState?: VoidFunction, |
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
// successUpdateState?: VoidFunction, |
src/api/todos.ts
Outdated
import { client } from '../utils/fetchClient'; | ||
|
||
export const USER_ID = 839; | ||
//https://mate.academy/students-api/todos?userId=839 |
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.
//https://mate.academy/students-api/todos?userId=839 |
src/components/TodoItem/TodoItem.tsx
Outdated
// const successUpdateState = () => { | ||
// setIsEdited(false); | ||
// }; |
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 successUpdateState = () => { | |
// setIsEdited(false); | |
// }; |
src/components/TodoItem/TodoItem.tsx
Outdated
|
||
const newTodo = { ...todo, title: tempTitle.trim() }; | ||
|
||
// setIsEdited(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.
// setIsEdited(true); |
src/components/TodoItem/TodoItem.tsx
Outdated
// className={classNames('modal overlay', { | ||
// 'is-active': !todo.id || tempArray.includes(todo), | ||
// })} |
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.
// className={classNames('modal overlay', { | |
// 'is-active': !todo.id || tempArray.includes(todo), | |
// })} |
src/App.tsx
Outdated
.getTodos() | ||
.then(setTodos) | ||
.catch(() => setErrorMessage('Unable to load todos')); | ||
wait(3000).then(() => setErrorMessage('')); |
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 you need wait here and then()
again?
You can use finally()
method
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! A few more small comments 🙂
src/App.tsx
Outdated
setErrorMessage('Title should not be empty'); | ||
wait(3000).finally(() => setErrorMessage('Title should not be empty')); |
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.
setErrorMessage('Title should not be empty'); | |
wait(3000).finally(() => setErrorMessage('Title should not be empty')); | |
setErrorMessage('Title should not be empty'); |
you already showed the message, no need to do it again after a delay
src/components/TodoForm/TodoForm.tsx
Outdated
<> | ||
{/* this button should have `active` class only if all todos are completed */} | ||
{!!todos.length && ( | ||
// что значит !! |
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.
Is it a question?) just remove it
src/App.tsx
Outdated
.getTodos() | ||
.then(setTodos) | ||
.catch(() => setErrorMessage('Unable to load todos')); | ||
wait(3000).finally(() => setErrorMessage('')); |
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.
Hint: you can add useEffect with errorMessage
in dependencies array
if it's not empty add 3000ms timeout and set setErrorMessage('')
It will allow to remove this in every method
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.
Great!
DEMO LINK