feat(special-curation): complete implementation with all components

- Database: SpecialSong model with startTime
- Backend: API endpoints for curation
- Admin: Waveform editor and curation page
- Game: startTime support in AudioPlayer
- UI: Curate button in admin dashboard
This commit is contained in:
Hördle Bot
2025-11-23 00:50:35 +01:00
parent 4f088305df
commit 587fa59b79
8 changed files with 564 additions and 23 deletions

View File

@@ -0,0 +1,60 @@
import { NextResponse } from 'next/server';
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export async function GET(
request: Request,
{ params }: { params: { id: string } }
) {
try {
const specialId = parseInt(params.id);
const special = await prisma.special.findUnique({
where: { id: specialId },
include: {
songs: {
include: {
song: true
},
orderBy: {
order: 'asc'
}
}
}
});
if (!special) {
return NextResponse.json({ error: 'Special not found' }, { status: 404 });
}
return NextResponse.json(special);
} catch (error) {
console.error('Error fetching special:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
}
}
export async function PUT(
request: Request,
{ params }: { params: { id: string } }
) {
try {
const specialId = parseInt(params.id);
const { name, maxAttempts, unlockSteps } = await request.json();
const special = await prisma.special.update({
where: { id: specialId },
data: {
name,
maxAttempts,
unlockSteps: JSON.stringify(unlockSteps)
}
});
return NextResponse.json(special);
} catch (error) {
console.error('Error updating special:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
}
}

View File

@@ -0,0 +1,86 @@
import { NextResponse } from 'next/server';
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export async function POST(
request: Request,
{ params }: { params: { id: string } }
) {
try {
const specialId = parseInt(params.id);
const { songId, startTime = 0, order } = await request.json();
const specialSong = await prisma.specialSong.create({
data: {
specialId,
songId,
startTime,
order
},
include: {
song: true
}
});
return NextResponse.json(specialSong);
} catch (error) {
console.error('Error adding song to special:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
}
}
export async function PUT(
request: Request,
{ params }: { params: { id: string } }
) {
try {
const specialId = parseInt(params.id);
const { songId, startTime, order } = await request.json();
const specialSong = await prisma.specialSong.update({
where: {
specialId_songId: {
specialId,
songId
}
},
data: {
startTime,
order
},
include: {
song: true
}
});
return NextResponse.json(specialSong);
} catch (error) {
console.error('Error updating special song:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
}
}
export async function DELETE(
request: Request,
{ params }: { params: { id: string } }
) {
try {
const specialId = parseInt(params.id);
const { songId } = await request.json();
await prisma.specialSong.delete({
where: {
specialId_songId: {
specialId,
songId
}
}
});
return NextResponse.json({ success: true });
} catch (error) {
console.error('Error removing song from special:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
}
}