Calender & Linked Added

This commit is contained in:
JCBSComputer
2026-06-26 16:38:18 +02:00
parent ffa595451e
commit 68483e9b60
35 changed files with 5042 additions and 118 deletions
+28
View File
@@ -0,0 +1,28 @@
import { NextRequest, NextResponse } from "next/server"
import { getSessionUser } from "@/lib/auth"
import { query } from "@/lib/db"
export async function GET() {
try {
const user = await getSessionUser()
if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
const isAdmin = user.role === "admin" || user.role === "super_admin"
if (!isAdmin) return NextResponse.json({ error: "Forbidden" }, { status: 403 })
const result = await query(
`SELECT id, recipient, subject, body_text, created_at FROM sent_emails ORDER BY created_at DESC LIMIT 50`,
)
return NextResponse.json({ emails: result.rows.map((r: any) => ({
id: r.id,
recipient: r.recipient,
subject: r.subject,
bodyText: r.body_text,
createdAt: r.created_at,
})) })
} catch (error) {
console.error("Emails GET error:", error)
return NextResponse.json({ error: "Failed to load sent emails" }, { status: 500 })
}
}