Skip to content

Commit

Permalink
🐛 fix: fix showing ready badge only on specific game phases
Browse files Browse the repository at this point in the history
  • Loading branch information
omidnikrah committed Dec 15, 2024
1 parent 8f948e3 commit c8427e9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/frontend/src/pages/GameRoom/components/Player/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GamePhases } from '@gol-ya-pooch/frontend/enums';
import {
useGuessHand,
useRequestEmptyPlay,
Expand All @@ -20,11 +21,15 @@ interface IPlayer {
}

export const Player = ({ team, data, isJoined, position }: IPlayer) => {
const { playingPlayerId, gameState } = useGameStore();
const { playingPlayerId, gameState, phase } = useGameStore();
const { requestEmptyPlay } = useRequestEmptyPlay();
const { guessObjectLocation } = useGuessHand();

const isPlaying = playingPlayerId === data?.id;
const phasesToShowReadyBadge = [
GamePhases.WAITING_FOR_PLAYERS,
GamePhases.WAITING_FOR_READY,
];

const handleRequestEmptyPlay = () => {
if (data?.id) {
Expand Down Expand Up @@ -54,7 +59,7 @@ export const Player = ({ team, data, isJoined, position }: IPlayer) => {
},
)}
>
{data?.isReady && (
{data?.isReady && phasesToShowReadyBadge.includes(phase) && (
<span
className={clsx(
'absolute translate-x-1/2 right-1/2 bg-green-300 text-green-800 px-4 py-1 rounded-full',
Expand Down

0 comments on commit c8427e9

Please sign in to comment.