Implementiere i18n für Frontend, Admin und Datenbank
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getOrCreateDailyPuzzle } from '@/lib/dailyPuzzle';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { getLocalizedValue } from '@/lib/i18n';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const genreName = searchParams.get('genre');
|
||||
|
||||
const puzzle = await getOrCreateDailyPuzzle(genreName);
|
||||
let genre = null;
|
||||
if (genreName) {
|
||||
// Find genre by localized name (try both locales)
|
||||
const allGenres = await prisma.genre.findMany();
|
||||
genre = allGenres.find(g =>
|
||||
getLocalizedValue(g.name, 'de') === genreName ||
|
||||
getLocalizedValue(g.name, 'en') === genreName
|
||||
) || null;
|
||||
}
|
||||
|
||||
const puzzle = await getOrCreateDailyPuzzle(genre);
|
||||
|
||||
if (!puzzle) {
|
||||
return NextResponse.json({ error: 'Failed to get or create puzzle' }, { status: 404 });
|
||||
|
||||
Reference in New Issue
Block a user