Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
venher-v committed Jan 18, 2025
1 parent b03bb65 commit 89e363d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/components/NewMovie/NewMovie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ export const NewMovie: React.FC<Props> = ({ onAdd }) => {
setImdbUrl(val);
};

const handleImdbUId = (val: string) => {
const handleImdbId = (val: string) => {
setImdbId(val);
};

const trimedTitle = title.trim();
const trimedDescription = description.trim();
const trimedImgUrl = imgUrl.trim();
const trimmedTitle = title.trim();
const trimmedDescription = description.trim();
const trimmedImgUrl = imgUrl.trim();
const trimmedImdbUrl = imdbUrl.trim();
const trimmedImdbId = imdbId.trim();

const newMovie = {
title: trimedTitle,
description: trimedDescription,
imgUrl: trimedImgUrl,
title: trimmedTitle,
description: trimmedDescription,
imgUrl: trimmedImgUrl,
imdbUrl: trimmedImdbUrl,
imdbId: trimmedImdbId,
};

const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();

if (trimedTitle || trimedImgUrl || trimmedImdbUrl || trimmedImdbId) {
if (trimmedTitle && trimmedImgUrl && trimmedImdbUrl && trimmedImdbId) {
onAdd(newMovie);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ export const NewMovie: React.FC<Props> = ({ onAdd }) => {
name="imdbId"
label="Imdb ID"
value={imdbId}
onChange={handleImdbUId}
onChange={handleImdbId}
required
/>

Expand Down

0 comments on commit 89e363d

Please sign in to comment.