@ -4,6 +4,7 @@ import { defineMessages, useIntl } from 'react-intl';
import useSWR from 'swr' ;
import useSWR from 'swr' ;
import type { MediaResultsResponse } from '../../../server/interfaces/api/mediaInterfaces' ;
import type { MediaResultsResponse } from '../../../server/interfaces/api/mediaInterfaces' ;
import type { RequestResultsResponse } from '../../../server/interfaces/api/requestInterfaces' ;
import type { RequestResultsResponse } from '../../../server/interfaces/api/requestInterfaces' ;
import { Permission , useUser } from '../../hooks/useUser' ;
import PageTitle from '../Common/PageTitle' ;
import PageTitle from '../Common/PageTitle' ;
import MediaSlider from '../MediaSlider' ;
import MediaSlider from '../MediaSlider' ;
import RequestCard from '../RequestCard' ;
import RequestCard from '../RequestCard' ;
@ -28,6 +29,7 @@ const messages = defineMessages({
const Discover = ( ) = > {
const Discover = ( ) = > {
const intl = useIntl ( ) ;
const intl = useIntl ( ) ;
const { hasPermission } = useUser ( ) ;
const { data : media , error : mediaError } = useSWR < MediaResultsResponse > (
const { data : media , error : mediaError } = useSWR < MediaResultsResponse > (
'/api/v1/media?filter=allavailable&take=20&sort=mediaAdded' ,
'/api/v1/media?filter=allavailable&take=20&sort=mediaAdded' ,
@ -43,23 +45,29 @@ const Discover = () => {
return (
return (
< >
< >
< PageTitle title = { intl . formatMessage ( messages . discover ) } / >
< PageTitle title = { intl . formatMessage ( messages . discover ) } / >
< div className = "slider-header" >
{ hasPermission ( [ Permission . MANAGE_REQUESTS , Permission . RECENT_VIEW ] , {
< div className = "slider-title" >
type : 'or' ,
< span > { intl . formatMessage ( messages . recentlyAdded ) } < / span >
} ) && (
< / div >
< >
< / div >
< div className = "slider-header" >
< Slider
< div className = "slider-title" >
sliderKey = "media"
< span > { intl . formatMessage ( messages . recentlyAdded ) } < / span >
isLoading = { ! media && ! mediaError }
< / div >
isEmpty = { ! ! media && ! mediaError && media . results . length === 0 }
< / div >
items = { media ? . results ? . map ( ( item ) = > (
< Slider
< TmdbTitleCard
sliderKey = "media"
key = { ` media-slider-item- ${ item . id } ` }
isLoading = { ! media && ! mediaError }
tmdbId = { item . tmdbId }
isEmpty = { ! ! media && ! mediaError && media . results . length === 0 }
type = { item . mediaType }
items = { media ? . results ? . map ( ( item ) = > (
< TmdbTitleCard
key = { ` media-slider-item- ${ item . id } ` }
tmdbId = { item . tmdbId }
type = { item . mediaType }
/ >
) ) }
/ >
/ >
) ) }
</ >
/ >
) }
< div className = "slider-header" >
< div className = "slider-header" >
< Link href = "/requests?filter=all" >
< Link href = "/requests?filter=all" >
< a className = "slider-title" >
< a className = "slider-title" >