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

Solution #2897

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

Solution #2897

wants to merge 3 commits into from

Conversation

Krzychu92
Copy link

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this project! 😊 There are a few critical issues that need to be addressed before we can approve the pull request:

  1. Data Preparation: The TodoInfo component imports usersFromServer directly, which violates the guideline of preparing data in the App component and passing it down to child components. Please modify the component to receive user data as a prop.

  2. Key Prop in Lists: Ensure that each child in a list has a unique key prop. This applies to both the TodoInfo components and the option elements within the select tag.

  3. Handling Null Values: Components using the getUser function should handle cases where it returns null to prevent potential runtime errors.

  4. Class Name Check: Verify that the TodoInfo component correctly adds the TodoInfo--completed class for completed todos.

  5. Max ID Calculation: Update the calculation of maxId after adding a new task to ensure it reflects the latest state.

Please address these issues to align with the task requirements and ensure the functionality is robust. Keep up the great work, and feel free to reach out if you have any questions or need further assistance! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

src/App.tsx Outdated
setTodos(tasks);
}, []);

let maxId = Math.max(...todos.map((o) => o.id)) + 1;

Choose a reason for hiding this comment

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

The calculation of maxId should be updated after adding a new task. Consider moving this logic inside the handleSubmit function after updating the todos state.

src/App.tsx Outdated
Choose a user
</option>
{users.map((user) => {
return <option value={user.id}>{user.name}</option>;

Choose a reason for hiding this comment

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

Each child in a list should have a unique key prop. Add a key prop to the option element, using a unique value like user.id.

completed: true,
user: user1,
};

mount(<TodoInfo todo={completedTodo} />);

cy.get('.TodoInfo').should('have.class', 'TodoInfo--completed');
cy.get(".TodoInfo").should("have.class", "TodoInfo--completed");

Choose a reason for hiding this comment

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

Ensure that the TodoInfo component adds the TodoInfo--completed class correctly when a todo is completed. Verify that the component implementation aligns with this test expectation.

import { UserInfo } from "../UserInfo";
import { Todo } from "../../Types/Todo";
import "./TodoInfo.scss";
import usersFromServer from "../../api/users";

Choose a reason for hiding this comment

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

Avoid using the import keyword in non-root components for data preparation. Instead, prepare the data in the App component and pass it down as props. This aligns with the guideline: 'Prepare data in one place (App component) and pass it to child components.'

return (
<section className="TodoList">
{todos.map((todo) => (
<TodoInfo todo={todo} />

Choose a reason for hiding this comment

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

Each child in a list should have a unique key prop to help React identify which items have changed. Add a key prop to the TodoInfo component, using a unique value like todo.id.

};

mount(<UserInfo user={user1} />);

cy.get('.UserInfo').should('have.attr', 'href', 'mailto:Sincere@april.biz');
cy.get(".UserInfo").should("have.attr", "href", "mailto:Sincere@april.biz");

Choose a reason for hiding this comment

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

Ensure that the UserInfo component renders an element with the href attribute for the mailto link. If the .UserInfo class is applied to a container element, the test should target the specific element with the href attribute.

const foundUser = usersFromServer.find((user) => user.id === userId);

// if there is no user with a given userId
return foundUser || null;

Choose a reason for hiding this comment

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

Ensure that components using the getUser function handle the case where it returns null. This is important to avoid potential runtime errors when accessing properties of a null user.

Copy link

@danon321 danon321 left a comment

Choose a reason for hiding this comment

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

Wygląda dobrze :))

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.

3 participants