import Emails from '@/analyst/Emails'
import { EmailSelection } from '@/analyst/utilities'
import { useParams } from '@/router'
import useEmailsEnabled from '@inject/graphql/utils/useEmailsEnabled'

const Home = () => {
  const { exerciseId, tab, threadId } = useParams(
    '/analyst/:exerciseId/emails/:tab/:threadId'
  )
  const emailsEnabled = useEmailsEnabled({
    variables: { exerciseId },
  })

  return emailsEnabled ? (
    <Emails
      exerciseId={exerciseId}
      tab={tab ? (tab as EmailSelection) : EmailSelection.SENT}
      threadId={threadId ? threadId : undefined}
    />
  ) : (
    'Emails are disabled for this exercise'
  )
}

export default Home
