import { appendEventToService } from "@/apicalls/custom/events/endpoints";
import { NextRequest } from "next/server";
import { withErrorHandling } from "@/app/api/utils/requestHandlers";
import {
  successResponse,
  errorResponse,
} from "@/app/api/utils/responseHandlers";

export const POST = withErrorHandling(
  async (request: NextRequest, body: any) => {
    const payload = {
      event_uu_id: body.event_uu_id,
      service_uu_id: body.service_uu_id,
    };
    const result = await appendEventToService(payload);
    if (!result) {
      return errorResponse("Error appending event to service");
    } else {
      return successResponse(result);
    }
  }
);
