From 68b2fb3464479936bad851a23cde4c04b8e5929c Mon Sep 17 00:00:00 2001 From: johan Date: Sun, 8 Jan 2023 16:34:56 +0100 Subject: [PATCH] =?UTF-8?q?On=20peut=20manger=20des=20cr=C3=AApes,=20?= =?UTF-8?q?=C3=A0=20table=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/main.css | 4 ++-- static/index.html | 11 ++++++++- static/js/main.js | 55 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/static/css/main.css b/static/css/main.css index c258fed..419395a 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -248,7 +248,7 @@ button[type="submit"]:hover { border-left: 3px solid black; } -.activity-uid, .prank-uid, .prank-date, .treasure-uid, .treasure-date, #activite-place { +.activity-uid, .prank-uid, .prank-date, .treasure-uid, .treasure-date, #activite-place, .prank-status { color: #00000078; margin-top: 5px; font-size: 12px; @@ -262,7 +262,7 @@ button[type="submit"]:hover { margin-left: 10px; } -#error-message { +#error-message, #error-message-demande { color: red; } diff --git a/static/index.html b/static/index.html index 9a18493..69e8865 100644 --- a/static/index.html +++ b/static/index.html @@ -137,7 +137,12 @@
- +
@@ -145,6 +150,9 @@
+
+

+
@@ -154,6 +162,7 @@

Vos demandes en cours

+
diff --git a/static/js/main.js b/static/js/main.js index c8a5b34..7486e0b 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -525,8 +525,8 @@ $('#demande-button').click(function () { type: "crêpe", amount: $('#demande-amount').val(), where: $('#demande-where').val(), - supplement: $('#demande-supplement').val(), - note: $('#demande-note').val() + supplement: $('#demande-supp').val(), + note: $('#demande-note').val(), }), contentType: "application/json; charset=utf-8", dataType: "json", @@ -534,13 +534,61 @@ $('#demande-button').click(function () { success: function(data) { if(data.success) { $('#demande-form input').val(""); + updateDemandes(); } else { - alert(data.why); + $('#error-message-demande').empty(); + t = new TypeIt('#error-message-demande', { + speed: 100, + lifeLike: true + }) + .type(data.why) + .go(); + if(data.why.startsWith('Token expired') || data.why.startsWith('Not authen')) + show_page("#login-page"); } } }); }); +function updateDemandes() { + $.ajax({ + type: "POST", + url: base_url + "get", + data: JSON.stringify({ + uid: localStorage.getItem('user'), + token: localStorage.getItem('token'), + type: "prank" + + }), + contentType: "application/json; charset=utf-8", + dataType: "json", + + success: function (data) { + if(data.success) { + $('#demande-list').html(''); + let pd = data.prankData; + for(const pd_uid in pd) { + $('#demande-list').append(` + +

Demande de crêpe

+
Quantité: ${pd[pd_uid].amount}
+
Garniture: ${pd[pd_uid].supplement}
+
Livraison: ${pd[pd_uid].where}
+
Notes: ${pd[pd_uid].note}
+
Statue: ${pd[pd_uid].state}
+
+ + `) + } + } + else { + console.alert(data.why); + } + } + + }); +} + function updateNextActivity() { $.ajax({ type: "POST", @@ -604,6 +652,7 @@ $(window).on("load", function() { } updateNextActivity(); + updateDemandes(); /* load timer */ window.setInterval(function() {