import mongoose from "mongoose";

const SubscriptionSchema = new mongoose.Schema({
  user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true },

  subscription: {
    name: { type: String, required: true },
    durationMinutes: { type: Number, default: 0 },
    lessonCount: { type: Number, default: 1 },
    price: { type: Number, required: true },
    description: String,
    features: [String],
    users: [String],
  },

  price: { type: Number, required: true },
  paymentStatus: {
    type: String,
    enum: ["pending", "paid", "failed", "refunded"],
    default: "pending",
  },
  paymentIntentId: String,
  purchasedAt: Date,
  expiresAt: Date,
  usedLessons: { type: Number, default: 0 },
});

export default mongoose.model("Subscription", SubscriptionSchema);
