main
Last change
on this file since 41d3f60 was faff334, checked in by anastasovv <simon@…>, 2 years ago |
Ability for admin to watch live games and for user to see games history
|
-
Property mode
set to
100644
|
File size:
2.2 KB
|
Rev | Line | |
---|
[87614a5] | 1 | import React from 'react'
|
---|
| 2 |
|
---|
| 3 | import { useSelector, useDispatch } from 'react-redux'
|
---|
| 4 | import { setStyle } from '../redux/reducers/styleSlice';
|
---|
| 5 |
|
---|
| 6 | import { AiOutlineClose } from 'react-icons/ai';
|
---|
| 7 |
|
---|
[faff334] | 8 | import axios from 'axios';
|
---|
| 9 |
|
---|
[87614a5] | 10 | const Stats = () => {
|
---|
| 11 | const styleState = useSelector(state => state.style);
|
---|
| 12 |
|
---|
| 13 | const dispatch = useDispatch();
|
---|
| 14 |
|
---|
| 15 | function close() {
|
---|
| 16 | dispatch(setStyle({
|
---|
| 17 | ...styleState.style,
|
---|
| 18 | displayStatsScreen: false,
|
---|
| 19 | }))
|
---|
| 20 | }
|
---|
| 21 |
|
---|
[faff334] | 22 | function openHistory() {
|
---|
| 23 | axios.get(`/api/postgre?action=get_games_history&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => {
|
---|
| 24 | if (res.data?.success) {
|
---|
| 25 | dispatch(setStyle({
|
---|
| 26 | ...styleState.style,
|
---|
| 27 | gamesHistory: {
|
---|
| 28 | blackjack: {
|
---|
| 29 | rooms: res.data?.blackjack,
|
---|
| 30 | },
|
---|
| 31 | roulette: {
|
---|
| 32 | games: res.data?.roulette,
|
---|
| 33 | },
|
---|
| 34 | poker: {
|
---|
| 35 | tables: res.data?.poker,
|
---|
| 36 | },
|
---|
| 37 | },
|
---|
| 38 | displayGamesHistoryScreen: true,
|
---|
| 39 | }))
|
---|
| 40 | }
|
---|
| 41 | })
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[87614a5] | 44 | return (
|
---|
| 45 | <div className="fullscreen fs-centered statsScreen" style={{display: styleState.style.displayStatsScreen ? 'block' : 'none'}}>
|
---|
| 46 | <AiOutlineClose onClick={() => close()} style={{position: 'absolute', top: '20px', right: '20px'}}/>
|
---|
| 47 | <div>
|
---|
| 48 | <h1>Stats:</h1>
|
---|
| 49 | <p>Total money won: <span>${styleState.style.statsScreenInfo.money.earned}</span></p>
|
---|
| 50 | <p>Total blackjack games won: <span>{styleState.style.statsScreenInfo.blackjack.wins}</span></p>
|
---|
| 51 | <p>Total roulette games won: <span>{styleState.style.statsScreenInfo.roulette.wins}</span></p>
|
---|
| 52 | <p>Total poker games won: <span>{styleState.style.statsScreenInfo.poker.wins}</span></p>
|
---|
[faff334] | 53 |
|
---|
| 54 | <button onClick={() => openHistory()} className="primaryButton" style={{marginTop: '5rem', marginLeft: '1rem'}}>See Games History</button>
|
---|
[87614a5] | 55 | </div>
|
---|
| 56 | </div>
|
---|
| 57 | )
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | export default Stats |
---|
Note:
See
TracBrowser
for help on using the repository browser.