import { useRecoilValue } from 'recoil'

import { isIOS } from 'config/userAgent'
import { isLffClient } from 'config/clients'

import { HeaderMenu } from 'features/HeaderMenu'
import { DateFilter } from 'features/HeaderFilters'
import { ScoreSwitch } from 'features/MatchSwitches'
import { SportsFilter } from 'features/SportsFilter'
import { isSportFilterShownAtom } from 'features/HomePage/Atoms/HomePageAtoms'
import { SmartBanner } from 'components/SmartBanner'

import {
  HeaderStyled,
  ScoreSwitchWrapper,
  ScSportsWrapper,
} from './styled'

type HeaderBannerProps = {
  isOpenDownload: boolean,
  setIsOpenDownload: (open: boolean) => void,
}

export const HeaderMobile = ({ isOpenDownload, setIsOpenDownload }: HeaderBannerProps) => {
  const isSportFilterShown = useRecoilValue(isSportFilterShownAtom)

  return (
    <>
      {
        isOpenDownload
        && !isIOS
        && <SmartBanner setIsOpenDownload={setIsOpenDownload} />
      }
      <HeaderStyled>
        <HeaderMenu />
        <DateFilter />
        <ScSportsWrapper>
          {!isLffClient && isSportFilterShown ? <SportsFilter /> : null}
          <ScoreSwitchWrapper>
            <ScoreSwitch />
          </ScoreSwitchWrapper>
        </ScSportsWrapper>
      </HeaderStyled>
    </>
  )
}
