import { usePageLogger } from 'hooks/usePageLogger'

import { ProfileHeader } from 'features/ProfileHeader'
import { UserFavorites } from 'features/UserFavorites'
import {
  PageWrapper,
  Main,
} from 'features/PageLayout'

import { MatchProfileCard } from './components/MatchProfileCard'
import { FinishedMatch } from './components/FinishedMatch'
import { LiveMatch } from './components/LiveMatch'
import { useMatchProfile } from './hooks/useMatchProfile'
import { Wrapper } from './styled'

const MatchPage = () => {
  usePageLogger()
  const profile = useMatchProfile()
  const hasVideo = profile?.has_video

  return (
    <PageWrapper>
      <ProfileHeader color='rgb(0,0,0)' height={4.5}>
        <MatchProfileCard profile={profile} />
      </ProfileHeader>
      <Main>
        <UserFavorites />
        <Wrapper>
          {(!hasVideo && profile) && <LiveMatch />}
          {(hasVideo && profile) && <FinishedMatch profile={profile} />}
        </Wrapper>
      </Main>
    </PageWrapper>
  )
}

export default MatchPage
