Files
mintel.me/apps/web/src/actions/contact.ts
Marc Mintel 6864903cff
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 10s
Build & Deploy / 🧪 QA (push) Failing after 2m24s
Build & Deploy / 🏗️ Build (push) Failing after 3m40s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 3s
fix(web): remove redundant prop-types and unblock lint pipeline
2026-02-24 11:38:43 +01:00

66 lines
1.7 KiB
TypeScript

"use server";
import { sendEmail } from "../lib/mail/mailer";
import {
getInquiryEmailHtml,
getConfirmationEmailHtml,
} from "../components/ContactForm/EmailTemplates";
import { getPayload } from "payload";
import configPromise from "@payload-config";
export async function sendContactInquiry(data: {
name: string;
email: string;
companyName: string;
projectType: string;
message: string;
isFreeText: boolean;
config?: any;
}) {
try {
// 1. Save to Payload CMS (Replaces Directus)
const payload = await getPayload({ config: configPromise });
await payload.create({
collection: "inquiries",
data: {
name: data.name,
email: data.email,
companyName: data.companyName,
projectType: data.projectType,
message: data.message,
isFreeText: data.isFreeText,
config: data.config || null,
},
});
// 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",
};
}
}