chore: commit previously untracked runtime files (splits, auth, participants, shared)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib/db";
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const body = await req.json();
|
||||
const { participant_id, split_ids } = body as {
|
||||
participant_id?: number;
|
||||
split_ids?: number[];
|
||||
};
|
||||
|
||||
const now = new Date();
|
||||
|
||||
if (participant_id) {
|
||||
const result = await prisma.transaction_splits.updateMany({
|
||||
where: { participant_id, settled: false },
|
||||
data: { settled: true, settled_at: now },
|
||||
});
|
||||
return NextResponse.json({ settled: result.count });
|
||||
}
|
||||
|
||||
if (split_ids?.length) {
|
||||
const result = await prisma.transaction_splits.updateMany({
|
||||
where: { id: { in: split_ids }, settled: false },
|
||||
data: { settled: true, settled_at: now },
|
||||
});
|
||||
return NextResponse.json({ settled: result.count });
|
||||
}
|
||||
|
||||
return NextResponse.json({ error: "participant_id or split_ids required" }, { status: 400 });
|
||||
}
|
||||
Reference in New Issue
Block a user