Implement Specials feature, Admin UI enhancements, and Database Rebuild tool
This commit is contained in:
@@ -12,6 +12,7 @@ export async function GET() {
|
||||
include: {
|
||||
puzzles: true,
|
||||
genres: true,
|
||||
specials: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -25,6 +26,7 @@ export async function GET() {
|
||||
coverImage: song.coverImage,
|
||||
activations: song.puzzles.length,
|
||||
genres: song.genres,
|
||||
specials: song.specials,
|
||||
}));
|
||||
|
||||
return NextResponse.json(songsWithActivations);
|
||||
@@ -146,7 +148,7 @@ export async function POST(request: Request) {
|
||||
filename,
|
||||
coverImage,
|
||||
},
|
||||
include: { genres: true }
|
||||
include: { genres: true, specials: true }
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
@@ -161,7 +163,7 @@ export async function POST(request: Request) {
|
||||
|
||||
export async function PUT(request: Request) {
|
||||
try {
|
||||
const { id, title, artist, genreIds } = await request.json();
|
||||
const { id, title, artist, genreIds, specialIds } = await request.json();
|
||||
|
||||
if (!id || !title || !artist) {
|
||||
return NextResponse.json({ error: 'Missing fields' }, { status: 400 });
|
||||
@@ -175,10 +177,16 @@ export async function PUT(request: Request) {
|
||||
};
|
||||
}
|
||||
|
||||
if (specialIds) {
|
||||
data.specials = {
|
||||
set: specialIds.map((sId: number) => ({ id: sId }))
|
||||
};
|
||||
}
|
||||
|
||||
const updatedSong = await prisma.song.update({
|
||||
where: { id: Number(id) },
|
||||
data,
|
||||
include: { genres: true }
|
||||
include: { genres: true, specials: true }
|
||||
});
|
||||
|
||||
return NextResponse.json(updatedSong);
|
||||
|
||||
Reference in New Issue
Block a user