mirror of
https://git.coastit.co.za/caitlin/CRM_ENVR.git
synced 2026-07-12 20:17:16 +02:00
21 lines
625 B
TypeScript
21 lines
625 B
TypeScript
import { NextResponse } from "next/server"
|
|
import { getSessionUser } from "@/lib/auth"
|
|
import { fetchJobs } from "@/lib/ai"
|
|
|
|
export async function GET() {
|
|
try {
|
|
const user = await getSessionUser()
|
|
if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
|
|
|
|
if (!["sales", "admin", "super_admin"].includes(user.role)) {
|
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 })
|
|
}
|
|
|
|
const jobs = await fetchJobs()
|
|
return NextResponse.json({ jobs })
|
|
} catch {
|
|
console.warn("Failed to fetch AI jobs in API route")
|
|
return NextResponse.json({ jobs: [] })
|
|
}
|
|
}
|