import mongoose from "mongoose";

const vendorSchema = new mongoose.Schema(
  {
    owner: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true },
    storeName: { type: String, required: true, index: true },
    slug: { type: String, required: true, unique: true },
    category: String,
    logo: String,
    banner: String,
    kycStatus: { type: String, enum: ["pending", "approved", "rejected"], default: "pending" },
    rating: { type: Number, default: 0 },
    totalOrders: { type: Number, default: 0 },
    payoutAccount: {
      bankName: String,
      accountNumber: String,
      accountName: String
    },
    analytics: {
      revenue: { type: Number, default: 0 },
      conversionRate: { type: Number, default: 0 },
      responseRate: { type: Number, default: 0 }
    }
  },
  { timestamps: true }
);

export const Vendor = mongoose.model("Vendor", vendorSchema);
