Client portal: profile, activity pages + middleware fix
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { query } from "@/lib/db"
|
||||
import { getPortalSession, isPortalError } from "../portal-utils"
|
||||
|
||||
export async function GET() {
|
||||
const session = await getPortalSession()
|
||||
if (isPortalError(session)) return session
|
||||
|
||||
if (!session.customerId) {
|
||||
return NextResponse.json({ projects: [] })
|
||||
}
|
||||
|
||||
const result = await query(
|
||||
`SELECT id, name, description, status, start_date, end_date, budget, currency,
|
||||
created_at, updated_at
|
||||
FROM projects
|
||||
WHERE customer_id = $1 AND deleted_at IS NULL
|
||||
ORDER BY created_at DESC`,
|
||||
[session.customerId],
|
||||
)
|
||||
|
||||
return NextResponse.json({ projects: result.rows })
|
||||
}
|
||||
Reference in New Issue
Block a user