Skip to content

Commit 637440a

Browse files
committed
Updates to contact info
1 parent 113c95a commit 637440a

File tree

3 files changed

+112
-2
lines changed

3 files changed

+112
-2
lines changed

next-js-app/src/app/components/contact/ContactButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function ContactButton() {
1010
return (
1111
<>
1212
<button
13-
className="fixed bottom-4 right-4 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full shadow-lg"
13+
className="fixed bottom-4 right-4 bg-white hover:bg-gray-100 text-gray-800 font-bold py-2 px-4 rounded-full shadow-lg border border-gray-300"
1414
onClick={() => setShowForm(true)}
1515
>
1616
Contact Me
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
5+
export default function ContactFormEmbedded() {
6+
const [name, setName] = useState('');
7+
const [email, setEmail] = useState('');
8+
const [message, setMessage] = useState('');
9+
const [submitting, setSubmitting] = useState(false);
10+
const [error, setError] = useState('');
11+
const [success, setSuccess] = useState(false);
12+
13+
const handleSubmit = async (e: React.FormEvent) => {
14+
e.preventDefault();
15+
setSubmitting(true);
16+
setError('');
17+
setSuccess(false);
18+
19+
try {
20+
const response = await fetch('/api/contact', {
21+
method: 'POST',
22+
headers: {
23+
'Content-Type': 'application/json',
24+
},
25+
body: JSON.stringify({ name, email, message }),
26+
});
27+
28+
if (response.ok) {
29+
setSuccess(true);
30+
setName('');
31+
setEmail('');
32+
setMessage('');
33+
} else {
34+
const data = await response.json();
35+
setError(data.message || 'Something went wrong.');
36+
}
37+
} catch (error) {
38+
setError('Something went wrong.');
39+
} finally {
40+
setSubmitting(false);
41+
}
42+
};
43+
44+
return (
45+
<div className="bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-lg p-8 w-full max-w-md mx-auto">
46+
<h2 className="text-2xl font-bold mb-4 text-center">Contact Me</h2>
47+
{success ? (
48+
<div className="text-green-500">Your message has been sent successfully!</div>
49+
) : (
50+
<form onSubmit={handleSubmit}>
51+
<div className="mb-4">
52+
<label htmlFor="name" className="block text-sm font-medium text-gray-700 dark:text-gray-300">
53+
Name
54+
</label>
55+
<input
56+
type="text"
57+
id="name"
58+
value={name}
59+
onChange={(e) => setName(e.target.value)}
60+
className="mt-1 block w-full px-3 py-2 bg-gray-100 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
61+
required
62+
/>
63+
</div>
64+
<div className="mb-4">
65+
<label htmlFor="email" className="block text-sm font-medium text-gray-700 dark:text-ray-300">
66+
Email
67+
</label>
68+
<input
69+
type="email"
70+
id="email"
71+
value={email}
72+
onChange={(e) => setEmail(e.target.value)}
73+
className="mt-1 block w-full px-3 py-2 bg-gray-100 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
74+
required
75+
/>
76+
</div>
77+
<div className="mb-4">
78+
<label htmlFor="message" className="block text-sm font-medium text-gray-700 dark:text-gray-300">
79+
Message
80+
</label>
81+
<textarea
82+
id="message"
83+
value={message}
84+
onChange={(e) => setMessage(e.target.value)}
85+
rows={4}
86+
className="mt-1 block w-full px-3 py-2 bg-gray-100 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
87+
required
88+
></textarea>
89+
</div>
90+
{error && <div className="text-red-500 mb-4">{error}</div>}
91+
<div className="flex justify-end">
92+
<button
93+
type="submit"
94+
className="bg-white hover:bg-gray-100 text-gray-800 font-bold py-2 px-4 rounded border border-gray-300"
95+
disabled={submitting}
96+
>
97+
{submitting ? 'Submitting...' : 'Submit'}
98+
</button>
99+
</div>
100+
</form>
101+
)}
102+
</div>
103+
);
104+
}

next-js-app/src/app/home/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import { useState } from "react";
44
import Image, { StaticImageData } from "next/image";
55

6+
import ContactFormEmbedded from "../components/contact/ContactFormEmbedded";
7+
68
import headshot from "../../../public/image-assets/beaver-headshot.jpg";
79

810
import esteeLauderLogo from "../../../public/image-assets/estee_lauder_companies_logo.png";
@@ -279,7 +281,7 @@ function ExperienceCard({ experience }: { experience: Experience }) {
279281
</p>
280282
<p className="text-sm text-gray-500">{experience.period}</p>
281283
</div>
282-
<div className="w-16 h-16 bg-white rounded-lg flex items-center justify-center">
284+
<div className="w-16 h-16 bg-.white rounded-lg flex items-center justify-center">
283285
{experience.logo ? (
284286
<Image
285287
src={experience.logo}
@@ -419,6 +421,10 @@ export default function HomePage() {
419421
))}
420422
</div>
421423
</section>
424+
425+
<section id="contact" className="text-center mt-16">
426+
<ContactFormEmbedded />
427+
</section>
422428
</div>
423429
</div>
424430
);

0 commit comments

Comments
 (0)