/**
 * POST /api/sms/optout — opt out of SMS alerts.
 */
import { NextResponse } from "next/server";
import { getCurrentUser } from "@/lib/auth";
import { optOutSms } from "@/lib/services/sms-sender";

export const dynamic = "force-dynamic";

export async function POST() {
  const user = await getCurrentUser();
  if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  await optOutSms(user.id);
  return NextResponse.json({ ok: true });
}
