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).
This commit is contained in:
Bilal Godil
2026-07-02 11:47:39 -07:00
parent d5d2f27a96
commit 055df23ffb
@@ -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: {},
};
},
});