const mongoose = require('mongoose')

const GuaranteeReportSchema = mongoose.Schema({
  // system structure
  _openedBy: { type: mongoose.ObjectId, ref: 'User' },
  _updatedBy: { type: mongoose.ObjectId, ref: 'User' },
  user_id: { type: mongoose.ObjectId, ref: 'User' },
  agent_id: { type: mongoose.ObjectId, ref: 'Representation' },

  // form info
  description: String,
  createDate: String,
  sendDate: String,
  trackingCode: String,
  items: [
    {
      // customer info
      customerName: String,
      customerTel: String,
      // product info
      ItemName: String,
      SerialNo1: String,
      ItemID: String,
      ItemCode: String,

      // product issue
      productIssue: String,
      usedPieces: String,

      // dates
      recieveDate: String,
      deliverDate: String
    }
  ],

  // admin operations
  seen: { type: Boolean, default: false },
  archived: { type: Boolean, default: false },
  status: { type: String, enum: ['temp', 'sent'], default: 'temp' }
})

module.exports = mongoose.model('GuaranteeReport', GuaranteeReportSchema)
