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

const memberRewardsSchema = new Schema<IMemberRewards>(
  {
    heroTitle: {
      type: localizedStringSchema,
      default: { en: 'Member Rewards', zh: '會員獎勵' },
    },
    heroSubtitle: {
      type: localizedStringSchema,
      default: {
        en: 'As a valued Golf ID Member, you can enjoy exclusive merchant offers and earn points rewards on everyday spending.',
        zh: '作為尊貴的高球証會員，您可享受獨家商戶優惠，並在日常消費中賺取積分獎賞。',
      },
    },
    heroImage: String,
    highlights: [
      {
        value: { type: String, default: '' },
        label: { type: localizedStringSchema },
      },
    ],
    featureSections: [
      {
        title: { type: localizedStringSchema },
        description: { type: localizedStringSchema },
        bulletPoints: [{ type: localizedStringSchema }],
        image: String,
      },
    ],
    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 MemberRewards = mongoose.model<IMemberRewards>('MemberRewards', memberRewardsSchema);
