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

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

add task solution #2111

wants to merge 3 commits into from

Conversation

avakiel
Copy link

@avakiel avakiel commented Jan 16, 2024

Copy link

@OleksandrRezanov OleksandrRezanov left a comment

Choose a reason for hiding this comment

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

Good work! It`s great that you made advanced validation!

Comment on lines 6 to 12
movie: {
title: string,
description: string,
imgUrl: string,
imdbUrl: string,
imdbId: string,
}

Choose a reason for hiding this comment

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

You create type State and can use it as type for movie. Actually we already have the same type in 'types' folder, so you may use it instead of creating you own.

Choose a reason for hiding this comment

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

agree)

Copy link

@olya-shyian olya-shyian left a comment

Choose a reason for hiding this comment

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

Nice! Validation is working! I like it!🤗

disabled={!title
|| !urlValidator(imgUrl)
|| !urlValidator(imdbUrl)
|| !imdbId}

Choose a reason for hiding this comment

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

maybe put this check in const

@@ -23,6 +24,7 @@ export const TextField: React.FC<Props> = ({
placeholder = `Enter ${label}`,
required = false,
onChange = () => {},
checkUrl = undefined,

Choose a reason for hiding this comment

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

please don't write undefined as a default value

you have already done this by adding ? here:
checkUrl?: (urlString: string) => boolean,

Comment on lines 6 to 12
movie: {
title: string,
description: string,
imgUrl: string,
imdbUrl: string,
imdbId: string,
}

Choose a reason for hiding this comment

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

agree)

setDescription('');
setImgUrl('');
setImdbUrl('');
setImdbId('');

Choose a reason for hiding this comment

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

you can create a reset function for this

@avakiel avakiel requested a review from olya-shyian January 21, 2024 01:08
Copy link

@olya-shyian olya-shyian left a comment

Choose a reason for hiding this comment

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

Thank you for the changes!
Let's do the last one☘️

imdbUrl: string,
imdbId: string,
}
) => void
Copy link

@olya-shyian olya-shyian Jan 22, 2024

Choose a reason for hiding this comment

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

If you don't understand what Oleksandr meant, then look at this

 onAdd: (movie: Movie) => void

you already have Movie type

dont write

 onAdd: (
   movie: {
     title: string,
     description: string,
     imgUrl: string,
     imdbUrl: string,
     imdbId: string,
   }

Copy link
Author

Choose a reason for hiding this comment

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

i fixed only in App. here I scroll and missed it))

const [imdbId, setImdbId] = useState('');

const urlValidator = (urlString: string): boolean => {
// eslint-disable-next-line max-len

Choose a reason for hiding this comment

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

put this function inside utils folder

= !title
|| !urlValidator(imgUrl)
|| !urlValidator(imdbUrl)
|| !imdbId;

Choose a reason for hiding this comment

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

try to fix code formatting

@avakiel avakiel requested a review from olya-shyian January 22, 2024 15:50
Copy link

@DanilWeda DanilWeda left a comment

Choose a reason for hiding this comment

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

Good job!
Approved with small comments.
Many thanks.

@@ -55,6 +57,8 @@ export const TextField: React.FC<Props> = ({
{hasError && (
<p className="help is-danger">{`${label} is required`}</p>
)}

{((touched && value) && (checkUrl && !checkUrl(value))) && (<p className="help is-danger">{`${label} incorrect URL`}</p>)}

Choose a reason for hiding this comment

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

You can write this condition in constant ( too long )

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