forked from fahrPool/fahrPool
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { createAdminClient } from "@/lib/supabase/admin";
|
|
import { ladeAdminKontext } from "@/lib/firma/admin-kontext";
|
|
import { ladeFirmenSmtp, type SmtpAnzeige } from "@/lib/firma/smtp";
|
|
import { FirmaEinstellungenForm } from "@/components/firma/FirmaEinstellungenForm";
|
|
import { AppIconForm } from "@/components/firma/AppIconForm";
|
|
import { LogoForm } from "@/components/firma/LogoForm";
|
|
import { SmtpForm } from "@/components/firma/SmtpForm";
|
|
import { iconUrl } from "@/lib/pwa/app-icon";
|
|
import { Card } from "@/components/ui/Card";
|
|
|
|
export default async function FirmaPage() {
|
|
const kontext = await ladeAdminKontext();
|
|
if (!kontext.ok) {
|
|
redirect("/dashboard");
|
|
}
|
|
|
|
// Das Passwort verlaesst den Server nie, nur ob eins gesetzt ist.
|
|
const zeile = await ladeFirmenSmtp(createAdminClient(), kontext.firma.id);
|
|
const smtp: SmtpAnzeige | null = zeile
|
|
? {
|
|
host: zeile.host,
|
|
port: zeile.port,
|
|
secure: zeile.secure,
|
|
benutzer: zeile.benutzer,
|
|
absender_adresse: zeile.absender_adresse,
|
|
absender_name: zeile.absender_name,
|
|
passwortGesetzt: Boolean(zeile.passwort_verschluesselt),
|
|
}
|
|
: null;
|
|
|
|
return (
|
|
<div className="mx-auto flex max-w-2xl flex-col gap-6 p-4 md:p-8">
|
|
<h1 className="text-xl font-semibold text-asphalt-grey">Firma</h1>
|
|
<Card>
|
|
<h2 className="mb-4 font-semibold text-asphalt-grey">Allgemein</h2>
|
|
<FirmaEinstellungenForm firma={kontext.firma} />
|
|
</Card>
|
|
<Card>
|
|
<h2 className="mb-4 font-semibold text-asphalt-grey">Logo</h2>
|
|
<LogoForm hatLogo={Boolean(kontext.firma.logo_pfad)} />
|
|
</Card>
|
|
<Card>
|
|
<h2 className="mb-4 font-semibold text-asphalt-grey">App-Icon</h2>
|
|
{/* iconUrl nutzt node:crypto, deshalb hier im Server berechnet */}
|
|
<AppIconForm hatAppIcon={Boolean(kontext.firma.app_icon_pfad)} vorschauUrl={iconUrl(kontext.firma, "192")} />
|
|
</Card>
|
|
<Card>
|
|
<h2 className="mb-4 font-semibold text-asphalt-grey">E-Mail-Versand (SMTP)</h2>
|
|
<SmtpForm smtp={smtp} />
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|