Skip to content

Solution#2040

Open
HiBlurryface wants to merge 2 commits into
mate-academy:masterfrom
HiBlurryface:develop
Open

Solution#2040
HiBlurryface wants to merge 2 commits into
mate-academy:masterfrom
HiBlurryface:develop

Conversation

@HiBlurryface

Copy link
Copy Markdown

No description provided.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Great job on structuring the application and splitting the components correctly! The data preparation logic is also well-implemented.

I'm requesting a few changes before I can approve this. There are a couple of functional bugs and style violations that need to be addressed:

  • Broken Email Links: In UserInfo.tsx and CommentInfo.tsx, the href attribute for email links is hardcoded. Please make it dynamic by using the email from the component's props, like href={mailto:${user.email}}.
  • Function Naming: The functions getUser and getComments in App.tsx should be renamed to be more descriptive, such as getUserById and getCommentsByPostId, as required by checklist item #6.
  • String Usage in JSX: In several components, you're wrapping static text in {'...'}. This should be avoided per checklist item #5. You can write the text directly, like <strong> by </strong>.

You're very close to a perfect solution! Please address these points and resubmit. 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

Comment thread src/App.tsx Outdated

<b data-cy="NoCommentsMessage">No comments yet</b>
</div>
function getUser(userId: number): UsersType | null {

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 violates checklist item #6: 'If you are searching some entity by some filter, specify it in function/method name'. Since this function finds a user by their ID, a more descriptive name would be getUserById.

Comment thread src/App.tsx Outdated

<p>
{' Posted by '}
function getComments(postId: number): CommentsType[] | null {

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 violates checklist item #6: 'If you are searching some entity by some filter, specify it in function/method name'. A more descriptive name like getCommentsByPostId would better reflect that this function filters comments based on the postId.

<div className="CommentInfo__title">
<strong className="CommentInfo__name">{comment.name}</strong>

{' by '}

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 violates checklist item #5: 'Use string interpolation inside tag content'. Using {'...'} for static text is discouraged. You can write the text directly between the JSX elements, and React will render it. For example: </strong> by <a>.


{' by '}

<a className="CommentInfo__email" href="mailto:Nikita@garfield.biz">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The href attribute for the email link is hardcoded. It should be dynamic and use the email property from the comment prop, like href={mailto:${comment.email}}.

Comment thread src/components/UserInfo/UserInfo.tsx Outdated
export const UserInfo: React.FC<Props> = ({ user }) => {
return (
<p>
{' Posted by '}

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 violates checklist item #5: 'Use string interpolation inside tag content'. Instead of using {'...'} for a simple string, you can write the text directly within the <p> tag. For example: <p>Posted by {user && ...}</p>.

Comment thread src/components/UserInfo/UserInfo.tsx Outdated
{' Posted by '}

{user !== null && (
<a className="UserInfo" href="mailto:Julianne.OConner@kory.org">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The href attribute is hardcoded. It should dynamically use the email property from the user prop to create the correct mailto link. For example: href={mailto:${user.email}}.

Comment thread src/types/PostsType.ts
Comment on lines +1 to +2
import { UsersType } from './../types/UsersType';
import { CommentsType } from './../types/CommentsType';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The relative paths for these imports are a bit complex. Since UsersType.ts and CommentsType.ts are in the same directory, you can simplify the paths to ./UsersType and ./CommentsType respectively. This makes the code cleaner and easier to read.

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

Copy link
Copy Markdown

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 task! You've successfully implemented all the core requirements, and the component structure is very well done. I am happy to approve your solution. I have a couple of small suggestions to make your code even more consistent and readable: - In src/App.tsx, consider renaming the function to getCommentsByPostId to be more specific about its purpose, as it filters by postId. [CHECKLIST ITEM #6] - In UserInfo.tsx and CommentInfo.tsx, it's a good practice to use template literals for constructing strings, like `mailto:${user.email}`. This improves consistency. [CHECKLIST ITEM #5] These are minor points for future reference. Great job overall!


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

Footnotes

  1. Rate AI review example

Comment thread src/App.tsx

<p>
{' Posted by '}
function getCommentsById(postId: number): CommentsType[] | null {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To be more specific and fully align with the previous suggestion, please rename this function to getCommentsByPostId. This makes it clearer that the function filters comments based on the postId.

<div className="CommentInfo__title">
<strong className="CommentInfo__name">{comment.name}</strong>
<span> by </span>
<a className="CommentInfo__email" href={`mailto:` + comment.email}>

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 works, but a more idiomatic way to use template literals is to embed the variable directly, like `mailto:${comment.email}`. This avoids mixing template literals with string concatenation.

return (
<p>
Posted by {user !== null && (
<a className="UserInfo" href={`mailto:` + user.email}>

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 works correctly, but for consistency with modern JavaScript practices and the feedback on other components, it's better to use a template literal here: `mailto:${user.email}`. This avoids mixing concatenation with template literals.

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