Skip to content

Commit

Permalink
chore: better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
zaida04 committed Jun 7, 2024
1 parent 8061fe6 commit 727e6b7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/contact-me/ContactForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { useForm } from "react-hook-form"
import { set, useForm } from "react-hook-form"

export default function ContactForm() {
const form = useForm<{
Expand Down Expand Up @@ -39,8 +39,17 @@ export default function ContactForm() {
form.reset();
setSuccess(true);
setError(null);

setTimeout(() => {
setSuccess(false);
}, 5000);
} catch (e) {
setError("Failed to submit form. Please try again later, or email me.");
setError((e as Error).message);
setSuccess(false);

setTimeout(() => {
setError(null);
}, 5000);
}
})}>
<h3 className="text-3xl">Contact Me</h3>
Expand Down

0 comments on commit 727e6b7

Please sign in to comment.