-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
base: master
Are you sure you want to change the base?
aasdasd #2682
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! There are a few critical issues that need to be addressed before we can approve the pull request:
-
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. -
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.
-
State Management for Inputs: The
value
prop inTextField
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. -
Movies Array Structure: Ensure that
moviesFromServer
is correctly structured as an array ofMovie
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); |
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 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.
src/components/NewMovie/NewMovie.tsx
Outdated
const [imgUrl, setImgUrl] = useState<string>(''); | ||
const [imdbUrl, setImdbUrl] = useState<string>(''); | ||
const [imdbId, setImdbId] = useState<string>(''); | ||
const buttonEnabled = title || imgUrl || imdbUrl || imdbId; |
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 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.
src/components/NewMovie/NewMovie.tsx
Outdated
className="NewMovie" | ||
key={count} | ||
onSubmit={event => handleSubmit(event)} | ||
> | ||
<h2 className="title">Add a movie</h2> | ||
|
||
<TextField | ||
name="title" | ||
label="Title" | ||
value="" |
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 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.
src/components/NewMovie/NewMovie.tsx
Outdated
<TextField | ||
name="description" | ||
label="Description" | ||
value="" |
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 value
prop should be set to the description
state variable to reflect the current input value.
src/components/NewMovie/NewMovie.tsx
Outdated
<TextField | ||
name="imgUrl" | ||
label="Image URL" | ||
value="" |
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 value
prop should be set to the imgUrl
state variable to reflect the current input value.
src/components/NewMovie/NewMovie.tsx
Outdated
<TextField | ||
name="imdbUrl" | ||
label="Imdb URL" | ||
value="" |
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 value
prop should be set to the imdbUrl
state variable to reflect the current input value.
src/components/NewMovie/NewMovie.tsx
Outdated
<TextField | ||
name="imdbId" | ||
label="Imdb ID" | ||
value="" |
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 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} |
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 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.
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.
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:
-
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. -
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. -
State Management for Inputs: Make sure that the
onChange
handlers forTextField
components correctly update the state variables liketitle
,imgUrl
,imdbUrl
, andimdbId
. -
required
Attribute Logic: Therequired
attribute should be set based on therequired
prop, not thevalue
. This ensures correct form validation behavior. -
Movies Array Structure: Verify that
moviesFromServer
is correctly structured as an array ofMovie
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[]); |
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 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; |
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 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.
value={title} | ||
required | ||
onChange={setTitle} |
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 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.
value={imgUrl} | ||
required | ||
onChange={setImgUrl} |
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 setImgUrl
function is correctly updating the imgUrl
state variable. The onChange
handler should receive the current input value.
value={imdbUrl} | ||
required | ||
onChange={setImdbUrl} |
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 setImdbUrl
function is correctly updating the imdbUrl
state variable. The onChange
handler should receive the current input value.
value={imdbId} | ||
required | ||
onChange={setImdbId} |
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 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} |
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 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.
No description provided.