Update notification text handling in API and dashboard to support separate application and server notification texts.

This commit is contained in:
headlessdev
2025-04-21 13:22:40 +02:00
parent 49eeab4848
commit 21dd61c597
3 changed files with 48 additions and 22 deletions

View File

@@ -2,13 +2,14 @@ import { NextResponse, NextRequest } from "next/server";
import { prisma } from "@/lib/prisma";
interface AddRequest {
text: string;
text_application: string;
text_server: string;
}
export async function POST(request: NextRequest) {
try {
const body: AddRequest = await request.json();
const { text } = body;
const { text_application, text_server } = body;
// Check if there is already a settings entry
const existingSettings = await prisma.settings.findFirst();
@@ -16,14 +17,15 @@ export async function POST(request: NextRequest) {
// Update the existing settings entry
const updatedSettings = await prisma.settings.update({
where: { id: existingSettings.id },
data: { notification_text: text },
data: { notification_text_application: text_application, notification_text_server: text_server },
});
return NextResponse.json({ message: "Success", updatedSettings });
}
// If no settings entry exists, create a new one
const settings = await prisma.settings.create({
data: {
notification_text: text,
notification_text_application: text_application,
notification_text_server: text_server,
}
});