const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const customerSchema = new Schema({
  companyId: {
    type: Schema.Types.ObjectId,
    ref: 'Company',  // Assuming you have a Company model
    required: true
  },
  name: {
    type: String,
    required: true
  },
  phone: {
    type: String,
    required: false
  },
  customerType: {
    type: String,
    enum: ['supplier', 'customer'],
    required: true,
    default: 'customer' // Set default to 'customer'
  },

  status: {
    type: String,
    enum: ['active', 'inactive'],
    default: 'active' // Set default status
  }
}, { timestamps: true });

// Correctly export the model
module.exports = mongoose.model('Customer', customerSchema);
