|
@@ -1,23 +1,43 @@
|
|
import styled from '@emotion/styled'
|
|
import styled from '@emotion/styled'
|
|
import React, { FC } from 'react'
|
|
import React, { FC } from 'react'
|
|
|
|
|
|
|
|
+import { useMostViewedVideosAllTimeIds } from '@/api/hooks'
|
|
import { useMostViewedVideos } from '@/api/hooks'
|
|
import { useMostViewedVideos } from '@/api/hooks'
|
|
import { useMostViewedChannelsAllTimeIds } from '@/api/hooks'
|
|
import { useMostViewedChannelsAllTimeIds } from '@/api/hooks'
|
|
-import { InfiniteChannelWithVideosGrid, VideoGallery, ViewWrapper } from '@/components'
|
|
|
|
|
|
+import { InfiniteChannelWithVideosGrid, InfiniteVideoGrid, VideoGallery, ViewWrapper } from '@/components'
|
|
import { absoluteRoutes } from '@/config/routes'
|
|
import { absoluteRoutes } from '@/config/routes'
|
|
import { CallToActionButton, CallToActionWrapper, Text } from '@/shared/components'
|
|
import { CallToActionButton, CallToActionWrapper, Text } from '@/shared/components'
|
|
import { SvgNavChannels, SvgNavHome, SvgNavNew } from '@/shared/icons'
|
|
import { SvgNavChannels, SvgNavHome, SvgNavNew } from '@/shared/icons'
|
|
import { sizes } from '@/shared/theme'
|
|
import { sizes } from '@/shared/theme'
|
|
|
|
|
|
export const PopularView: FC = () => {
|
|
export const PopularView: FC = () => {
|
|
|
|
+ const {
|
|
|
|
+ mostViewedVideosAllTime,
|
|
|
|
+ loading: mostViewedVideosLoading,
|
|
|
|
+ error: mostViewedVideosError,
|
|
|
|
+ } = useMostViewedVideosAllTimeIds({
|
|
|
|
+ limit: 200,
|
|
|
|
+ })
|
|
|
|
+ const mostViewedVideosIds = mostViewedVideosAllTime?.map((item) => item.id)
|
|
const { mostViewedChannelsAllTime } = useMostViewedChannelsAllTimeIds({ limit: 15 })
|
|
const { mostViewedChannelsAllTime } = useMostViewedChannelsAllTimeIds({ limit: 15 })
|
|
const mostViewedChannelsAllTimeIds = mostViewedChannelsAllTime?.map((item) => item.id)
|
|
const mostViewedChannelsAllTimeIds = mostViewedChannelsAllTime?.map((item) => item.id)
|
|
const { videos, loading } = useMostViewedVideos({ viewedWithinDays: 30, limit: 10 })
|
|
const { videos, loading } = useMostViewedVideos({ viewedWithinDays: 30, limit: 10 })
|
|
|
|
+
|
|
|
|
+ if (mostViewedVideosError) {
|
|
|
|
+ throw mostViewedVideosError
|
|
|
|
+ }
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<StyledViewWrapper>
|
|
<StyledViewWrapper>
|
|
<Header variant="h2">Popular</Header>
|
|
<Header variant="h2">Popular</Header>
|
|
<StyledVideoGallery hasRanking title="Top 10 this month" videos={videos || []} loading={loading} />
|
|
<StyledVideoGallery hasRanking title="Top 10 this month" videos={videos || []} loading={loading} />
|
|
- <StyledInfiniteChannelWithVideosGrid
|
|
|
|
|
|
+ <StyledInfiniteVideoGrid
|
|
|
|
+ title="Popular videos"
|
|
|
|
+ idIn={mostViewedVideosIds}
|
|
|
|
+ ready={!mostViewedVideosLoading}
|
|
|
|
+ onDemand
|
|
|
|
+ />
|
|
|
|
+ <InfiniteChannelWithVideosGrid
|
|
title="Popular channels"
|
|
title="Popular channels"
|
|
onDemand
|
|
onDemand
|
|
idIn={mostViewedChannelsAllTimeIds}
|
|
idIn={mostViewedChannelsAllTimeIds}
|
|
@@ -59,7 +79,7 @@ const StyledViewWrapper = styled(ViewWrapper)`
|
|
padding-bottom: ${sizes(10)};
|
|
padding-bottom: ${sizes(10)};
|
|
`
|
|
`
|
|
|
|
|
|
-const StyledInfiniteChannelWithVideosGrid = styled(InfiniteChannelWithVideosGrid)`
|
|
|
|
|
|
+const StyledInfiniteVideoGrid = styled(InfiniteVideoGrid)`
|
|
:not(:last-of-type) {
|
|
:not(:last-of-type) {
|
|
margin-bottom: ${sizes(38)};
|
|
margin-bottom: ${sizes(38)};
|
|
}
|
|
}
|