|
|
@@ -73,13 +73,9 @@ const Shortener = () => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- const onSubmit = async e => {
|
|
|
- e.preventDefault();
|
|
|
- if (loading) return;
|
|
|
- setCopied(false);
|
|
|
- setLoading(true);
|
|
|
+ const submitLink = async (reCaptchaToken?: string) => {
|
|
|
try {
|
|
|
- const link = await submit(formState.values);
|
|
|
+ const link = await submit({ ...formState.values, reCaptchaToken });
|
|
|
setLink(link);
|
|
|
formState.clear();
|
|
|
} catch (err) {
|
|
|
@@ -90,6 +86,33 @@ const Shortener = () => {
|
|
|
setLoading(false);
|
|
|
};
|
|
|
|
|
|
+ const onSubmit = async e => {
|
|
|
+ e.preventDefault();
|
|
|
+ if (loading) return;
|
|
|
+ setCopied(false);
|
|
|
+ setLoading(true);
|
|
|
+
|
|
|
+ if (process.env.NODE_ENV === "production" && !isAuthenticated) {
|
|
|
+ window.grecaptcha.execute(window.captchaId);
|
|
|
+ const getCaptchaToken = () => {
|
|
|
+ setTimeout(() => {
|
|
|
+ if (window.isCaptchaReady) {
|
|
|
+ const reCaptchaToken = window.grecaptcha.getResponse(
|
|
|
+ window.captchaId
|
|
|
+ );
|
|
|
+ window.isCaptchaReady = false;
|
|
|
+ window.grecaptcha.reset(window.captchaId);
|
|
|
+ return submitLink(reCaptchaToken);
|
|
|
+ }
|
|
|
+ return getCaptchaToken();
|
|
|
+ }, 200);
|
|
|
+ };
|
|
|
+ return getCaptchaToken();
|
|
|
+ }
|
|
|
+
|
|
|
+ return submitLink();
|
|
|
+ };
|
|
|
+
|
|
|
const title = !link && (
|
|
|
<H1 light>
|
|
|
Kutt your links{" "}
|