-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder.js
55 lines (49 loc) · 2.1 KB
/
order.js
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
53
54
55
let status = window.localStorage.getItem("loginStatus");
function logOut() {
window.localStorage.setItem("loginStatus", "false")
window.location.href = "login.html";
}
const getUsers = () => {
axios
.get("https://5fc1a1c9cb4d020016fe6b07.mockapi.io/api/v1/orders")
.then(function (response) {
// handle success
var mydatas = response.data;
console.log(mydatas);
// let resEle = document.querySelector(".result");
// get the value of checkbox which are selected and stroed in array
let checkboxArray = [];
let finalData = [];
let filtredData = [];
document.getElementById("mytabledata").innerHTML = "";
var cb = document.getElementsByName("orders");
console.log("This is my",cb)
var total = 0;
for (var i = 0; i < cb.length; i++) {
if (cb[i].checked) {
checkboxArray.push(cb[i].value);
console.log("This is CheckboxArray ",checkboxArray) //New / Packed / Intransition / Delivered
}
}
// api data filter acc to checkbox
filtredDataTotal = mydatas.filter((item) =>
checkboxArray.includes(item.orderStatus)
);
console.log("This is Filtereddatatotal1", filtredDataTotal)
var temp = " ";
filtredDataTotal.forEach((itemData) => {
temp += "<tr >";
temp += "<td>" + itemData.id + "</td>";
temp += "<td>" + itemData.customerName + "</td>";
temp += "<td>" + itemData.orderDate + "</td>";
temp += "<td>" + itemData.amount + "</td>";
temp += "<td>" + itemData.orderStatus + "</td></tr>";
});
document.getElementById("mytabledata").innerHTML = temp;
total = filtredDataTotal.length;
let mycount1 = document.getElementById("count");
mycount1.innerHTML = `Count: ${total}`;
console.log("This is a Count", filtredDataTotal);
});
};
getUsers();