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

develop:modified_todo-form #2900

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

Conversation

pti4ka121
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.


Thank you for your hard work on this project! 😊 While your implementation is mostly on point, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Data Preparation and Import Usage: The TodoInfo component is importing getUserById directly, which goes against the guideline of preparing data in the App component and passing it down as props. This is crucial for maintaining a clean data flow in React applications.

  2. Ensure Correct Data Structure: Verify that usersFromServer and todosFromServer are correctly structured and implemented, as they are essential for the app's functionality.

Please address these issues to ensure the code meets the core requirements. Once resolved, your code will be in great shape for approval! Keep up the great work! 🚀

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

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

Comment on lines +3 to +4
import usersFromServer from './api/users';
import todosFromServer from './api/todos';

Choose a reason for hiding this comment

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

Ensure that the imported files usersFromServer and todosFromServer exist and are correctly implemented in the project. This is crucial for the functionality of the app.

src/App.tsx Outdated

export const App = () => {
const [todos, setTodos] = useState<Todo[]>(todosFromServer);

Choose a reason for hiding this comment

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

The initial state for todos is set using todosFromServer. Ensure that this data is correctly fetched and structured as expected.

src/App.tsx Outdated
Comment on lines 29 to 37
const handleAddTodo = (inputData: FormData) => {
const newTodo = {
...inputData,
id: getNewTodoId(todos),
completed: false,
};

setTodos(currentTodos => [...currentTodos, newTodo]);
};

Choose a reason for hiding this comment

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

The handleAddTodo function correctly adds a new todo with a unique ID and default completed status. Ensure that getNewTodoId is implemented correctly to avoid ID conflicts.

src/App.tsx Outdated
Comment on lines 55 to 66
const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();
if (isDisabledAdd) {
setIsTitleError(!title);
setIsUserError(!userId);

return;
}

handleAddTodo(formData);
reset();
};

Choose a reason for hiding this comment

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

The handleSubmit function correctly prevents form submission if validation fails and resets the form upon successful submission. Ensure that the error states are managed properly to provide user feedback.

src/App.tsx Outdated
Comment on lines 101 to 105
{usersFromServer.map(user => (
<option key={user.id} value={user.id}>
{user.name}
</option>
))}

Choose a reason for hiding this comment

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

Ensure that usersFromServer is an array of user objects with id and name properties, as this is crucial for rendering the user options correctly.

@@ -1 +1,27 @@
export const TodoInfo = () => {};
import { getUserById } from '../../services';

Choose a reason for hiding this comment

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

Avoid using the import keyword in non-root components like TodoInfo. Instead, prepare data in the App component and pass it down as props. This aligns with the checklist guideline: 'Prepare data in one place (App component) and pass it to child components. Don't use import keyword in non-root components.'

};

export const TodoInfo: React.FC<Props> = ({ todo }) => {
const user = getUserById(todo.userId);

Choose a reason for hiding this comment

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

Ensure that getUserById is correctly fetching the user data based on todo.userId. This function should be verified to return the correct user object or null if not found.

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 implementing the task requirements! 🎉 Your code meets the necessary constraints and successfully addresses the previous issues. Here are some key points and areas for improvement:

  1. Data Preparation and Flow: You've correctly prepared the data in the App component by importing usersFromServer and todosFromServer, and using the getUserById function to associate users with todos. This data is then passed down to child components, maintaining the integrity of data flow as per the guidelines.

  2. Component Structure: The TodoInfo component is well-implemented, displaying todo information and utilizing the UserInfo component without directly importing getUserById. This aligns with the guideline of preparing data in the App component.

  3. TypeScript Types: Your types.ts file defines the necessary TypeScript types for User and Todo, which are crucial for type-checking throughout the application. However, ensure that the TodoListProps type is utilized if needed or consider removing it if it's unnecessary.

  4. Critical Issues: While the code is approved, please ensure that the TodoInfo component receives the todo prop, including the user property, from the App component rather than fetching user data directly. This is crucial for maintaining proper data flow.

Overall, you've done a fantastic job! Keep in mind the critical issues mentioned, and make sure to address them in future projects to enhance your coding skills. Keep up the great work and continue learning from each task! 🚀

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

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