Skip to content

Conversation

@Sviatoslav593
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.

Review Summary

I am requesting a few changes before this can be approved. While the overall component structure is correct, there's a functional bug and a few violations of the project's coding standards.

Specifically, in src/components/Person/Person.jsx:

  1. Incorrect Output: The text for an unmarried person is currently "not married" but the requirement is "I am not married".
  2. Complex Logic in JSX: The nested ternary operator for determining the partner status should be extracted into a new variable before the return statement. This is a violation of [CHECKLIST ITEM #3].
  3. Code Formatting: The ternary operator itself is not formatted correctly. Each operand should be on a new line for readability, as noted in [CHECKLIST ITEM #2].

Please address these points. You're on the right track!


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

Important

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

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

export const Person = ({ person }) => (
<section className="Person">
<h2 className="Person__name">My name is {person.name}</h2>
{person.age ? <p className="Person__age">I am {person.age}</p> : ''}

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Format ternary operator operands correctly - move each operand to the separate line'. The ternary operator should be split across multiple lines for better readability.

<section className="Person">
<h2 className="Person__name">My name is {person.name}</h2>
{person.age ? <p className="Person__age">I am {person.age}</p> : ''}
<p className="Person__partner">{`${person.isMarried ? `${person.sex === 'm' ? `${person.partnerName} is my wife` : `${person.partnerName} is my husband`}` : 'not married'}`}</p>

Choose a reason for hiding this comment

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

This line has multiple issues:

  1. The text for an unmarried person should be "I am not married", but the current output is "not married".
  2. This violates checklist item Solution #2 regarding the formatting of ternary operators.
  3. This also violates checklist item Resolved #3: 'Avoid putting several cases to conditional rendering. Create separate variable for the condition.'

Please extract the logic for generating the partner status message into a variable before the return statement.

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.

Review Summary

Great work on this submission! You've successfully addressed all the previous feedback, and the solution now meets all functional requirements. The code is clean and works as expected, so I am approving your work. For future improvements, you could make the Person.jsx component even more readable by destructuring the person object itself (e.g., const { name, age } = person;). This would remove the need to repeat person. when accessing its properties in the JSX. Keep up the great work!


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

Footnotes

  1. Rate AI review example

@@ -1 +1,19 @@
// export const Person = ({ person }) => ();
export const Person = ({ person }) => {

Choose a reason for hiding this comment

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

While you've correctly destructured props to get the person object, you can take it a step further to fully adhere to [CHECKLIST ITEM #1]. Consider destructuring the person object as well to get direct access to its properties (name, age, isMarried, etc.). This will make the component's body cleaner by removing the repetitive use of person..

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.

2 participants