-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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:
-
Data Preparation and Import Usage: The
TodoInfo
component is importinggetUserById
directly, which goes against the guideline of preparing data in theApp
component and passing it down as props. This is crucial for maintaining a clean data flow in React applications. -
Ensure Correct Data Structure: Verify that
usersFromServer
andtodosFromServer
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.
import usersFromServer from './api/users'; | ||
import todosFromServer from './api/todos'; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
const handleAddTodo = (inputData: FormData) => { | ||
const newTodo = { | ||
...inputData, | ||
id: getNewTodoId(todos), | ||
completed: false, | ||
}; | ||
|
||
setTodos(currentTodos => [...currentTodos, newTodo]); | ||
}; |
There was a problem hiding this comment.
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
const handleSubmit = (event: React.FormEvent) => { | ||
event.preventDefault(); | ||
if (isDisabledAdd) { | ||
setIsTitleError(!title); | ||
setIsUserError(!userId); | ||
|
||
return; | ||
} | ||
|
||
handleAddTodo(formData); | ||
reset(); | ||
}; |
There was a problem hiding this comment.
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
{usersFromServer.map(user => ( | ||
<option key={user.id} value={user.id}> | ||
{user.name} | ||
</option> | ||
))} |
There was a problem hiding this comment.
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.
src/components/TodoInfo/TodoInfo.tsx
Outdated
@@ -1 +1,27 @@ | |||
export const TodoInfo = () => {}; | |||
import { getUserById } from '../../services'; |
There was a problem hiding this comment.
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.'
src/components/TodoInfo/TodoInfo.tsx
Outdated
}; | ||
|
||
export const TodoInfo: React.FC<Props> = ({ todo }) => { | ||
const user = getUserById(todo.userId); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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:
-
Data Preparation and Flow: You've correctly prepared the data in the
App
component by importingusersFromServer
andtodosFromServer
, and using thegetUserById
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. -
Component Structure: The
TodoInfo
component is well-implemented, displaying todo information and utilizing theUserInfo
component without directly importinggetUserById
. This aligns with the guideline of preparing data in theApp
component. -
TypeScript Types: Your
types.ts
file defines the necessary TypeScript types forUser
andTodo
, which are crucial for type-checking throughout the application. However, ensure that theTodoListProps
type is utilized if needed or consider removing it if it's unnecessary. -
Critical Issues: While the code is approved, please ensure that the
TodoInfo
component receives thetodo
prop, including theuser
property, from theApp
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! ✨
DEMO LINK