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 #2749

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

Develop #2749

wants to merge 4 commits into from

Conversation

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

Thank you for your hard work on this project! 😊 There are a few critical issues that need to be addressed to meet the core requirements of the task:

  1. Form Submission Handling: The NewMovie component should use the form's onSubmit event instead of the button's onClick event. This ensures proper form submission behavior, including handling the Enter key.

  2. Form Clearing and Error Handling: After adding a new movie, the form should be cleared, and errors should not persist. This can be achieved by reinitializing the form.

  3. State Naming: The state variable managing the list of movies should be renamed from post to movies for better clarity and readability.

Please address these issues to ensure the functionality aligns with the task requirements. Keep up the great work, and don't hesitate to reach out if you need any help! 🚀

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

src/App.tsx Outdated

export const App = () => {
const [post, setPost] = useState(moviesFromServer);

Choose a reason for hiding this comment

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

The state variable post and its setter setPost are used to manage a list of movies. It would be more intuitive to name these variables movies and setMovies to better reflect their purpose and improve code readability.

imdbUrl.trim() !== '' &&
imdbId.trim() !== '';

const onSubmit = (event: React.FormEvent<HTMLButtonElement>) => {

Choose a reason for hiding this comment

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

The onSubmit function is attached to the button's onClick event. It would be more appropriate to attach it to the form's onSubmit event to ensure that the form submission is handled correctly, even if the user submits the form using the Enter key. This change would also allow you to remove the type="submit" attribute from the button.

@@ -27,7 +28,15 @@ export const TextField: React.FC<Props> = ({

// To show errors only if the field was touched (onBlur)
const [touched, setTouched] = useState(false);
const hasError = touched && required && !value;
const [generatedValue, setGeneratedValue] = useState('');

Choose a reason for hiding this comment

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

The generatedValue state is used to manage the input value, but the value prop is also being passed to the input field. This can lead to inconsistencies if the value prop is controlled externally. Consider using only the value prop for the input's value and removing the generatedValue state to avoid conflicts.

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 main functionality of managing and displaying a list of movies! 🎬 The App.tsx file is mostly well-implemented, but there's a critical issue with the naming of the addPost function. It should be renamed to addMovie to better reflect its purpose. This aligns with the previous suggestion to rename the state variable from post to movies for clarity.

The NewMovie component is well-structured, handling form submission correctly and meeting task requirements effectively. Similarly, the TextField component is well-implemented, providing a reusable input field with validation and error handling.

You've addressed previous issues, such as using the form's onSubmit event, clearing the form after submission, and improving state naming. However, ensure that the parameter name currentPost is updated to currentMovies or similar for consistency.

The decision to approve is made to help you move forward with your learning. Please review the comments to improve your code. Addressing these issues will enhance the clarity and functionality of your code in future projects. Keep up the good work and continue learning from your experiences! 🚀

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


export const App = () => {
const [movies, setMovies] = useState(moviesFromServer);

const addPost = (newPost: Movie) => {

Choose a reason for hiding this comment

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

The function addPost should be renamed to addMovie to better reflect its purpose of adding a movie to the list. This aligns with the previous suggestion to rename the state variable from post to movies for clarity.

const [movies, setMovies] = useState(moviesFromServer);

const addPost = (newPost: Movie) => {
setMovies(currentPost => [...currentPost, newPost]);

Choose a reason for hiding this comment

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

Ensure that the parameter name currentPost is updated to currentMovies or similar, to maintain consistency with the renaming of the state variable and function.

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