import { OrderedParams, TemplateContent } from './types'
import { createModule } from './createModule'
import { SocialProfileLinkTypes } from '../../redux/User/types'
import { ModuleType } from '@komi-app/shared-types'

export function createBusinessTemplate(): TemplateContent {
  return {
    avatar:
      'https://komi-production-assets.s3-accelerate.amazonaws.com/photos/_nrQDlCdYlLcSW0MssswJ.png?tr=w-564%2Ch-709%2Ccm-extract%2Cx-0%2Cy-0&crp=%7B%22x%22%3A0%2C%22y%22%3A0%2C%22zoomVal%22%3A1%7D',
    socialProfileLinks: [
      {
        link: 'https://www.instagram.com/instagram',
        type: SocialProfileLinkTypes.INSTAGRAM
      },
      {
        link: 'https://www.example.com',
        type: SocialProfileLinkTypes.WEBSITE
      },
      {
        link: 'example@example.com',
        type: SocialProfileLinkTypes.EMAIL
      },
      {
        link: 'https://www.facebook.com/facebook',
        type: SocialProfileLinkTypes.FACEBOOK
      },
      {
        link: 'https://www.tiktok.com/@tiktok',
        type: SocialProfileLinkTypes.TIKTOK
      }
    ],

    modules: [
      createFeaturedVideoModule({ order: 0 }),
      createSharePressModule({ order: 1 }),
      createPostcastAppearancesModule({ order: 2 }),
      createFormModule({ order: 3 }),
      createProductModule({ order: 4 })
    ]
  }
}

function createFeaturedVideoModule({ order }: { order: number }) {
  return createModule({
    type: ModuleType.YOUTUBE_VIDEO,
    name: 'Featured Video',
    order,
    data: {
      items: [
        {
          metadata: {
            title: 'Welcome to ELEAT',
            author_name: 'ELEAT',
            author_url: 'https://www.youtube.com/@ELEAT_CEREAL',
            type: 'video',
            height: 113,
            width: 200,
            version: '1.0',
            provider_name: 'YouTube',
            provider_url: 'https://www.youtube.com/',
            thumbnail_height: 360,
            thumbnail_width: 480,
            thumbnail_url: 'https://i.ytimg.com/vi/s8rUMJ--dhk/hqdefault.jpg',
            html: '<iframe width="200" height="113" src="https://www.youtube.com/embed/s8rUMJ--dhk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen title="Welcome to ELEAT"></iframe>'
          },
          url: 'https://www.youtube.com/watch?v=s8rUMJ--dhk',
          visible: true
        }
      ]
    }
  })
}

const createSharePressModule = ({ order }: OrderedParams) => {
  return createModule({
    type: ModuleType.LINK,
    name: 'Share Press',
    order,
    data: {
      items: [
        {
          url: 'https://www.rollingstone.co.uk/tv/features/munya-chawawa-interview-comedy-rolling-stone-33917/',
          order: 0,
          title:
            'Rolling Stone | Munya Chawawa on redefining masculinity through his comedy',
          visible: true,
          thumbnail:
            'https://komi-production-assets.s3-accelerate.amazonaws.com/photos/EZ11NYEI_fHGqX81y4ogp.jpeg'
        },
        {
          url: 'https://www.theguardian.com/lifeandstyle/2023/oct/14/munya-chawawa-looks-back-bullies-shamed-me-for-being-proud-of-my-culture-so-id-go-home-and-write-raps-about-the-cold-hard-streets-of-norfolk',
          order: 1,
          title:
            'The Guardian | Family joke-offs, double life, and going viral',
          visible: true,
          thumbnail:
            'https://komi-production-assets.s3-accelerate.amazonaws.com/photos/GpXr-LjUoaxYA9sCAFXv_.jpeg'
        }
      ]
    }
  })
}

