import { useContext } from 'react'

import { ArtistContext } from '../contexts/ArtistContext'
import { GraphQLContext } from '../contexts/GraphQLContext'
import { GetArtistVideosQuery } from '../graphql/__generated__/sdk'
import { useNetwork } from './useNetwork'

export function useVideos() {
  const g = useContext(GraphQLContext)
  const artist = useContext(ArtistContext)

  const variables = {
    artistId: artist.sonyArtistId,
  }

  const response = useNetwork<GetArtistVideosQuery>(
    g.useGetArtistVideos(`${artist.sonyArtistId}/videos`, variables, {
      shouldRetryOnError: false,
    })
  )

  return response
}
