Add a contact page with a form and essential contact details

Create a new contact page with a form that submits to an API endpoint. Register the route for this page and add a link to the footer.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: ff98bd6b-82f0-4f2d-a2ce-62874cb0f0af
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/23852c00-4779-460a-9e0c-d09fee4b6c92/koutl3W
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sebastjanartic
2026-03-06 14:04:40 +00:00
parent a1dd9a1414
commit 72e4df3fe1
5 changed files with 275 additions and 0 deletions
+28
View File
@@ -462,6 +462,34 @@ export async function registerRoutes(
}
});
app.post("/api/contact", async (req, res) => {
try {
const { name, email, subject, message } = req.body;
if (!name || !email || !message) {
return res.status(400).json({ message: "Name, E-Mail und Nachricht sind erforderlich." });
}
const contactPath = path.join(process.cwd(), "server/contact-messages.json");
let messages: any[] = [];
if (fs.existsSync(contactPath)) {
messages = JSON.parse(fs.readFileSync(contactPath, "utf-8"));
}
messages.push({
id: Date.now(),
name,
email,
subject: subject || "Keine Angabe",
message,
createdAt: new Date().toISOString(),
read: false,
});
fs.writeFileSync(contactPath, JSON.stringify(messages, null, 2));
console.log(`[contact] New message from ${name} <${email}>: ${subject || "No subject"}`);
res.json({ ok: true });
} catch (err: any) {
res.status(500).json({ message: err.message });
}
});
app.get("/api/gallery/artists", (_req, res) => {
try {
const aPath = path.join(process.cwd(), "server/gallery-artist-overrides.json");