Files
einfach-produktiv/app/company-settings-preview/page.tsx
T
Marco a3912a47c4 Model Stammkapital/Grundkapital and Gesellschafter for the not-yet-needed legal forms
Mirrors the backend's new CompanySettings.shareCapital/generalPartners fields: rendered in the Impressum (AnbieterAngaben.tsx — new "Gesellschafter" section, Stammkapital line under Handelsregister, and the "Verantwortlich für den Inhalt" fallback now considers a general partner before falling back to sellerName) and wired into buildLegalFooterLines() for the invoice/email footer, same as registerCourt/registerNumber/managingDirector already were.

No visible change today (current legalForm is sole-proprietorship, neither field is set) — this is prep so a future legalForm change in company-settings updates the Impressum automatically instead of needing a manual Impressum edit at that point.
2026-07-23 13:26:33 +00:00

48 lines
1.8 KiB
TypeScript

import type { Metadata } from "next";
import { draftMode } from "next/headers";
import { notFound } from "next/navigation";
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: "",
legalForm: "sole-proprietorship",
registerCourt: null,
registerNumber: null,
managingDirector: null,
shareCapital: null,
generalPartners: null,
sellerStreet: "",
sellerZip: "",
sellerCity: "",
sellerCountry: "",
sellerEmail: "",
vatId: "",
taxRatePercent: 19,
iban: null,
bic: null,
};
// Entered exclusively via CompanySettings.ts's admin.livePreview.url (a
// Payload-admin-only iframe target, see buildPreviewUrl()/api/preview) —
// gated on Draft Mode actually being enabled, unlike email-templates'
// preview: this data includes a real bank IBAN/address once filled in,
// not just marketing email copy, so this page must not render for an
// unauthenticated visitor who happens to find the URL. Unlike
// email-templates there's no draft/published distinction in the data
// itself (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() {
const draft = await draftMode();
if (!draft.isEnabled) notFound();
const initialSettings = (await getCompanySettings()) ?? FALLBACK;
return <LiveCompanySettingsPreviewClient initialSettings={initialSettings} />;
}