26 lines
579 B
TypeScript
26 lines
579 B
TypeScript
import { prisma } from "@/lib/prisma"
|
|
import { NextResponse } from "next/server"
|
|
import bcrypt from "bcryptjs"
|
|
|
|
export async function GET() {
|
|
const managers = await prisma.shiftManager.findMany({
|
|
where: { status: "active" }
|
|
})
|
|
return NextResponse.json(managers)
|
|
}
|
|
|
|
export async function POST(req: Request) {
|
|
const body = await req.json()
|
|
|
|
const defaultPassword = await bcrypt.hash("muller123", 10)
|
|
|
|
const manager = await prisma.shiftManager.create({
|
|
data: {
|
|
...body,
|
|
password: defaultPassword
|
|
}
|
|
})
|
|
|
|
return NextResponse.json(manager)
|
|
}
|