26 lines
691 B
TypeScript
26 lines
691 B
TypeScript
import { prisma } from "@/lib/prisma"
|
|
import { auth } from "@/lib/auth"
|
|
import { NextResponse } from "next/server"
|
|
|
|
export async function GET() {
|
|
const session = await auth()
|
|
|
|
if (!session?.user?.email) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
|
|
}
|
|
|
|
const manager = await prisma.shiftManager.findFirst({
|
|
where: { email: session.user.email },
|
|
include: {
|
|
teams: true
|
|
}
|
|
})
|
|
|
|
if (!manager || !manager.teams || manager.teams.length === 0) {
|
|
return NextResponse.json({ error: "No team assigned" }, { status: 404 })
|
|
}
|
|
|
|
// Return the first team (managers should only have one team)
|
|
return NextResponse.json(manager.teams[0])
|
|
}
|