import { NextResponse } from 'next/server';

import { withAuth } from '@/lib/api/helpers';
import { errorResponse, ValidationError } from '@/lib/errors';
import { dismissAlert } from '@/lib/services/alerts.service';

export const POST = withAuth(async (_req, ctx, params) => {
  try {
    const id = params.id;
    if (!id) throw new ValidationError('id is required');
    await dismissAlert(id, ctx.portId, ctx.userId);
    return new NextResponse(null, { status: 204 });
  } catch (error) {
    return errorResponse(error);
  }
});
