Skip to content

Commit

Permalink
updated captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
PrathamLalwani committed Dec 21, 2023
1 parent 566901c commit f91d5e6
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/components/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,27 @@ const Contact = () => {
};
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
console.log();
try {
const response = await postData();
console.log(response);
if (response.statusCode == 200) {
alert("Thank you for your message. I will get back to you soon!");
} else {
alert("Send Message Failed. Please try again later");
if (recaptchaRef.current?.getValue()) {
try {
const response = await postData();
console.log(response);
if (response.statusCode == 200) {
alert("Thank you for your message. I will get back to you soon!");
} else {
alert("Send Message Failed. Please try again later");
}
} catch (e) {
alert("Send Message failed. Please try again later.");
}
} catch (e) {
alert("Send Message failed. Please try again later.");
}

dispatch({ type: "EMAIL", payload: "" });
dispatch({ type: "NAME", payload: "" });
dispatch({ type: "MESSAGE", payload: "" });
dispatch({ type: "TOKEN", payload: "" });
dispatch({ type: "EMAIL", payload: "" });
dispatch({ type: "NAME", payload: "" });
dispatch({ type: "MESSAGE", payload: "" });
dispatch({ type: "TOKEN", payload: "" });
recaptchaRef.current.reset();
} else {
alert("Please finish the captcha");
}
};

return (
Expand Down

0 comments on commit f91d5e6

Please sign in to comment.