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

solution for movies form add #2770

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

Conversation

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

Great job on implementing the core functionality of managing and adding movies! 🎉 While there are some minor improvements suggested, such as renaming variables for clarity and updating the onChange handlers for better readability, these do not impact the overall functionality of your code. Keep up the good work and consider these suggestions for future enhancements! 😊

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

src/App.tsx Outdated

export const App = () => {
const [movie, setMovie] = useState<Movie[]>(moviesFromServer);

Choose a reason for hiding this comment

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

Consider renaming the state variable movie to movies to better reflect that it holds an array of movies. This will improve code readability and maintain consistency with the plural form used in moviesFromServer.

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.

The onChange handler should be a function that receives an event and updates the state. Consider changing onChange={setTitle} to onChange={(e) => setTitle(e.target.value)} to properly handle the input change event.

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.

Similar to the previous comment, update onChange={setDescription} to onChange={(e) => setDescription(e.target.value)} to correctly handle the input change event.

name="imgUrl"
label="Image URL"
value={imgUrl}
onChange={setImgUrl}

Choose a reason for hiding this comment

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

Update onChange={setImgUrl} to onChange={(e) => setImgUrl(e.target.value)} to ensure the input change event is handled properly.

name="imdbUrl"
label="Imdb URL"
value={imdbUrl}
onChange={setImdbUrl}

Choose a reason for hiding this comment

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

Update onChange={setImdbUrl} to onChange={(e) => setImdbUrl(e.target.value)} to correctly handle the input change event.

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.

Update onChange={setImdbId} to onChange={(e) => setImdbId(e.target.value)} to ensure the input change event is handled properly.

Comment on lines 11 to 15
const [title, setTitle] = useState('');
const [description, setDescription] = useState('');
const [imgUrl, setImgUrl] = useState('');
const [imdbUrl, setImdbUrl] = useState('');
const [imdbId, setImdbId] = useState('');

Choose a reason for hiding this comment

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

we can combine it in one useState

const [newMovie, setNewMovie] = useState({
  title: '',
  ...
})

now we can also create only one handle function for all fields

const handleChange = (e: ...) => {
  const {name, value} = e.target;
  setMovie((prevMovie) => ({...prevMovie, [name]: value}))
}

don't forget to specify name attr to input in TextField

@nadiia21 nadiia21 requested a review from etojeDenys March 1, 2025 15:42
Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

amazing

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.

3 participants