Skip to content

Commit

Permalink
contact loading states added
Browse files Browse the repository at this point in the history
  • Loading branch information
sanidhyy committed Jan 1, 2024
1 parent f99192a commit ba1f73d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pages/contact/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { motion } from "framer-motion";
import { BsArrowRight } from "react-icons/bs";

import { fadeIn } from "../../variants";
import { useState } from "react";

const Contact = () => {
const [isLoading, setIsLoading] = useState(false);

const handleSubmit = (event) => {
event.preventDefault();
setIsLoading(true);

const myForm = event.target;
const formData = new FormData(myForm);
Expand All @@ -16,7 +20,8 @@ const Contact = () => {
body: new URLSearchParams(formData).toString(),
})
.then(() => alert("Thank you. I will get back to you ASAP."))
.catch((error) => console.log(error));
.catch((error) => console.log(error))
.finally(() => setIsLoading(false));
};

return (
Expand Down Expand Up @@ -55,6 +60,8 @@ const Contact = () => {
name="name"
placeholder="Name"
className="input"
disabled={isLoading}
aria-disabled={isLoading}
required
aria-required
/>
Expand All @@ -63,6 +70,8 @@ const Contact = () => {
name="email"
placeholder="E-mail"
className="input"
disabled={isLoading}
aria-disabled={isLoading}
required
aria-required
/>
Expand All @@ -72,19 +81,25 @@ const Contact = () => {
name="subject"
placeholder="Subject"
className="input"
disabled={isLoading}
aria-disabled={isLoading}
required
aria-required
/>
<textarea
name="message"
placeholder="Message..."
className="textarea"
disabled={isLoading}
aria-disabled={isLoading}
required
aria-required
/>
<button
type="submit"
className="btn rounded-full border border-white/50 max-w-[170px] px-8 transition-all duration-300 flex items-center justify-center overflow-hidden hover:border-accent group"
disabled={isLoading}
aria-disabled={isLoading}
>
<span className="group-hover:-translate-y-[120%] group-hover:opacity-0 transition-all duration-500">
Let's talk
Expand Down

0 comments on commit ba1f73d

Please sign in to comment.