feat: 拆分"再来一轮"为 Top N 决赛和换一批餐厅两个选项
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user