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

commit for chat #1183

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

Conversation

Vasyl-Zhyliakov
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.

Great work on implementing the core functionality correctly! 🎉 While there are a few minor improvements suggested, they don't impact the overall functionality. Keep up the good work and consider the feedback for future enhancements!

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

src/App.tsx Outdated
const [posts, setPosts] = useState<Post[]>([]);
const [errorMessage, setErrorMessage] = useState('');
const [notificationMessage, setNotificationMessage] = useState('');
const [activePostId, setActivePostId] = useState<number | null>(null)

Choose a reason for hiding this comment

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

It seems you forgot to add a semicolon at the end of this line. While this is not a critical issue in JavaScript, it's a good practice to include semicolons to avoid potential issues.

Comment on lines +26 to +30
useEffect(() => {
getUsersFromServer()
.then(setUsers)
.catch(() => {});
}, []);

Choose a reason for hiding this comment

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

Consider adding error handling logic in the catch block of this useEffect hook. According to the checklist, you should use try {..} catch for error handling .

Comment on lines +46 to +47
.catch(() => {
setErrorMessage('Something went wrong!');

Choose a reason for hiding this comment

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

The error message for the catch block is incomplete. It seems like the string is not properly closed. Make sure to complete the error message string.

export const USER_ID = 1549;

export const getUsersFromServer = () => {
return client.get<User[]>(`/users`);

Choose a reason for hiding this comment

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

The endpoint /users is hardcoded in the getUsersFromServer function. Ensure that this endpoint is correct and matches the API specification you are working with.

setActivePostId: (param: number | null) => void;
};

export const OnePost: React.FC<Props> = ({ post, activePostId, setActivePostId }) => {

Choose a reason for hiding this comment

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

The component OnePost is correctly implemented with the necessary props and logic to handle post selection. However, ensure that the Post type imported from '../types/Post' includes all the necessary fields used in this component.

};

export const OneUser: React.FC<Props> = ({ user, setSelectedUserId, setIsDropDownOpen }) => {
const handleUserSelect = () => {

Choose a reason for hiding this comment

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

The function handleUserSelect is correctly implemented to set the selected user ID and close the dropdown. Ensure that the User type includes an id field of type number.

className="dropdown-item"
onClick={handleUserSelect}
>
{user.name}

Choose a reason for hiding this comment

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

The href attribute in the anchor tag is using a template string to dynamically set the URL fragment. Ensure that the user.id is always defined to avoid potential issues.

</button>
</td>
</tr>
{posts.map(post => (

Choose a reason for hiding this comment

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

Consider adding a unique key prop to the OnePost component when mapping over the posts array. This is important for React to efficiently update and render components. You can use post.id as the key.

>
<span>Choose a user</span>

{activeUser?.name

Choose a reason for hiding this comment

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

Ensure that the activeUser variable correctly handles cases where selectedUserId does not match any user in the users array. This will prevent potential issues with undefined values.

{users.map(user => (
<OneUser
user={user}
key={user.id}

Choose a reason for hiding this comment

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

Good job using user.id as the key for the OneUser component. This ensures that each component instance is uniquely identified, which is important for React's reconciliation process.

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

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

Great start! Try to pass tests. Feel free to ask for help in the chat
Screenshot 2024-10-27 at 13 16 10
The layout looks a bit broken

Comment on lines 23 to 33
// export interface Comment {
// id: number;
// postId: number;
// name: string;
// email: string;
// body: string;
// }

// export const updateTodo = ({ id, title, completed }: Omit<Todo, 'userId'>) => {
// return client.patch<Todo>(`/todos/${id}`, { title, completed });
// };

Choose a reason for hiding this comment

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

Suggested change
// export interface Comment {
// id: number;
// postId: number;
// name: string;
// email: string;
// body: string;
// }
// export const updateTodo = ({ id, title, completed }: Omit<Todo, 'userId'>) => {
// return client.patch<Todo>(`/todos/${id}`, { title, completed });
// };

Consider removing unused lines of code

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