const createProductModule = ({ order }: OrderedParams) => {
  return createModule({
    type: ModuleType.PRODUCT,
    name: 'Our Products',
    order,
    data: {
      items: [
        {
          url: 'https://www.jomalone.co.uk/product/25969/10082/home-collection/pomegranate-noir-home-candle?size=200g',
          order: 0,
          price: 56,
          title: 'Pomegranate Noir Home Candle',
          visible: true,
          currency: 'GBP',
          thumbnail:
            'https://komi-production-assets.s3-accelerate.amazonaws.com/photos/7bc8hDw2yYpJ2QyWBDWh-.jpg'
        },
        {
          url: 'https://www.jomalone.co.uk/product/26322/103765/gift-sets/most-loved-mini-candles-trio?size=3_x_60g&gad=1&gclid=Cj0KCQjwj5mpBhDJARIsAOVjBdqsAuOmcll5I-Zoui2aCWq8LHinTxgnSq0LmIcRs9me3ZdkcCkWQAMaAnxhEALw_wcB&gclsrc=aw.ds',
          order: 1,
          price: 84,
          title: 'Most Loved Mini Candles Trio',
          visible: true,
          currency: 'GBP',
          thumbnail:
            'https://komi-production-assets.s3-accelerate.amazonaws.com/photos/40b1YJRJMIAjFSHzUzQeb.jpg'
        },
        {
          url: 'https://www.fortnumandmason.com/jo-malone-london-pomegranate-noir-home-candle-200g?gclid=Cj0KCQjwj5mpBhDJARIsAOVjBdpP-DhB8b1u51bgE5p-0xCUReEsoT55FsaBN-zJN7ASPzWyL4KeHzUaApEbEALw_wcB&gclsrc=aw.ds',
          order: 2,
          price: 56,
          title: 'Jo Malone London Pomegranate Noir Home Candle, 200g',
          visible: true,
          currency: 'GBP',
          thumbnail:
            'https://komi-production-assets.s3-accelerate.amazonaws.com/photos/UzSwDKWhzpu5HeUqIEpO8.jpg'
        }
      ]
    }
  })
}

const createFormModule = ({ order }: OrderedParams) => {
  return createModule({
    type: ModuleType.FORM_DATA,
    name: 'Sign Up Now',
    order,
    data: {
      items: [
        {
          form: {
            name: 'Updates',
            fields: [
              {
                name: 'INPUT',
                type: 'INPUT',
                label: 'Name',
                required: true
              },
              {
                name: 'EMAIL_ADDRESS',
                type: 'EMAIL_ADDRESS',
                label: 'Email',
                required: true
              }
            ]
          },
          title: 'Exclusive updates',
          layout: 'left',
          visible: true,
          subTitle: 'Receive updates and exclusive discounts',
          enableImage: false
        }
      ]
    }
  })
}

const createPostcastAppearancesModule = ({ order }: OrderedParams) => {
  return createModule({
    order: 0,
    name: 'Podcast Appearance',
    type: ModuleType.PODCAST,
    data: {
      items: [
        {
          links: [
            {
              type: 'SPOTIFY',
              url: 'https://open.spotify.com/episode/0WhokFSgLKuLzwGOWMB8bv?si=4487729d1ce84b61&nd=1&dlsi=f4abac7af2ee47fb'
            }
          ],
          customUrl:
            'e36-hugh-and-hywel-redefining-the-cereal-market-with-eleat-performance-cereal-for-everyone',
          metadata: {
            name: 'E.36 Hugh and Hywel Redefining The Cereal Market with ELEAT; Performance Cereal for Everyone',
            images: [
              {
                url: 'https://i.scdn.co/image/ab67656300005f1f590e4c3c90bca339f64fad26'
              }
            ],
            publisher: 'Georgia Symonds',
            previewUrl:
              'https://podz-content.spotifycdn.com/audio/clips/4OlZqKBg9goPcec6QRD09V/clip_0_60000.mp3'
          },
          order: 0,
          visible: true
        }
      ]
    }
  })
}
