Add title field to EmailTemplate model and update UI
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user