const mongoose = require('mongoose')
const timestamp = require('mongoose-timestamp')
const mongoosePaginate = require('mongoose-paginate-v2')

const advertisingProfileSchema = new mongoose.Schema({
  user: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    required: true
  },
  profile_image: {
    type: String,
    required: false,
    trim: true,
    default: null
  },
  image_count: {
    type: Number,
    default: 0
  },
  like_count: {
    type: Number,
    default: 0
  },
  comment_count: {
    type: Number,
    default: 0
  },
  vitrine_name: {
    type: String,
    required: false,
    trim: true,
    minLength: 1,
    maxLength: 255,
    default: null
  },
  category: {
    type: String,
    required: false,
    trim: true,
    minLength: 1,
    maxLength: 255,
    default: null
  },
  about_us: {
    type: String,
    required: false,
    minLength: 1,
    maxLength: 1024,
    default: null
  },
  province: {
    type: Object,
    default: null
  },
  city: {
    type: Object,
    default: null
  },
  lat: {
    type: String,
    trim: true,
    minLength: 1,
    maxLength: 512,
    default: null
  },
  lng: {
    type: String,
    trim: true,
    minLength: 1,
    maxLength: 512,
    default: null
  },
  address: {
    type: String,
    required: false,
    trim: true,
    default: null
  },
  neighbourhood: {
    type: String,
    required: false,
    trim: true,
    default: null
  },
  adTotalRatings: {
    type: Number,
    default: 0
  },
  adRatingsCount: {
    type: Number,
    default: 0
  },
  adAverageRating: {
    type: Number,
    default: 0
  },
  contactInfo: {
    phone: String,
    mobile: String,
    telegramLink: String,
    whatsappNumber: String,
    instagramLink: String,
    saveInfoForNextAds: { type: Boolean, default: false }
  }
})

advertisingProfileSchema.plugin(timestamp)
advertisingProfileSchema.plugin(mongoosePaginate)

const AdvertisingProfileModel = mongoose.model('AdvertisingProfile', advertisingProfileSchema)

module.exports = AdvertisingProfileModel
