import mongoose from 'mongoose';

const storeSettingsSchema = new mongoose.Schema(
  {
    storeName: { type: String, default: 'My Store' },
    storeAddress: { type: String, default: '' },
    contactDetails: { type: String, default: '' },
    storeEmail: { type: String, default: '' },
    gstin: { type: String, default: '' },
    discountConfig: {
      tier1: { min: { type: Number, default: 1 }, max: { type: Number, default: 4 }, discount: { type: Number, default: 0 } },
      tier2: { min: { type: Number, default: 5 }, max: { type: Number, default: 9 }, discount: { type: Number, default: 5 } },
      tier3: { min: { type: Number, default: 10 }, max: { type: Number, default: 9999 }, discount: { type: Number, default: 10 } },
    },
    receipt: {
      width: { type: String, enum: ['58mm', '80mm'], default: '80mm' },
      footerMessage: { type: String, default: 'Thank you for shopping! Please visit again.' },
      returnPolicy: { type: String, default: '' },
      autoPrint: { type: Boolean, default: false },
    },
    refundApprovalLimit: { type: Number, default: 5000, min: 0 },
  },
  { timestamps: true, strict: false }
);

export default mongoose.model('StoreSettings', storeSettingsSchema);
