source: components/Alert.jsx

main
Last change on this file was 55701f0, checked in by anastasovv <simon@…>, 23 months ago

Added 1 second update_state calls in blackjack

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import React from 'react'
2
3import { useSelector, useDispatch } from 'react-redux'
4
5import { HiOutlineArrowNarrowRight } from 'react-icons/hi'
6
7import axios from 'axios'
8
9import { setStyle } from '../redux/reducers/styleSlice'
10
11const Alert = ({ onTop = false }) => {
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') {
20 axios.get(`/api/blackjack?action=play_again&session_id=${localStorage.CAESSINO_SESSION_ID}`);
21 }
22 else if (styleState.style.alert.button.action === 'continue_from_side_bet') {
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 }
32 }))
33 }
34 }
35
36 return (
37 <div className="alert" style={{display: display, top: `${onTop ? '35vh' : '50vh'}`}}>
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
45export default Alert
Note: See TracBrowser for help on using the repository browser.