import { NextRequest } from "next/server";

import { proxyHermesRequest } from "@/lib/server/hermes-proxy";
import { assertSameOrigin } from "@/lib/server/request-guards";

type Params = {
  params: Promise<{
    id: string;
  }>;
};

export async function PUT(request: NextRequest, { params }: Params) {
  const originError = assertSameOrigin(request);

  if (originError) {
    return originError;
  }

  const { id } = await params;
  return proxyHermesRequest(request, `/repairs/${id}/status`);
}
