import mongoose from "mongoose";

const supportTicketSchema = new mongoose.Schema(
  {
    customer: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true },
    order: { type: mongoose.Schema.Types.ObjectId, ref: "Order" },
    subject: String,
    channel: { type: String, enum: ["live_chat", "email", "whatsapp", "ticket"], default: "ticket" },
    status: { type: String, enum: ["open", "pending", "resolved"], default: "open" },
    priority: { type: String, enum: ["low", "medium", "high", "urgent"], default: "medium" },
    messages: [{ sender: String, body: String, createdAt: { type: Date, default: Date.now } }]
  },
  { timestamps: true }
);

export const SupportTicket = mongoose.model("SupportTicket", supportTicketSchema);
