import AppError from "../../errors/AppError";
import SchedulingNotify from "../../models/SchedulingNotify";
import { getIO } from "../../libs/socket";


const DeleteSchedulingNotifyService = async (id: string | number): Promise<void> => {
    const schedulingNotify = await SchedulingNotify.findOne({
      where: { id }
    });
  
    if (!schedulingNotify) {
      throw new AppError("ERR_NO_SCHEDULING_NOTIFY_FOUND", 404); 
    }
  
    await schedulingNotify.destroy();

    const io = getIO();
    io.emit("schedulingNotify", {action: "delete", schedulingNotifyId: id});  
    
    
  };
  
  export default DeleteSchedulingNotifyService;