const mongoose = require('mongoose')
const timestamp = require('mongoose-timestamp')

const requestSchema = new mongoose.Schema({
  project: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Project',
    required: true
  },
  user: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    required: true
  },
  time: {
    type: Number,
    required: true
  },
  price: {
    type: Number,
    required: true
  },
  status: {
    type: String,
    enum: ['pending', 'accepted', 'rejected'],
    default: 'pending'
  }
})

requestSchema.plugin(timestamp)

const RequestModel = mongoose.model('Request', requestSchema)
module.exports = RequestModel
