samoulla-backend / models /whyChooseUsModel.js
Samoulla Sync Bot
Auto-deploy Samoulla Backend: 8574a71f0fc617aeb1ce9b5e35dac24c5319a12a
59c49c1
const mongoose = require('mongoose');
const whyChooseUsItemSchema = new mongoose.Schema(
{
icon: {
type: String,
default: 'FaShippingFast',
},
titleAr: {
type: String,
required: true,
},
titleEn: {
type: String,
default: '',
},
descriptionAr: {
type: String,
required: true,
},
descriptionEn: {
type: String,
default: '',
},
order: {
type: Number,
default: 0,
},
},
{ _id: true },
);
const whyChooseUsSchema = new mongoose.Schema(
{
isEnabled: {
type: Boolean,
default: true,
},
sectionTitleAr: {
type: String,
default: 'لماذا تختارنا؟',
},
sectionTitleEn: {
type: String,
default: 'Why Choose Us?',
},
items: [whyChooseUsItemSchema],
},
{
timestamps: true,
},
);
// Ensure only one settings document exists
whyChooseUsSchema.statics.getSettings = async function () {
let settings = await this.findOne();
if (!settings) {
settings = await this.create({
isEnabled: true,
sectionTitleAr: 'لماذا تختارنا؟',
sectionTitleEn: 'Why Choose Us?',
items: [
{
icon: 'FaShippingFast',
titleAr: 'شحن سريع',
titleEn: 'Fast Shipping',
descriptionAr: 'نوصل طلبك في أسرع وقت ممكن',
descriptionEn: 'We deliver your order as fast as possible',
order: 0,
},
{
icon: 'BsPatchCheck',
titleAr: 'جودة مضمونة',
titleEn: 'Quality Guaranteed',
descriptionAr: 'منتجات أصلية بأعلى معايير الجودة',
descriptionEn: 'Original products with the highest quality standards',
order: 1,
},
{
icon: 'BsHeadset',
titleAr: 'دعم متواصل',
titleEn: '24/7 Support',
descriptionAr: 'فريق دعمنا متاح على مدار الساعة',
descriptionEn: 'Our support team is available around the clock',
order: 2,
},
{
icon: 'BsShieldCheck',
titleAr: 'دفع آمن',
titleEn: 'Secure Payment',
descriptionAr: 'معاملاتك محمية دائماً',
descriptionEn: 'Your transactions are always protected',
order: 3,
},
],
});
}
return settings;
};
module.exports = mongoose.model('WhyChooseUs', whyChooseUsSchema);