import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';

@Injectable()
export class ScheduleService {
  constructor(private prisma: PrismaService) {}

  async findAll() {
    return this.prisma.schedule.findMany({ include: { doctor: true, poli: true }, orderBy: [{ day: 'asc' }, { startTime: 'asc' }] });
  }

  async create(data: { doctorId: number; poliId: number; day: string; startTime: string; endTime: string; room?: string }) {
    return this.prisma.schedule.create({ data });
  }

  async update(id: number, data: { day?: string; startTime?: string; endTime?: string; room?: string }) {
    return this.prisma.schedule.update({ where: { id }, data });
  }

  async remove(id: number) {
    return this.prisma.schedule.delete({ where: { id } });
  }
}
