import { NextRequest, NextResponse } from "next/server";

const CALENDAR_URL = process.env.CALENDAR_SERVICE_URL || "http://127.0.0.1:8084";

export async function DELETE(
  _request: NextRequest,
  { params }: { params: Promise<{ id: string }> }
) {
  const { id } = await params;
  try {
    const res = await fetch(`${CALENDAR_URL}/reminders/${encodeURIComponent(id)}`, {
      method: "DELETE",
    });
    const data = await res.json();
    return NextResponse.json(data, { status: res.status });
  } catch {
    return NextResponse.json({ error: "Calendar service unavailable" }, { status: 502 });
  }
}
