import React from 'react' import { GiTwoCoins } from 'react-icons/gi' import { AiOutlineClose } from 'react-icons/ai' import { useSelector, useDispatch } from 'react-redux' import { setRoulette } from '../../redux/reducers/styleSlice'; import axios from 'axios'; import { setPlayer, setRouletteGame } from '../../redux/reducers/playerSlice'; const BetModal = () => { const dispatch = useDispatch(); const playerState = useSelector(state => state.player); const styleState = useSelector(state => state.style); function chooseBet(e) { dispatch(setRoulette({ ...styleState.roulette, inputControls: { ...styleState.roulette.inputControls, bet: { ...styleState.roulette.inputControls.bet, chosenCredits: parseInt(e.target.value), } } })); } function placeBet() { axios.get(`/api/roulette?action=place_bet&session_id=${localStorage.CAESSINO_SESSION_ID}&betAmount=${styleState.roulette.inputControls.bet.chosenCredits}&whichBets=${styleState.roulette.whichBets.toString()}`).then(res => { if (res.data?.success) { dispatch(setPlayer({ ...playerState.player, credits: res.data?.credits, })); dispatch(setRouletteGame(res.data?.game)); closeModal(false); } }); } function closeModal(removeCoin = true) { if (removeCoin) { dispatch(setRoulette({ ...styleState.roulette, displays: { ...styleState.roulette.displays, betModal: false, }, showCoin: false, })) } else { dispatch(setRoulette({ ...styleState.roulette, displays: { ...styleState.roulette.displays, betModal: false, }, showCoin: true, })); } } return (
10 ? 'flex' : 'none'}}>

You have chosen to bet on: {styleState.roulette.whichBets.map((bet, i) => `${bet} `)}
Please select the amount you will bet

chooseBet(e)} />
${styleState.roulette.inputControls.bet.chosenCredits}

) } export default BetModal