Changeset 55701f0 for components/Alert.jsx
- Timestamp:
- 07/16/22 11:18:24 (2 years ago)
- Branches:
- main
- Children:
- e007fcd
- Parents:
- 433e0c5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
components/Alert.jsx
r433e0c5 r55701f0 7 7 import axios from 'axios' 8 8 9 import { setBlackjack, setStyle } from '../redux/reducers/styleSlice' 10 import { setBlackjackGame } from '../redux/reducers/playerSlice' 9 import { setStyle } from '../redux/reducers/styleSlice' 11 10 12 11 const Alert = ({ onTop = false }) => { 13 const playerState = useSelector(state => state.player)14 12 const styleState = useSelector(state => state.style) 15 13 … … 19 17 20 18 function clicked() { 21 dispatch(setStyle({22 ...styleState.style,23 alert: {24 ...styleState.style.alert,25 show: false26 }27 }))28 29 19 if (styleState.style.alert.button.action === 'play_again') { 30 axios.get(`/api/blackjack?action=play_again&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => { 31 if (res.data?.success && res.data?.game) { 32 dispatch(setBlackjackGame({ 33 ...playerState.blackjackGame, 34 status: res.data.game?.status, 35 playerCards: res.data.game?.playerCards, 36 dealerCards: res.data.game?.dealerCards, 37 sideBetName: res.data.game?.sideBetName, 38 })) 39 40 dispatch(setBlackjack({ 41 ...styleState.blackjack, 42 inputControls: { 43 ...styleState.blackjack.inputControls, 44 initialBet: { 45 ...styleState.blackjack.inputControls.initialBet, 46 chosenCredits: parseInt(playerState.player.credits/2), 47 }, 48 sideBet: { 49 ...styleState.blackjack.inputControls.sideBet, 50 chosenCredits: parseInt(0), 51 } 52 }, 53 displays: { 54 ...styleState.blackjack.displays, 55 initialBet: true, 56 hitStand: false, 57 } 58 })) 59 } 60 }); 20 axios.get(`/api/blackjack?action=play_again&session_id=${localStorage.CAESSINO_SESSION_ID}`); 61 21 } 62 22 else if (styleState.style.alert.button.action === 'continue_from_side_bet') { 63 dispatch(setBlackjack({64 ...styleState.blackjack,65 inputControls:{66 ...styleState.blackjack.inputControls,67 sideBet: {68 ...styleState.blackjack.inputControls.sideBet,69 chosenCredits: parseInt(0),70 }71 } ,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 } 72 32 })) 73 33 }
Note:
See TracChangeset
for help on using the changeset viewer.