Skip to content

Commit

Permalink
Quickfix: Sessions laden
Browse files Browse the repository at this point in the history
Server: Kontaktmail hinzugefügt für Homepage
  • Loading branch information
Simon Luthe authored and Simon Luthe committed Aug 8, 2024
1 parent da22ece commit 2d9a2fe
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 15 deletions.
88 changes: 88 additions & 0 deletions backend/contact-email-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HymnoScribe Kontaktanfrage</title>
<style>
body {
font-family: 'Jost', Arial, sans-serif;
line-height: 1.6;
color: #333333;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #f4f4f4;
}
.container {
background-color: #ffffff;
padding: 30px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.logo {
text-align: center;
margin-bottom: 20px;
}
.logo img {
max-width: 200px;
height: auto;
}
h1 {
color: #1a5f7a;
font-size: 24px;
margin-bottom: 20px;
}
.content {
background-color: #f9f9f9;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.button {
display: inline-block;
background-color: #1a5f7a;
color: #ffffff;
padding: 10px 20px;
text-decoration: none;
border-radius: 5px;
}
.button:hover {
background-color: #154c61;
}
.signature {
margin-top: 30px;
padding-top: 15px;
border-top: 1px solid #dddddd;
font-size: 14px;
color: #666666;
}
</style>
</head>
<body>
<div class="container">
<div class="logo">
<img src="[LOGO_URL]" alt="HymnoScribe Logo">
</div>

<h1>Neue Kontaktanfrage</h1>

<div class="content">
[Hauptinhalt]
</div>

<a href="[ButtonUrl]" class="button">[ButtonText]</a>

<div class="signature">
<p>
Mit freundlichen Grüßen,<br>
Ihr HymnoScribe Team
</p>
<p>
HymnoScribe - Der Liedblatt Generator<br>
© 2024 Pastor Simon Luthe. Alle Rechte vorbehalten.
</p>
</div>
</div>
</body>
</html>
35 changes: 21 additions & 14 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,27 @@ app.get('/reset-password.html', (req, res) => {
});

apiRouter.post('/contact', async (req, res) => {
const { name, email, subject, message, inquiryType } = req.body;
const { name, email, subject, message, inquiryType, institution, purpose } = req.body;

try {
const emailContent = `
Name: ${name}
E-Mail: ${email}
Anfragetyp: ${inquiryType}
Betreff: ${subject}
Nachricht: ${message}
let emailContent = `
<strong>Name:</strong> ${name}<br>
<strong>E-Mail:</strong> ${email}<br>
<strong>Anfragetyp:</strong> ${inquiryType}<br>
<strong>Betreff:</strong> ${subject}<br>
<strong>Nachricht:</strong> ${message}<br>
`;

if (inquiryType === 'usage-request') {
emailContent += `
<strong>Institution/Organisation:</strong> ${institution}<br>
<strong>Einsatzzweck:</strong> ${purpose}<br>
`;
}

await sendContactEmail(email, subject, emailContent);

res.json({ message: 'Nachricht erfolgreich gesendet' });
res.status(200).json({ message: 'Nachricht erfolgreich gesendet' });
} catch (error) {
console.error('Fehler beim Senden der Kontaktnachricht:', error);
res.status(500).json({ error: 'Interner Serverfehler beim Senden der Nachricht' });
Expand All @@ -185,14 +192,10 @@ apiRouter.post('/contact', async (req, res) => {

async function sendContactEmail(senderEmail, subject, content) {
const transporter = createTransporter();
const template = getEmailTemplate();
const template = getContactEmailTemplate(); // Neue Funktion zum Laden des Kontakt-Templates

const renderedTemplate = renderEmailTemplate(template, {
Name: 'Administrator',
Hauptinhalt: `
<p>Eine neue Kontaktanfrage wurde über das Formular gesendet:</p>
<pre>${content}</pre>
`,
Hauptinhalt: content,
ButtonText: 'Antworten',
ButtonUrl: `mailto:${senderEmail}`
});
Expand All @@ -212,6 +215,10 @@ async function sendContactEmail(senderEmail, subject, content) {
}
}

function getContactEmailTemplate() {
return fs.readFileSync(path.join(__dirname, 'contact-email-template.html'), 'utf8');
}

// Anforderung zum Zurücksetzen des Passworts
apiRouter.post('/request-password-reset', async (req, res) => {
const { email } = req.body;
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/generatePDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const QUILL_H2_MARGIN_TOP = 5;
const QUILL_H2_MARGIN_BOTTOM = 10;
const QUILL_H3_MARGIN_TOP = 5;
const QUILL_H3_MARGIN_BOTTOM = 5;
const COPYRIGHT_MARGIN_TOP = -8;
const COPYRIGHT_MARGIN_TOP = -5;
const COPYRIGHT_MARGIN_BOTTOM = -5;

// Funktion zum Skalieren der Werte basierend auf der globalen Schriftgröße
Expand Down
7 changes: 7 additions & 0 deletions frontend/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ async function initializeApp() {
await customAlert('Fehler beim Initialisieren der App: ' + error.message);
window.location.href = 'index.html';
}
document.getElementById('session-select').addEventListener('change', async (e) => {
const sessionId = e.target.value;
if (sessionId) {
await loadSession(sessionId);
e.target.value = ''; // Reset dropdown nach dem Laden
}
});
document.getElementById('vorlage-select').addEventListener('change', async (e) => {
const vorlageId = e.target.value;
if (vorlageId) {
Expand Down

0 comments on commit 2d9a2fe

Please sign in to comment.