Skip to content

Solution#3578

Open
Stan0men wants to merge 2 commits intomate-academy:masterfrom
Stan0men:develop
Open

Solution#3578
Stan0men wants to merge 2 commits intomate-academy:masterfrom
Stan0men:develop

Conversation

@Stan0men
Copy link

No description provided.

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 job implementing the core features! The form validation and state management are well-handled. However, several checklist items were violated, so I am requesting a few changes to align the code with the project's architectural guidelines. The main issues are:

  • Data Preparation: The logic for finding a user for a given todo is currently in TodoList.tsx. This data preparation should be moved to the App component to keep child components simpler. [CHECKLIST ITEM #5]
  • Code Duplication: The TodoInfo component duplicates the display logic found in UserInfo. Please refactor TodoInfo to reuse the UserInfo component. Also, UserInfo should import the shared User type instead of defining its own. [CHECKLIST ITEM #2]
  • Variable Naming: Throughout the code, single-letter variables like e, t, and u are used. Please replace them with more descriptive names like event, todo, and user to improve readability. [CHECKLIST ITEM #1]

Once you've addressed these points, your solution will be excellent. Keep up the great work!


✨ 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

src/App.tsx Outdated
return value.replace(/[^^\p{Script=Latin}\p{Script=Cyrillic}\d ]+/gu, '');
};

const onTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {

Choose a reason for hiding this comment

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

This violates checklist item #1: 'Don't use one-letter variable naming.' The parameter e should have a more descriptive name, such as event. This advice also applies to the event handlers on lines 34 and 41.

src/App.tsx Outdated
return;
}

const maxId = todos.length ? Math.max(...todos.map(t => t.id)) : 0;

Choose a reason for hiding this comment

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

This violates checklist item #1: 'Don't use one-letter variable naming.' The parameter t in the map callback should be more descriptive, like todo. This also applies to the parameters in the callbacks on line 62 and line 110.

}

export const TodoInfo = ({ todo, user }: Props) => {
const actualUser = user ?? todo.user;

Choose a reason for hiding this comment

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

This logic is redundant. The user prop passed from TodoList is already resolved (it's either todo.user or the result of users.find()). You can simplify this by assigning the user prop directly to actualUser.

Comment on lines +19 to +21
<a className="UserInfo" href={`mailto:${actualUser.email}`}>
{actualUser.name}
</a>

Choose a reason for hiding this comment

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

This implementation duplicates the functionality of the UserInfo component. This violates checklist item #2: "Don't repeat yourself". You should import and use the UserInfo component here to display the user's information.

return (
<section className="TodoList">
{todos.map(todo => {
const user = todo.user ?? users.find(u => u.id === todo.userId);

Choose a reason for hiding this comment

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

This line violates two checklist items:

  1. Checklist item Solution 1-6 #5: 'Prepare data in one place (App component) and pass it to child components'. The logic to find a user for a given todo constitutes data preparation and should be done in the App component, not here. TodoList should be a simpler component that only focuses on rendering the data it receives.

  2. Checklist item Solution #1: 'Don't use one-letter variable naming'. The variable u in users.find(u => ...) is not descriptive. A better name would be user.

Comment on lines +1 to +6
interface UserInfoProps {
user: {
name: string;
email: string;
};
}

Choose a reason for hiding this comment

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

A User type is already defined in src/types/index.ts. To avoid duplication and ensure consistency, you should import and reuse that type here instead of defining a new shape for the user prop. This aligns with the 'Don't Repeat Yourself' principle mentioned in checklist item #2.

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