import { NextRequest, NextResponse } from "next/server";
import { updatePricing } from "@/lib/adminrpc/client";

export const runtime = "nodejs";

// PATCH /api/admin/ai/pricing/{id} — update pricing
export async function PATCH(
  req: NextRequest,
  { params }: { params: Promise<{ id: string }> }
) {
  try {
    const { id } = await params;
    const body = await req.json();
    const data = await updatePricing(id, body);
    return NextResponse.json(data);
  } catch (e) {
    const msg = e instanceof Error ? e.message : String(e);
    console.error("Update pricing error:", msg);
    return NextResponse.json({ error: `更新失败: ${msg}` }, { status: 500 });
  }
}
