const mongoose = require('mongoose');

const notificationSchema = new mongoose.Schema({
    user: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Account',
        required: true,
      },
      title: {
        type: String,
        required: true,
      },
      message: {
        type: String,
        required: true,
      },
      type: {
        type: String,
        required: true,
        enum: ['order_created', 'order_accepted', 'order_rejected', 'order_shipped', 'order_completed', 'product_approved', 'product_rejected', 'payment_received', 'referral_bonus', 'general', 'deposit_successful', 'deposit_failed', 'withdrawal_successful', 'withdrawal_failed', 'transfer_received', 'transfer_sent', 'bid_created', 'bid_accepted', 'bid_rejected', 'bid_completed', 'swap_offer_received', 'swap_offer_accepted', 'swap_offer_rejected'],
        default: 'general',
      },
      isRead: {
        type: Boolean,
        required: true,
        default: false,
      },
      data: {
        type: Object,
        required: false,
      },
      fcmToken: {
        type: String,
        required: false,
      },
      sentAt: {
        type: Date,
        required: true,
      },
}, {
    timestamps: true,
    collection: 'notifications'
})

module.exports = mongoose.model("Notification", notificationSchema);