|
|
|
|
@ -1,13 +1,22 @@ |
|
|
|
|
import React, { |
|
|
|
|
RefObject, |
|
|
|
|
useEffect, |
|
|
|
|
useState, |
|
|
|
|
} from 'react' |
|
|
|
|
|
|
|
|
|
import map from 'lodash/map' |
|
|
|
|
import size from 'lodash/size' |
|
|
|
|
|
|
|
|
|
import { ProfileTypes, SportTypes } from 'config' |
|
|
|
|
|
|
|
|
|
import { PlayerPlaylistOptions, PlayerPlaylistOption } from 'features/MatchPage/types' |
|
|
|
|
import { useMatchPopupStore } from 'features/MatchPopup/store' |
|
|
|
|
import { Loader } from 'features/Loader' |
|
|
|
|
|
|
|
|
|
import { Teams } from '../../types' |
|
|
|
|
import { |
|
|
|
|
List, |
|
|
|
|
LoaderWrapper, |
|
|
|
|
Item, |
|
|
|
|
Logo, |
|
|
|
|
PlayerName, |
|
|
|
|
@ -28,19 +37,39 @@ export const PlayersList = ({ |
|
|
|
|
team, |
|
|
|
|
}: Props) => { |
|
|
|
|
const { match } = useMatchPopupStore() |
|
|
|
|
const [imagesList, setImagesList] = useState< |
|
|
|
|
Array<RefObject<HTMLImageElement>> |
|
|
|
|
>([]) |
|
|
|
|
|
|
|
|
|
const [allImagesReady, setAllImagesReady] = useState(false) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (size(imagesList) === size(players)) { |
|
|
|
|
setAllImagesReady(true) |
|
|
|
|
} |
|
|
|
|
}, [imagesList, players]) |
|
|
|
|
|
|
|
|
|
if (!match) return null |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<List team={team}> |
|
|
|
|
{!allImagesReady |
|
|
|
|
&& ( |
|
|
|
|
<LoaderWrapper> |
|
|
|
|
<Loader color='#515151' /> |
|
|
|
|
</LoaderWrapper> |
|
|
|
|
)} |
|
|
|
|
{ |
|
|
|
|
map(players, (player) => ( |
|
|
|
|
<Item key={player.id}> |
|
|
|
|
<Item key={player.id} isReady={allImagesReady}> |
|
|
|
|
<Button onClick={() => onClick(player)}> |
|
|
|
|
<Logo |
|
|
|
|
id={player.id} |
|
|
|
|
sportType={sportType} |
|
|
|
|
profileType={ProfileTypes.PLAYERS} |
|
|
|
|
team={team} |
|
|
|
|
imagesList={imagesList} |
|
|
|
|
setImagesList={setImagesList} |
|
|
|
|
/> |
|
|
|
|
<PlayerName nameObj={player} /> |
|
|
|
|
</Button> |
|
|
|
|
|