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

feat: implement ReCaptcha component #317

Merged
merged 3 commits into from
Oct 21, 2018
Merged

Conversation

AlejandroYanes
Copy link
Collaborator

fixes #290

const getUrl = () => {
if (lang) {
return `https://www.google.com/recaptcha/api.js?render=explicit&hl=${lang}`;
}

Choose a reason for hiding this comment

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

put this in other file(get-url.js) in order to test it and then below call it as getUrl(lang)

/** The color theme of the widget. */
theme: PropTypes.oneOf(['light', 'dark']),
/** The size of the widget. */
size: PropTypes.oneOf(['normal', 'compact']),

Choose a reason for hiding this comment

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

here you forgot to pass a tabIndex prop that defaults to 0

error: undefined,
onChange: () => {},
className: undefined,
style: {},

Choose a reason for hiding this comment

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

in all components we are setting style to undefined

import RenderIf from '../RenderIf';
import './styles.css';

export default class ReCaptchaLoader extends Component {

Choose a reason for hiding this comment

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

it better call this ReCaptchaComponent and the file component.js

explicit: true,
sitekey: value,
theme,
size,

Choose a reason for hiding this comment

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

pass tabIndex here

const { error, style } = this.props;
return (
<div className={this.getContainerClassNames()} style={style}>
<div id="reCaptcha-container" />

Choose a reason for hiding this comment

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

id="recaptcha-container"

return (
<div className={this.getContainerClassNames()} style={style}>
<div id="reCaptcha-container" />
<RenderIf isTrue={error}>

Choose a reason for hiding this comment

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

Review the console and you will see a warning because you are not passing a bool here your are passing undefined, a node or a string. So:

<RenderIf isTrue={!!error}>

}

ReCaptchaLoader.propTypes = {
/** Specifies the site key for the recaptcha. */

Choose a reason for hiding this comment

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

here you don't need to put description, they are only needed in the index.js

ReCaptchaLoader.defaultProps = {
value: undefined,
theme: 'light',
size: 'normal',

Choose a reason for hiding this comment

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

And you can put the props that receive a value different form undefined and null as required.
In this case theme, size, onChange can be set as required since they come from index with 'light', 'normal' and () => {}.

renderReCaptcha() {
const { value, theme, size, onChange } = this.props;
window.grecaptcha.render('reCaptcha-container', {
explicit: true,

Choose a reason for hiding this comment

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

remove this

}

renderReCaptcha() {
const { value, theme, size, tabIndex, onChange } = this.props;
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.

@coveralls
Copy link

coveralls commented Oct 21, 2018

Pull Request Test Coverage Report for Build 1481

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.2%) to 72.376%

Totals Coverage Status
Change from base Build 1468: -1.2%
Covered Lines: 927
Relevant Lines: 1218

💛 - Coveralls

@codeclimate
Copy link

codeclimate bot commented Oct 21, 2018

Code Climate has analyzed commit a7be0f6 and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 1

View more on Code Climate.

@LeandroTorresSicilia LeandroTorresSicilia merged commit 373e42c into master Oct 21, 2018
@reiniergs reiniergs deleted the implement-recaptcha branch October 21, 2018 05:51
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.

feat: implement reCaptcha component
3 participants