const mongoose = require('mongoose');

const tableSchema = new mongoose.Schema({
  number: String,
  capacity: Number,
  isAvailable: {
    type: Boolean,
    default: true
  }
});

const restaurantSchema = new mongoose.Schema({
  owner: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    required: true,
  },
  name: {
    type: String,
    required: [true, 'Restaurant name is required'],
  },
  location: {
    type: String,
    required: true,
  },
  cuisine: {
    type: String,
    default: 'Modern Fusion'
  },
  priceRange: {
    type: String,
    default: '$$$'
  },
  description: String,
  menu: [{
    name: String,
    price: Number,
    category: String,
    image: String
  }],
  openingTime: {
    type: String,
    default: '10:00 AM'
  },
  closingTime: {
    type: String,
    default: '10:00 PM'
  },
  tables: [tableSchema],
  image: String,
  createdAt: {
    type: Date,
    default: Date.now,
  },
});

const Restaurant = mongoose.model('Restaurant', restaurantSchema);
module.exports = Restaurant;
