Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4256155ab7 | |||
| 244717c96d | |||
| d1381d3c86 | |||
| d4b782117f | |||
| 618f7b32d5 |
104
src/app/api/contact/route.ts
Normal file
104
src/app/api/contact/route.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export async function POST(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const { name, email, phone, message } = await request.json();
|
||||||
|
|
||||||
|
// Validate required fields
|
||||||
|
if (!name || !email || !message) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Missing required fields' },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Email validation
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
if (!emailRegex.test(email)) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Invalid email address' },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format the email content
|
||||||
|
const emailContent = `
|
||||||
|
New Contact Form Submission from Earl Boys Services Website
|
||||||
|
|
||||||
|
Name: ${name}
|
||||||
|
Email: ${email}
|
||||||
|
Phone: ${phone || 'Not provided'}
|
||||||
|
|
||||||
|
Message:
|
||||||
|
${message}
|
||||||
|
|
||||||
|
---
|
||||||
|
This message was sent from your website contact form.
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Send email notification (you'll need to configure your email service)
|
||||||
|
// This is a placeholder for your email sending logic
|
||||||
|
// You can use services like Nodemailer, SendGrid, AWS SES, etc.
|
||||||
|
|
||||||
|
// Example with a generic webhook or internal email service:
|
||||||
|
const emailResponse = await sendEmailNotification({
|
||||||
|
to: 'info@earlboysservices.com',
|
||||||
|
subject: `New Contact Form Submission from ${name}`,
|
||||||
|
text: emailContent,
|
||||||
|
replyTo: email,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!emailResponse.success) {
|
||||||
|
console.error('Email sending failed:', emailResponse.error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Failed to send message' },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return success response
|
||||||
|
return NextResponse.json(
|
||||||
|
{ message: 'Contact form submitted successfully' },
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Contact form error:', error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Internal server error' },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Email notification function - implement based on your email service
|
||||||
|
async function sendEmailNotification({
|
||||||
|
to,
|
||||||
|
subject,
|
||||||
|
text,
|
||||||
|
replyTo,
|
||||||
|
}: {
|
||||||
|
to: string;
|
||||||
|
subject: string;
|
||||||
|
text: string;
|
||||||
|
replyTo: string;
|
||||||
|
}): Promise<{ success: boolean; error?: string }> {
|
||||||
|
try {
|
||||||
|
// Placeholder for email service integration
|
||||||
|
// Configure your email service here (SendGrid, AWS SES, Nodemailer, etc.)
|
||||||
|
|
||||||
|
// Example: Using fetch to call an external email service
|
||||||
|
// const response = await fetch('YOUR_EMAIL_SERVICE_ENDPOINT', {
|
||||||
|
// method: 'POST',
|
||||||
|
// headers: { 'Content-Type': 'application/json' },
|
||||||
|
// body: JSON.stringify({ to, subject, text, replyTo }),
|
||||||
|
// });
|
||||||
|
|
||||||
|
// For now, return success (implement actual email service)
|
||||||
|
console.log(`Email notification: ${subject} to ${to}`);
|
||||||
|
|
||||||
|
return { success: true };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Email notification error:', error);
|
||||||
|
return { success: false, error: String(error) };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import FeatureCardTen from "@/components/sections/feature/FeatureCardTen";
|
|||||||
import TestimonialCardTwelve from "@/components/sections/testimonial/TestimonialCardTwelve";
|
import TestimonialCardTwelve from "@/components/sections/testimonial/TestimonialCardTwelve";
|
||||||
import FaqDouble from "@/components/sections/faq/FaqDouble";
|
import FaqDouble from "@/components/sections/faq/FaqDouble";
|
||||||
import FooterBaseReveal from "@/components/sections/footer/FooterBaseReveal";
|
import FooterBaseReveal from "@/components/sections/footer/FooterBaseReveal";
|
||||||
import { Sparkles, CheckCircle, TrendingUp, Users } from "lucide-react";
|
import { Sparkles, CheckCircle, TrendingUp, Users, Shield, Zap, Globe } from "lucide-react";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const navItems = [
|
const navItems = [
|
||||||
|
|||||||
@@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
--background: #ffffff;
|
--background: #ffffff;
|
||||||
--card: #f9f9f9;
|
--card: #f9f9f9;
|
||||||
--foreground: #120006e6;
|
--foreground: #000612e6;
|
||||||
--primary-cta: #e63946;
|
--primary-cta: #15479c;
|
||||||
--primary-cta-text: #ffffff;
|
--primary-cta-text: #ffffff;
|
||||||
--secondary-cta: #f9f9f9;
|
--secondary-cta: #f9f9f9;
|
||||||
--secondary-cta-text: #120006e6;
|
--secondary-cta-text: #000612e6;
|
||||||
--accent: #e2e2e2;
|
--accent: #e2e2e2;
|
||||||
--background-accent: #c4c4c4;
|
--background-accent: #c4c4c4;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user