import type { NextApiRequest, NextApiResponse } from 'next' import { db, schema } from '../../../../lib/db/connection' import { eq } from 'drizzle-orm' export default async function handler( req: NextApiRequest, res: NextApiResponse ) { if (req.method !== 'PATCH') { return res.status(405).json({ error: 'Method not allowed' }) } const { id } = req.query const { status, admin_notes } = req.body if (!id || !status) { return res.status(400).json({ error: 'ID and status are required' }) } try { await db .update(schema.reports) .set({ status: status, adminNotes: admin_notes || null, processedAt: new Date(), updatedAt: new Date() }) .where(eq(schema.reports.id, parseInt(id as string))) return res.status(200).json({ success: true }) } catch (error) { console.error('Database error:', error) return res.status(500).json({ error: 'Internal server error' }) } }