import mongoose, { Document, Schema } from 'mongoose';

export interface ILocalizedString {
  en: string;
  zh: string;
}

const localizedStringSchema = {
  en: { type: String, default: '' },
  zh: { type: String, default: '' },
};

export interface IBonusPoints extends Document {
  heroTitle: ILocalizedString;
  heroSubtitle: ILocalizedString;
  heroImage?: string;
  highlights: Array<{
    value: string;
    label: ILocalizedString;
  }>;
  products: Array<{
    brand: ILocalizedString;
    name: ILocalizedString;
    image?: string;
    pointsRequired: string;
  }>;
  ctaTitle: ILocalizedString;
  ctaHotline?: string;
  ctaButtonText: ILocalizedString;
  ctaButtonLink?: string;
  updatedAt: Date;
}

const bonusPointsSchema = new Schema<IBonusPoints>(
  {
    heroTitle: {
      type: localizedStringSchema,
      default: { en: 'Bonus Points', zh: '積分獎賞' },
    },
    heroSubtitle: {
      type: localizedStringSchema,
      default: {
        en: 'Earn 1 Bonus Point for every $1 spent with your card. Accumulate Bonus Points to redeem a wide range of exclusive golf-related products and elevate your golfing experience!',
        zh: '每消費$1即可賺取1積分。累積積分可兌換各種獨家高爾夫相關產品，提升您的高爾夫體驗！',
      },
    },
    heroImage: String,
    highlights: [
      {
        value: { type: String, default: '' },
        label: { type: localizedStringSchema },
      },
    ],
    products: [
      {
        brand: { type: localizedStringSchema },
        name: { type: localizedStringSchema },
        image: String,
        pointsRequired: { type: String, default: '' },
      },
    ],
    ctaTitle: {
      type: localizedStringSchema,
      default: { en: 'Enjoy Golf ID Now!', zh: '立即尊享高球証！' },
    },
    ctaHotline: { type: String, default: '(852) 3582-3088' },
    ctaButtonText: {
      type: localizedStringSchema,
      default: { en: 'Enjoy Golf ID', zh: '尊享高球証' },
    },
    ctaButtonLink: { type: String, default: 'https://golfcard.com.hk/register' },
  },
  {
    timestamps: true,
  }
);

export const BonusPoints = mongoose.model<IBonusPoints>('BonusPoints', bonusPointsSchema);
