Skip to content
Snippets Groups Projects
Commit 48a9c883 authored by Joni Laukka's avatar Joni Laukka
Browse files

Confirmation added to faction leaving

parent b7554c0f
No related branches found
No related tags found
3 merge requests!46Development to testing,!41Notifications + small updates,!39Notification view
...@@ -67,27 +67,29 @@ export default class GameView extends React.Component { ...@@ -67,27 +67,29 @@ export default class GameView extends React.Component {
} }
handleLeaveFaction = e => { handleLeaveFaction = e => {
let token = sessionStorage.getItem("token"); if (window.confirm("Are you sure you want to leave your faction?")) {
fetch( let token = sessionStorage.getItem("token");
`${process.env.REACT_APP_API_URL}/faction/leave/${ fetch(
this.state.gameInfo.id `${process.env.REACT_APP_API_URL}/faction/leave/${
}`, this.state.gameInfo.id
{ }`,
method: "DELETE", {
headers: { method: "DELETE",
Authorization: "Bearer " + token headers: {
} Authorization: "Bearer " + token
} }
)
.then(res => {
if (!res.ok) {
} }
return res.json(); )
}) .then(res => {
.then(res => { if (!res.ok) {
alert(res.message); }
}) return res.json();
.catch(error => console.log(error)); })
.then(res => {
alert(res.message);
})
.catch(error => console.log(error));
}
}; };
// setting the socket signal automatically fires shouldComponentUpdate function where socketSignal prop is present // setting the socket signal automatically fires shouldComponentUpdate function where socketSignal prop is present
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment