"use client"; import React, { useRef, useState } from "react"; import { motion } from "framer-motion"; import emailjs from "@emailjs/browser"; import { SectionWrapper } from "src/hoc"; import { slideIn } from "src/utils/motion"; import { styles } from "src/style"; // import { EarthCanvas } from "./canvas"; const Contact = () => { const formRef = useRef(); const [form, setForm] = useState({ name: "", email: "", message: "", }); const [loading, setLoading] = useState(false); const handleChange = (e) => { const { target } = e; const { name, value } = target; setForm({ ...form, [name]: value, }); }; const handleSubmit = (e) => { e.preventDefault(); setLoading(true); emailjs .send( import.meta.env.VITE_APP_EMAILJS_SERVICE_ID, import.meta.env.VITE_APP_EMAILJS_TEMPLATE_ID, { from_name: form.name, to_name: "JavaScript Mastery", from_email: form.email, to_email: "sujata@jsmastery.pro", message: form.message, }, import.meta.env.VITE_APP_EMAILJS_PUBLIC_KEY ) .then( () => { setLoading(false); alert("Thank you. I will get back to you as soon as possible."); setForm({ name: "", email: "", message: "", }); }, (error) => { setLoading(false); alert("Ahh, something went wrong. Please try again."); } ); }; return (
Get in touch