feat: add directory opt-out sync and layout/xss seed data extensions

This commit is contained in:
t.indorf
2026-05-22 15:22:12 +02:00
parent e9595fab21
commit f28956194c
4 changed files with 89 additions and 0 deletions
@@ -16,6 +16,7 @@ type ContactFormProps = {
street: string | null;
postalCode: string | null;
city: string | null;
directoryOptIn: boolean;
};
};
@@ -30,6 +31,7 @@ export function ContactForm({ contact }: ContactFormProps) {
street: String(formData.get("street") ?? ""),
postalCode: String(formData.get("postalCode") ?? ""),
city: String(formData.get("city") ?? ""),
directoryOptIn: formData.get("directoryOptIn") === "on",
});
if (result.error) {
@@ -106,6 +108,22 @@ export function ContactForm({ contact }: ContactFormProps) {
</div>
</div>
<div className="flex items-center gap-2 mt-2">
<input
type="checkbox"
id="directoryOptIn"
name="directoryOptIn"
defaultChecked={contact.directoryOptIn}
className="rounded border-[var(--hairline)] accent-[var(--accent-deep)]"
/>
<Label
htmlFor="directoryOptIn"
className="font-normal cursor-pointer text-xs text-[var(--ink-soft)]"
>
Im Adressbuch anzeigen (Datenschutzerklärung)
</Label>
</div>
<div className="flex justify-end pt-1">
<Button type="submit" disabled={isPending}>
{isPending ? (
+16
View File
@@ -80,6 +80,7 @@ const contactSchema = z.object({
"Bitte eine gültige Postleitzahl angeben.",
),
city: z.string().trim().max(100).optional(),
directoryOptIn: z.boolean().optional(),
});
// Gibt die erste konkrete Field-Error-Message aus einem Zod-Fehler zurück,
@@ -183,6 +184,20 @@ export async function updateMyContact(rawPayload: unknown) {
}
try {
const currentUser = await prisma.user.findUniqueOrThrow({
where: { id: session.user.id },
select: { directoryOptInAt: true },
});
let newDirectoryOptInAt: Date | null = currentUser.directoryOptInAt;
if (parsed.data.directoryOptIn) {
if (!newDirectoryOptInAt) {
newDirectoryOptInAt = new Date();
}
} else {
newDirectoryOptInAt = null;
}
await prisma.user.update({
where: { id: session.user.id },
data: {
@@ -190,6 +205,7 @@ export async function updateMyContact(rawPayload: unknown) {
street: parsed.data.street || null,
postalCode: parsed.data.postalCode || null,
city: parsed.data.city || null,
directoryOptInAt: newDirectoryOptInAt,
},
});
+2
View File
@@ -51,6 +51,7 @@ export default async function ProfilPage() {
street: true,
postalCode: true,
city: true,
directoryOptInAt: true,
createdAt: true,
family: {
select: {
@@ -173,6 +174,7 @@ export default async function ProfilPage() {
street: user.street,
postalCode: user.postalCode,
city: user.city,
directoryOptIn: !!user.directoryOptInAt,
}}
/>
</CardContent>