fix: TypeScript-Fehler in batch route korrigiert

- Verwende lokale Variable curatorAssignments statt nullable assignments
- TypeScript erkennt jetzt korrekt, dass die Variable nicht null ist
This commit is contained in:
Hördle Bot
2025-12-04 00:57:02 +01:00
parent 91ebaa0e44
commit 7879b63498

View File

@@ -81,12 +81,12 @@ export async function POST(request: Request) {
let assignments: { genreIds: Set<number>; specialIds: Set<number> } | null = null;
if (context.role === 'curator') {
assignments = await getCuratorAssignments(context.curator.id);
const curatorAssignments = await getCuratorAssignments(context.curator.id);
assignments = curatorAssignments;
// Validate genre/special toggles are within curator's assignments
// assignments is guaranteed to be non-null here since we're in the curator block
if (hasGenreToggle) {
const invalidGenre = genreToggleIds.some((id: number) => !assignments!.genreIds.has(id));
const invalidGenre = genreToggleIds.some((id: number) => !curatorAssignments.genreIds.has(id));
if (invalidGenre) {
return NextResponse.json(
{ error: 'Curators may only toggle their own genres' },
@@ -96,7 +96,7 @@ export async function POST(request: Request) {
}
if (hasSpecialToggle) {
const invalidSpecial = specialToggleIds.some((id: number) => !assignments!.specialIds.has(id));
const invalidSpecial = specialToggleIds.some((id: number) => !curatorAssignments.specialIds.has(id));
if (invalidSpecial) {
return NextResponse.json(
{ error: 'Curators may only toggle their own specials' },