Ott 435 make clickable (#141)

* feat(ott-435): made team names clickable

* fix(ott-435): added underline

* fix(ott-435): minor bug

* fix(ott-435): changed to immutable

* fix(ott-435): minor bug

* fix(ott-435): minor bug

* fix(ott-435): some minor changes

* fix(ott-435): minor changes
keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Armen 5 years ago committed by GitHub
parent 81e1792a1c
commit df6e5c4f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      src/features/MatchPage/MatchProfileCard/hooks.tsx
  2. 55
      src/features/MatchPage/MatchProfileCard/index.tsx
  3. 10
      src/features/MatchPage/MatchProfileCard/styled.tsx

@ -15,23 +15,32 @@ export const useMatchProfileCard = () => {
const pageId = usePageId() const pageId = usePageId()
const { suffix } = useLexicsStore() const { suffix } = useLexicsStore()
const matchProfileNames = { const addNames = (profile: MatchInfo, suffixArg: string) => (
team1Name: matchProfile?.team1[`name_${suffix}` as Name], profile
team2Name: matchProfile?.team2[`name_${suffix}` as Name], ? ({
tournament: matchProfile?.tournament[`name_${suffix}` as Name], ...profile,
} team1: {
...profile.team1,
name: profile.team1[`name_${suffixArg}` as Name],
},
team2: {
...profile.team2,
name: profile.team2[`name_${suffixArg}` as Name],
},
tournament: {
...profile.tournament,
name: profile.tournament[`name_${suffixArg}` as Name],
},
})
: null
)
useEffect(() => { useEffect(() => {
getMatchInfo(sportType, pageId) getMatchInfo(sportType, pageId)
.then(setMatchProfile) .then(setMatchProfile)
}, }, [sportType, pageId])
[
sportType,
pageId,
])
return { return {
matchProfile, matchProfile: addNames(matchProfile, suffix),
matchProfileNames,
} }
} }

@ -1,9 +1,12 @@
import React, { Fragment } from 'react' import React, { Fragment } from 'react'
import isEmpty from 'lodash/isEmpty' import isNull from 'lodash/isNull'
import { getProfileUrl } from 'helpers'
import { getSportColor } from 'helpers/getSportColor' import { getSportColor } from 'helpers/getSportColor'
import { ProfileTypes } from 'config'
import { SportName } from 'features/Common/SportName' import { SportName } from 'features/Common/SportName'
import { useScoreStore } from 'features/ToggleScore' import { useScoreStore } from 'features/ToggleScore'
@ -16,32 +19,52 @@ import {
Score, Score,
Tournament, Tournament,
Dash, Dash,
StyledLink,
} from './styled' } from './styled'
export const MatchProfileCard = () => { export const MatchProfileCard = () => {
const { const {
matchProfile, matchProfile,
matchProfileNames: {
team1Name,
team2Name,
tournament,
},
} = useMatchProfileCard() } = useMatchProfileCard()
const { sportName, sportType } = useSportNameParam() const { sportName, sportType } = useSportNameParam()
const { isHidden } = useScoreStore() const { isHidden } = useScoreStore()
const { team1, team2 } = matchProfile || {}
const color = getSportColor(sportType) const color = getSportColor(sportType)
const {
team1,
team2,
tournament,
} = matchProfile || {}
return ( return (
<Wrapper> <Wrapper>
{!isEmpty(matchProfile) {!isNull(matchProfile)
&& ( && (
<Fragment> <Fragment>
<Teams> <Teams>
{team1Name} <Dash /> {team2Name} {team1 && (
<StyledLink
to={getProfileUrl({
id: team1.id,
profileType: ProfileTypes.TEAMS,
sportType,
})}
>
{team1.name}
</StyledLink>
)}
<Dash />
{team2 && (
<StyledLink to={getProfileUrl({
id: team2.id,
profileType: ProfileTypes.TEAMS,
sportType,
})}
>
{team2.name}
</StyledLink>
)}
</Teams> </Teams>
{!isHidden && ( {!isHidden && (
<Score> <Score>
@ -52,7 +75,17 @@ export const MatchProfileCard = () => {
<SportName <SportName
color={color} color={color}
t={sportName} t={sportName}
/>{tournament} />
{tournament && (
<StyledLink to={getProfileUrl({
id: tournament.id,
profileType: ProfileTypes.TEAMS,
sportType,
})}
>
{tournament?.name}
</StyledLink>
)}
</Tournament> </Tournament>
</Fragment> </Fragment>
)} )}

@ -1,3 +1,5 @@
import { Link } from 'react-router-dom'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { devices } from 'config/devices' import { devices } from 'config/devices'
@ -23,6 +25,14 @@ export const Teams = styled.div`
` `
export const StyledLink = styled(Link)`
font-weight: bold;
color: white;
&:hover{
text-decoration: underline;
}
`
export const Dash = styled.span` export const Dash = styled.span`
position: relative; position: relative;
width: 40px; width: 40px;

Loading…
Cancel
Save