Skip to content

add task solution#3633

Open
Ivan7457 wants to merge 3 commits intomate-academy:masterfrom
Ivan7457:develop
Open

add task solution#3633
Ivan7457 wants to merge 3 commits intomate-academy:masterfrom
Ivan7457:develop

Conversation

@Ivan7457
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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. Your solution correctly meets all the functional requirements, which is great work! However, there are a couple of important code style issues in src/components/Person/Person.jsx that need to be addressed as they violate the project's guidelines.

First, the nested ternary operator for displaying the partner's information is difficult to read and goes against our style guide [CHECKLIST ITEM #2, #3]. Please refactor this by extracting the logic into a separate variable before the return statement to improve readability.

Additionally, you destructured age from the person prop, but later in the component, you use person.age. For consistency, please use the destructured age variable everywhere.

Once these improvements are made, your code will be much cleaner and easier to maintain.


✨ 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 }) => {
const { name, age, partnerName, isMarried, sex } = person;
const partnerText = isMarried
? `${partnerName} is my ${sex === 'f' ? 'husband' : 'wife'}`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This nested ternary operator is difficult to read and violates the code style guideline for formatting ternaries (Checklist item #2). For better readability, consider extracting this logic into a separate variable.

return (
<section className="Person">
<h2 className="Person__name">My name is {name}</h2>
{person.age && <p className="Person__age">I am {age}</p>}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You have already destructured age from the person object on line 2. For consistency, it's better to use the age variable here directly, instead of person.age.

Copy link
Copy Markdown

@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

Thank you for the update and for correctly addressing the issue with the age variable.

However, the main point from the previous review still needs your attention. The logic for displaying the partner's status in src/components/Person/Person.jsx remains a complex nested ternary operator directly within the JSX. This makes the code difficult to read and violates a key project requirement. [CHECKLIST ITEM #3]

Please refactor this by extracting the conditional logic into a separate variable before the return statement. This will significantly improve the component's readability and align it with the project's coding standards.


✨ 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

Comment on lines +9 to +11
{isMarried
? `${partnerName} is my ${sex === 'f' ? 'husband' : 'wife'}`
: 'I am not married'}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This logic, including the nested ternary operator, is too complex to be placed directly within the JSX. This was the main point of the previous review and it violates checklist item #3: 'Avoid putting several cases to conditional rendering. Create separate variable for the condition'.

Please extract this logic into a variable before the return statement to improve readability.

Copy link
Copy Markdown

@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

Excellent work on this update! You did a fantastic job refactoring the Person component to move the logic out of the JSX, which makes the code much more readable and maintainable. This was the most important part of the feedback, and you addressed it perfectly.

I am approving your solution so you can move forward, but please note one minor style detail for the future. In src/components/Person/Person.jsx, the ternary operator is on a single line. To improve readability, it should be split so each part is on its own line, as mentioned in the project's style guide [CHECKLIST ITEM #2].

Overall, this is a great improvement. Well done!


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

Footnotes

  1. Rate AI review example

let partnerText = 'I am not married';

if (isMarried) {
const partnerRole = sex === 'f' ? 'husband' : 'wife';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a great improvement! However, please format this ternary operator to follow the project's code style guidelines. Each part of the operator should be on a new line to improve readability.

This violates checklist item #2: 'Format ternary operator operands correctly - move each operand to the separate line'

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