import { NextRequest, NextResponse } from 'next/server';
import { getMorningSummaryService } from '@/lib/services/morning-summary-service';

export async function POST(request: NextRequest) {
  try {
    const body = await request.json();
    const { webhookId } = body as { webhookId: number };

    if (!webhookId) {
      return NextResponse.json({ error: 'webhookId is required' }, { status: 400 });
    }

    const service = getMorningSummaryService();
    const result = await service.testSend(webhookId);

    return NextResponse.json({ success: result.success, result });
  } catch (error) {
    console.error('[POST /api/notifications/morning-summary/test]', error);
    return NextResponse.json({ error: String(error) }, { status: 500 });
  }
}
