-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.js
More file actions
52 lines (44 loc) · 1.67 KB
/
admin.js
File metadata and controls
52 lines (44 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const correctCredentials = {
name: "cantech",
password: "tist"
};
function login() {
const inputName = document.getElementById("adminName").value.trim();
const inputPassword = document.getElementById("adminPassword").value;
const errorMsg = document.getElementById("errorMsg");
if (inputName === correctCredentials.name && inputPassword === correctCredentials.password) {
document.querySelector(".login-container").style.display = "none";
document.getElementById("adminDashboard").style.display = "block";
displayOrderCounts();
} else {
errorMsg.textContent = "Incorrect name or password. Please try again.";
}
}
function displayOrderCounts() {
const orders = JSON.parse(localStorage.getItem("orders")) || [];
const counts = {};
orders.forEach(order => {
order.forEach(item => {
counts[item] = (counts[item] || 0) + 1;
});
});
const orderList = document.getElementById("orderList");
orderList.innerHTML = "";
for (let item in counts) {
const li = document.createElement("li");
li.textContent = `${item}: ${counts[item]}`;
orderList.appendChild(li);
}
}
function saveMenu(day) {
const menuInput = document.getElementById(`${day}Menu`).value;
localStorage.setItem(day, menuInput); // Saving the menu input for each day in localStorage
alert(`${day.charAt(0).toUpperCase() + day.slice(1)}'s menu saved.`);
}
function finaliseOrder() {
alert("Order has been finalised.");
// Add any other finalization logic if necessary
}
function finaliseOrder() {
window.location.href = "newhome.html"; // Redirect to your final payment page
}