Tighten typing and input validation across study pages
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m2s

This commit is contained in:
Elijah 2026-07-13 06:55:17 -07:00
parent 6d1d918355
commit d6f3502cb1
16 changed files with 170 additions and 56 deletions

View file

@ -1,19 +1,20 @@
import { NextRequest, NextResponse } from "next/server";
import { prisma } from "@/lib/db";
import { reorderRequestSchema } from "@/lib/validation/reorderSchemas";
export async function PATCH(request: NextRequest) {
try {
const body = await request.json();
const { items } = body;
if (!Array.isArray(items)) {
const parsed = reorderRequestSchema.safeParse(await request.json());
if (!parsed.success) {
return NextResponse.json({ error: "Invalid input" }, { status: 400 });
}
const { items } = parsed.data;
// items should be an array of { id, sortOrder, groupId }
// Using a transaction to perform all updates
await prisma.$transaction(
items.map((item: any) =>
items.map((item) =>
prisma.quizSet.update({
where: { id: item.id },
data: {