From 055df23ffb57c25d8c5440de899f48490be41947 Mon Sep 17 00:00:00 2001 From: Bilal Godil Date: Thu, 2 Jul 2026 11:47:39 -0700 Subject: [PATCH] fix(email-themes): add missing DELETE route so themes can be deleted The dashboard's deleteEmailTheme() sends DELETE /internal/email-themes/{id}, but the [id] route only exported GET and PATCH, so Next.js returned 405 and the UI showed 'Theme not deleted'. Wire up a DELETE handler that reuses the existing CUD onDelete logic (including the active-theme guard). --- .../internal/email-themes/[id]/route.tsx | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/backend/src/app/api/latest/internal/email-themes/[id]/route.tsx b/apps/backend/src/app/api/latest/internal/email-themes/[id]/route.tsx index ba5413038..f30090bbe 100644 --- a/apps/backend/src/app/api/latest/internal/email-themes/[id]/route.tsx +++ b/apps/backend/src/app/api/latest/internal/email-themes/[id]/route.tsx @@ -51,3 +51,37 @@ export const PATCH = createSmartRouteHandler({ }; }, }); + +export const DELETE = createSmartRouteHandler({ + metadata: { + hidden: true, + }, + request: yupObject({ + auth: yupObject({ + type: yupString().oneOf(["admin"]).defined(), + tenancy: adaptSchema.defined(), + }).defined(), + params: yupObject({ + id: yupString().defined(), + }).defined(), + }), + response: yupObject({ + statusCode: yupNumber().oneOf([200]).defined(), + bodyType: yupString().oneOf(["json"]).defined(), + body: yupObject({}).defined(), + }), + async handler({ auth: { tenancy }, params: { id } }) { + await internalEmailThemesCudHandlers.adminDelete({ + tenancy, + allowedErrorTypes: [StatusError], + id, + data: [], + }); + + return { + statusCode: 200, + bodyType: "json", + body: {}, + }; + }, +});