feat: add template delete — backend DELETE route, frontend trash button
- DELETE /templates/:id — backend route - deleteTemplate() API client function - Trash icon on each template list item (shows on hover) - Confirms inline, no dialog needed - Resets builder if the deleted template was being edited Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -151,6 +151,21 @@ export function createTemplatesRouter(db: Db): Hono {
|
||||
return c.json(updated);
|
||||
});
|
||||
|
||||
router.delete('/:id', async (c) => {
|
||||
const id = c.req.param('id');
|
||||
|
||||
const existing = await db.query.templates.findFirst({
|
||||
where: eq(templates.id, id),
|
||||
});
|
||||
|
||||
if (!existing) {
|
||||
throw new HTTPException(404, { message: 'Template not found' });
|
||||
}
|
||||
|
||||
await db.delete(templates).where(eq(templates.id, id));
|
||||
return c.json({ ok: true });
|
||||
});
|
||||
|
||||
router.post('/preview', async (c) => {
|
||||
const body = await c.req.json();
|
||||
const subjectTemplate = String(body.subject_template ?? '');
|
||||
|
||||
Reference in New Issue
Block a user