main
Last change
on this file since aac3b2b was 87614a5, checked in by anastasovv <simon@…>, 2 years ago |
Blackjack prototype
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
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 | import { setPlayer } from '../redux/reducers/playerSlice';
|
---|
8 |
|
---|
9 | import axios from 'axios';
|
---|
10 |
|
---|
11 | const ManageCredits = () => {
|
---|
12 | const playerState = useSelector(state => state.player);
|
---|
13 | const styleState = useSelector(state => state.style);
|
---|
14 |
|
---|
15 | const dispatch = useDispatch();
|
---|
16 |
|
---|
17 | function close() {
|
---|
18 | dispatch(setStyle({
|
---|
19 | ...styleState.style,
|
---|
20 | displayManageCreditsScreen: false,
|
---|
21 | }))
|
---|
22 | }
|
---|
23 |
|
---|
24 | 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 | });
|
---|
33 | }
|
---|
34 |
|
---|
35 | return (
|
---|
36 | <div className="fullscreen fs-centered manageCreditsScreen" style={{display: styleState.style.displayManageCreditsScreen ? 'block' : 'none'}}>
|
---|
37 | <AiOutlineClose onClick={() => close()} style={{position: 'absolute', top: '20px', right: '20px'}}/>
|
---|
38 | <div>
|
---|
39 | <h1>Manage Credits:</h1>
|
---|
40 | <p>You currently have: ${playerState.player.credits}</p>
|
---|
41 | <div>
|
---|
42 | <button className="primaryButton" onClick={() => buyCredits()}>Buy Credits</button>
|
---|
43 | </div>
|
---|
44 | </div>
|
---|
45 | </div>
|
---|
46 | )
|
---|
47 | }
|
---|
48 |
|
---|
49 | export default ManageCredits |
---|
Note:
See
TracBrowser
for help on using the repository browser.