diff --git a/static/js/main.js b/static/js/main.js
index 21a1e3c..47840fb 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -61,6 +61,8 @@ $("#logo").click(function () {
if (localStorage.getItem('token')) {
if (localStorage.getItem('isAdmin')) {
show_page('#admin-page');
+ // Load prank by default
+
}
else {
show_page('#demande-page');
@@ -71,6 +73,76 @@ $("#logo").click(function () {
}
});
+function get_admin(type) {
+ $("#admin-content").innerHTML = "";
+ $.ajax({
+ type: "POST",
+ url: base_url + "login",
+ data: JSON.stringify({
+ uid: localStorage.getItem('user'),
+ token: localStorage.getItem('token'),
+ type: type,
+ }),
+ contentType: "application/json; charset=utf-8",
+ dataType: "json",
+
+ success: function (data) {
+ if(data.success) {
+ switch (type) {
+ case: "prank":
+ let doneCnt = 0;
+ let prankData = [];
+ for (prankUid in data.prankData) {
+ data.prankData[prankUid].prankUid = prankUid;
+ prankData.push(data.prankData[prankUid]);
+ }
+ prankData.sort((a, b) => Date(a.date) - Date(b.date));
+ for (entry in prankData) {
+ switch (prankData[entry].type) {
+ case: "crêpe":
+ if (prankData[entry].state == "pending"
+ || prankData[entry].state == "accepted") {
+ $("#admin-content").insertAdjacentHTML("beforeend", `
+
+ Demande de crêpe par ${prankData[entry].creator}
+ Quantité: ${prankData[entry].amount}
+ Garniture: ${prankData[entry].supplement}
+ Livraison: ${prankData[entry].where}
+ Livraison: ${prankData[entry].note}
+
+
+ ${(prankData[entry].state == "pending") ? "Accepter" : "Récupérer (accepté par: "+prankData[entry].manageBy+")"}
+ Refuser
+ Done
+
+
+ `)
+ } else if(prankData[entry].state == "done") {
+ doneCnt++;
+ }
+ break;
+ case: "kidnap":
+ // On garde ou pas ?
+ break;
+ }
+ }
+ break;
+ case: "treasure":
+ break;
+ case: "activity":
+ break;
+ }
+ } else {
+ alert(data.why);
+ }
+
+ }
+ });
+}
+
$(window).on("load", function() {
/* Register the Service Worker */