import type { AdType } from 'requests'

import { isMobileDevice } from 'config'

import type { AdsPropsType } from './types'
import { AdComponent } from './components/AdComponent'
import { MobileAd } from './components/MobileAd'

import {
  HeaderWrapAd,
} from './styled'

export const HeaderAds = ({ ads }: AdsPropsType) => (
  ads?.length ? (
    <HeaderWrapAd column={ads?.length}>
      {ads.map((ad: AdType) => (
        !isMobileDevice ? (
          <AdComponent
            ad={ad}
            key={ad.id}
          />
        ) : (
          <MobileAd
            ad={ad}
            key={ad.id}
          />
        )
      ))}
    </HeaderWrapAd>
  ) : null
)
