const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const refundSchema = new Schema({
    userId: {
        type: Schema.Types.ObjectId,
        ref: "User",
        required: true
    },
    adminId: {
        type: Schema.Types.ObjectId,
        ref: "Admin",
        required: true
    },
    shopId: {
        type: Schema.Types.ObjectId,
        ref: "Order",
        required: true
    },
    orderId: {
        type: Schema.Types.ObjectId,
        ref: "Order"
    },
    transactionId:{
        type: String,
        required: true
    },
    products:[{
        type: Schema.Types.ObjectId,
        ref: "Product",
        requried: true
    }],
    condition: {
        type: String,
        required: true
    },
    reason:{
        type: String,
        required: true
    },
    shippingMethod: {
        type: String,
        enum: ["Standard", "In-Store"],
        required: true
    },
    receivingMethod:{
        type: String,
        enum: ["I would like a store voucher", "I want a refund", "I would like a replacement product"],
        required: true
    },
    status:{
        type: String,
        enum: ["Pending", "Approved", "Rejected", "Refund Completed"],
        default: "Pending"
    }
}, { timestamps: true });

const refundModel = mongoose.model("Refund", refundSchema);
module.exports = refundModel;