Skip to content

solution with failed tests#1122

Open
luchali wants to merge 1 commit intomate-academy:masterfrom
luchali:develop
Open

solution with failed tests#1122
luchali wants to merge 1 commit intomate-academy:masterfrom
luchali:develop

Conversation

@luchali
Copy link

@luchali luchali commented Feb 3, 2026

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 migrating the application to Redux! The core functionality is in place and you've successfully set up all the required slices.

I'm requesting a few changes to improve consistency across your data-fetching slices, which is a key aspect of building a predictable and maintainable Redux store. Currently, postsSlice and usersSlice handle state differently than commentsSlice.

Please standardize them by making the following adjustments:

  1. In usersSlice and postsSlice, ensure the loaded flag is set to true when the async thunk is fulfilled or rejected, not pending. This will make its meaning consistent across the app.
  2. In usersSlice, please rename the users property to items for consistency with the other slices.
  3. In both postsSlice and usersSlice, change the error property to hasError: boolean instead of error: string to match the state shape in commentsSlice.

Lastly, please remove the unused counter slice and its import from src/app/store.ts as it's leftover from the template. After these adjustments, your solution will be excellent!


✨ 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 store = configureStore({
reducer: {
counter: counterReducer,

Choose a reason for hiding this comment

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

The counter slice is not part of the task requirements. It seems to be a leftover from the template. Please remove it from the store, along with its import on line 3.

type PostsState = {
items: Post[];
loaded: boolean;
hasError: string;

Choose a reason for hiding this comment

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

The task requires a hasError property, but its type is inconsistent between slices. Here it's a string, while in the commentsSlice it is a boolean. For consistency across the application's state, it would be better to use a boolean type here as well.

Comment on lines +35 to +46
.addCase(fetchPosts.pending, state => {
state.loaded = true;
state.hasError = '';
})
.addCase(fetchPosts.fulfilled, (state, action) => {
state.loaded = false;
state.items = action.payload;
})
.addCase(fetchPosts.rejected, (state, action) => {
state.loaded = false;
state.hasError = action.error.message || 'Something went wrong';
});

Choose a reason for hiding this comment

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

The logic for the loaded state is the reverse of how it's implemented in the commentsSlice. Here, loaded is set to true during the pending state, effectively acting as an isLoading flag. In commentsSlice, loaded is false during pending and true on fulfilled or rejected. To maintain consistency, please update this logic to match the implementation in commentsSlice.

Comment on lines +8 to +11
type UsersState = {
users: User[];
error: string;
loaded: boolean;

Choose a reason for hiding this comment

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

For consistency with other slices (like commentsSlice), it's better to use common property names. Consider renaming users to items and changing error: string to hasError: boolean to make the state shape uniform across the application.

Comment on lines +30 to +41
.addCase(fetchUsers.pending, state => {
state.loaded = true;
state.error = '';
})
.addCase(fetchUsers.fulfilled, (state, action) => {
state.loaded = false;
state.users = Array.isArray(action.payload) ? action.payload : [];
})
.addCase(fetchUsers.rejected, (state, action) => {
state.loaded = false;
state.error = action.error.message ?? 'Unknown error';
});

Choose a reason for hiding this comment

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

The logic for the loaded flag is inconsistent with its implementation in commentsSlice. Here, loaded: true is used to signify a loading state (pending), whereas in commentsSlice it signifies that the loading process has completed (either successfully or not). To maintain consistency, please adjust the logic here to match the one in commentsSlice.

Copy link

@Anton-Kuchmasov Anton-Kuchmasov left a comment

Choose a reason for hiding this comment

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

Great job!

don't forget to erase all unused inline comments

// });

// setComments(currentComments => [...currentComments, newComment]);

Choose a reason for hiding this comment

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

Don't forget to erase all unused inline comments in further tasks

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.

4 participants