-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from judygab/1.6-customizations
1.6 customizations
- Loading branch information
Showing
4 changed files
with
107 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
import React from "react"; | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import GithubIcon from "../../../public/github-icon.svg"; | ||
import LinkedinIcon from "../../../public/linkedin-icon.svg"; | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
|
||
const EmailSection = () => { | ||
const [emailSubmitted, setEmailSubmitted] = useState(false); | ||
|
||
const handleSubmit = async (e) => { | ||
e.preventDefault(); | ||
const data = { | ||
email: e.target.email.value, | ||
subject: e.target.subject.value, | ||
message: e.target.message.value, | ||
}; | ||
const JSONdata = JSON.stringify(data); | ||
const endpoint = "/api/send"; | ||
|
||
// Form the request for sending data to the server. | ||
const options = { | ||
// The method is POST because we are sending data. | ||
method: "POST", | ||
// Tell the server we're sending JSON. | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
// Body of the request is the JSON data we created above. | ||
body: JSONdata, | ||
}; | ||
|
||
const response = await fetch(endpoint, options); | ||
const resData = await response.json(); | ||
|
||
if (response.status === 200) { | ||
console.log("Message sent."); | ||
setEmailSubmitted(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<section | ||
id="contact" | ||
|
@@ -30,59 +64,67 @@ const EmailSection = () => { | |
</Link> | ||
</div> | ||
</div> | ||
<div className="z-10"> | ||
<form className="flex flex-col"> | ||
<div className="mb-6"> | ||
<label | ||
htmlFor="email" | ||
className="text-white block mb-2 text-sm font-medium" | ||
> | ||
Your email | ||
</label> | ||
<input | ||
type="email" | ||
id="email" | ||
required | ||
className="bg-[#18191E] border border-[#33353F] placeholder-[#9CA2A9] text-gray-100 text-sm rounded-lg block w-full p-2.5" | ||
placeholder="[email protected]" | ||
/> | ||
</div> | ||
<div className="mb-6"> | ||
<label | ||
htmlFor="subject" | ||
className="text-white block text-sm mb-2 font-medium" | ||
> | ||
Subject | ||
</label> | ||
<input | ||
type="text" | ||
id="subject" | ||
required | ||
className="bg-[#18191E] border border-[#33353F] placeholder-[#9CA2A9] text-gray-100 text-sm rounded-lg block w-full p-2.5" | ||
placeholder="Just saying hi" | ||
/> | ||
</div> | ||
<div className="mb-6"> | ||
<label | ||
htmlFor="message" | ||
className="text-white block text-sm mb-2 font-medium" | ||
<div> | ||
{emailSubmitted ? ( | ||
<p className="text-green-500 text-sm mt-2"> | ||
Email sent successfully! | ||
</p> | ||
) : ( | ||
<form className="flex flex-col" onSubmit={handleSubmit}> | ||
<div className="mb-6"> | ||
<label | ||
htmlFor="email" | ||
className="text-white block mb-2 text-sm font-medium" | ||
> | ||
Your email | ||
</label> | ||
<input | ||
name="email" | ||
type="email" | ||
id="email" | ||
required | ||
className="bg-[#18191E] border border-[#33353F] placeholder-[#9CA2A9] text-gray-100 text-sm rounded-lg block w-full p-2.5" | ||
placeholder="[email protected]" | ||
/> | ||
</div> | ||
<div className="mb-6"> | ||
<label | ||
htmlFor="subject" | ||
className="text-white block text-sm mb-2 font-medium" | ||
> | ||
Subject | ||
</label> | ||
<input | ||
name="subject" | ||
type="text" | ||
id="subject" | ||
required | ||
className="bg-[#18191E] border border-[#33353F] placeholder-[#9CA2A9] text-gray-100 text-sm rounded-lg block w-full p-2.5" | ||
placeholder="Just saying hi" | ||
/> | ||
</div> | ||
<div className="mb-6"> | ||
<label | ||
htmlFor="message" | ||
className="text-white block text-sm mb-2 font-medium" | ||
> | ||
Message | ||
</label> | ||
<textarea | ||
name="message" | ||
id="message" | ||
className="bg-[#18191E] border border-[#33353F] placeholder-[#9CA2A9] text-gray-100 text-sm rounded-lg block w-full p-2.5" | ||
placeholder="Let's talk about..." | ||
/> | ||
</div> | ||
<button | ||
type="submit" | ||
className="bg-primary-500 hover:bg-primary-600 text-white font-medium py-2.5 px-5 rounded-lg w-full" | ||
> | ||
Message | ||
</label> | ||
<textarea | ||
name="message" | ||
id="message" | ||
className="bg-[#18191E] border border-[#33353F] placeholder-[#9CA2A9] text-gray-100 text-sm rounded-lg block w-full p-2.5" | ||
placeholder="Let's talk about..." | ||
/> | ||
</div> | ||
<button | ||
type="submit" | ||
className="bg-primary-500 hover:bg-primary-600 text-white font-medium py-2.5 px-5 rounded-lg w-full" | ||
> | ||
Send Message | ||
</button> | ||
</form> | ||
Send Message | ||
</button> | ||
</form> | ||
)} | ||
</div> | ||
</section> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters