|
|
|
|
@ -8,7 +8,7 @@ import { getMatchesPreviewImages } from 'requests' |
|
|
|
|
|
|
|
|
|
import { MatchStatuses } from 'features/HeaderFilters' |
|
|
|
|
|
|
|
|
|
import type { Matches } from './types' |
|
|
|
|
import type { MatchesBySection, Matches } from './types' |
|
|
|
|
|
|
|
|
|
const combinePreviews = (matches: Matches, previews: Previews) => ( |
|
|
|
|
map(matches, (match) => { |
|
|
|
|
@ -23,7 +23,7 @@ const combinePreviews = (matches: Matches, previews: Previews) => ( |
|
|
|
|
/** |
|
|
|
|
* Запрашивает превью картинок матчей с видео и статус которых Завершенный |
|
|
|
|
*/ |
|
|
|
|
export const getPreviews = async (matches: Matches) => { |
|
|
|
|
const getPreviews = async (matches: Matches) => { |
|
|
|
|
const previewsData = reduce( |
|
|
|
|
matches, |
|
|
|
|
(acc: PreviewsData, { |
|
|
|
|
@ -48,3 +48,34 @@ export const getPreviews = async (matches: Matches) => { |
|
|
|
|
const previews = await getMatchesPreviewImages(previewsData) |
|
|
|
|
return combinePreviews(matches, previews) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const getMatchesPreviews = async (matches: MatchesBySection) => { |
|
|
|
|
if (matches.isVideoSections) { |
|
|
|
|
const [ |
|
|
|
|
broadcast, |
|
|
|
|
features, |
|
|
|
|
highlights, |
|
|
|
|
] = await Promise.all( |
|
|
|
|
[ |
|
|
|
|
getPreviews(matches.broadcast), |
|
|
|
|
getPreviews(matches.features), |
|
|
|
|
getPreviews(matches.highlights), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
return { |
|
|
|
|
...matches, |
|
|
|
|
broadcast, |
|
|
|
|
features, |
|
|
|
|
highlights, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const broadcast = await getPreviews(matches.broadcast) |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
...matches, |
|
|
|
|
broadcast, |
|
|
|
|
features: [], |
|
|
|
|
highlights: [], |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|