diff --git a/apps/api/lib/validations/user.ts b/apps/api/lib/validations/user.ts index 107db36ba6..de9e22a976 100644 --- a/apps/api/lib/validations/user.ts +++ b/apps/api/lib/validations/user.ts @@ -75,6 +75,7 @@ export const schemaUserBaseBodyParams = User.pick({ theme: true, defaultScheduleId: true, locale: true, + hideBranding: true, timeFormat: true, brandColor: true, darkBrandColor: true, @@ -95,6 +96,7 @@ const schemaUserEditParams = z.object({ weekStart: z.nativeEnum(weekdays).optional(), brandColor: z.string().min(4).max(9).regex(/^#/).optional(), darkBrandColor: z.string().min(4).max(9).regex(/^#/).optional(), + hideBranding: z.boolean().optional(), timeZone: timeZone.optional(), theme: z.nativeEnum(theme).optional().nullable(), timeFormat: z.nativeEnum(timeFormat).optional(), @@ -115,6 +117,7 @@ const schemaUserCreateParams = z.object({ weekStart: z.nativeEnum(weekdays).optional(), brandColor: z.string().min(4).max(9).regex(/^#/).optional(), darkBrandColor: z.string().min(4).max(9).regex(/^#/).optional(), + hideBranding: z.boolean().optional(), timeZone: timeZone.optional(), theme: z.nativeEnum(theme).optional().nullable(), timeFormat: z.nativeEnum(timeFormat).optional(), @@ -157,6 +160,7 @@ export const schemaUserReadPublic = User.pick({ defaultScheduleId: true, locale: true, timeFormat: true, + hideBranding: true, brandColor: true, darkBrandColor: true, allowDynamicBooking: true, diff --git a/apps/api/pages/api/users/[userId]/_patch.ts b/apps/api/pages/api/users/[userId]/_patch.ts index 59d8b76f94..84f6ffb45b 100644 --- a/apps/api/pages/api/users/[userId]/_patch.ts +++ b/apps/api/pages/api/users/[userId]/_patch.ts @@ -53,6 +53,9 @@ import { schemaUserEditBodyParams, schemaUserReadPublic } from "~/lib/validation * timeZone: * description: The user's time zone * type: string + * hideBranding: + * description: Remove branding from the user's calendar page + * type: boolean * theme: * description: Default theme for the user. Acceptable values are one of [DARK, LIGHT] * type: string @@ -79,7 +82,7 @@ import { schemaUserEditBodyParams, schemaUserReadPublic } from "~/lib/validation * - users * responses: * 200: - * description: OK, user edited successfuly + * description: OK, user edited successfully * 400: * description: Bad request. User body is invalid. * 401: @@ -94,9 +97,10 @@ export async function patchHandler(req: NextApiRequest) { if (!isAdmin && query.userId !== req.userId) throw new HttpError({ statusCode: 403, message: "Forbidden" }); const body = await schemaUserEditBodyParams.parseAsync(req.body); - // disable role changes unless admin. - if (!isAdmin && body.role) { - body.role = undefined; + // disable role or branding changes unless admin. + if (!isAdmin) { + if (body.role) body.role = undefined; + if (body.hideBranding) body.hideBranding = undefined; } const userSchedules = await prisma.schedule.findMany({ diff --git a/apps/api/pages/api/users/_post.ts b/apps/api/pages/api/users/_post.ts index 7c945399d0..15c68aa31d 100644 --- a/apps/api/pages/api/users/_post.ts +++ b/apps/api/pages/api/users/_post.ts @@ -42,6 +42,9 @@ import { schemaUserCreateBodyParams } from "~/lib/validations/user"; * darkBrandColor: * description: The new user's brand color for dark mode * type: string + * hideBranding: + * description: Remove branding from the user's calendar page + * type: boolean * weekStart: * description: Start of the week. Acceptable values are one of [SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY] * type: string