From 09d417907bd9b81047ba6c0234411c0adb622b13 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 11 Dec 2025 13:54:14 -0800 Subject: [PATCH] fix: save branding toggle fields in project API endpoints POST/PUT/PATCH handlers were ignoring showFeaturedImageInHeader, showBackgroundColorInHeader, and showLogoInHeader fields sent by the form, so background colors weren't persisting. --- src/routes/api/projects/+server.ts | 8 +++++++- src/routes/api/projects/[id]/+server.ts | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/routes/api/projects/+server.ts b/src/routes/api/projects/+server.ts index 41725a4..de74fd1 100644 --- a/src/routes/api/projects/+server.ts +++ b/src/routes/api/projects/+server.ts @@ -37,6 +37,9 @@ interface ProjectCreateBody { status?: string password?: string | null slug?: string + showFeaturedImageInHeader?: boolean + showBackgroundColorInHeader?: boolean + showLogoInHeader?: boolean } // GET /api/projects - List all projects @@ -148,7 +151,10 @@ export const POST: RequestHandler = async (event) => { displayOrder: body.displayOrder || 0, status: body.status || 'draft', password: body.password || null, - publishedAt: body.status === 'published' ? new Date() : null + publishedAt: body.status === 'published' ? new Date() : null, + showFeaturedImageInHeader: body.showFeaturedImageInHeader ?? true, + showBackgroundColorInHeader: body.showBackgroundColorInHeader ?? true, + showLogoInHeader: body.showLogoInHeader ?? true } }) diff --git a/src/routes/api/projects/[id]/+server.ts b/src/routes/api/projects/[id]/+server.ts index 4b1ec87..98955df 100644 --- a/src/routes/api/projects/[id]/+server.ts +++ b/src/routes/api/projects/[id]/+server.ts @@ -36,6 +36,9 @@ interface ProjectUpdateBody { status?: string password?: string | null slug?: string + showFeaturedImageInHeader?: boolean + showBackgroundColorInHeader?: boolean + showLogoInHeader?: boolean } // GET /api/projects/[id] - Get a single project @@ -129,7 +132,19 @@ export const PUT: RequestHandler = async (event) => { status: body.status !== undefined ? body.status : existing.status, password: body.password !== undefined ? body.password : existing.password, publishedAt: - body.status === 'published' && !existing.publishedAt ? new Date() : existing.publishedAt + body.status === 'published' && !existing.publishedAt ? new Date() : existing.publishedAt, + showFeaturedImageInHeader: + body.showFeaturedImageInHeader !== undefined + ? body.showFeaturedImageInHeader + : existing.showFeaturedImageInHeader, + showBackgroundColorInHeader: + body.showBackgroundColorInHeader !== undefined + ? body.showBackgroundColorInHeader + : existing.showBackgroundColorInHeader, + showLogoInHeader: + body.showLogoInHeader !== undefined + ? body.showLogoInHeader + : existing.showLogoInHeader } }) @@ -269,6 +284,11 @@ export const PATCH: RequestHandler = async (event) => { if (body.projectType !== undefined) updateData.projectType = body.projectType if (body.displayOrder !== undefined) updateData.displayOrder = body.displayOrder if (body.password !== undefined) updateData.password = body.password + if (body.showFeaturedImageInHeader !== undefined) + updateData.showFeaturedImageInHeader = body.showFeaturedImageInHeader + if (body.showBackgroundColorInHeader !== undefined) + updateData.showBackgroundColorInHeader = body.showBackgroundColorInHeader + if (body.showLogoInHeader !== undefined) updateData.showLogoInHeader = body.showLogoInHeader // Handle slug update if provided if (body.slug && body.slug !== existing.slug) {