import { isMobileDevice } from 'config'

import { usePageLogger } from 'hooks'

import { ProfileHeader } from 'features/ProfileHeader'
import { ProfileCard } from 'features/ProfileCard'
import { Matches } from 'features/Matches'
import { UserFavorites } from 'features/UserFavorites'
import {
  PageWrapper,
  Main,
  Content,
} from 'features/PageLayout'
import { BuyMatchPopup } from 'features/BuyMatchPopup'

import { useTeamPage } from './hooks'

const TeamPage = () => {
  usePageLogger()
  const {
    fetchMatches,
    headerImage,
    profile,
    teamId,
  } = useTeamPage()

  return (
    <PageWrapper>
      <ProfileHeader
        headerImage={headerImage}
        profileId={teamId}
      >
        {profile && <ProfileCard profile={profile} />}
      </ProfileHeader>
      <Main>
        <UserFavorites />
        <Content>
          <Matches fetch={fetchMatches} />
        </Content>
      </Main>
      {!isMobileDevice && <BuyMatchPopup />}
    </PageWrapper>
  )
}

export default TeamPage
