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 IUpgradeOffers extends Document {
  heroTitle: ILocalizedString;
  heroSubtitle: ILocalizedString;
  heroImage?: string;
  highlights: Array<{
    value: string;
    label: ILocalizedString;
  }>;
  featureSections: Array<{
    title: ILocalizedString;
    description: ILocalizedString;
    bulletPoints: ILocalizedString[];
    image?: string;
  }>;
  upgradeTiers: Array<{
    name: ILocalizedString;
    subtitle: ILocalizedString;
    features: ILocalizedString[];
    highlighted?: boolean;
  }>;
  termsAndConditions: ILocalizedString;
  ctaTitle: ILocalizedString;
  ctaHotline?: string;
  ctaButtonText: ILocalizedString;
  ctaButtonLink?: string;
  updatedAt: Date;
}

const upgradeOffersSchema = new Schema<IUpgradeOffers>(
  {
    heroTitle: {
      type: localizedStringSchema,
      default: { en: 'Upgrade Offers', zh: '升級優惠' },
    },
    heroSubtitle: {
      type: localizedStringSchema,
      default: {
        en: 'Exclusive year-round offers for Golf ID credit card members',
        zh: '高球証信用卡會員專享全年優惠',
      },
    },
    heroImage: String,
    highlights: [
      {
        value: { type: String, default: '' },
        label: { type: localizedStringSchema },
      },
    ],
    featureSections: [
      {
        title: { type: localizedStringSchema },
        description: { type: localizedStringSchema },
        bulletPoints: [{ type: localizedStringSchema }],
        image: String,
      },
    ],
    upgradeTiers: [
      {
        name: { type: localizedStringSchema },
        subtitle: { type: localizedStringSchema },
        features: [{ type: localizedStringSchema }],
        highlighted: { type: Boolean, default: false },
      },
    ],
    termsAndConditions: {
      type: localizedStringSchema,
      default: {
        en: 'All monetary terms are denominated in Hong Kong Dollars (HKD); Terms and conditions are subject to change without prior notice; Limited offers, first come first served; Golf ID credit card members can redeem Welcome Offers once per partner; All offers must be redeemed within 1 year after the Golf ID card is successfully activated; GLG & Merchant Partners retain sole & final authority regarding all matters.',
        zh: '所有金額以港幣（HKD）計算；條款及細則如有更改，恕不另行通知；優惠數量有限，先到先得；高球証信用卡會員每位合作夥伴只可兌換迎新優惠一次；所有優惠須於高球証成功激活後一年內兌換；GLG及商戶合作夥伴保留所有事項的最終決定權。',
      },
    },
    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 UpgradeOffers = mongoose.model<IUpgradeOffers>('UpgradeOffers', upgradeOffersSchema);
