import React from 'react' import { useEffect } from 'react'; import { useSelector, useDispatch } from 'react-redux' import axios from 'axios'; import { setAdminInformation } from '../../redux/reducers/adminInformationSlice'; import { setAdmin } from '../../redux/reducers/adminSlice'; import FreeflowCard from '../FreeflowCard'; import Calculations from './Calculations'; const LiveGames = () => { const dispatch = useDispatch(); const adminState = useSelector(state => state.admin); const adminInformationState = useSelector(state => state.adminInformation); useEffect(() => { let interval = setInterval(() => { axios.get(`/api/postgre?action=get_live_games_as_admin&admin_id=${localStorage.CAESSINO_ADMIN_ID}`).then(res => { if (res.data?.success) { dispatch(setAdminInformation({ ...adminInformationState.adminInformation, liveGames: { blackjack: { rooms: res.data?.blackjack, }, roulette: res.data?.roulette, poker: { tables: res.data?.poker, }, } })) } }) }, 1000); return () => { if (interval !== null) clearInterval(interval); }; }, []) function hideLiveGamesScreen() { dispatch(setAdmin({ ...adminState.admin, displays: { ...adminState.admin.displays, liveGamesScreen: false, } })) } return (

hideLiveGamesScreen()}>⬅ Go Back

These are the current live games.

Live BLackjack Games:

{ adminInformationState.adminInformation.liveGames.blackjack?.rooms?.map(room => (
{ room?.playerCards?.map((card, i) => ( ))}

Player {room?.displayName} (${parseInt(room.initialBet) + parseInt(room.sideBet)})

Status:
{room.status}
{ room?.outcome?.length > 0 &&
Outcome:
{room.outcome}
} { room?.sideBetOutcome?.length > 0 &&
Side Bet Outcome:
{room.sideBetOutcome}
}
{ room?.dealerCards?.map((card, i) => ( ))}

Dealer {room.dealerName}

)) }

Live Roulette Game:

Status: {adminInformationState.adminInformation?.liveGames?.roulette?.status}     Time to start: {adminInformationState.adminInformation?.liveGames?.roulette?.timeToStart}     { adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber != -1 && <>Ball on number: {adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber}     } { adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber != -1 && <>Winning bets: {adminInformationState.adminInformation?.liveGames?.roulette?.winningBets?.join(", ")} }
Players:
{ adminInformationState.adminInformation?.liveGames?.roulette?.players?.map((player, i) => (
Player {i+1} ->
{player.name} (${player?.betAmount})
{ player?.whichBets?.length > 0 &&
Betted on: {player?.whichBets?.join(", ")}
}
{ adminInformationState.adminInformation?.liveGames?.roulette?.magicNumber != -1 && player?.whichBets?.length > 0 &&
Outcome: {player.outcome}
}
)) }

Live Poker Games:

{ adminInformationState.adminInformation.liveGames.poker?.tables?.map(table => (
Round: {table?.round}/4     Started: {table?.started}     Player on turn: {table.players[table.turnIdx]?.displayName ?? '-'}     Pot: ${table?.pot}     { table?.winners?.length > 0 && <>Winners: {table?.winners?.map(e=>e?.displayName)?.join(", ")} }
{ table?.cards?.map((card, i) => ( ))}
Players:
{table.players?.map(player => (
Player {player?.displayName} (${player.betAmount})
{ player?.cards?.map((card, i) => ( ))}
{ table?.cards?.length > 0 &&
Hand:
}
))}
)) }
) } export default LiveGames