import mongoose from "mongoose";

const slotSchema = new mongoose.Schema(
  {
    start: { type: String, required: true }, // "09:00"
    end: { type: String, required: true }, // "11:00"
  },
  { _id: false },
);

const availabilitySchema = new mongoose.Schema(
  {
    day: {
      type: String,
      required: true,
      enum: [
        "Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday",
        "Saturday",
        "Sunday",
      ],
    },

    slots: [slotSchema], // ✅ FIXED HERE

    timezone: {
      type: String,
      default: "-05:00",
    },

    isActive: {
      type: Boolean,
      default: false,
    },
  },
  { _id: false },
);
const teacherSchema = new mongoose.Schema(
  {
    userId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
      required: true,
    },
    bio: {
      type: String,
      default: "",
    },

    introVideo: {
      type: String,
      default: "",
    },
    thumbnail: {
      type: String,
    },
    skills: [
      {
        type: String,
      },
    ],

    hourlyRate: {
      type: Number,

      min: 0,
    },
    isApproved: {
      type: Boolean,
      default: false,
    },
    availability: [availabilitySchema],
  },
  { timestamps: true },
);

export const Teacher = mongoose.model("Teacher", teacherSchema);
