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.
This commit is contained in:
parent
2d1d344133
commit
09d417907b
2 changed files with 28 additions and 2 deletions
|
|
@ -37,6 +37,9 @@ interface ProjectCreateBody {
|
||||||
status?: string
|
status?: string
|
||||||
password?: string | null
|
password?: string | null
|
||||||
slug?: string
|
slug?: string
|
||||||
|
showFeaturedImageInHeader?: boolean
|
||||||
|
showBackgroundColorInHeader?: boolean
|
||||||
|
showLogoInHeader?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /api/projects - List all projects
|
// GET /api/projects - List all projects
|
||||||
|
|
@ -148,7 +151,10 @@ export const POST: RequestHandler = async (event) => {
|
||||||
displayOrder: body.displayOrder || 0,
|
displayOrder: body.displayOrder || 0,
|
||||||
status: body.status || 'draft',
|
status: body.status || 'draft',
|
||||||
password: body.password || null,
|
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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ interface ProjectUpdateBody {
|
||||||
status?: string
|
status?: string
|
||||||
password?: string | null
|
password?: string | null
|
||||||
slug?: string
|
slug?: string
|
||||||
|
showFeaturedImageInHeader?: boolean
|
||||||
|
showBackgroundColorInHeader?: boolean
|
||||||
|
showLogoInHeader?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /api/projects/[id] - Get a single project
|
// 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,
|
status: body.status !== undefined ? body.status : existing.status,
|
||||||
password: body.password !== undefined ? body.password : existing.password,
|
password: body.password !== undefined ? body.password : existing.password,
|
||||||
publishedAt:
|
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.projectType !== undefined) updateData.projectType = body.projectType
|
||||||
if (body.displayOrder !== undefined) updateData.displayOrder = body.displayOrder
|
if (body.displayOrder !== undefined) updateData.displayOrder = body.displayOrder
|
||||||
if (body.password !== undefined) updateData.password = body.password
|
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
|
// Handle slug update if provided
|
||||||
if (body.slug && body.slug !== existing.slug) {
|
if (body.slug && body.slug !== existing.slug) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue