This commit is contained in:
johan 2023-01-10 09:34:07 +01:00
parent e8ecae93fb
commit 38d3519a86

View file

@ -241,6 +241,32 @@ function get_admin(type) {
break;
}
}
$.ajax({
type: "POST",
url: base_url + "get",
data: JSON.stringify({
uid: localStorage.getItem('user'),
token: localStorage.getItem('token'),
type: "state"
}),
success: function(data) {
if(data.success) {
if(data.state == "open") {
var text = 'Vérouiller';
} else {
var text = 'Dévérouiller';
}
$('#admin-content').append(`
<span class="prank">
<h2>Changer l'état de commande de crêpe :</h2>
<div class="prank-btn-accept" id="switch-state">${text}</div>
</span>
`)
}
}
});
$("#admin-content").append(`
<span class="prank">
<div id=prankDone>Nombre totale de missions achevées: ${doneCnt}</div>
@ -351,6 +377,28 @@ function get_admin(type) {
}
function refreshListener() {
$('#switch-state').click(() => {
$.ajax({
type: "POST",
url: base_url + "switchState",
data: JSON.stringify({
uid: localStorage.getItem('user'),
token: localStorage.getItem('token'),
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
if(data.state == 'open') {
$("#switch-state").text('Vérouiller');
} else {
$("#switch-state").text('Dévérouiller');
}
}
})
})
$(".prank-btn-accept").click((e) => {
let uid = e.target.parentNode.parentNode.id
$.ajax({
@ -715,8 +763,35 @@ $('#demande-button').click(function () {
});
});
var saved_form = $('#login-form').html();
function is_locked() {
}
function updateDemandes() {
if(localStorage.getItem('user') && localStorage.getItem('token')) {
$.ajax({
type: "POST",
url: base_url + "get",
data: JSON.stringify({
uid: localStorage.getItem('user'),
token: localStorage.getItem('token'),
type: "state"
}),
success: function(data) {
if(data.success) {
if(data.state == "open") {
$('#login-form').html(saved_form);
} else {
$('#login-form').html('<h2>Les commandes sont fermés pour le moment mais on revient vite !</h2>');
}
}
}
});
$.ajax({
type: "POST",
url: base_url + "get",