Update: Bestätigungsseite
This commit is contained in:
59
index.js
59
index.js
@ -2,11 +2,12 @@ const dotenv = require("dotenv");
|
||||
dotenv.config();
|
||||
|
||||
const express = require("express");
|
||||
const bodyParser = require('body-parser');
|
||||
const bodyParser = require("body-parser");
|
||||
const cors = require("cors");
|
||||
|
||||
const nodemailer = require("nodemailer");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: "smtp-relay.brevo.com",
|
||||
@ -15,33 +16,39 @@ const transporter = nodemailer.createTransport({
|
||||
auth: {
|
||||
user: process.env.smtp_user,
|
||||
pass: process.env.smtp_pass,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
app.use(cors({
|
||||
app.use(
|
||||
cors({
|
||||
origin: process.env.origin,
|
||||
}))
|
||||
})
|
||||
);
|
||||
app.use(express.static("assets"));
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
app.post("/post", (req, res) => {
|
||||
fs.writeFile(`./data/${req.body.firstname}-${req.body.lastname}.json`, JSON.stringify(req.body), (err) => {
|
||||
console.log(err)
|
||||
})
|
||||
fs.writeFile(
|
||||
`./data/${req.body.firstname}-${req.body.lastname}.json`,
|
||||
JSON.stringify(req.body),
|
||||
(err) => {
|
||||
console.log(err);
|
||||
}
|
||||
);
|
||||
|
||||
transporter.sendMail({
|
||||
transporter.sendMail(
|
||||
{
|
||||
from: "Alumnihub <alumnihub@kocoder.xyz>",
|
||||
to: `${req.body.firstname} ${req.body.lastname} <${req.body.email}>`,
|
||||
envelope: {
|
||||
from: "alumnihub@kocoder.xyz",
|
||||
to: req.body.email,
|
||||
},
|
||||
subject: "Anmeldungs für's Absolvententreffen.",
|
||||
text:
|
||||
`
|
||||
subject: "Deine Anmeldung für's Absolvententreffen.",
|
||||
text: `
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.5;">
|
||||
@ -71,25 +78,27 @@ app.post("/post", (req, res) => {
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
}, (err, info) => {
|
||||
},
|
||||
(err, info) => {
|
||||
if (err) return res.send(err);
|
||||
}
|
||||
);
|
||||
|
||||
return res.sendFile("bestaetigung.html", {
|
||||
root: path.join(__dirname, "views"),
|
||||
});
|
||||
return res.send("Du wurdest erfolgreich angemeldet!");
|
||||
});
|
||||
|
||||
app.post("/cancel", (req, res) => {
|
||||
fs.writeFile(`./data/${req.body.firstname}-${req.body.lastname}.json`, JSON.stringify(req.body), (err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
transporter.sendMail({
|
||||
transporter.sendMail(
|
||||
{
|
||||
from: "Alumnihub <alumnihub@kocoder.xyz>",
|
||||
to: `${req.body.firstname} ${req.body.lastname} <${req.body.email}>`,
|
||||
envelope: {
|
||||
from: "alumnihub@kocoder.xyz",
|
||||
to: req.body.email,
|
||||
},
|
||||
subject: "Anmeldungs für's Absolvententreffen.",
|
||||
subject: "Deine Absage für's Absolvententreffen.",
|
||||
text: `
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
@ -111,12 +120,16 @@ app.post("/cancel", (req, res) => {
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
}, (err, info) => {
|
||||
},
|
||||
(err, info) => {
|
||||
if (err) return res.send(err);
|
||||
});
|
||||
return res.send("Du hast erfolgreich abgesagt !");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return res.sendFile("bestaetigung.html", {
|
||||
root: path.join(__dirname, "views"),
|
||||
});
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening on port ${port}`);
|
||||
|
24
views/bestaetigung.html
Normal file
24
views/bestaetigung.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Absolvententreffen 2025</title>
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<img src="logo.png" alt="HTL Ungargasse Logo" class="logo" />
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h1>Absolvententreffen</h1>
|
||||
<h2>2025</h2>
|
||||
<div class="buttons">
|
||||
Vielen Dank für das hinterlassen der Informationen zu dir und das
|
||||
Interesse am Absolventinnentreffen. Wir werden dich über folgende
|
||||
Veranstaltungen informieren.
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user