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

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

solution #1892

wants to merge 4 commits into from

Conversation

xnquaint
Copy link

Copy link

@sTorba24 sTorba24 left a comment

Choose a reason for hiding this comment

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

Add url validation before enabling button

Comment on lines 61 to 65
const isDisabled = !(title.trim()
&& imgUrl.trim()
&& imdbUrl.trim()
&& imdbId.trim()
);

Choose a reason for hiding this comment

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

here

@xnquaint xnquaint requested a review from sTorba24 October 16, 2023 22:08
Comment on lines 10 to 14
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

@xnquaint xnquaint requested a review from etojeDenys October 19, 2023 22:10
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.

awesome

id={id}
data-cy={`movie-${name}`}
className={classNames('input', {
'is-danger': hasError,
})}
placeholder={placeholder}
value={value}
onChange={event => onChange(event.target.value)}
onChange={event => onChange(event)}

Choose a reason for hiding this comment

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

Suggested change
onChange={event => onChange(event)}
onChange={onChange}

we can simplify it

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