Add title field to EmailTemplate model and update UI

This commit is contained in:
Ken Yasue
2025-03-25 11:43:47 +01:00
parent 6b9e208214
commit e1440bcea7
6 changed files with 41 additions and 13 deletions

View File

@ -28,18 +28,19 @@ export async function POST(request: NextRequest) {
const emailTemplateRepository = dataSource.getRepository(EmailTemplate);
const data = await request.json();
const { content } = data;
const { title, content } = data;
// Validate required fields
if (!content) {
if (!title || !content) {
return NextResponse.json(
{ error: 'Content is required' },
{ error: 'Title and content are required' },
{ status: 400 }
);
}
// Create and save the new email template
const emailTemplate = new EmailTemplate();
emailTemplate.title = title;
emailTemplate.content = content;
const savedEmailTemplate = await emailTemplateRepository.save(emailTemplate);