import useGetSelectedTeams from '@/instructor/InstructorTeamSelector/useGetSelectedTeams'
import { useParams } from '@/router'
import useActionLogSubscriptionInstructor from '@inject/graphql/utils/Subscriptions/instructor'
import useQuestionnaireSubscriptionInstructor from '@inject/graphql/utils/Subscriptions/instructorQuestionnaireState'
import { Outlet } from 'react-router-dom'

const LayoutExercise = () => {
  const { exerciseId } = useParams('/instructor/:exerciseId')

  const selectedTeamStates = useGetSelectedTeams(exerciseId)

  useActionLogSubscriptionInstructor({
    exerciseId,
  })
  useQuestionnaireSubscriptionInstructor({
    exerciseId,
    teamIds: selectedTeamStates.map(team => team.id),
  })

  return <Outlet />
}

export default LayoutExercise
