diff --git a/src/components/GameView.js b/src/components/GameView.js index 2a0f8903204d37d561a4070944aa768dd54e29f8..f6b075e95769824d10b2212a142e0d88d6718dee 100644 --- a/src/components/GameView.js +++ b/src/components/GameView.js @@ -67,27 +67,29 @@ export default class GameView extends React.Component { } handleLeaveFaction = e => { - let token = sessionStorage.getItem("token"); - fetch( - `${process.env.REACT_APP_API_URL}/faction/leave/${ - this.state.gameInfo.id - }`, - { - method: "DELETE", - headers: { - Authorization: "Bearer " + token - } - } - ) - .then(res => { - if (!res.ok) { + if (window.confirm("Are you sure you want to leave your faction?")) { + let token = sessionStorage.getItem("token"); + fetch( + `${process.env.REACT_APP_API_URL}/faction/leave/${ + this.state.gameInfo.id + }`, + { + method: "DELETE", + headers: { + Authorization: "Bearer " + token + } } - return res.json(); - }) - .then(res => { - alert(res.message); - }) - .catch(error => console.log(error)); + ) + .then(res => { + if (!res.ok) { + } + return res.json(); + }) + .then(res => { + alert(res.message); + }) + .catch(error => console.log(error)); + } }; // setting the socket signal automatically fires shouldComponentUpdate function where socketSignal prop is present