import { usePageLogger } from 'hooks/usePageLogger'

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 { useTournamentPage } from './hooks'

const TournamentPage = () => {
  usePageLogger()
  const {
    fetchMatches,
    headerImage,
    profile,
    tournamentId,
  } = useTournamentPage()

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

export default TournamentPage
