diff --git a/src/features/MatchCard/hooks.tsx b/src/features/MatchCard/hooks.tsx index b766a963..a4f9d469 100644 --- a/src/features/MatchCard/hooks.tsx +++ b/src/features/MatchCard/hooks.tsx @@ -10,7 +10,7 @@ export const useCard = () => { isOpen, open, } = useToggle() - const { isVisible } = useScoreStore() + const { isHidden } = useScoreStore() const onKeyPress = useCallback((e: KeyboardEvent) => { if (e.key === 'Enter') { @@ -23,6 +23,6 @@ export const useCard = () => { isOpen, onKeyPress, open, - showScore: !isVisible, + showScore: isHidden, } } diff --git a/src/features/MatchPage/MatchProfileCard/index.tsx b/src/features/MatchPage/MatchProfileCard/index.tsx index f2df0bb2..fc6e4dea 100644 --- a/src/features/MatchPage/MatchProfileCard/index.tsx +++ b/src/features/MatchPage/MatchProfileCard/index.tsx @@ -5,6 +5,7 @@ import isEmpty from 'lodash/isEmpty' import { getSportColor } from 'helpers/getSportColor' import { SportName } from 'features/Common/SportName' +import { useScoreStore } from 'features/ToggleScore' import { useSportNameParam } from 'hooks/useSportNameParam' import { useMatchPage } from '../hooks' @@ -28,6 +29,7 @@ export const MatchProfileCard = () => { } = useMatchPage() const { sportName, sportType } = useSportNameParam() + const { isHidden } = useScoreStore() const { team1, team2 } = matchProfile || {} @@ -41,9 +43,11 @@ export const MatchProfileCard = () => { {team1Name} {team2Name} - - {team1?.score} : {team2?.score} - + {!isHidden && ( + + {team1?.score} : {team2?.score} + + )} { - const { isVisible, toggle } = useScoreStore() + const { isHidden, toggle } = useScoreStore() + return ( - <Icon isOn={isVisible} /> + <Icon isOn={isHidden} /> </Switch> ) } diff --git a/src/features/ToggleScore/store.tsx b/src/features/ToggleScore/store.tsx index c5a5c5a3..4911202d 100644 --- a/src/features/ToggleScore/store.tsx +++ b/src/features/ToggleScore/store.tsx @@ -11,7 +11,7 @@ import { useLocalStore } from 'hooks' const SCORE_KEY = 'hide_score' type ScoreStore = { - isVisible: boolean, + isHidden: boolean, toggle: () => void, } @@ -28,7 +28,7 @@ export const ScoreStore = ({ children }: Props) => { const toggle = () => setIsOpen(!isOpen) return ( - <ScoreContext.Provider value={{ isVisible: isOpen, toggle }}> + <ScoreContext.Provider value={{ isHidden: isOpen, toggle }}> {children} </ScoreContext.Provider> )