Changeset 433e0c5 for components
- Timestamp:
- 07/15/22 14:45:30 (2 years ago)
- Branches:
- main
- Children:
- 55701f0
- Parents:
- 1df3fde
- Location:
- components
- Files:
-
- 2 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
components/Header.jsx
r1df3fde r433e0c5 54 54 } 55 55 56 function complain() { 57 dispatch(setStyle({ 58 ...styleState.style, 59 displayComplainScreen: true, 60 })) 61 } 62 56 63 function showStats() { 57 64 axios.get(`/api/postgre?action=get_stats&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => { … … 87 94 ...styleState.style, 88 95 displayManageCreditsScreen: true, 96 displayDepositModal: false, 97 displayWithdrawModal: false, 89 98 })) 90 99 } … … 144 153 <> 145 154 <li onClick={() => {manageCredits()}}>Manage Credits</li> 146 <li onClick={() => {showStats()}}>Stats</li> 155 <li onClick={() => {showStats()}}>Statistics</li> 156 <li onClick={() => {complain()}}>Complain</li> 147 157 <li onClick={() => {logout()}}>Logout</li> 148 158 </> -
components/ManageCredits.jsx
r1df3fde r433e0c5 15 15 const dispatch = useDispatch(); 16 16 17 function close( ) {17 function close(action = '') { 18 18 dispatch(setStyle({ 19 19 ...styleState.style, 20 20 displayManageCreditsScreen: false, 21 displayDepositModal: false, 22 displayWithdrawModal: false, 23 depositModalInputs: { 24 name: '', 25 card: '', 26 expire: '', 27 ccv: '', 28 amount: '', 29 }, 30 displayWithdrawModal: false, 31 withdrawModalInputs: { 32 citibank: '', 33 iban: '', 34 bic: '', 35 beneficiary: '', 36 address: '', 37 amount: '', 38 }, 39 inlineAlertText: '', 40 notification: action === 'deposit' ? { 41 show: true, 42 text: `Deposited $${styleState.style.depositModalInputs.amount} successfully`, 43 status: 'success', 44 } : action === 'withdraw' ? { 45 show: true, 46 text: `Withdrawed $${styleState.style.withdrawModalInputs.amount} successfully`, 47 status: 'success', 48 } : { 49 show: false, 50 text: '', 51 status: '' 52 }, 53 })) 54 } 55 56 57 function openDepositModal() { 58 dispatch(setStyle({ 59 ...styleState.style, 60 displayDepositModal: true, 61 displayWithdrawModal: false, 62 inlineAlertText: '', 63 })) 64 } 65 66 function openWithdrawModal() { 67 dispatch(setStyle({ 68 ...styleState.style, 69 displayDepositModal: false, 70 displayWithdrawModal: true, 71 inlineAlertText: '', 21 72 })) 22 73 } 23 74 24 75 function buyCredits() { 25 axios.get(`/api/postgre/?action=add_credits&session_id=${localStorage.CAESSINO_SESSION_ID}&credits=${500}&dont_update_stats=true`).then(res => { 26 if (res.data?.success) { 27 dispatch(setPlayer({ 28 ...playerState.player, 29 credits: res.data.credits, 30 })) 31 } 32 }); 76 axios.post(`/api/postgre`, { 77 action: 'deposit', 78 session_id: localStorage.CAESSINO_SESSION_ID, 79 data: styleState.style.depositModalInputs 80 }) 81 .then(res => { 82 if (res.data?.success) { 83 dispatch(setPlayer({ 84 ...playerState.player, 85 credits: res.data.credits, 86 })) 87 88 close('deposit'); 89 } 90 else { 91 dispatch(setStyle({ 92 ...styleState.style, 93 displayManageCreditsScreen: true, 94 inlineAlertText: res.data?.message, 95 })); 96 } 97 }) 98 } 99 100 function sellCredits() { 101 axios.post(`/api/postgre`, { 102 action: 'withdraw', 103 session_id: localStorage.CAESSINO_SESSION_ID, 104 data: styleState.style.withdrawModalInputs 105 }) 106 .then(res => { 107 if (res.data?.success) { 108 dispatch(setPlayer({ 109 ...playerState.player, 110 credits: res.data.credits, 111 })) 112 113 close('withdraw'); 114 } 115 else { 116 dispatch(setStyle({ 117 ...styleState.style, 118 displayManageCreditsScreen: true, 119 inlineAlertText: res.data?.message, 120 })); 121 } 122 }) 33 123 } 34 124 … … 37 127 <AiOutlineClose onClick={() => close()} style={{position: 'absolute', top: '20px', right: '20px'}}/> 38 128 <div> 39 <h1>Manage Credits:</h1>40 <p>You currently have: ${playerState.player.credits}</p>41 129 <div> 42 <button className="primaryButton" onClick={() => buyCredits()}>Buy Credits</button> 130 <h2>Manage (In-Game) Credits:</h2> 131 <p>You currently have: ${playerState.player.credits}</p> 132 </div> 133 <div className="main"> 134 <div> 135 { styleState.style.displayDepositModal && styleState.style.inlineAlertText.length > 0 && <span className="inlineAlert">{styleState.style.inlineAlertText}</span>} 136 { !styleState.style.displayDepositModal && <button className="primaryButton" onClick={() => openDepositModal()}>Deposit From Credit Card<br/><span>Buy (In-Game) Credits</span></button> } 137 { styleState.style.displayDepositModal && ( 138 <div className="fs-inputs-container"> 139 <div> 140 <label>Name and Surname</label> 141 <input type="text" className="primaryInput" onChange={(e) => {onChangeDeposit(e, 'name')}} value={styleState.style.depositModalInputs.name} placeholder="John Doe"/> 142 <label>Card Number</label> 143 <input type="text" className="primaryInput" onChange={(e) => {onChangeDeposit(e, 'card')}} value={styleState.style.depositModalInputs.card} placeholder="2333 9298 9821 1111"/> 144 <label>Expire Date</label> 145 <input type="text" className="primaryInput" onChange={(e) => {onChangeDeposit(e, 'expire')}} value={styleState.style.depositModalInputs.expire} placeholder="07/24"/> 146 <label>CCV</label> 147 <input type="text" className="primaryInput" onChange={(e) => {onChangeDeposit(e, 'ccv')}} value={styleState.style.depositModalInputs.ccv} placeholder="337"/> 148 <label><span>Amount</span></label> 149 <input type="text" className="primaryInput" onChange={(e) => {onChangeDeposit(e, 'amount')}} value={styleState.style.depositModalInputs.amount} placeholder="500"/> 150 <button className="primaryButton" onClick={() => buyCredits()}>Deposit</button> 151 </div> 152 </div> 153 )} 154 </div> 155 <div> 156 { styleState.style.displayWithdrawModal && styleState.style.inlineAlertText.length > 0 && <span className="inlineAlert">{styleState.style.inlineAlertText}</span>} 157 { !styleState.style.displayWithdrawModal && <button className="primaryButton" onClick={() => openWithdrawModal()}>Withdraw To Personal Account<br/><span>Sell (In-Game) Credits</span></button> } 158 { styleState.style.displayWithdrawModal && ( 159 <div className="fs-inputs-container"> 160 <div> 161 <label>Bank name</label> 162 <input type="text" className="primaryInput" onChange={(e) => {onChangeWithdraw(e, 'citibank')}} value={styleState.style.withdrawModalInputs.citibank} placeholder="Swedbank"/> 163 <label>IBAN</label> 164 <input type="text" className="primaryInput" onChange={(e) => {onChangeWithdraw(e, 'iban')}} value={styleState.style.withdrawModalInputs.iban} placeholder="SE45 5000 0000 0583 9825 7466"/> 165 <label>BIC</label> 166 <input type="text" className="primaryInput" onChange={(e) => {onChangeWithdraw(e, 'bic')}} value={styleState.style.withdrawModalInputs.bic} placeholder="SWEDSESSXXX"/> 167 <label>Beneficiary Name</label> 168 <input type="text" className="primaryInput" onChange={(e) => {onChangeWithdraw(e, 'beneficiary')}} value={styleState.style.withdrawModalInputs.beneficiary} placeholder="John Doe"/> 169 <label>Bank Address</label> 170 <input type="text" className="primaryInput" onChange={(e) => {onChangeWithdraw(e, 'address')}} value={styleState.style.withdrawModalInputs.address} placeholder="Landsvรคgen 40, Sundbyberg"/> 171 <label><span>Amount</span></label> 172 <input type="text" className="primaryInput" onChange={(e) => {onChangeWithdraw(e, 'amount')}} value={styleState.style.withdrawModalInputs.amount} placeholder="500"/> 173 <button className="primaryButton" onClick={() => sellCredits()}>Withdraw</button> 174 </div> 175 </div> 176 )} 177 </div> 43 178 </div> 44 179 </div> 45 180 </div> 46 181 ) 182 183 function onChangeDeposit(e, what) { 184 dispatch(setStyle({ 185 ...styleState.style, 186 depositModalInputs: { 187 name: what === 'name' ? e.target.value : styleState.style.depositModalInputs.name, 188 card: what === 'card' ? e.target.value : styleState.style.depositModalInputs.card, 189 expire: what === 'expire' ? e.target.value : styleState.style.depositModalInputs.expire, 190 ccv: what === 'ccv' ? e.target.value : styleState.style.depositModalInputs.ccv, 191 amount: what === 'amount' ? e.target.value : styleState.style.depositModalInputs.amount, 192 } 193 })) 194 } 195 196 function onChangeWithdraw(e, what) { 197 dispatch(setStyle({ 198 ...styleState.style, 199 withdrawModalInputs: { 200 citibank: what === 'citibank' ? e.target.value : styleState.style.depositModalInputs.citibank, 201 iban: what === 'iban' ? e.target.value : styleState.style.depositModalInputs.iban, 202 bic: what === 'bic' ? e.target.value : styleState.style.depositModalInputs.bic, 203 beneficiary: what === 'beneficiary' ? e.target.value : styleState.style.depositModalInputs.beneficiary, 204 address: what === 'address' ? e.target.value : styleState.style.depositModalInputs.address, 205 amount: what === 'amount' ? e.target.value : styleState.style.depositModalInputs.amount, 206 } 207 })) 208 } 47 209 } 48 210 -
components/blackjack/Blackjack.jsx
r1df3fde r433e0c5 10 10 import Alert from '../Alert' 11 11 import Notification from '../Notification' 12 import LostConnection from '../LostConnection' 12 13 13 14 const Blackjack = () => { … … 31 32 32 33 <Notification/> 34 35 <LostConnection/> 33 36 </div> 34 37 ) -
components/poker/Poker.jsx
r1df3fde r433e0c5 8 8 import Notification from '../Notification' 9 9 import PokerSections from './PokerSections' 10 import LostConnection from '../LostConnection' 10 11 11 12 const Poker = () => { … … 25 26 26 27 <Notification/> 28 29 <LostConnection/> 27 30 </div> 28 31 ) -
components/poker/PokerHeader.jsx
r1df3fde r433e0c5 10 10 import { useDispatch, useSelector } from 'react-redux' 11 11 12 import { setPlayer, setPokerGame , setSocket} from '../../redux/reducers/playerSlice'12 import { setPlayer, setPokerGame } from '../../redux/reducers/playerSlice' 13 13 import { setStyle } from '../../redux/reducers/styleSlice' 14 14 … … 36 36 if (interval !== null) clearInterval(interval); 37 37 38 dispatch(setPlayer({39 ...playerState.player,40 displayName: res.data?.displayName,41 session_id: res.data?.session_id,42 credits: res.data?.credits,43 }));44 45 dispatch(setStyle({46 ...styleState.style,47 displayLoadingScreen: false,48 }))49 50 38 interval = setInterval(() => { 51 39 axios.get(`/api/poker?action=update_state&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(newRes => { … … 56 44 dispatch(setPlayer({ 57 45 ...playerState.player, 46 displayName: res.data?.displayName, 47 session_id: res.data?.session_id, 58 48 credits: newRes.data?.pokerGame?.player?.credits, 59 49 })) 60 50 } 61 51 } 52 53 dispatch(setStyle({ 54 ...styleState.style, 55 displayLoadingScreen: false, 56 notification: { 57 ...styleState.style.notification, 58 show: false, 59 }, 60 lostConnectionInfo: { 61 show: false, 62 message: '' 63 } 64 })) 65 }).catch(error => { 66 dispatch(setStyle({ 67 ...styleState.style, 68 displayLoadingScreen: false, 69 lostConnectionInfo: { 70 show: true, 71 message: 'Game will be played until the end upon server gets live. You cannot continue your game, but the money earned / lost will be updated.' 72 } 73 })) 62 74 }); 63 }, 2000);75 }, 1000); 64 76 } 65 77 else { -
components/poker/PokerSections.jsx
r1df3fde r433e0c5 1 1 import React from 'react' 2 2 3 import Cards from './sections/Cards'4 3 import CardsInTheMiddle from './sections/CardsInTheMiddle' 5 4 import Chairs from './sections/Chairs' … … 8 7 import PickATable from './sections/PickATable' 9 8 10 import { useSelector , useDispatch} from 'react-redux'9 import { useSelector } from 'react-redux' 11 10 import Pot from './sections/Pot' 12 11 import RaiseModal from './sections/RaiseModal' … … 21 20 22 21 <Chairs/> 23 24 <Cards/>25 22 26 23 <CardsInTheMiddle/> -
components/poker/sections/PickATable.jsx
r1df3fde r433e0c5 6 6 7 7 import axios from 'axios'; 8 import { setPokerGame } from '../../../redux/reducers/playerSlice';9 8 10 9 const PickATable = () => { -
components/roulette/BetModal.jsx
r1df3fde r433e0c5 8 8 9 9 import axios from 'axios'; 10 import { setPlayer, setRouletteGame } from '../../redux/reducers/playerSlice';11 10 12 11 const BetModal = () => { -
components/roulette/Roulette.jsx
r1df3fde r433e0c5 8 8 import Notification from '../Notification' 9 9 import Sections from './Sections' 10 import LostConnection from '../LostConnection' 10 11 11 12 const Roulette = () => { … … 25 26 26 27 <Notification/> 28 29 <LostConnection/> 27 30 </div> 28 31 ) -
components/roulette/RouletteHeader.jsx
r1df3fde r433e0c5 79 79 dispatch(setPlayer({ 80 80 ...playerState.player, 81 displayName: res.data?.displayName, 82 session_id: res.data?.session_id, 81 83 credits: newRes.data?.rouletteGame?.player?.credits, 82 84 })) 83 85 } 84 86 } 87 88 if (newRes.data?.extraAction && newRes.data?.extraAction !== "spin_wheel") { 89 dispatch(setStyle({ 90 ...styleState.style, 91 displayLoadingScreen: false, 92 notification: { 93 ...styleState.style.notification, 94 show: false, 95 }, 96 lostConnectionInfo: { 97 show: false, 98 message: '' 99 } 100 })) 101 } 102 }).catch(error => { 103 dispatch(setStyle({ 104 ...styleState.style, 105 displayLoadingScreen: false, 106 lostConnectionInfo: { 107 show: true, 108 message: 'Game will resume upon reconnection to the server.' 109 } 110 })) 85 111 }); 86 112 }, 1000); … … 97 123 showCoin: false, 98 124 })); 99 100 dispatch(setStyle({101 ...styleState.style,102 displayLoadingScreen: false,103 }))104 125 } 105 126 else { -
components/roulette/Timer.jsx
r1df3fde r433e0c5 1 1 import React from 'react' 2 2 3 import { useEffect } from 'react'; 4 import { useDispatch, useSelector } from 'react-redux' 5 import { setPlayer, setRouletteGame } from '../../redux/reducers/playerSlice'; 6 7 import axios from 'axios'; 8 import { setRoulette, setStyle } from '../../redux/reducers/styleSlice'; 3 import { useSelector } from 'react-redux' 9 4 10 5 const Timer = () => { 11 const dispatch = useDispatch();12 13 6 const playerState = useSelector(state => state.player); 14 const styleState = useSelector(state => state.style);15 7 16 8 function getTimer() {
Note:
See TracChangeset
for help on using the changeset viewer.