This commit is contained in:
asyncnomi 2023-01-08 23:14:04 +01:00
parent e3f4b5e9cf
commit f87b5076d0

View file

@ -564,10 +564,33 @@ function refreshListener() {
}
});
})
$(".prank-btn-delete").click((e) => {
let uid = e.target.parentNode.parentNode.id;
$.ajax({
type: 'POST',
url: base_url + 'delPrank',
data: JSON.stringify({
uid: localStorage.getItem('user'),
token: localStorage.getItem('token'),
prankUid: uid
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
if (data.success) {
updateDemandes();
}
else {
alert(data.why);
}
}
});
});
}
$('#demande-button').click(function () {
$.ajax({
type: "POST",
url: base_url + "addPrank",
@ -636,38 +659,14 @@ function updateDemandes() {
<div class="prank-status">Statue: ${pd[pd_uid].state}</div>
${ (pd[pd_uid].state != "Accepted" && pd[pd_uid].state != "Refused" ) ?
`<span class="activity-btn">
<div id="${pd_uid}" class="prank-btn-delete">Annuler</div>
<div class="prank-btn-delete">Annuler</div>
</span>`
: ''
}
</span>
`)
$('#' + pd_uid + " .prank-btn-delete").click(() => {
$.ajax({
type: 'POST',
url: base_url + 'delPrank',
data: JSON.stringify({
uid: localStorage.getItem('user'),
token: localStorage.getItem('token'),
prankUid: this.id()
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
if (data.success) {
updateDemandes();
}
else {
alert(data.why);
}
}
});
});
}
refreshListener();
}
else {
if (data.why == "Not authentificated") {