Skip to content

Commit

Permalink
Merge pull request #3 from siberiacancode/#1
Browse files Browse the repository at this point in the history
#1 into main ☄ add token to callback
  • Loading branch information
debabin authored Dec 13, 2023
2 parents 50ef8d1 + f71cb7e commit fe9e739
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ module.exports = {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-namespace': 'off'
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-var-requires': 'off',
'no-restricted-syntax': 'off',
'promise/always-return': 'off'
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/components/GoogleReCaptchaCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface GoogleReCaptchaCheckboxProps extends Omit<ComponentProps<'div'>
action?: string;
className?: string;
container?: ContainerId | HTMLElement;
callback?: () => void;
callback?: (token: string) => void;
errorCallback?: () => void;
expiredCallback?: () => void;
language?: GoogleReCaptcha.Language;
Expand Down
23 changes: 8 additions & 15 deletions src/context/GoogleReCaptchaContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,28 @@ export interface GoogleReCaptchaContextProps {
) => void;
}

const contextError =
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider';

export const GoogleReCaptchaContext = createContext<GoogleReCaptchaContextProps>({
googleReCaptcha: {},
siteKey: '',
language: '',
isLoading: true,
executeV3: () => {
throw Error(
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
);
throw Error(contextError);
},
executeV2Invisible: () => {
throw Error(
'GoogleReCaptchaContext has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
);
throw Error(contextError);
},
reset: () => {
throw Error(
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
);
throw Error(contextError);
},
getResponse: () => {
throw Error(
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
);
throw Error(contextError);
},
render: () => {
throw Error(
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
);
throw Error(contextError);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/context/GoogleReCaptchaProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import React from 'react';
import { render } from '@testing-library/react';

import type { GoogleReCaptchaProviderProps } from './GoogleReCaptchaProvider';
import { GoogleReCaptchaProvider } from './GoogleReCaptchaProvider';
Expand Down
10 changes: 5 additions & 5 deletions src/context/GoogleReCaptchaProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';

import type { GoogleReCaptcha, ContainerId } from '../utils';
import type { ContainerId, GoogleReCaptcha } from '../utils';
import {
removeGoogleReCaptchaScript,
injectGoogleReCaptchaScript,
checkGoogleReCaptchaInjected,
hideGoogleReCaptchaBadge,
removeGoogleReCaptchaContainer,
injectGoogleReCaptchaScript,
removeGoogleReCaptchaBadge,
checkGoogleReCaptchaInjected
removeGoogleReCaptchaContainer,
removeGoogleReCaptchaScript
} from '../utils';

import { GoogleReCaptchaContextProvider } from './GoogleReCaptchaContext';
Expand Down
2 changes: 1 addition & 1 deletion src/context/withGoogleReCaptcha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface WithGoogleReCaptchaParams {
googleReCaptcha: GoogleReCaptchaContextProps;
}

export const withGoogleReCaptcha = <OwnProps extends unknown>(
export const withGoogleReCaptcha = <OwnProps,>(
Component: React.ComponentType<OwnProps & WithGoogleReCaptchaParams>
) => {
const WithGoogleReCaptchaComponent = (props: OwnProps & Partial<WithGoogleReCaptchaParams>) => (
Expand Down

0 comments on commit fe9e739

Please sign in to comment.