import { NextResponse } from 'next/server';
import { withErrorHandler, RouteContext } from '@server/middleware/withErrorHandler';
import { withAuth, AuthedRequest } from '@server/middleware/withAuth';
import { resendDeliveryAttempt } from '@server/services/webhooks.service';

export const POST = withErrorHandler(
  withAuth(async (req: AuthedRequest, ctx: RouteContext) => {
    const { id } = await ctx.params;
    const attempt = await resendDeliveryAttempt(id, req.session.restaurantId!);
    return NextResponse.json({ attempt });
  })
);
