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

export async function GET() {
  try {
    const service = getMorningSummaryService();
    const config = await service.getConfig();
    return NextResponse.json({ config });
  } catch (error) {
    console.error('[GET /api/notifications/morning-summary/config]', error);
    return NextResponse.json({ error: String(error) }, { status: 500 });
  }
}

export async function PUT(request: NextRequest) {
  try {
    const body = await request.json();
    const service = getMorningSummaryService();
    const config = await service.updateConfig(body);
    return NextResponse.json({ config });
  } catch (error) {
    console.error('[PUT /api/notifications/morning-summary/config]', error);
    return NextResponse.json({ error: String(error) }, { status: 500 });
  }
}
