feat: 拆分"再来一轮"为 Top N 决赛和换一批餐厅两个选项

This commit is contained in:
2026-02-24 19:34:35 +08:00
parent 5d297684fc
commit cb9f4a3d0f
4 changed files with 102 additions and 16 deletions
+15 -1
View File
@@ -2,13 +2,27 @@ import { NextResponse } from "next/server";
import { atomicUpdateRoom } from "@/lib/store";
export async function POST(
_req: Request,
req: Request,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;
let restaurantIds: string[] | undefined;
try {
const body = await req.json().catch(() => null);
if (body?.restaurantIds && Array.isArray(body.restaurantIds)) {
restaurantIds = body.restaurantIds;
}
} catch {
// No body or invalid JSON — plain reset
}
try {
const updated = await atomicUpdateRoom(id, (data) => {
if (restaurantIds && restaurantIds.length > 0) {
const idSet = new Set(restaurantIds);
data.restaurants = data.restaurants.filter((r) => idSet.has(r.id));
}
data.likes = {};
data.swipeCounts = {};
data.match = null;