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

add task solution #2401

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

Conversation

Hy-tapa-kot
Copy link

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

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

Great work! Consider using the trimming function to avoid submitting fields with spaces only
Screenshot 2024-06-06 at 17 43 26

src/App.tsx Outdated
</div>
<div className="sidebar">
<NewMovie /* onAdd={(movie) => {}} */ />
<NewMovie onAddMovie={handleAddMovie} />

Choose a reason for hiding this comment

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

Suggested change
<NewMovie onAddMovie={handleAddMovie} />
<NewMovie onAdd={handleAddMovie} />

setTouched(prev => ({ ...prev, [name]: true }));
};

const handleChange = (name: string, value: string) => {

Choose a reason for hiding this comment

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

Suggested change
const handleChange = (name: string, value: string) => {
const handleChange = (event) => {

Copy link
Author

Choose a reason for hiding this comment

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

IT DOESN'T WORK THAT WAY(

Choose a reason for hiding this comment

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

it should work, you can always ask for some help in the chat

but you also can leave your version, just specify types more precisely

Suggested change
const handleChange = (name: string, value: string) => {
const handleChange = (name: keyof Movie, value: string) => {

Choose a reason for hiding this comment

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

please fix it
Uploading image.png…

const handleChange = (name: string, value: string) => {
setForm(prevForm => ({
...prevForm,
[name]: value,

Choose a reason for hiding this comment

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

Suggested change
[name]: value,
[event.target.name]: event.target.value,

value=""
onChange={() => {}}
value={form.title}
onChange={value => handleChange('title', value)}

Choose a reason for hiding this comment

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

Suggested change
onChange={value => handleChange('title', value)}
onChange={handleChange}

You can create one event handler for all fields

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.

image I can create an empty movie, let's fix that behavior

@Hy-tapa-kot Hy-tapa-kot requested a review from etojeDenys June 6, 2024 15:20
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.

please, feel free to tag me in the mate chat if you have some problems with this task

setTouched(prev => ({ ...prev, [name]: true }));
};

const handleChange = (name: string, value: string) => {

Choose a reason for hiding this comment

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

it should work, you can always ask for some help in the chat

but you also can leave your version, just specify types more precisely

Suggested change
const handleChange = (name: string, value: string) => {
const handleChange = (name: keyof Movie, value: string) => {

Comment on lines 35 to 38
const isFormValid = () => {
const requiredFields = ['title', 'imgUrl', 'imdbUrl', 'imdbId'];
return requiredFields.every(field => !!form[field as keyof MovieForm]);
};

Choose a reason for hiding this comment

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

Suggested change
const isFormValid = () => {
const requiredFields = ['title', 'imgUrl', 'imdbUrl', 'imdbId'];
return requiredFields.every(field => !!form[field as keyof MovieForm]);
};
const isFormValid = () => {
const requiredFields = ['title', 'imgUrl', 'imdbUrl', 'imdbId'];
return requiredFields.every(field => !!form[field as keyof MovieForm].trim());
};

to fix my prev comment

@Hy-tapa-kot Hy-tapa-kot requested a review from etojeDenys June 17, 2024 07:48
Copy link

@DarkMistyRoom DarkMistyRoom left a comment

Choose a reason for hiding this comment

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

It's still possible to add a new movie with only white spaces. Please use trim on verification

setTouched(prev => ({ ...prev, [name]: true }));
};

const handleChange = (name: string, value: string) => {

Choose a reason for hiding this comment

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

please fix it
Uploading image.png…

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.

4 participants