Skip to content

message#1127

Open
SoraEmpty wants to merge 4 commits intomate-academy:masterfrom
SoraEmpty:develop
Open

message#1127
SoraEmpty wants to merge 4 commits intomate-academy:masterfrom
SoraEmpty:develop

Conversation

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

There are no files to review. Please make sure that you have added files to the pull request. Some files and directories may be ignored from the review or failed to load.
[CODE: NFR]

Additional info:
Ignored files list:

  • package-lock.json
  • package.json

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

There are no files to review. Please make sure that you have added files to the pull request. Some files and directories may be ignored from the review or failed to load.
[CODE: NFR]

Additional info:
Ignored files list:

  • package-lock.json
  • package.json

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

@SoraEmpty SoraEmpty marked this pull request as draft February 5, 2026 10:19
@SoraEmpty SoraEmpty marked this pull request as ready for review February 5, 2026 10:20
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

Good effort on migrating the application to use Redux Toolkit. However, a few critical changes are needed before this can be approved.

The main issue is that the author and selectedPost states are still managed by useState in App.tsx. The task requires these to be moved into their own dedicated Redux slices. Additionally, your usersSlice has a logical bug: in the usersThunk.fulfilled case, hasError is incorrectly set to true when it should be false on a successful request.

Please also address the missing error handling in comentsSlice.ts by adding a rejected case for the fetch thunk to correctly set the hasError state. Once these requirements are met and the bug is fixed, your solution will be in great shape.


✨ 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
const [loaded, setLoaded] = useState(false);
const [hasError, setError] = useState(false);

const [author, setAuthor] = useState<User | null>(null);

Choose a reason for hiding this comment

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

According to the task requirements, the author state should be managed by its own Redux slice, not with useState in the App component.

src/App.tsx Outdated
const [hasError, setError] = useState(false);

const [author, setAuthor] = useState<User | null>(null);
const [selectedPost, setSelectedPost] = useState<Post | null>(null);

Choose a reason for hiding this comment

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

The task requires creating a Redux slice for selectedPost. This state should be moved from useState to the Redux store.

@@ -0,0 +1,16 @@
import { combineSlices, configureStore } from '@reduxjs/toolkit';
import { commentsSlice } from '../slicers/comentsSlice';

Choose a reason for hiding this comment

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

There seems to be a typo in the filename. It should probably be commentsSlice instead of comentsSlice to maintain consistency.



