export interface ServiceParser {
  parse: (data: any[]) => Anniversary[]
}

export class AnniversaryServiceParsers {
  static readonly AnniversaryAppService = {
    parse: (data: any[]): Anniversary[] => {
      return data.map(item => ({
        month: item.month,
        day: item.day,
        name: item.name,
        position: item.description,
        image: item.image,
        optional: item.optional
       }))
    }
  }

  static readonly RexmasAnniversaryService = {
    parse: (data: any[]): Anniversary[] => {
      return data.map(item => ({
        month: item.month,
        day: item.day,
        name: item.name,
        position: undefined, 
        image: item.image,
        optional: undefined
      }))
    }
  }

  static readonly BukAnniversaryService = {
    parse: (data: any[]): Anniversary[] => {
      return data.map(item => ({
        month: item.month,
        day: item.day,
        name: item.name,
        position: item.position,
        image: item.image,
        optional: undefined
      }))
    }
  }

  static readonly TalanaAnniversariesService = {
    parse: (data: any[]): Anniversary[] => {
      return data.map(item => ({
        month: item.month,
        day: item.day,
        name: item.name,
        position: item.position,
        image: item.image,
        optional: undefined
      }))
    }
  }

  static getParser(serviceType: VixonicData['parameters']['displayService']): ServiceParser {
    switch (serviceType) {
      case 'RexmasAnniversarieService':
        return this.RexmasAnniversaryService
      case 'BukAnniversarieService':
        return this.BukAnniversaryService
      case 'TalanaAnniversariesService':
        return this.TalanaAnniversariesService
      default:
        return this.AnniversaryAppService 
    }
  }
}
