Rename invoice-settings to company-settings, add its own Live Preview, and refine invoice PDF layout

Company data now has its own Payload admin group and a live in-browser
PDF preview (react-pdf's PDFViewer) instead of just a plain settings
form. Invoice header is a brand-colored rule instead of a filled band,
and the footer is now pinned to the page bottom instead of following
content flow.
This commit is contained in:
Marco
2026-07-22 11:11:58 +00:00
parent f144ad25f2
commit e50d43ea44
8 changed files with 261 additions and 75 deletions
+34
View File
@@ -0,0 +1,34 @@
import type { Metadata } from "next";
import { draftMode } from "next/headers";
import { getCompanySettings, type CompanySettings } from "../lib/payload";
import { LiveCompanySettingsPreviewClient } from "./components/LiveCompanySettingsPreviewClient";
export const metadata: Metadata = {
title: "Firmendaten-Vorschau",
robots: { index: false, follow: false },
};
const FALLBACK: CompanySettings = {
sellerName: "",
sellerStreet: "",
sellerZip: "",
sellerCity: "",
sellerCountry: "",
sellerEmail: "",
vatId: "",
taxRatePercent: 19,
bankDetails: null,
};
// Entered exclusively via CompanySettings.ts's admin.livePreview.url (a
// Payload-admin-only iframe target, see buildPreviewUrl()/api/preview) —
// not a page a real visitor would ever land on. Unlike email-templates
// there's no draft/published distinction here (company-settings has no
// content-versioning concept, it's just the current row) — the initial
// fetch is the same live data getCompanySettings() always returns,
// useLivePreview() takes over from there as the admin edits fields.
export default async function CompanySettingsPreviewPage() {
await draftMode();
const initialSettings = (await getCompanySettings()) ?? FALLBACK;
return <LiveCompanySettingsPreviewClient initialSettings={initialSettings} />;
}