feat(ott-348): score is fixed (#113)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Armen 5 years ago committed by GitHub
parent 6cbd99ac7a
commit 26f234df2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/features/MatchCard/hooks.tsx
  2. 4
      src/features/MatchPage/MatchProfileCard/index.tsx
  3. 7
      src/features/ToggleScore/index.tsx
  4. 4
      src/features/ToggleScore/store.tsx

@ -10,7 +10,7 @@ export const useCard = () => {
isOpen, isOpen,
open, open,
} = useToggle() } = useToggle()
const { isVisible } = useScoreStore() const { isHidden } = useScoreStore()
const onKeyPress = useCallback((e: KeyboardEvent<HTMLLIElement>) => { const onKeyPress = useCallback((e: KeyboardEvent<HTMLLIElement>) => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
@ -23,6 +23,6 @@ export const useCard = () => {
isOpen, isOpen,
onKeyPress, onKeyPress,
open, open,
showScore: !isVisible, showScore: isHidden,
} }
} }

@ -5,6 +5,7 @@ import isEmpty from 'lodash/isEmpty'
import { getSportColor } from 'helpers/getSportColor' import { getSportColor } from 'helpers/getSportColor'
import { SportName } from 'features/Common/SportName' import { SportName } from 'features/Common/SportName'
import { useScoreStore } from 'features/ToggleScore'
import { useSportNameParam } from 'hooks/useSportNameParam' import { useSportNameParam } from 'hooks/useSportNameParam'
import { useMatchPage } from '../hooks' import { useMatchPage } from '../hooks'
@ -28,6 +29,7 @@ export const MatchProfileCard = () => {
} = useMatchPage() } = useMatchPage()
const { sportName, sportType } = useSportNameParam() const { sportName, sportType } = useSportNameParam()
const { isHidden } = useScoreStore()
const { team1, team2 } = matchProfile || {} const { team1, team2 } = matchProfile || {}
@ -41,9 +43,11 @@ export const MatchProfileCard = () => {
<Teams> <Teams>
{team1Name} <Dash /> {team2Name} {team1Name} <Dash /> {team2Name}
</Teams> </Teams>
{!isHidden && (
<Score> <Score>
{team1?.score} : {team2?.score} {team1?.score} : {team2?.score}
</Score> </Score>
)}
<Tournament> <Tournament>
<SportName <SportName
color={color} color={color}

@ -10,15 +10,16 @@ import {
export * from './store' export * from './store'
export const ToggleScore = () => { export const ToggleScore = () => {
const { isVisible, toggle } = useScoreStore() const { isHidden, toggle } = useScoreStore()
return ( return (
<Switch <Switch
onClick={toggle} onClick={toggle}
role='switch' role='switch'
aria-checked={isVisible} aria-checked={isHidden}
> >
<Title t='hide_score' /> <Title t='hide_score' />
<Icon isOn={isVisible} /> <Icon isOn={isHidden} />
</Switch> </Switch>
) )
} }

@ -11,7 +11,7 @@ import { useLocalStore } from 'hooks'
const SCORE_KEY = 'hide_score' const SCORE_KEY = 'hide_score'
type ScoreStore = { type ScoreStore = {
isVisible: boolean, isHidden: boolean,
toggle: () => void, toggle: () => void,
} }
@ -28,7 +28,7 @@ export const ScoreStore = ({ children }: Props) => {
const toggle = () => setIsOpen(!isOpen) const toggle = () => setIsOpen(!isOpen)
return ( return (
<ScoreContext.Provider value={{ isVisible: isOpen, toggle }}> <ScoreContext.Provider value={{ isHidden: isOpen, toggle }}>
{children} {children}
</ScoreContext.Provider> </ScoreContext.Provider>
) )

Loading…
Cancel
Save