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

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

Develop #2713

wants to merge 10 commits into from

Conversation

taniavozniuk
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 code is mostly on the right track, there are a few critical issues that need to be addressed before we can approve it. These include typographical errors in state variable names, which can lead to confusion and bugs, and the need for proper validation and error handling in the NewMovie component. Additionally, ensure that the getImageById function's behavior aligns with the application's requirements. Once these issues are resolved, your code will be in great shape! Keep up the good 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.

Comment on lines +9 to +13
function getImageById(imdbID: string): string | null {
return (
moviesFromServer.find(movie => movie.imdbId === imdbID)?.imgUrl || null
);
}

Choose a reason for hiding this comment

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

The getImageById function returns null if no movie with the given imdbId is found. Ensure that this behavior is intended and handled appropriately in the application. If an image is required for every movie, you might want to handle the null case differently.

const [hasTitleError, setHasTitleError] = useState(false);

const [description, setDescription] = useState('');
const [hasdesctiptionError, setHasDesctiptionError] = useState(false);

Choose a reason for hiding this comment

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

There is a typo in the state variable name hasdesctiptionError. It should be hasDescriptionError to maintain consistency and avoid confusion.

const [imgUrl, setImgUrl] = useState('');
const [hasImageUrlError, setHasImageUrlError] = useState(false);

const [imdbUrl, setImdbdUrl] = useState('');

Choose a reason for hiding this comment

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

There is a typo in the state variable name setImdbdUrl. It should be setImdbUrl to match the naming convention used elsewhere in the code.

// to reset touched status of all the `Field`s
const [count] = useState(0);
setHasTitleError(!title);
// setHasDesctiptionError(!description);

Choose a reason for hiding this comment

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

The line for setting the description error state is commented out. If you intend to validate the description field, you should uncomment this line to ensure that the error state is set correctly.

value={description}
onChange={handleDesctiptionChange}
required
error={hasdesctiptionError}

Choose a reason for hiding this comment

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

The error prop for the description field uses hasdesctiptionError, which contains a typo. It should be hasDescriptionError to match the corrected state variable name.

onChange = () => {},
}) => {
// generate a unique id once on component load
const [id] = useState(() => `${name}-${getRandomDigits()}`);

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

Choose a reason for hiding this comment

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

The hasError logic checks if the field is required and not filled, but it only triggers after the field is touched. This is correct, but ensure that this behavior aligns with the overall form validation strategy. If you want immediate validation feedback, consider adjusting this logic.

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 submission! 🎉 Your code is on the right track, but there are a few critical issues that need attention to ensure robustness and alignment with the task requirements:

  1. Typographical Errors: There are typographical errors in the function and state variable names, such as handleDesctiptionChange and setHasDesctiptionError. These should be corrected to handleDescriptionChange and setHasDescriptionError respectively, to maintain consistency and avoid confusion.

  2. Validation and Error Handling: In the NewMovie component, ensure that all required fields are validated correctly before submission. The description field is optional, so adjust the validation logic accordingly.

  3. getImageById Function: The function currently returns null if no image is found. Make sure this behavior aligns with the application's requirements. Consider handling this case appropriately in the MoviesList component or when setting the movie data to avoid rendering issues.

Please address these issues to improve your code. This decision to approve is made to help you move forward with your learning. Remember to review the comments and make necessary improvements. Keep up the good work and continue learning from these experiences! 🚀

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

Comment on lines +9 to +13
function getImageById(imdbID: string): string | null {
return (
moviesFromServer.find(movie => movie.imdbId === imdbID)?.imgUrl || null
);
}

Choose a reason for hiding this comment

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

The getImageById function currently returns null if no image is found. Ensure this behavior aligns with the application's requirements. According to the checklist, you should not render components if the property passed to them is null or undefined. Consider handling this case appropriately in the MoviesList component or when setting the movie data.

const [hasTitleError, setHasTitleError] = useState(false);

const [description, setDescription] = useState('');
const [hasDescriptionError, setHasDesctiptionError] = useState(false);

Choose a reason for hiding this comment

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

There is a typographical error in the state variable name setHasDesctiptionError. It should be setHasDescriptionError to match the corresponding state variable hasDescriptionError.

setHasTitleError(false);
};

const handleDesctiptionChange = (value: string) => {

Choose a reason for hiding this comment

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

There is a typographical error in the function name handleDesctiptionChange. It should be handleDescriptionChange to match the corresponding state variable description.

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