added contact form

This commit is contained in:
2026-08-23 16:15:26 -07:00
parent 1bf1b7c797
commit 9544814031
6 changed files with 288 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ const projects = [
</div>
</div>
<a href="/contact" class="nav-link">Contact</a>
<a href="/about" class="nav-link">About</a>
</nav>
</div>

View File

@@ -10,7 +10,7 @@ import noelleImage2 from '../assets/images/brand-package/noelle-paris2.jpg';
<Layout title="About Noelle | Noelle Paris Design">
<main class="about-container">
<header class="about-header">
<h1>About Noelle</h1>
<h1>Noelle Paris, MA, Realtor<sup>®</sup></h1>
<p class="subtitle">Design for Well-Being, Inside & Out</p>
</header>

View File

@@ -0,0 +1,39 @@
import type { APIRoute } from 'astro';
import { Resend } from 'resend';
const resend = new Resend(import.meta.env.RESEND_API_KEY);
export const POST: APIRoute = async ({ request }) => {
try {
const data = await request.json();
const { name, email, phone, message } = data;
if (!name || !email || !message) {
return new Response(
JSON.stringify({ message: 'Missing required fields' }),
{ status: 400, headers: { 'Content-Type': 'application/json' } }
);
}
// Send email via Resend
await resend.emails.send({
from: 'Noelle Paris Design Contact Form <contactform@noelleparisdesign.com>', // Update to your domain once verified in Resend
//to: 'github@juchatz.com',
to: 'inquiries@noelleparisdesign.com',
replyTo: email,
subject: `New Inquiry from ${name}`,
text: `Name: ${name}\nEmail: ${email}\nPhone: ${phone || 'N/A'}\n\nMessage:\n${message}`,
});
return new Response(
JSON.stringify({ message: 'Message sent successfully' }),
{ status: 200, headers: { 'Content-Type': 'application/json' } }
);
} catch (error) {
console.error('Email error:', error);
return new Response(
JSON.stringify({ message: 'Error sending email' }),
{ status: 500, headers: { 'Content-Type': 'application/json' } }
);
}
};

194
src/pages/contact.astro Normal file
View File

@@ -0,0 +1,194 @@
---
import Layout from '../layouts/Layout.astro';
---
<Layout title="Contact | Noelle Paris Design">
<main class="contact-container">
<header class="contact-header">
<h1>Contact</h1>
<p class="subtitle">Let's discuss your project</p>
</header>
<div class="form-wrapper">
<form id="contact-form" method="POST">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" required placeholder="Your full name" />
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" required placeholder="your.email@example.com" />
</div>
<div class="form-group">
<label for="phone">Phone (Optional)</label>
<input type="tel" id="phone" name="phone" placeholder="(555) 000-0000" />
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea id="message" name="message" rows="6" required placeholder="Tell us about your project or inquiry..."></textarea>
</div>
<button type="submit" id="submit-btn" class="submit-button">Send Message</button>
<p id="form-status" class="status-message"></p>
</form>
</div>
</main>
</Layout>
<script>
const form = document.getElementById('contact-form') as HTMLFormElement;
const statusMsg = document.getElementById('form-status') as HTMLParagraphElement;
const submitBtn = document.getElementById('submit-btn') as HTMLButtonElement;
form?.addEventListener('submit', async (e) => {
e.preventDefault();
submitBtn.disabled = true;
submitBtn.textContent = 'Sending...';
statusMsg.textContent = '';
statusMsg.className = 'status-message';
const formData = new FormData(form);
const data = Object.fromEntries(formData.entries());
try {
const response = await fetch('/api/send-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
if (response.ok) {
statusMsg.textContent = 'Thank you! Your message has been sent successfully.';
statusMsg.classList.add('success');
form.reset();
} else {
statusMsg.textContent = 'Something went wrong. Please try again later.';
statusMsg.classList.add('error');
}
} catch (err) {
statusMsg.textContent = 'Network error. Please check your connection and try again.';
statusMsg.classList.add('error');
} finally {
submitBtn.disabled = false;
submitBtn.textContent = 'Send Message';
}
});
</script>
<style>
.contact-container {
max-width: 600px;
margin: 0 auto;
padding: 4rem 1.5rem;
color: #2b2b2b;
}
.contact-header {
text-align: center;
margin-bottom: 3rem;
}
.contact-header h1 {
font-size: 2.5rem;
font-weight: 300;
margin-bottom: 0.5rem;
letter-spacing: -0.01em;
}
.subtitle {
font-size: 0.95rem;
color: #666;
text-transform: uppercase;
letter-spacing: 0.15em;
}
.form-wrapper {
background: rgba(255, 255, 255, 0.4);
padding: 2.5rem;
border-radius: 4px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
border: 1px solid rgba(0, 0, 0, 0.05);
}
.form-group {
margin-bottom: 1.75rem;
display: flex;
flex-direction: column;
}
label {
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.1em;
color: #444;
margin-bottom: 0.5rem;
}
input, textarea {
width: 100%;
padding: 0.85rem 1rem;
border: 1px solid #dcd8d0;
background-color: #faf8f5;
border-radius: 2px;
font-size: 1rem;
color: #222;
transition: border-color 0.2s ease, background-color 0.2s ease;
}
input:focus, textarea:focus {
outline: none;
border-color: #444;
background-color: #ffffff;
}
.submit-button {
width: 100%;
padding: 1rem;
background-color: #222;
color: #fff;
border: none;
border-radius: 2px;
font-size: 0.9rem;
text-transform: uppercase;
letter-spacing: 0.12em;
cursor: pointer;
transition: background-color 0.2s ease;
}
.submit-button:hover {
background-color: #444;
}
.submit-button:disabled {
background-color: #888;
cursor: not-allowed;
}
.status-message {
margin-top: 1.5rem;
text-align: center;
font-size: 0.95rem;
}
.status-message.success {
color: #2e7d32;
}
.status-message.error {
color: #c62828;
}
@media (max-width: 600px) {
.contact-container {
padding: 2.5rem 1.25rem;
}
.form-wrapper {
padding: 1.5rem;
}
}
</style>