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 @@
-
+
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() {