Skip to content

Commit

Permalink
misc: embarassing error but will do for now
Browse files Browse the repository at this point in the history
  • Loading branch information
oreHGA committed Jun 1, 2024
1 parent a13b672 commit 0942e93
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,33 @@ import Image from "next/image";
import { fusionOfferingFeatures } from "./data";

import { CustomLink, ButtonLink } from "~/components/ui";
import { api } from "~/config";

export const OfferingSection = ({ isResearch = false }) => {
const [submitted, setSubmitted] = useState(false);

const handleSubmit = (e: { preventDefault: () => void }) => {
const [contactName, setContactName] = useState("");
const [contactEmail, setContactEmail] = useState("");
const [contactMessage, setContacMessage] = useState("");

const handleSubmit = async (e: { preventDefault: () => void }) => {
e.preventDefault();
// Submit logic here, e.g., send form data to server
setSubmitted(true);
try {
const res = await api.post("/sendContactEmail", {
name: contactName,
email: contactEmail,
message: contactMessage,
});

if (res.status === 200) {
setSubmitted(true);
} else {
alert("Failed to send email. You can send one directly to [email protected]");
}
} catch (e) {
alert("Failed to send email. You can send one directly to [email protected]");
}
};

return (
Expand All @@ -38,7 +57,7 @@ export const OfferingSection = ({ isResearch = false }) => {
<p className="font-normal text-md text-gray-500">
Got any questions about the product or contributing to our research? We're here to help!
</p>
<form className="w-full max-w-lg mt-3" onSubmit={handleSubmit}>
<div className="w-full max-w-lg mt-3">
<div className="flex flex-wrap -m-2">
<div className="w-full p-2">
<label htmlFor="name" className="block text-gray-700">
Expand All @@ -48,6 +67,8 @@ export const OfferingSection = ({ isResearch = false }) => {
type="text"
id="name"
name="name"
value={contactName}
onChange={(e) => setContactName(e.target.value)}
placeholder="Enter your name"
className="form-input mt-1 block w-full p-2.5 border-2"
/>
Expand All @@ -60,6 +81,8 @@ export const OfferingSection = ({ isResearch = false }) => {
type="email"
id="email"
name="email"
value={contactEmail}
onChange={(e) => setContactEmail(e.target.value)}
placeholder="[email protected]"
className="form-input mt-1 block w-full p-2.5 border-2"
/>
Expand All @@ -73,6 +96,8 @@ export const OfferingSection = ({ isResearch = false }) => {
name="message"
rows={4}
cols={40}
value={contactMessage}
onChange={(e) => setContacMessage(e.target.value)}
placeholder="Type your message here..."
className="form-textarea mt-1 p-2.5 block w-full border-2"
></textarea>
Expand All @@ -89,7 +114,7 @@ export const OfferingSection = ({ isResearch = false }) => {
</ButtonLink>
</div>
</div>
</form>
</div>
</>
)}
</div>
Expand Down

0 comments on commit 0942e93

Please sign in to comment.