59 lines
2.7 KiB
JavaScript
59 lines
2.7 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
|
|
// Sendet eine Benachrichtigungs-Mail bei neuer Demo-Anfrage
|
|
onRecordCreate((e) => {
|
|
e.next();
|
|
|
|
if (e.collection.name !== "inquiries") return;
|
|
|
|
const r = e.record;
|
|
const name = r.getString("name");
|
|
const company = r.getString("company");
|
|
const email = r.getString("email");
|
|
const phone = r.getString("phone");
|
|
const message = r.getString("message");
|
|
const plan = r.getString("plan");
|
|
|
|
const subject = `checkflo: Neue Anfrage von ${name}${company ? " (" + company + ")" : ""}`;
|
|
|
|
const html = `
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head><meta charset="utf-8"></head>
|
|
<body style="font-family:sans-serif;background:#f5f7fa;margin:0;padding:0">
|
|
<div style="max-width:560px;margin:32px auto;background:#fff;border-radius:12px;padding:32px;box-shadow:0 2px 8px rgba(0,0,0,.08)">
|
|
<div style="margin-bottom:24px">
|
|
<span style="background:#0B1023;color:#F97316;padding:6px 14px;border-radius:20px;font-size:12px;font-weight:700;letter-spacing:1px">NEUE DEMO-ANFRAGE</span>
|
|
</div>
|
|
<h2 style="color:#0B1023;margin:0 0 4px">${name}</h2>
|
|
${company ? `<p style="color:#888;margin:0 0 20px;font-size:14px">${company}</p>` : `<div style="margin-bottom:20px"></div>`}
|
|
|
|
<table style="width:100%;border-collapse:collapse;font-size:14px">
|
|
<tr><td style="padding:8px 0;color:#888;width:100px">E-Mail</td><td style="padding:8px 0;color:#0B1023"><a href="mailto:${email}" style="color:#F97316">${email}</a></td></tr>
|
|
${phone ? `<tr><td style="padding:8px 0;color:#888">Telefon</td><td style="padding:8px 0;color:#0B1023">${phone}</td></tr>` : ""}
|
|
${plan ? `<tr><td style="padding:8px 0;color:#888">Plan</td><td style="padding:8px 0;color:#0B1023;font-weight:600">${plan}</td></tr>` : ""}
|
|
${message ? `<tr><td style="padding:8px 0;color:#888;vertical-align:top">Nachricht</td><td style="padding:8px 0;color:#0B1023">${message}</td></tr>` : ""}
|
|
</table>
|
|
|
|
<div style="margin-top:28px;padding-top:20px;border-top:1px solid #eee">
|
|
<a href="https://api.checkflo.de/_/#/collections/inquiries"
|
|
style="background:#F97316;color:#fff;padding:12px 24px;border-radius:8px;text-decoration:none;font-weight:700;font-size:14px">
|
|
Alle Anfragen in PocketBase →
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>`;
|
|
|
|
try {
|
|
const message = new MailerMessage({
|
|
from: { address: "hallo@checkflo.de", name: "checkflo" },
|
|
to: [{ address: "checkflo@motocamp.de" }],
|
|
subject: subject,
|
|
html: html,
|
|
});
|
|
$app.newMailClient().send(message);
|
|
} catch (err) {
|
|
console.error("Inquiry-Mail Fehler:", err);
|
|
}
|
|
});
|