main
Last change
on this file since 55701f0 was 55701f0, checked in by anastasovv <simon@…>, 2 years ago |
Added 1 second update_state calls in blackjack
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[87614a5] | 1 | import React from 'react'
|
---|
| 2 |
|
---|
| 3 | import { useSelector, useDispatch } from 'react-redux'
|
---|
| 4 |
|
---|
| 5 | import { HiOutlineArrowNarrowRight } from 'react-icons/hi'
|
---|
| 6 |
|
---|
| 7 | import axios from 'axios'
|
---|
| 8 |
|
---|
[55701f0] | 9 | import { setStyle } from '../redux/reducers/styleSlice'
|
---|
[87614a5] | 10 |
|
---|
[ace7865] | 11 | const Alert = ({ onTop = false }) => {
|
---|
[87614a5] | 12 | const styleState = useSelector(state => state.style)
|
---|
| 13 |
|
---|
| 14 | const dispatch = useDispatch()
|
---|
| 15 |
|
---|
| 16 | const display = styleState?.style?.alert?.show ? 'flex' : 'none'
|
---|
| 17 |
|
---|
| 18 | function clicked() {
|
---|
| 19 | if (styleState.style.alert.button.action === 'play_again') {
|
---|
[55701f0] | 20 | axios.get(`/api/blackjack?action=play_again&session_id=${localStorage.CAESSINO_SESSION_ID}`);
|
---|
[87614a5] | 21 | }
|
---|
| 22 | else if (styleState.style.alert.button.action === 'continue_from_side_bet') {
|
---|
[55701f0] | 23 | axios.get(`/api/blackjack?action=continue_from_side_bet&session_id=${localStorage.CAESSINO_SESSION_ID}`);
|
---|
| 24 | }
|
---|
| 25 | else {
|
---|
| 26 | dispatch(setStyle({
|
---|
| 27 | ...styleState.style,
|
---|
| 28 | alert: {
|
---|
| 29 | ...styleState.style.alert,
|
---|
| 30 | show: false
|
---|
| 31 | }
|
---|
[87614a5] | 32 | }))
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | return (
|
---|
[ace7865] | 37 | <div className="alert" style={{display: display, top: `${onTop ? '35vh' : '50vh'}`}}>
|
---|
[87614a5] | 38 | <h1>{styleState.style.alert.title}</h1>
|
---|
| 39 | <h3>{styleState.style.alert.subtitle}</h3>
|
---|
| 40 | <button className='primaryButton' onClick={() => clicked()}>{styleState.style.alert.button.text} <HiOutlineArrowNarrowRight style={{marginTop: '3px', marginBottom: '-3px'}} /></button>
|
---|
| 41 | </div>
|
---|
| 42 | )
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | export default Alert |
---|
Note:
See
TracBrowser
for help on using the repository browser.