diff --git a/src/app/api/v1/alerts/dismiss-all/route.ts b/src/app/api/v1/alerts/dismiss-all/route.ts new file mode 100644 index 00000000..0d46bb11 --- /dev/null +++ b/src/app/api/v1/alerts/dismiss-all/route.ts @@ -0,0 +1,23 @@ +import { NextResponse } from 'next/server'; +import { z } from 'zod'; + +import { withAuth } from '@/lib/api/helpers'; +import { parseBody } from '@/lib/api/route-helpers'; +import { errorResponse } from '@/lib/errors'; +import { ALERT_RULES } from '@/lib/db/schema/insights'; +import { dismissAllForPort } from '@/lib/services/alerts.service'; + +const bodySchema = z.object({ + ruleId: z.enum(ALERT_RULES).optional(), + severity: z.enum(['info', 'warning', 'critical']).optional(), +}); + +export const POST = withAuth(async (req, ctx) => { + try { + const { ruleId, severity } = await parseBody(req, bodySchema); + const dismissed = await dismissAllForPort(ctx.portId, ctx.userId, { ruleId, severity }); + return NextResponse.json({ data: { dismissed } }); + } catch (error) { + return errorResponse(error); + } +}); diff --git a/src/components/alerts/alert-card.tsx b/src/components/alerts/alert-card.tsx index a8e090df..ac0465d8 100644 --- a/src/components/alerts/alert-card.tsx +++ b/src/components/alerts/alert-card.tsx @@ -62,7 +62,7 @@ export function AlertCard({ alert, readOnly = false }: AlertCardProps) { {!readOnly ? ( -