Wire landing footer contact info to site settings.

Admin phone/email/address/socials now drive the public footer instead of stale section JSON.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-30 21:36:43 +03:30
co-authored by Cursor
parent e9eafdaabc
commit 55e3b6a0e9
4 changed files with 112 additions and 32 deletions
+28 -2
View File
@@ -10,7 +10,7 @@ export class ContentService {
return this.prisma.siteSettings.findUniqueOrThrow({ where: { id: "default" } });
}
updateSettings(data: {
async updateSettings(data: {
brandName?: string;
tagline?: string;
email?: string;
@@ -21,7 +21,7 @@ export class ContentService {
logoUrl?: string | null;
}) {
const { logoUrl, timezone, ...rest } = data;
return this.prisma.siteSettings.update({
const settings = await this.prisma.siteSettings.update({
where: { id: "default" },
data: {
...rest,
@@ -29,6 +29,32 @@ export class ContentService {
...(logoUrl !== undefined ? { logoUrl: logoUrl || null } : {}),
},
});
// Keep footer section contact fields in sync with site settings
const footer = await this.prisma.sectionContent.findUnique({ where: { key: "footer" } });
if (footer) {
const prev = (footer.data || {}) as Record<string, unknown>;
const addressLines = settings.address
? settings.address.split(/\n|,/).map((s) => s.trim()).filter(Boolean)
: (prev.address as string[]) || [];
const socials = Array.isArray(settings.socials)
? (settings.socials as Array<{ label: string; url: string }>).map((s) => s.label).filter(Boolean)
: prev.socials;
await this.prisma.sectionContent.update({
where: { key: "footer" },
data: {
data: {
...prev,
email: settings.email,
phone: settings.phone,
address: addressLines,
socials,
},
},
});
}
return settings;
}
async listSections() {