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

react_movies-list-add-form #2677

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

Conversation

Yaroslav65
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 Pull Request! 😊 While your implementation is mostly on point, there are a few critical issues that need to be addressed before we can proceed:

  1. Duplicate Movies Issue: The MoviesList component is receiving both moviesFromServer and movies, which can lead to duplicate entries. Ensure that only movies is used, as it already includes moviesFromServer.

  2. Form Validation: The NewMovie form should utilize the onBlur event for validation of required fields. Currently, this is not explicitly shown, so please ensure that onBlur is used to trigger validation.

  3. Submit Button Logic: The submit button should be disabled until all required fields are filled with trimmed values. Make sure trimming is applied before enabling the button.

  4. Form Reset: After adding a new movie, the form should be cleared, and errors should not be shown. Double-check that the reset function also clears any error states.

Once these issues are resolved, your code will be in great shape! Keep up the great work, and don't hesitate to reach out if you have any questions. 🚀

✨ 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
return (
<div className="page">
<div className="page-content">
<MoviesList movies={moviesFromServer} />
<MoviesList movies={[...moviesFromServer, ...movies]} />

Choose a reason for hiding this comment

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

The MoviesList component is receiving both moviesFromServer and movies, which will result in duplicate entries if movies already contains movies from the server. Consider using only movies to avoid duplicates, as movies is initialized with moviesFromServer.

Comment on lines +37 to +42
const pattern = new RegExp(
'^((([A-Za-z]{3,9}:(?://)?)(?:[-;:&=+$,w]+@)?[A-Za-z0-9.-]+|(?:www.|' +
'[-;:&=+$,w]+@)[A-Za-z0-9.-]+)' +
'((?:\\/[+~%/\\.\\w-_]*)?\\??(?:[-+=&;%@,\\.\\w_]*)#?' +
'(?:[,.!/\\\\\\w]*))?)$',
);

Choose a reason for hiding this comment

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

The regex pattern used for URL validation might not cover all valid URL formats. Consider using a more comprehensive regex or a library like 'validator' to ensure accurate URL validation.

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.

Great job on addressing most of the issues from the previous review! 🎉 Your implementation now effectively handles duplicate movies and ensures form validation is mostly in place. However, there are a few critical areas to focus on:

  1. Duplicate Movies Issue: Ensure that moviesFromServer is not separately passed to MoviesList to avoid duplicate entries. It's great that the MoviesList component filters duplicates based on imdbId.

  2. Form Validation: Consider using the onBlur event for validation of fields like imdbId, imdbUrl, imgUrl, description, and title to ensure they are filled correctly. This will enhance the user experience by providing immediate feedback.

  3. Submit Button Logic: Ensure the submit button is only enabled when all required fields are filled with trimmed values. This will prevent accidental submissions with incomplete data.

Your progress is commendable, and addressing these points will further strengthen your code. Keep up the great work and continue learning from these 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<Movie[]>(moviesFromServer);

Choose a reason for hiding this comment

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

The movies state is initialized with moviesFromServer, which is correct. However, ensure that moviesFromServer is not separately passed to MoviesList to avoid duplicate entries.

return (
<div className="page">
<div className="page-content">
<MoviesList movies={moviesFromServer} />
<MoviesList movies={[...movies]} />

Choose a reason for hiding this comment

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

Ensure that moviesFromServer is not separately passed to MoviesList to avoid duplicate entries. The spread operator here is correct if movies is the only source of truth for the movie list.

value=""
onChange={() => {}}
value={title}
onChange={setTitle}

Choose a reason for hiding this comment

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

Consider using the onBlur event for validation of the title field to ensure it is filled correctly.

name="description"
label="Description"
value={description}
onChange={setDescription}

Choose a reason for hiding this comment

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

Consider using the onBlur event for validation of the description field if it is required.

onChange={value => {
setImgUrl(value);
setImgUrlError(null);
}}

Choose a reason for hiding this comment

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

Consider using the onBlur event for validation of the imgUrl field to ensure it is filled correctly.

onChange={value => {
setImdbUrl(value);
setImdbUrlError(null);
}}

Choose a reason for hiding this comment

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

Consider using the onBlur event for validation of the imdbUrl field to ensure it is filled correctly.

name="imdbId"
label="Imdb ID"
value={imdbId}
onChange={setImdbId}

Choose a reason for hiding this comment

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

Consider using the onBlur event for validation of the imdbId field to ensure it is filled correctly.


<div className="field is-grouped">
<div className="control">
<button
type="submit"
data-cy="submit-button"
className="button is-link"
disabled={!title || !imgUrl || !imdbUrl || !imdbId}

Choose a reason for hiding this comment

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

Ensure that the submit button is only enabled when all required fields are filled with trimmed values. Currently, it checks for non-empty values, but trimming should be applied.

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