import { NextRequest, NextResponse } from 'next/server'

const LS = process.env.LEGAL_SERVICE_URL ?? 'http://localhost:3200'

export async function GET(req: NextRequest) {
  const search = req.nextUrl.searchParams.toString()
  const res = await fetch(`${LS}/annual-compliance${search ? `?${search}` : ''}`, { cache: 'no-store' })
  const data = await res.json()
  return NextResponse.json(data, { status: res.status })
}

export async function POST(req: NextRequest) {
  const body = await req.json()
  const res = await fetch(`${LS}/annual-compliance`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  })
  const data = await res.json()
  return NextResponse.json(data, { status: res.status })
}
