import { db } from "@/lib/db"
import type { PrismaClient } from "@prisma/client"

import type { ShiftInput } from "./schema"

const prisma = db as PrismaClient

export async function listShiftsAdmin() {
  return prisma.shift.findMany({ orderBy: { name: "asc" } })
}

export async function createShift(input: ShiftInput) {
  return prisma.shift.create({
    data: {
      name: input.name,
      startTime: input.startTime,
      endTime: input.endTime,
    },
  })
}

export async function deleteShift(id: string) {
  return prisma.shift.delete({ where: { id } })
}
