11import React , { useState } from 'react'
22import { useSelector } from 'react-redux'
33import { Contestant } from '../../api/contestants'
4- import { selectRollingNameDie } from '../../slices/contestantSlice'
4+ import { selectContestants , selectRollingNameDie } from '../../slices/contestantSlice'
55import { selectPlayerId } from '../../slices/playerSlice'
66import { Button } from '../Button'
77import { FieldSet } from '../FieldSet'
@@ -18,11 +18,15 @@ export const NameDie = ({ contestant }: NameDieProps) => {
1818 const playerId = useSelector ( selectPlayerId )
1919 const isCurrentPlayer = playerId === contestant . playerId
2020 const isCurrentPlayerRolling = isCurrentPlayer && rolling
21+ const isTied = Object . values ( useSelector ( selectContestants ) )
22+ . some ( c => c . dicePool . score === contestant . dicePool . score && c . playerId !== contestant . playerId )
23+ console . log ( Object . values ( useSelector ( selectContestants ) ) )
24+ console . log ( isTied )
2125
2226 const [ showDiceSelector , setShowDiceSelector ] = useState ( false )
2327
2428 const nameDie = contestant . dicePool . nameDie
25-
29+
2630 if ( ! isCurrentPlayer ) {
2731 return < > </ >
2832 }
@@ -53,7 +57,7 @@ export const NameDie = ({ contestant }: NameDieProps) => {
5357 { isCurrentPlayerRolling && (
5458 < Placeholder className = "animate-pulse anim w-full md:w-auto" > Rolling Name Die...</ Placeholder >
5559 ) }
56- { isCurrentPlayer && ! rolling && (
60+ { isCurrentPlayer && ! rolling && isTied && (
5761 < Button
5862 className = "w-full md:w-auto"
5963 onClick = { ( ) => {
0 commit comments