|
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import React from 'react' |
|
|
|
|
import type { MouseEvent, FocusEvent } from 'react' |
|
|
|
|
import React, { useState } from 'react' |
|
|
|
|
|
|
|
|
|
import map from 'lodash/map' |
|
|
|
|
|
|
|
|
|
import { FavoritesActions } from 'requests' |
|
|
|
|
import { handleImageError } from 'helpers' |
|
|
|
|
|
|
|
|
|
@ -20,6 +20,7 @@ import { |
|
|
|
|
ExclamationSign, |
|
|
|
|
FavoriteModal, |
|
|
|
|
Text, |
|
|
|
|
ScrollWrapper, |
|
|
|
|
} from './styled' |
|
|
|
|
|
|
|
|
|
export const UserFavorites = () => { |
|
|
|
|
@ -30,43 +31,58 @@ export const UserFavorites = () => { |
|
|
|
|
userFavorites, |
|
|
|
|
} = useUserFavoritesStore() |
|
|
|
|
|
|
|
|
|
const [position, setPosition] = useState<number | null>(null) |
|
|
|
|
|
|
|
|
|
const getPosition = (event: MouseEvent<HTMLDivElement> | FocusEvent<HTMLDivElement>) => { |
|
|
|
|
if (event.currentTarget) { |
|
|
|
|
setPosition(event.currentTarget.getBoundingClientRect().top) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<UserSportFavWrapper> |
|
|
|
|
<UserSportFavLogoWrapper height={12} width={52} /> |
|
|
|
|
<UserSportFavStar /> |
|
|
|
|
{ |
|
|
|
|
map(userFavorites, (item) => ( |
|
|
|
|
<UserSportFavItemLogoWrapper key={`${item.type}_${item.sport}_${item.id}`}> |
|
|
|
|
<UserSportFavXWrapper |
|
|
|
|
onClick={() => addRemoveFavorite({ |
|
|
|
|
action: FavoritesActions.REMOVE, |
|
|
|
|
id: item.id, |
|
|
|
|
sport: item.sport, |
|
|
|
|
type: item.type, |
|
|
|
|
})} |
|
|
|
|
/> |
|
|
|
|
<TooltipBlock |
|
|
|
|
countryName={item.countryName} |
|
|
|
|
teamName={item.name} |
|
|
|
|
playerTeamName={item.teamName} |
|
|
|
|
playerFirstName={item.firstname} |
|
|
|
|
playerLastName={item.lastname} |
|
|
|
|
sport={item.sport} |
|
|
|
|
/> |
|
|
|
|
<StyledLink to={item.profileUrl} target='_blank'> |
|
|
|
|
<UserSportFavImgWrapper |
|
|
|
|
src={item.profileLogo} |
|
|
|
|
alt={item.name} |
|
|
|
|
onError={(e) => handleImageError({ |
|
|
|
|
e, |
|
|
|
|
<ScrollWrapper> |
|
|
|
|
{ |
|
|
|
|
map(userFavorites, (item) => ( |
|
|
|
|
<UserSportFavItemLogoWrapper |
|
|
|
|
onFocus={getPosition} |
|
|
|
|
onMouseOver={getPosition} |
|
|
|
|
key={`${item.type}_${item.sport}_${item.id}`} |
|
|
|
|
> |
|
|
|
|
<UserSportFavXWrapper |
|
|
|
|
onClick={() => addRemoveFavorite({ |
|
|
|
|
action: FavoritesActions.REMOVE, |
|
|
|
|
id: item.id, |
|
|
|
|
sport: item.sport, |
|
|
|
|
type: item.type, |
|
|
|
|
})} |
|
|
|
|
/> |
|
|
|
|
</StyledLink> |
|
|
|
|
</UserSportFavItemLogoWrapper> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
<TooltipBlock |
|
|
|
|
topPosition={position} |
|
|
|
|
countryName={item.countryName} |
|
|
|
|
teamName={item.name} |
|
|
|
|
playerTeamName={item.teamName} |
|
|
|
|
playerFirstName={item.firstname} |
|
|
|
|
playerLastName={item.lastname} |
|
|
|
|
sport={item.sport} |
|
|
|
|
/> |
|
|
|
|
<StyledLink to={item.profileUrl} target='_blank'> |
|
|
|
|
<UserSportFavImgWrapper |
|
|
|
|
src={item.profileLogo} |
|
|
|
|
alt={item.name} |
|
|
|
|
onError={(e) => handleImageError({ |
|
|
|
|
e, |
|
|
|
|
sport: item.sport, |
|
|
|
|
type: item.type, |
|
|
|
|
})} |
|
|
|
|
/> |
|
|
|
|
</StyledLink> |
|
|
|
|
</UserSportFavItemLogoWrapper> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
</ScrollWrapper> |
|
|
|
|
<Modal |
|
|
|
|
isOpen={isOpen} |
|
|
|
|
close={close} |
|
|
|
|
|