import {
  deleteJadwalPelatihanById,
  updateJadwalPelatihan,
} from "@/models/jadwal.pelatihan";
import { NextResponse } from "next/server";
export async function PATCH(request) {
  try {
    const body = await request.json();
    const result = await updateJadwalPelatihan(body);
    return NextResponse.json(result, { status: 200 });
  } catch (error) {
    return NextResponse.json({ error: "Failed" }, { status: 500 });
  }
}
export async function DELETE(request) {
  try {
    const { searchParams } = new URL(request.url);
    const _id = searchParams.get("_id");
    // const body = await request.json();
    const result = await deleteJadwalPelatihanById(_id);

    return NextResponse.json(result, { status: 200 });
  } catch (error) {
    console.log(error);
    return NextResponse.json({ error: "Failed" }, { status: 500 });
  }
}
