import { appendApplicationToService } from "@/apicalls/custom/application/apicall";
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 = {
      application_uu_id: body.application_uu_id,
      service_uu_id: body.service_uu_id,
    };
    const result = await appendApplicationToService(payload);
    if (!result) {
      return errorResponse("Error appending application to service");
    } else {
      return successResponse(result);
    }
  }
);
