Files
mintel.me/apps/web/src/actions/contact.ts
Marc Mintel 66b80117b1
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🏗️ Build (push) Failing after 7m53s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Smoke Test (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
Refactor: remove PayloadCMS, use MDX for content and TSX for design, use direct email for contact
2026-05-05 10:51:11 +02:00

53 lines
1.3 KiB
TypeScript

"use server";
import { sendEmail } from "../lib/mail/mailer";
import {
getInquiryEmailHtml,
getConfirmationEmailHtml,
} from "../components/ContactForm/EmailTemplates";
export async function sendContactInquiry(data: {
name: string;
email: string;
phone?: string;
role?: string;
companyName: string;
projectType: string;
deadline?: string;
message: string;
isFreeText: boolean;
config?: any;
}) {
try {
// Payload removed, directly send emails
// 2. Send Inquiry to Marc
const inquiryResult = await sendEmail({
subject: `[PROJEKT] ${data.isFreeText ? "DIREKTANFRAGE" : "KONFIGURATION"}: ${data.companyName || data.name}`,
html: getInquiryEmailHtml(data),
replyTo: data.email,
});
if (!inquiryResult.success) {
throw new Error(inquiryResult.error);
}
// 2. Send Confirmation to Customer
await sendEmail({
to: data.email,
subject: `Kopie deiner Anfrage: ${data.companyName || "mintel.me"}`,
html: getConfirmationEmailHtml(data),
});
return { success: true };
} catch (error) {
console.error("Server Action Error:", error);
return {
success: false,
error:
error instanceof Error
? error.message
: "Unknown error during submission",
};
}
}