const rootReducer = combineSlices(
commentsSlice, usersSlice, postsSlice

Choose a reason for hiding this comment

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

According to the task description, you also need to create and include slices for author and selectedPost in the root reducer.

Comment on lines 29 to 46
extraReducers: (builder) => {
builder.addCase(commentsThunkCreate.fulfilled, (state, action) => {
state.items.push(action.payload)},
)
builder.addCase(commentsThunkGet.fulfilled, (state, action) => {
state.items = action.payload,
state.loaded = true;
},
)
builder.addCase(commentsThunkGet.pending, state => {
state.loaded = false;
state.hasError = false;
})
builder.addCase(commentsThunkDelete.fulfilled, (state, action) => {
state.items = state.items.filter(item => item.id !== action.meta.arg);
},
)
}

Choose a reason for hiding this comment

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

The error handling for async operations is incomplete. You're missing a case for commentsThunkGet.rejected, which is necessary to set hasError: true when fetching comments fails. It's also good practice to add rejected handlers for commentsThunkCreate and commentsThunkDelete to handle potential errors during those operations.

import { Comment, CommentData } from '../types/Comment';
import { CommentData } from '../types/Comment';
import { useAppDispatch, useAppSelector } from './App/hooks';
import { commentsThunkCreate, commentsThunkDelete, commentsThunkGet } from './slicers/comentsSlice';

Choose a reason for hiding this comment

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

There appears to be a typo in the import path. The file should likely be named commentsSlice.ts for consistency.

builder.addCase(usersThunk.fulfilled, (state, action) => {
state.items = action.payload;
state.loaded = true;
state.hasError = true;

Choose a reason for hiding this comment

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

When the thunk is fulfilled, it means the request was successful. Therefore, hasError should be set to false here, not true.

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 refactoring the application to use Redux and for fixing the bugs from the previous review! The state management is much cleaner now. However, a few changes are needed to fully align with the task requirements regarding the Redux store structure.

The task explicitly requires dedicated slices for the selected author and the selected post. Currently, this logic is mixed in with the users and posts slices.

Please make the following adjustments:

  1. Create a new authorSlice.ts and move the selectedUserId state and its corresponding reducer logic out of usersSlice.
  2. Create a new selectedPostSlice.ts and move the selectedPost state and its reducer from postsSlice.

Additionally, please correct the consistent typo in comentsSlice to commentsSlice in the filename and all related imports for consistency. Once these structural changes are complete, your solution will be perfect.


✨ 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
.finally(() => setLoaded(true));
}
const dispatch = useAppDispatch();
const { items: users, selectedUserId } = useAppSelector(state => state.users);

Choose a reason for hiding this comment

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

According to the task description, the state for the selected author (user) should be in its own dedicated author slice. Therefore, selectedUserId should be selected from state.author.

src/App.tsx Outdated
}
const dispatch = useAppDispatch();
const { items: users, selectedUserId } = useAppSelector(state => state.users);
const { items: posts, loaded, hasError, selectedPost } = useAppSelector(state => state.posts)

Choose a reason for hiding this comment

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

The task requires a separate slice for the selected post. This means selectedPost should be managed in its own slice and selected from a different part of the state, for example state.selectedPost.

@@ -0,0 +1,16 @@
import { combineSlices, configureStore } from '@reduxjs/toolkit';
import { comentsSlice } from '../slicers/comentsSlice';

Choose a reason for hiding this comment

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

There's a consistent typo in the naming of the comments slice. It should be commentsSlice here and in the corresponding filename.



const rootReducer = combineSlices(
comentsSlice, usersSlice, postsSlice

Choose a reason for hiding this comment

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

The task requires creating dedicated slices named author and selectedPost. While you've correctly moved this state into Redux, it needs to be in separate slices that are then combined here. Currently, this state is managed within the usersSlice and postsSlice.

return deleteComment(commentId)
}
)
export const comentsSlice = createSlice({

Choose a reason for hiding this comment

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

There's a typo in the slice name. It should be commentsSlice to match the intended name 'comments'. This typo should also be corrected in the filename (commentsSlice.ts).

import { Comment, CommentData } from '../types/Comment';
import { CommentData } from '../types/Comment';
import { useAppDispatch, useAppSelector } from './App/hooks';
import { commentsThunkCreate, commentsThunkDelete, commentsThunkGet } from './slicers/comentsSlice';

Choose a reason for hiding this comment

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

There's a consistent typo in the filename and slice name for comments. It should be commentsSlice, not comentsSlice. Please correct this here and in the slice file itself for consistency.


export const postsSlice = createSlice({
name: 'posts',
initialState: {items: [] as Post[], loaded: false, hasError: false, selectedPost: null as Post | null },

Choose a reason for hiding this comment

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

According to the task description, the selectedPost state should be managed in a separate slice. This part of the state should be removed from the posts slice's initial state.

Comment on lines 17 to 19
setSelectedPost: (state, action: PayloadAction<Post | null>) => {
state.selectedPost = action.payload;
}

Choose a reason for hiding this comment

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

This reducer should be moved to the new, dedicated selectedPostSlice. The postsSlice should only be responsible for managing the list of posts (items, loaded, hasError).


export const usersSlice = createSlice({
name: 'users',
initialState: { items: [] as User[], loaded: false, hasError: false, selectedUserId: null as number | null },

Choose a reason for hiding this comment

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

The task requires a dedicated author slice for the selected user's state. The selectedUserId property should be removed from this initial state and managed within its own author slice.

Comment on lines 16 to 18
setSelectedUser: (state, action: PayloadAction<number | null>) => {
state.selectedUserId = action.payload;
}

Choose a reason for hiding this comment

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

This reducer logic for setting the selected user should be moved to the new author slice, as per the task requirements. The users slice should only be responsible for the list of all users, their loading status, and any related errors.

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 on refactoring the Redux store! You've done excellent work creating the dedicated authorSlice and selectedPostSlice, which significantly improves the application's structure. I am approving this submission as an educational override to help you move forward, but there are a few important things to address to finalize your solution.

Please remember to:

  • Remove the leftover selectedUserId state from src/components/slicers/usersSlice.ts and the selectedPost state from src/components/slicers/postsSlice.ts.
  • Correct the persistent typo in the filename and imports from comentsSlice to commentsSlice.
  • Fix the build error by updating the store's import path in src/index.tsx to point to ./components/App/Store.

Addressing these points will resolve the failing checks and make your state management clean and efficient. Keep up the fantastic work!


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

Footnotes

  1. Rate AI review example

@@ -0,0 +1,15 @@
import { combineSlices, configureStore } from '@reduxjs/toolkit';
import { commentsSlice } from '../slicers/comentsSlice';

Choose a reason for hiding this comment

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

The filename in the import path still has a typo. Please correct comentsSlice to commentsSlice to match the corrected slice filename.

import { Comment, CommentData } from '../types/Comment';
import { CommentData } from '../types/Comment';
import { useAppDispatch, useAppSelector } from './App/hooks';
import { commentsThunkCreate, commentsThunkDelete, commentsThunkGet } from './slicers/comentsSlice';

Choose a reason for hiding this comment

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

The filename in the import path still contains a typo. Please correct comentsSlice to commentsSlice to match the intended filename and maintain consistency with the rest of the application.

items: [] as Post[],
loaded: false,
hasError: false,
selectedPost: null as Post | null,

Choose a reason for hiding this comment

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

The selectedPost property should be removed from this slice's initial state. Its state is now managed by the dedicated selectedPostSlice, and keeping it here creates a duplicate and unused piece of state.

Comment on lines +15 to +21
selectedUserId: null as number | null,
},
reducers: {
setSelectedUser: (state, action: PayloadAction<number | null>) => {
state.selectedUserId = action.payload;
},
},

Choose a reason for hiding this comment

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

Excellent work on creating the separate authorSlice! However, the state and reducer related to the selected user (selectedUserId and setSelectedUser) should now be completely removed from this usersSlice. This slice should only be responsible for managing the list of users (items), loaded, and hasError states.

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