-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadminproducts.js
120 lines (105 loc) · 3.74 KB
/
adminproducts.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
document.querySelector(".theme-toggler .dark").addEventListener("click",function(){
let cont=document.querySelector(".container")
cont.style.backgroundColor="black";
let dash=document.querySelector(".container main h1")
dash.style.color="white"
let top=document.querySelector("aside .sidebar>a .material-symbols-sharp")
top.style.color="white"
let side=document.querySelector("aside .sidebar>a")
side.style.color="white";
let right=document.querySelector(".right .recent-updates h2")
right.style.color="white";
let right1=document.querySelector(".right .sales-analytics h2")
right1.style.color="white";
let main=document.querySelector(".container main .recentorder h2")
main.style.color="white";
let insight=document.querySelector("main .insights>div ")
insight.style.boxShadow="0 2rem 3rem rgba(104, 110, 164, 0.18);"
let top1=document.querySelector(".container .right>.top>.profile>.profile-name>p")
top1.style.color="white"
let q=theme-toggler.querySelector("span:nth-child(2)")
q.style
})
document.querySelector(".theme-toggler .active").addEventListener("click",function(){
let cont=document.querySelector(".container")
cont.style.backgroundColor=" aliceblue";
let cont1=document.querySelector(".container main h1");
cont1.style.color="black";
let main1=document.querySelector(".container main .recentorder h2")
main1.style.color="black"
let right3=document.querySelector(".right .recent-updates h2")
right3.style.color="black";
let right4=document.querySelector(".right .sales-analytics h2")
right4.style.color="black";
let top1=document.querySelector(".container .right>.top>.profile>.profile-name>p")
top1.style.color="black"
let side=document.querySelector(".sidebar #dash")
side.style.color="grey"
let side1=document.querySelector(".sidebar #dash span")
side1.style.color="grey"
})
let v= document.getElementById("feedback")
v.style.display="none"
function menuitem2(){
if(v.style.display=="none"){
v.style.display="block"
}
else{
v.style.display="none"
}
}
let x2= document.getElementById("feedback")
x2.style.display="none"
function feedbackPage(){
if(x2.style.display=="none"){
x2.style.display="flex"
}
else{
x2.style.display="none"
}
}
async function products(){
try {
let data1=await fetch("http://localhost:3000/api/products");
let proData=await data1.json()
renderProducts(proData)
// console.log(proData)
} catch (error) {
console.log(error)
}
}
products();
function renderProducts(cartdata)
{
cartdata.forEach((ele,index) => {
let box=document.createElement("tr");
let td1=document.createElement("td");
td1.id = "imgsec"
let image = document.createElement('img');
image.setAttribute("src",ele.img);
td1.appendChild(image);
let td2=document.createElement("td");
td2.innerText=ele.item.substring(0, 30);
let td3=document.createElement("td");
td3.innerText=ele.id;
let td4=document.createElement("td");
td4.innerText=ele.price;
let td6=document.createElement("td");
td6.innerText=ele.rating
let td5=document.createElement("td")
var button = document.createElement('button');
button.innerText="Remove";
button.addEventListener("click", async ()=>{
try {
fetch(`http://localhost:3000/api/products/${ele.id}`, {
method: "DELETE"
})
} catch (error) {
console.log(error);
}
})
td5.append(button)
box.append(td3,td2,td1,td4,td6,td5);
document.querySelector("#todata").append(box)
});
}