transform admin panel with comprehensive professional UI
- migrate from SQLite to PostgreSQL with Drizzle ORM - implement comprehensive AdminLayout with expandable sidebar navigation - create professional dashboard with real-time charts and metrics - add advanced monitoring, reporting, and export functionality - fix menu alignment and remove non-existent pages - eliminate duplicate headers and improve UI consistency - add Tailwind CSS v3 for professional styling - expand database schema from 6 to 15 tables - implement role-based access control and API key management - create comprehensive settings, monitoring, and system info pages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import sqlite3 from 'sqlite3'
|
||||
import path from 'path'
|
||||
import { db, schema } from '../../../../lib/db/connection'
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
@@ -17,33 +17,21 @@ export default async function handler(
|
||||
return res.status(400).json({ error: 'ID and status are required' })
|
||||
}
|
||||
|
||||
const dbPath = path.join(process.cwd(), 'database', 'antihoax.db')
|
||||
const db = new sqlite3.Database(dbPath)
|
||||
|
||||
try {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const query = `
|
||||
UPDATE reports
|
||||
SET status = ?, admin_notes = ?, processed_at = CURRENT_TIMESTAMP, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
db.run(
|
||||
query,
|
||||
[status, admin_notes || null, id],
|
||||
function(err) {
|
||||
if (err) reject(err)
|
||||
else resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
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' })
|
||||
} finally {
|
||||
db.close()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user