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

aasdasd #2682

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

aasdasd #2682

wants to merge 2 commits into from

Conversation

sinner1993
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 before we can approve the pull request:

  1. Form Validation on Blur: The NewMovie component should validate required fields (title, imgUrl, imdbUrl, imdbId) on blur and display errors if necessary. This is crucial for ensuring data integrity and user feedback.

  2. Submit Button Logic: The logic for enabling the submit button should ensure all required fields are filled and trimmed of spaces. Currently, it only checks if any field is filled, which could lead to incomplete submissions.

  3. State Management for Inputs: The value prop in TextField components should be linked to the corresponding state variables (e.g., title, description, etc.) to ensure they reflect the current input values. This is important for maintaining the correct state and user experience.

  4. Movies Array Structure: Ensure that moviesFromServer is correctly structured as an array of Movie objects. Mismatches can lead to runtime errors, affecting the application's functionality.

Please address these issues to align with the task requirements. Once resolved, your code will be in great shape! 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 [films, setFilms] = useState<Movie[]>(moviesFromServer);

Choose a reason for hiding this comment

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

Ensure that moviesFromServer is an array of objects that conform to the Movie type. If the structure of moviesFromServer does not match the Movie type, it could lead to runtime errors.

const [imgUrl, setImgUrl] = useState<string>('');
const [imdbUrl, setImdbUrl] = useState<string>('');
const [imdbId, setImdbId] = useState<string>('');
const buttonEnabled = title || imgUrl || imdbUrl || imdbId;

Choose a reason for hiding this comment

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

The buttonEnabled logic should ensure that all required fields are filled before enabling the submit button. Currently, it checks if any of the fields are filled, which might not be the intended behavior.

className="NewMovie"
key={count}
onSubmit={event => handleSubmit(event)}
>
<h2 className="title">Add a movie</h2>

<TextField
name="title"
label="Title"
value=""

Choose a reason for hiding this comment

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

The value prop should be set to the corresponding state variable (e.g., title, description, etc.) to reflect the current input value. Currently, it is set to an empty string, which will not update with user input.

<TextField
name="description"
label="Description"
value=""

Choose a reason for hiding this comment

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

The value prop should be set to the description state variable to reflect the current input value.

<TextField
name="imgUrl"
label="Image URL"
value=""

Choose a reason for hiding this comment

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

The value prop should be set to the imgUrl state variable to reflect the current input value.

<TextField
name="imdbUrl"
label="Imdb URL"
value=""

Choose a reason for hiding this comment

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

The value prop should be set to the imdbUrl state variable to reflect the current input value.

<TextField
name="imdbId"
label="Imdb ID"
value=""

Choose a reason for hiding this comment

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

The value prop should be set to the imdbId state variable to reflect the current input value.

onBlur={() => setTouched(true)}
required={name === 'description' ? false : data ? false : true}

Choose a reason for hiding this comment

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

The logic for the required attribute is a bit complex and might not behave as expected. It sets required to false for the 'description' field, which is fine, but for other fields, it checks if data is present to determine if the field is required. This logic might lead to unexpected behavior if data is not correctly initialized or updated. Consider simplifying this logic to ensure it aligns with the intended validation requirements.

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 your submission! 🎉 While there are a few critical issues that need attention, the decision to approve is made to help you move forward with your learning journey. Here are some key points to focus on:

  1. Form Validation on Blur: Ensure that the NewMovie component validates required fields (title, imgUrl, imdbUrl, imdbId) on blur. This will help catch errors early and improve user experience.

  2. Submit Button Logic: The logic for enabling the submit button should ensure all required fields are filled and trimmed of spaces. Consider using trim() to prevent submissions with only whitespace.

  3. State Management for Inputs: Make sure that the onChange handlers for TextField components correctly update the state variables like title, imgUrl, imdbUrl, and imdbId.

  4. required Attribute Logic: The required attribute should be set based on the required prop, not the value. This ensures correct form validation behavior.

  5. Movies Array Structure: Verify that moviesFromServer is correctly structured as an array of Movie objects to avoid runtime errors.

Addressing these issues will enhance the functionality and reliability of your code. Keep up the good work, and continue to learn and improve! 🚀

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


export const App = () => {
const [films, setFilms] = useState<Movie[]>(moviesFromServer as Movie[]);

Choose a reason for hiding this comment

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

Ensure that moviesFromServer is correctly structured as an array of Movie objects. The type assertion as Movie[] assumes that the data matches the Movie type, which can lead to runtime errors if the structure is incorrect. Verify the structure of moviesFromServer to prevent potential issues.

const [imgUrl, setImgUrl] = useState<string>('');
const [imdbUrl, setImdbUrl] = useState<string>('');
const [imdbId, setImdbId] = useState<string>('');
const buttonEnabled = title && imgUrl && imdbUrl && imdbId ? true : false;

Choose a reason for hiding this comment

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

The buttonEnabled logic should ensure that all required fields are not only filled but also trimmed of spaces. Consider using trim() on each field to prevent submissions with only whitespace.

Comment on lines +67 to +69
value={title}
required
onChange={setTitle}

Choose a reason for hiding this comment

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

The onChange handler should update the state with the current input value. Ensure that the setTitle function is correctly updating the title state variable. This applies to all TextField components.

Comment on lines +82 to +84
value={imgUrl}
required
onChange={setImgUrl}

Choose a reason for hiding this comment

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

Ensure that the setImgUrl function is correctly updating the imgUrl state variable. The onChange handler should receive the current input value.

Comment on lines +90 to +92
value={imdbUrl}
required
onChange={setImdbUrl}

Choose a reason for hiding this comment

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

Ensure that the setImdbUrl function is correctly updating the imdbUrl state variable. The onChange handler should receive the current input value.

Comment on lines +98 to +100
value={imdbId}
required
onChange={setImdbId}

Choose a reason for hiding this comment

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

Ensure that the setImdbId function is correctly updating the imdbId state variable. The onChange handler should receive the current input value.

onBlur={() => setTouched(true)}
required={name !== 'description' && !value}

Choose a reason for hiding this comment

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

The required attribute logic is incorrect. It should be set based on the required prop passed to the component, not the value. This ensures that the field is marked as required only if the required prop is true.

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