feat: Implement genre activation/deactivation with UI controls and main page filtering.
This commit is contained in:
@@ -27,7 +27,7 @@ export async function POST(request: Request) {
|
||||
if (authError) return authError;
|
||||
|
||||
try {
|
||||
const { name, subtitle } = await request.json();
|
||||
const { name, subtitle, active } = await request.json();
|
||||
|
||||
if (!name || typeof name !== 'string') {
|
||||
return NextResponse.json({ error: 'Invalid name' }, { status: 400 });
|
||||
@@ -36,7 +36,8 @@ export async function POST(request: Request) {
|
||||
const genre = await prisma.genre.create({
|
||||
data: {
|
||||
name: name.trim(),
|
||||
subtitle: subtitle ? subtitle.trim() : null
|
||||
subtitle: subtitle ? subtitle.trim() : null,
|
||||
active: active !== undefined ? active : true
|
||||
},
|
||||
});
|
||||
|
||||
@@ -76,7 +77,7 @@ export async function PUT(request: Request) {
|
||||
if (authError) return authError;
|
||||
|
||||
try {
|
||||
const { id, name, subtitle } = await request.json();
|
||||
const { id, name, subtitle, active } = await request.json();
|
||||
|
||||
if (!id) {
|
||||
return NextResponse.json({ error: 'Missing id' }, { status: 400 });
|
||||
@@ -86,7 +87,8 @@ export async function PUT(request: Request) {
|
||||
where: { id: Number(id) },
|
||||
data: {
|
||||
...(name && { name: name.trim() }),
|
||||
subtitle: subtitle ? subtitle.trim() : null // Allow clearing subtitle if empty string passed? Or just update if provided? Let's assume null/empty string clears it.
|
||||
subtitle: subtitle ? subtitle.trim() : null,
|
||||
...(active !== undefined && { active })
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user