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

Develop #1499

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

Develop #1499

wants to merge 19 commits into from

Conversation

Mariana-VV
Copy link

@Mariana-VV Mariana-VV commented Oct 24, 2024

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

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

Great work!
Screenshot 2024-10-24 at 14 13 48
Looks a bit broken on the edit fail. Consider fixing it

Copy link

@anastasiiavorobiova anastasiiavorobiova left a 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

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. on toggle all, you should show loaders only on todos that you need to update
  2. show loaders on clear completed all
Screen.Recording.2024-10-24.at.18.15.18.mov
  1. I can change the edited input (in the todo) to just have some spaces
image you need to remove the todo in this case
  1. error messages have too much spaces
image

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.

Hi, you need to fix all comments from the previous review and make a deploy again after your changes
image

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

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

Great work!
If a lot of todos are checked and a user clicks on the clear all button, every todo gets the loading state
Screenshot 2024-10-25 at 15 18 50

src/App.tsx Outdated
Comment on lines 216 to 220
{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'}

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?

Suggested change
{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

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.

Almost done!

src/App.tsx Outdated
Comment on lines 36 to 39
// const [loadError, setLoadError] = useState(false);
// const [addError, setAddError] = useState(false);
// const [deleteError, setDeleteError] = useState(false);
// const [updateError, setUpdateError] = useState(false);

Choose a reason for hiding this comment

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

Remove all comments

Suggested change
// const [loadError, setLoadError] = useState(false);
// const [addError, setAddError] = useState(false);
// const [deleteError, setDeleteError] = useState(false);
// const [updateError, setUpdateError] = useState(false);

src/App.tsx Outdated
Comment on lines 87 to 90
async function updateTodo(
updatedTodo: Todo,
// successUpdateState?: VoidFunction,
): Promise<void> {

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

Suggested change
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,

Choose a reason for hiding this comment

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

Remove comments

Suggested change
// 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

Choose a reason for hiding this comment

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

Suggested change
//https://mate.academy/students-api/todos?userId=839

Comment on lines 42 to 44
// const successUpdateState = () => {
// setIsEdited(false);
// };

Choose a reason for hiding this comment

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

Suggested change
// const successUpdateState = () => {
// setIsEdited(false);
// };


const newTodo = { ...todo, title: tempTitle.trim() };

// setIsEdited(true);

Choose a reason for hiding this comment

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

Suggested change
// setIsEdited(true);

Comment on lines 178 to 180
// className={classNames('modal overlay', {
// 'is-active': !todo.id || tempArray.includes(todo),
// })}

Choose a reason for hiding this comment

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

Suggested change
// 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(''));

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

Copy link

@TarasHoliuk TarasHoliuk left a 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
Comment on lines 51 to 52
setErrorMessage('Title should not be empty');
wait(3000).finally(() => setErrorMessage('Title should not be empty'));

Choose a reason for hiding this comment

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

Suggested change
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

<>
{/* this button should have `active` class only if all todos are completed */}
{!!todos.length && (
// что значит !!

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(''));

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

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.

Great!

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.

5 participants