diff --git a/src/App.jsx b/src/App.jsx index f2168a7..dd5383b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -19,11 +19,7 @@ const App = () => { } /> - -
- {/* */} - {/* */} -
+ {/**/} ); diff --git a/src/components/Contacter.jsx b/src/components/Contacter.jsx index 9ff57b2..921c086 100644 --- a/src/components/Contacter.jsx +++ b/src/components/Contacter.jsx @@ -1,53 +1,135 @@ -import React, { useRef } from 'react'; -import emailjs from '@emailjs/browser'; +import React, { useRef, useState } from "react"; +import { motion } from "framer-motion"; +import emailjs from "@emailjs/browser"; +import { styles } from "../styles"; +import { SectionWrapper } from "../hoc"; +import { slideIn } from "../utils/motion"; +import EarthCanvas from "./canvas/Earth.jsx"; +const Contact = () => { + const formRef = useRef(); + const [form, setForm] = useState({ + name: "", + email: "", + message: "", + }); -function Contact(){ - const form = useRef(); - const serviceKey = import.meta.env.SERVICE_KEY; - const template = import.meta.env.TEMPLATE; - const token = import.meta.env.TOKEN; + const [loading, setLoading] = useState(false); - function sendEmail(e) { - e.preventDefault(); + const handleChange = (e) => { + const { target } = e; + const { name, value } = target; - emailjs.sendForm(serviceKey, template, form.current, token) - .then((result) => { - console.log(result.text); - }, (error) => { - console.log(error.text); - }); - e.target.reset(); + setForm({ + ...form, + [name]: value, + }); + }; - } + const handleSubmit = (e) => { + e.preventDefault(); + setLoading(true); - return
- {/*

Contact

*/} -
-
-
-
-
-
-
-

Send PP any message

- -
-
-
-
- -
-
-
-
-
-
+ 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); + console.error(error); -export default Contact; \ No newline at end of file + alert("Ahh, something went wrong. Please try again."); + } + ); + }; + + return ( +
+ +

Get in touch

+

Contact.

+ +
+ + +