fix(admin): persist data directory and pass env vars
This commit is contained in:
parent
99e8201745
commit
1d7e7c41c9
39 changed files with 1297 additions and 32 deletions
28
app/admin/einstellungen/page.tsx
Normal file
28
app/admin/einstellungen/page.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { getSiteSettings } from "@/lib/admin/store";
|
||||
|
||||
export default async function AdminSettingsPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
const settings = await getSiteSettings();
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Konfiguration</p>
|
||||
<h1>Firmeneinstellungen</h1>
|
||||
</div>
|
||||
<form className="admin-card admin-form" action="/api/admin/settings" method="post">
|
||||
<label>Firmenname<input name="companyName" defaultValue={settings.companyName} /></label>
|
||||
<label>Telefon<input name="phone" defaultValue={settings.phone} /></label>
|
||||
<label>E-Mail<input name="email" type="email" defaultValue={settings.email} /></label>
|
||||
<label>Adresse<input name="address" defaultValue={settings.address} /></label>
|
||||
<label>Öffnungszeiten<input name="openingHours" defaultValue={settings.openingHours} /></label>
|
||||
<label>Google Maps Embed URL<input name="googleMapsEmbedUrl" defaultValue={settings.googleMapsEmbedUrl} /></label>
|
||||
<label>Social Links<textarea name="socialLinks" defaultValue={settings.socialLinks} /></label>
|
||||
<button className="button" type="submit">Speichern</button>
|
||||
</form>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
48
app/admin/kontaktanfragen/page.tsx
Normal file
48
app/admin/kontaktanfragen/page.tsx
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import StatusSelect from "@/components/admin/StatusSelect";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { getContactInquiries } from "@/lib/admin/store";
|
||||
|
||||
export default async function AdminContactsPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
const inquiries = await getContactInquiries();
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Anfragen</p>
|
||||
<h1>Kontaktanfragen</h1>
|
||||
</div>
|
||||
<section className="admin-card">
|
||||
<table className="admin-table">
|
||||
<thead><tr><th>Name</th><th>E-Mail</th><th>Betreff</th><th>Datum</th><th>Status</th></tr></thead>
|
||||
<tbody>
|
||||
{inquiries.map((item) => (
|
||||
<tr key={item.id}>
|
||||
<td>{item.name}</td>
|
||||
<td><a href={`mailto:${item.email}`}>{item.email}</a></td>
|
||||
<td>{item.subject}</td>
|
||||
<td>{new Date(item.createdAt).toLocaleString("de-DE")}</td>
|
||||
<td><StatusSelect id={item.id} type="contact" status={item.status} /></td>
|
||||
</tr>
|
||||
))}
|
||||
{inquiries.length === 0 && <tr><td colSpan={5}>Noch keine Kontaktanfragen vorhanden.</td></tr>}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section className="admin-card">
|
||||
<h2>Detailansicht</h2>
|
||||
<div className="admin-detail-grid">
|
||||
{inquiries.slice(0, 6).map((item) => (
|
||||
<article key={item.id} className="admin-detail">
|
||||
<h3>{item.name}</h3>
|
||||
<p><strong>{item.subject}</strong></p>
|
||||
<p>{item.message}</p>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
5
app/admin/layout.tsx
Normal file
5
app/admin/layout.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import type { ReactNode } from "react";
|
||||
|
||||
export default function AdminRootLayout({ children }: { children: ReactNode }) {
|
||||
return children;
|
||||
}
|
||||
13
app/admin/login/page.tsx
Normal file
13
app/admin/login/page.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import type { Metadata } from "next";
|
||||
import AdminLoginForm from "@/components/admin/AdminLoginForm";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Admin Login | Funktechnik Schubert",
|
||||
robots: { index: false, follow: false },
|
||||
};
|
||||
|
||||
export default async function AdminLoginPage({ searchParams }: { searchParams: Promise<{ next?: string }> }) {
|
||||
const params = await searchParams;
|
||||
const nextPath = params.next?.startsWith("/admin") ? params.next : "/admin";
|
||||
return <AdminLoginForm nextPath={nextPath} />;
|
||||
}
|
||||
47
app/admin/medien/page.tsx
Normal file
47
app/admin/medien/page.tsx
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { mkdir, readdir } from "fs/promises";
|
||||
import path from "path";
|
||||
import Image from "next/image";
|
||||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
|
||||
const uploadDir = path.join(process.cwd(), "public", "uploads", "images");
|
||||
|
||||
async function getFiles() {
|
||||
await mkdir(uploadDir, { recursive: true });
|
||||
return readdir(uploadDir);
|
||||
}
|
||||
|
||||
export default async function AdminMediaPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
const files = await getFiles();
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Assets</p>
|
||||
<h1>Medienverwaltung</h1>
|
||||
</div>
|
||||
<form className="admin-card admin-upload" action="/api/admin/media" method="post" encType="multipart/form-data">
|
||||
<label>Datei hochladen<input name="file" type="file" accept="image/jpeg,image/png,image/webp,application/pdf" /></label>
|
||||
<button className="button" type="submit">Datei hochladen</button>
|
||||
</form>
|
||||
<section className="admin-card">
|
||||
<h2>Uploads</h2>
|
||||
<div className="media-grid">
|
||||
{files.map((file) => {
|
||||
const url = `/uploads/images/${file}`;
|
||||
return (
|
||||
<a key={file} className="media-item" href={url} target="_blank" rel="noreferrer">
|
||||
{/\.(png|jpe?g|webp)$/i.test(file)
|
||||
? <Image src={url} alt={file} width={320} height={220} />
|
||||
: <span>{file}</span>}
|
||||
</a>
|
||||
);
|
||||
})}
|
||||
{files.length === 0 && <p className="admin-muted">Noch keine Uploads vorhanden.</p>}
|
||||
</div>
|
||||
</section>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
46
app/admin/page.tsx
Normal file
46
app/admin/page.tsx
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { getContactInquiries, getRepairInquiries } from "@/lib/admin/store";
|
||||
|
||||
function countNew<T extends { status: string }>(items: T[]) {
|
||||
return items.filter((item) => item.status === "new").length;
|
||||
}
|
||||
|
||||
export default async function AdminDashboardPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
const [contacts, repairs] = await Promise.all([getContactInquiries(), getRepairInquiries()]);
|
||||
const latest = [...contacts, ...repairs].sort((a, b) => b.createdAt.localeCompare(a.createdAt)).slice(0, 6);
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Administration</p>
|
||||
<h1>Dashboard</h1>
|
||||
</div>
|
||||
<div className="admin-kpis">
|
||||
<div className="admin-kpi"><span>Kontaktanfragen</span><strong>{countNew(contacts)}</strong><small>neu</small></div>
|
||||
<div className="admin-kpi"><span>Reparaturanfragen</span><strong>{countNew(repairs)}</strong><small>neu</small></div>
|
||||
<div className="admin-kpi"><span>Website</span><strong>Online</strong><small>OK</small></div>
|
||||
<div className="admin-kpi"><span>SMTP</span><strong>Vorbereitet</strong><small>nicht aktiv</small></div>
|
||||
</div>
|
||||
<section className="admin-card">
|
||||
<h2>Letzte Anfragen</h2>
|
||||
<table className="admin-table">
|
||||
<thead><tr><th>Datum</th><th>Name</th><th>Typ</th><th>Status</th></tr></thead>
|
||||
<tbody>
|
||||
{latest.map((item) => (
|
||||
<tr key={item.id}>
|
||||
<td>{new Date(item.createdAt).toLocaleDateString("de-DE")}</td>
|
||||
<td>{item.name}</td>
|
||||
<td>{"manufacturer" in item ? "Reparatur" : "Kontakt"}</td>
|
||||
<td><span className={`status ${item.status}`}>{item.status}</span></td>
|
||||
</tr>
|
||||
))}
|
||||
{latest.length === 0 && <tr><td colSpan={4}>Noch keine Anfragen vorhanden.</td></tr>}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
51
app/admin/reparaturanfragen/page.tsx
Normal file
51
app/admin/reparaturanfragen/page.tsx
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import StatusSelect from "@/components/admin/StatusSelect";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { getRepairInquiries } from "@/lib/admin/store";
|
||||
|
||||
export default async function AdminRepairsPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
const inquiries = await getRepairInquiries();
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Anfragen</p>
|
||||
<h1>Reparaturanfragen</h1>
|
||||
</div>
|
||||
<section className="admin-card">
|
||||
<table className="admin-table">
|
||||
<thead><tr><th>Datum</th><th>Name</th><th>Gerät</th><th>Hersteller</th><th>Modell</th><th>Status</th></tr></thead>
|
||||
<tbody>
|
||||
{inquiries.map((item) => (
|
||||
<tr key={item.id}>
|
||||
<td>{new Date(item.createdAt).toLocaleDateString("de-DE")}</td>
|
||||
<td>{item.name}</td>
|
||||
<td>{item.deviceType}</td>
|
||||
<td>{item.manufacturer}</td>
|
||||
<td>{item.model}</td>
|
||||
<td><StatusSelect id={item.id} type="repair" status={item.status} /></td>
|
||||
</tr>
|
||||
))}
|
||||
{inquiries.length === 0 && <tr><td colSpan={6}>Noch keine Reparaturanfragen vorhanden.</td></tr>}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section className="admin-card">
|
||||
<h2>Technische Details</h2>
|
||||
<div className="admin-detail-grid">
|
||||
{inquiries.slice(0, 6).map((item) => (
|
||||
<article key={item.id} className="admin-detail">
|
||||
<h3>{item.manufacturer} {item.model}</h3>
|
||||
<p><strong>Fehler:</strong> {item.description}</p>
|
||||
<p><strong>Zubehör:</strong> {item.accessories || "nicht angegeben"}</p>
|
||||
<p><strong>Vorarbeiten:</strong> {item.previousWork || "nicht angegeben"}</p>
|
||||
<button className="button light" type="button" disabled>In Olympus übernehmen</button>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
24
app/admin/seo/page.tsx
Normal file
24
app/admin/seo/page.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { defaultTitle, siteName, siteUrl } from "@/app/seo";
|
||||
|
||||
export default async function AdminSeoPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Sichtbarkeit</p>
|
||||
<h1>SEO Verwaltung</h1>
|
||||
</div>
|
||||
<section className="admin-card admin-form">
|
||||
<label>Seitentitel<input readOnly value={defaultTitle} /></label>
|
||||
<label>Site Name<input readOnly value={siteName} /></label>
|
||||
<label>Basis-URL<input readOnly value={siteUrl} /></label>
|
||||
<label>Meta Description<textarea readOnly value="Service, Reparatur, Diagnose und Abgleich von Funktechnik, CB-Funk, Amateurfunk und Kommunikationstechnik." /></label>
|
||||
<p className="admin-muted">Live-Bearbeitung pro Seite ist vorbereitet und wird in einer späteren Publishing-Ausbaustufe aktiviert.</p>
|
||||
</section>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
28
app/admin/smtp/page.tsx
Normal file
28
app/admin/smtp/page.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { getSmtpSettings } from "@/lib/admin/store";
|
||||
|
||||
export default async function AdminSmtpPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
const settings = await getSmtpSettings();
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">E-Mail</p>
|
||||
<h1>SMTP Einstellungen</h1>
|
||||
</div>
|
||||
<form className="admin-card admin-form" action="/api/admin/smtp" method="post">
|
||||
<label>SMTP Server<input name="host" defaultValue={settings.host} /></label>
|
||||
<label>Port<input name="port" defaultValue={settings.port} inputMode="numeric" /></label>
|
||||
<label>Benutzername<input name="username" defaultValue={settings.username} /></label>
|
||||
<label>Passwort<input name="password" type="password" placeholder="wird in dieser Foundation noch nicht gespeichert" disabled /></label>
|
||||
<label>Absenderadresse<input name="fromAddress" type="email" defaultValue={settings.fromAddress} /></label>
|
||||
<label>Antwortadresse<input name="replyToAddress" type="email" defaultValue={settings.replyToAddress} /></label>
|
||||
<label className="admin-checkbox"><input name="tls" type="checkbox" defaultChecked={settings.tls} /> TLS aktivieren</label>
|
||||
<button className="button" type="submit">Speichern</button>
|
||||
</form>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
36
app/admin/system/page.tsx
Normal file
36
app/admin/system/page.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
|
||||
export default async function AdminSystemPage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Betrieb</p>
|
||||
<h1>System</h1>
|
||||
</div>
|
||||
<div className="admin-detail-grid">
|
||||
<section className="admin-card">
|
||||
<h2>Technik</h2>
|
||||
<ul className="list">
|
||||
<li>Next.js 16 App Router</li>
|
||||
<li>TypeScript strict</li>
|
||||
<li>HttpOnly Admin-Session</li>
|
||||
<li>Lokale Foundation-Datenablage in JSON-Dateien</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section className="admin-card">
|
||||
<h2>Vorbereitet</h2>
|
||||
<ul className="list">
|
||||
<li>Olympus-Integration bleibt deaktiviert</li>
|
||||
<li>SMTP-Konfiguration ohne Versandlogik</li>
|
||||
<li>Medien-Upload mit Dateityp- und Größenprüfung</li>
|
||||
<li>SEO- und Inhaltsverwaltung als Admin-Grundlage</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
38
app/admin/website/page.tsx
Normal file
38
app/admin/website/page.tsx
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import AdminShell from "@/components/admin/AdminShell";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
|
||||
const editablePages = [
|
||||
["Startseite", "Hero, Vorteile, Textblöcke"],
|
||||
["Leistungen", "Funktechnik, Messtechnik, Servicebereiche"],
|
||||
["Funkgeräte-Service", "Diagnose, Abgleich, Fehlerbilder"],
|
||||
["Reparatur", "Reparaturannahme und Hinweise"],
|
||||
["Über uns", "Profil und Werkstattbeschreibung"],
|
||||
["Kontakt", "Kontakttext und Hinweise"],
|
||||
] as const;
|
||||
|
||||
export default async function AdminWebsitePage() {
|
||||
if (!await requireAdminSession()) redirect("/admin/login");
|
||||
|
||||
return (
|
||||
<AdminShell>
|
||||
<div className="admin-page-head">
|
||||
<p className="eyebrow">Website</p>
|
||||
<h1>Website-Inhalte</h1>
|
||||
</div>
|
||||
<section className="admin-card">
|
||||
<h2>Editierbare Inhalte</h2>
|
||||
<p className="admin-muted">Diese Foundation bereitet die Inhaltsverwaltung vor. Die öffentliche Website bleibt bis zur finalen Publishing-Funktion weiterhin quellcodebasiert.</p>
|
||||
<div className="admin-detail-grid">
|
||||
{editablePages.map(([title, description]) => (
|
||||
<article key={title} className="admin-detail">
|
||||
<h3>{title}</h3>
|
||||
<p>{description}</p>
|
||||
<button className="button light" type="button" disabled>Bearbeiten vorbereitet</button>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</AdminShell>
|
||||
);
|
||||
}
|
||||
19
app/api/admin/contact/[id]/route.ts
Normal file
19
app/api/admin/contact/[id]/route.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { updateContactStatus } from "@/lib/admin/store";
|
||||
import type { InquiryStatus } from "@/lib/admin/types";
|
||||
|
||||
const statuses: InquiryStatus[] = ["new", "in_progress", "done"];
|
||||
|
||||
export async function PATCH(request: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
|
||||
|
||||
const body = await request.json() as { status?: InquiryStatus };
|
||||
if (!body.status || !statuses.includes(body.status)) {
|
||||
return NextResponse.json({ message: "Ungültiger Status." }, { status: 400 });
|
||||
}
|
||||
|
||||
const { id } = await params;
|
||||
await updateContactStatus(id, body.status);
|
||||
return NextResponse.json({ message: "Status aktualisiert." });
|
||||
}
|
||||
16
app/api/admin/login/route.ts
Normal file
16
app/api/admin/login/route.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { adminCookieOptions, adminSessionCookie, createAdminSession, validateAdminCredentials } from "@/lib/admin/auth";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const form = await request.formData();
|
||||
const email = String(form.get("email") ?? "");
|
||||
const password = String(form.get("password") ?? "");
|
||||
|
||||
if (!validateAdminCredentials(email, password)) {
|
||||
return NextResponse.json({ message: "Ungültige Zugangsdaten." }, { status: 401 });
|
||||
}
|
||||
|
||||
const response = NextResponse.json({ message: "Anmeldung erfolgreich." });
|
||||
response.cookies.set(adminSessionCookie, createAdminSession(), adminCookieOptions());
|
||||
return response;
|
||||
}
|
||||
8
app/api/admin/logout/route.ts
Normal file
8
app/api/admin/logout/route.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { adminSessionCookie } from "@/lib/admin/auth";
|
||||
|
||||
export async function POST() {
|
||||
const response = NextResponse.json({ message: "Abgemeldet." });
|
||||
response.cookies.set(adminSessionCookie, "", { path: "/", maxAge: 0 });
|
||||
return response;
|
||||
}
|
||||
38
app/api/admin/media/route.ts
Normal file
38
app/api/admin/media/route.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { mkdir, readdir, writeFile } from "fs/promises";
|
||||
import path from "path";
|
||||
import { NextResponse } from "next/server";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
|
||||
const uploadDir = path.join(process.cwd(), "public", "uploads", "images");
|
||||
const allowedTypes = new Set(["image/jpeg", "image/png", "image/webp", "application/pdf"]);
|
||||
|
||||
async function ensureUploadDir() {
|
||||
await mkdir(uploadDir, { recursive: true });
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
|
||||
await ensureUploadDir();
|
||||
const files = await readdir(uploadDir);
|
||||
return NextResponse.json({
|
||||
files: files.map((file) => ({ name: file, url: `/uploads/images/${file}` })),
|
||||
});
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
|
||||
await ensureUploadDir();
|
||||
const form = await request.formData();
|
||||
const file = form.get("file");
|
||||
|
||||
if (!(file instanceof File) || !allowedTypes.has(file.type) || file.size > 5 * 1024 * 1024) {
|
||||
return NextResponse.json({ message: "Bitte eine JPG-, PNG-, WebP- oder PDF-Datei bis 5 MB hochladen." }, { status: 400 });
|
||||
}
|
||||
|
||||
const extension = path.extname(file.name).toLowerCase();
|
||||
const safeName = `${Date.now()}-${file.name.toLowerCase().replace(/[^a-z0-9.-]/g, "-")}`;
|
||||
const target = safeName.endsWith(extension) ? safeName : `${safeName}${extension}`;
|
||||
await writeFile(path.join(uploadDir, target), Buffer.from(await file.arrayBuffer()));
|
||||
|
||||
return NextResponse.redirect(new URL("/admin/medien?uploaded=1", request.url));
|
||||
}
|
||||
19
app/api/admin/repair/[id]/route.ts
Normal file
19
app/api/admin/repair/[id]/route.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { updateRepairStatus } from "@/lib/admin/store";
|
||||
import type { InquiryStatus } from "@/lib/admin/types";
|
||||
|
||||
const statuses: InquiryStatus[] = ["new", "in_progress", "done"];
|
||||
|
||||
export async function PATCH(request: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
|
||||
|
||||
const body = await request.json() as { status?: InquiryStatus };
|
||||
if (!body.status || !statuses.includes(body.status)) {
|
||||
return NextResponse.json({ message: "Ungültiger Status." }, { status: 400 });
|
||||
}
|
||||
|
||||
const { id } = await params;
|
||||
await updateRepairStatus(id, body.status);
|
||||
return NextResponse.json({ message: "Status aktualisiert." });
|
||||
}
|
||||
9
app/api/admin/settings/route.ts
Normal file
9
app/api/admin/settings/route.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { saveSiteSettings } from "@/lib/admin/store";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
|
||||
await saveSiteSettings(await request.formData());
|
||||
return NextResponse.redirect(new URL("/admin/einstellungen?saved=1", request.url));
|
||||
}
|
||||
9
app/api/admin/smtp/route.ts
Normal file
9
app/api/admin/smtp/route.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { requireAdminSession } from "@/lib/admin/auth";
|
||||
import { saveSmtpSettings } from "@/lib/admin/store";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
|
||||
await saveSmtpSettings(await request.formData());
|
||||
return NextResponse.redirect(new URL("/admin/smtp?saved=1", request.url));
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { addContactInquiry } from "@/lib/admin/store";
|
||||
|
||||
function text(value: FormDataEntryValue | null) {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
|
|
@ -8,16 +9,14 @@ export async function POST(request: Request) {
|
|||
const form = await request.formData();
|
||||
const name = text(form.get("name"));
|
||||
const email = text(form.get("email"));
|
||||
const subject = text(form.get("subject"));
|
||||
const message = text(form.get("message"));
|
||||
|
||||
if (!name || !email.includes("@") || message.length < 10 || form.get("privacy") !== "on") {
|
||||
if (!name || !email.includes("@") || !subject || message.length < 10 || form.get("privacy") !== "on") {
|
||||
return NextResponse.json({ message: "Bitte füllen Sie alle Pflichtfelder aus." }, { status: 400 });
|
||||
}
|
||||
|
||||
console.info("contact_request.received", {
|
||||
messageLength: message.length,
|
||||
hasEmail: true,
|
||||
});
|
||||
await addContactInquiry(form);
|
||||
|
||||
return NextResponse.json({
|
||||
message: "Ihre Nachricht wurde erfasst. Sie erhalten eine Rückmeldung.",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { addRepairInquiry } from "@/lib/admin/store";
|
||||
|
||||
function required(value: FormDataEntryValue | null) {
|
||||
return typeof value === "string" && value.trim().length > 0;
|
||||
|
|
@ -18,18 +19,7 @@ export async function POST(request: Request) {
|
|||
return NextResponse.json({ message: "Bitte füllen Sie alle Pflichtfelder aus." }, { status: 400 });
|
||||
}
|
||||
|
||||
const intakeUrl = process.env.OLYMPUS_INTAKE_API_URL;
|
||||
const hasIntegrationToken = Boolean(process.env.OLYMPUS_INTAKE_API_TOKEN);
|
||||
|
||||
console.info("repair_intake.received", {
|
||||
hasIntakeIntegration: Boolean(intakeUrl && hasIntegrationToken),
|
||||
manufacturer: String(manufacturer),
|
||||
model: String(model),
|
||||
deviceType: String(deviceType),
|
||||
hasPhone: required(form.get("phone")),
|
||||
hasSerialNumber: required(form.get("serialNumber")),
|
||||
hasAccessories: required(form.get("accessories")),
|
||||
});
|
||||
await addRepairInquiry(form);
|
||||
|
||||
return NextResponse.json({
|
||||
message: "Ihre Reparaturanfrage wurde erfasst. Sie erhalten nach Prüfung eine Rückmeldung.",
|
||||
|
|
|
|||
296
app/globals.css
296
app/globals.css
|
|
@ -461,6 +461,283 @@ h3 {
|
|||
font-size: 26px;
|
||||
}
|
||||
|
||||
.admin-login-page {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background:
|
||||
linear-gradient(90deg, rgba(6, 24, 52, 0.94), rgba(8, 42, 96, 0.76)),
|
||||
url("/admin-workbench-bg.png"),
|
||||
#07172d;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.admin-login-card {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
width: min(420px, calc(100% - 32px));
|
||||
border: 1px solid rgba(255, 255, 255, 0.16);
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
padding: 28px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.admin-login-card img {
|
||||
width: 230px;
|
||||
height: 64px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.admin-login-card h1 {
|
||||
margin-bottom: 4px;
|
||||
color: var(--ink);
|
||||
font-size: 24px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.admin-login-card label,
|
||||
.admin-form label,
|
||||
.admin-upload label {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
color: var(--ink);
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.admin-login-card input,
|
||||
.admin-form input,
|
||||
.admin-form textarea,
|
||||
.admin-upload input {
|
||||
width: 100%;
|
||||
border: 1px solid #cfd8e5;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
padding: 11px 12px;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.admin-shell {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: 248px minmax(0, 1fr);
|
||||
background: #eef2f6;
|
||||
}
|
||||
|
||||
.admin-sidebar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
height: 100vh;
|
||||
border-right: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: #071c3d;
|
||||
color: #fff;
|
||||
padding: 18px 14px;
|
||||
}
|
||||
|
||||
.admin-logo {
|
||||
display: block;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.admin-logo img {
|
||||
width: 190px;
|
||||
height: 54px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.admin-nav {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.admin-nav a,
|
||||
.admin-logout {
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
font: inherit;
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.admin-nav a:hover,
|
||||
.admin-nav a[aria-current="page"],
|
||||
.admin-logout:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.admin-logout {
|
||||
width: 100%;
|
||||
margin-top: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.admin-main {
|
||||
min-width: 0;
|
||||
padding: 28px;
|
||||
}
|
||||
|
||||
.admin-page-head {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.admin-page-head h1 {
|
||||
margin-bottom: 0;
|
||||
color: var(--ink);
|
||||
font-size: 34px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.admin-kpis {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.admin-kpi,
|
||||
.admin-card,
|
||||
.admin-detail {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
box-shadow: 0 10px 28px rgba(8, 42, 96, 0.06);
|
||||
}
|
||||
|
||||
.admin-kpi {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.admin-kpi span,
|
||||
.admin-kpi small,
|
||||
.admin-muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.admin-kpi strong {
|
||||
color: var(--navy);
|
||||
font-size: 28px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.admin-card {
|
||||
margin-bottom: 18px;
|
||||
padding: 20px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.admin-card h2 {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.admin-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
min-width: 760px;
|
||||
}
|
||||
|
||||
.admin-table th,
|
||||
.admin-table td {
|
||||
border-bottom: 1px solid var(--line);
|
||||
padding: 12px 10px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.admin-table th {
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.status,
|
||||
.status-select {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: #f8fafc;
|
||||
color: var(--navy);
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
padding: 6px 9px;
|
||||
}
|
||||
|
||||
.status.new {
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.status.in_progress {
|
||||
color: #0b63a7;
|
||||
}
|
||||
|
||||
.status.done {
|
||||
color: #157347;
|
||||
}
|
||||
|
||||
.admin-detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.admin-detail {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.admin-detail p {
|
||||
color: var(--muted);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.admin-form {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
max-width: 880px;
|
||||
}
|
||||
|
||||
.admin-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.admin-checkbox input {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.admin-upload {
|
||||
display: flex;
|
||||
align-items: end;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.media-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.media-item {
|
||||
display: grid;
|
||||
min-height: 130px;
|
||||
place-items: center;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.media-item img {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) and (min-width: 861px) {
|
||||
.brand-logo {
|
||||
width: 236px;
|
||||
|
|
@ -540,7 +817,24 @@ h3 {
|
|||
.grid.two,
|
||||
.service-grid,
|
||||
.split,
|
||||
.footer-grid {
|
||||
.footer-grid,
|
||||
.admin-shell,
|
||||
.admin-kpis,
|
||||
.admin-detail-grid,
|
||||
.media-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.admin-sidebar {
|
||||
position: static;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.admin-main {
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.admin-upload {
|
||||
display: grid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type { Metadata } from "next";
|
||||
import Header from "@/components/Header";
|
||||
import Footer from "@/components/Footer";
|
||||
import SiteFrame from "@/components/SiteFrame";
|
||||
import "./globals.css";
|
||||
import { createMetadata } from "./seo";
|
||||
|
||||
|
|
@ -13,9 +12,7 @@ export default function RootLayout({ children }: Readonly<{ children: React.Reac
|
|||
return (
|
||||
<html lang="de">
|
||||
<body>
|
||||
<Header />
|
||||
<main>{children}</main>
|
||||
<Footer />
|
||||
<SiteFrame>{children}</SiteFrame>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue