46 |
47 |
48 |
49 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | Top Selling Items
82 |
83 |
84 | Image |
85 | Item Name |
86 | Orders |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | Product Categories
100 |
101 |
102 | Id |
103 | Name |
104 | Total Products |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/frontend/adminlogin.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
137 |
138 |
139 |
144 |
151 |
152 |
153 |
154 |
155 |
Have account?
156 |
157 |
158 |
159 |
Do not have account?
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
228 |
229 |
230 |
--------------------------------------------------------------------------------
/frontend/cart.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
77 |
78 |
79 |
80 |
81 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
Category Register
114 |
117 |
118 |
119 |
120 |
121 |
View Category by id
122 |
125 |
126 |
127 |
128 |
129 |
View products by Category
130 |
133 |
134 |
135 |
136 |
137 |
Delete Category
138 |
141 |
142 |
143 |
144 |
145 |
View all Category
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/frontend/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
136 |
137 |
138 |
143 |
150 |
151 |
152 |
153 |
154 |
Have account?
155 |
156 |
157 |
158 |
Do not have account?
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
239 |
240 |
--------------------------------------------------------------------------------
/frontend/js/admin.js:
--------------------------------------------------------------------------------
1 | fetch('http://localhost:8888/product/top5')
2 | .then((response) => response.json())
3 | .then((data) => displayData(data));
4 |
5 |
6 | fetch('http://localhost:8888/category/viewAll')
7 | .then((response) => response.json())
8 | .then((data) => displayData1(data));
9 |
10 |
11 | function displayData(data){
12 |
13 | data.forEach(function(ele){
14 | let tr=document.createElement("tr")
15 | let td1=document.createElement("td")
16 | let img=document.createElement("img")
17 | img.setAttribute("src",ele.url)
18 | td1.append(img)
19 | let td2=document.createElement("td")
20 | td2.setAttribute("class","mid")
21 | td2.innerText=ele.productName
22 | let td3=document.createElement("td")
23 | td3.innerText=ele.soldCount
24 |
25 | tr.append(td1,td2,td3)
26 | document.getElementById("tab").append(tr)
27 | // document.querySelector("tbody").append(tr)
28 |
29 | });
30 |
31 | }
32 |
33 | function displayData1(data){
34 | console.log(data)
35 | data.forEach(function(ele){
36 | let tr=document.createElement("tr")
37 | let td1=document.createElement("td")
38 | td1.innerText=ele.categoryId;
39 | let td2=document.createElement("td")
40 | td2.setAttribute("class","mid")
41 | td2.innerText=ele.name
42 | let td3=document.createElement("td")
43 | td3.innerText=ele.products.length
44 |
45 | tr.append(td1,td2,td3)
46 | document.getElementById("tab1").append(tr)
47 | // document.querySelector("tbody").append(tr)
48 |
49 | });
50 |
51 | }
--------------------------------------------------------------------------------
/frontend/js/cart.js:
--------------------------------------------------------------------------------
1 |
2 | let user=JSON.parse(localStorage.getItem("user"))
3 | if(user==null){
4 | alert("please login")
5 | window.location.href="index.html"
6 | }
7 |
8 |
9 | viewCart();
10 |
11 |
12 | async function clearCart(){
13 | let uuid=user.uuid;
14 |
15 | let api_link=`http://localhost:8888/cart/clearCart/${uuid}`
16 | let response=await fetch(api_link,{
17 | method:"PUT",
18 | headers:{
19 | 'Content-Type':'application/json'
20 | }
21 | })
22 | let data=await response.json()
23 |
24 | if(data.message!=null){
25 | alert(data.message);
26 | }
27 | else{
28 | console.log(data)
29 | viewCart();
30 | }
31 | }
32 |
33 |
34 | function viewCart(){
35 | let uuid=user.uuid;
36 | fetch(`http://localhost:8888/cart/view/${uuid}`)
37 | .then((response) => response.json())
38 | .then((data) => displayData(data));
39 | }
40 |
41 |
42 | function displayData(data){
43 | console.log(data)
44 | let quantity=document.createElement("p")
45 | quantity.innerText="total quantity "+data.totalItems;
46 | quantity.setAttribute("class","quantity")
47 |
48 | let price=document.createElement("p")
49 | price.innerText="Total ₹ "+data.totalPrice;
50 | price.setAttribute("class","price")
51 | document.querySelector("#totalp").innerHTML="";
52 | document.querySelector("#totalp").append(quantity,price)
53 |
54 | displaymens(data.products);
55 | }
56 |
57 |
58 | function displaymens(mensData){
59 | document.querySelector("#parent").innerHTML="";
60 | mensData.forEach(function(el){
61 | let div=document.createElement("div")
62 | let imag=document.createElement("img")
63 | imag.setAttribute("src",el.url)
64 | imag.setAttribute("class","image")
65 |
66 | let name=document.createElement("p")
67 | name.innerText=el.productName;
68 | name.setAttribute("class","name")
69 |
70 | let btn1=document.createElement("button")
71 | btn1.innerText="-"
72 | let btn2=document.createElement("button")
73 | btn2.innerText="+"
74 | btn1.setAttribute("class","butn")
75 | btn2.setAttribute("class","butn")
76 |
77 | let spn=document.createElement("span")
78 |
79 | let quantity=document.createElement("span")
80 | quantity.innerText=el.quantity;
81 | quantity.setAttribute("class","quantity")
82 |
83 | let quantity1=document.createElement("span")
84 | quantity1.innerText="quantity";
85 | quantity1.setAttribute("class","quantity")
86 |
87 | spn.append(quantity1,btn1,quantity,btn2)
88 |
89 | let available=document.createElement("p")
90 | if(el.quantity>el.availableProduct){
91 | available.innerText="out of stock";
92 | }
93 | else if(el.availableProduct<=5){
94 | available.innerText="only "+el.availableProduct+" product left";
95 | }
96 | available.setAttribute("class","quantity")
97 |
98 | let price=document.createElement("p")
99 | price.innerText="price ₹ "+el.price
100 | price.setAttribute("class","price")
101 |
102 | let tprice=document.createElement("p")
103 | tprice.innerText="total ₹ "+el.price*el.quantity
104 | tprice.setAttribute("class","tprice")
105 |
106 | let btn=document.createElement("button")
107 | btn.innerText="Remove"
108 | btn.setAttribute("class","delete_from_cart")
109 | btn.addEventListener("click",function(){
110 | removeFromCart(el);
111 | })
112 |
113 | btn2.addEventListener("click",function(){
114 | incr(el);
115 | })
116 | btn1.addEventListener("click",function(){
117 | decr(el);
118 | })
119 |
120 | div.append(imag,name,spn,price,tprice,available,btn)
121 | document.querySelector("#parent").append(div)
122 | })
123 | }
124 |
125 |
126 | async function removeFromCart(el){
127 | let uuid=user.uuid;
128 | let pid=el.productId;
129 | let api_link=`http://localhost:8888/cart/removeItemFromCart/${pid}/${uuid}`
130 | let response=await fetch(api_link,{
131 | method:"PUT",
132 | headers:{
133 | 'Content-Type':'application/json'
134 | }
135 | })
136 | let data=await response.json()
137 |
138 | if(data.message!=null){
139 | alert(data.message);
140 | }
141 | else{
142 | viewCart();
143 | }
144 | }
145 |
146 |
147 | async function incr(el){
148 | let uuid=user.uuid;
149 | let pid=el.productId;
150 | let api_link=`http://localhost:8888/cart/increaseQuantity/${pid}/${uuid}`
151 | let response=await fetch(api_link,{
152 | method:"PUT",
153 | headers:{
154 | 'Content-Type':'application/json'
155 | }
156 | })
157 | let data=await response.json()
158 |
159 | if(data.message!=null){
160 | alert(data.message);
161 | }
162 | else{
163 | viewCart();
164 | }
165 | }
166 |
167 |
168 | async function decr(el){
169 | let uuid=user.uuid;
170 | let pid=el.productId;
171 | let api_link=`http://localhost:8888/cart/decreaseQuantity/${pid}/${uuid}`
172 | let response=await fetch(api_link,{
173 | method:"PUT",
174 | headers:{
175 | 'Content-Type':'application/json'
176 | }
177 | })
178 | let data=await response.json()
179 |
180 | if(data.message!=null){
181 | alert(data.message);
182 | }
183 | else{
184 | viewCart();
185 | }
186 | }
187 |
188 |
189 | async function checkout(){
190 |
191 | let uuid=user.uuid;
192 |
193 | let api_link=`http://localhost:8888/order/addOrder/${uuid}`
194 | let response=await fetch(api_link,{
195 | method:"POST",
196 | headers:{
197 | 'Content-Type':'application/json'
198 | }
199 | })
200 | let data=await response.json()
201 |
202 | if(data.message!=null){
203 | alert(data.message);
204 | }
205 | else{
206 | alert("order confirmed")
207 | console.log(data);
208 | }
209 | }
--------------------------------------------------------------------------------
/frontend/js/category.js:
--------------------------------------------------------------------------------
1 |
2 | let admin=JSON.parse(localStorage.getItem("admin"))
3 | if(admin==null){
4 | alert("please login")
5 | window.location.href="index.html"
6 | }
7 |
8 | async function addCat(){
9 | // let key=document.getElementById("key").value;
10 | let key=admin.uuid;
11 | let cat_data={
12 | name:document.getElementById("catname").value,
13 | }
14 |
15 | cat_data=JSON.stringify(cat_data)
16 |
17 | let api_link=`http://localhost:8888/category/add/${key}`
18 | let response=await fetch(api_link,{
19 | method:"POST",
20 | body:cat_data,
21 | headers:{
22 | 'Content-Type':'application/json'
23 | }
24 | })
25 | let data=await response.json()
26 | console.log(data)
27 |
28 | if(data.message!=null){
29 | alert(data.message);
30 | }
31 | else{
32 | alert("categoryId: "+data.categoryId+" name: "+data.name+" added successfully");
33 | }
34 | }
35 |
36 |
37 | async function viewAllCat(){
38 |
39 | fetch('http://localhost:8888/category/viewAll')
40 | .then((response) => response.json())
41 | .then((data) => displayData1(data));
42 |
43 | // http://localhost:8888/product/viewAllProduct
44 | }
45 |
46 |
47 | async function viewCatById(){
48 | let key=document.getElementById("catId").value;
49 |
50 | fetch(`http://localhost:8888/category/view/${key}`)
51 | .then((response) => response.json())
52 | .then((data) => fc(data));
53 |
54 | function fc(data){
55 | if(data.message!=null){
56 | alert(data.message);
57 | }
58 | else{
59 | alert("categoryId: "+data.categoryId+" name: "+data.name+" total products: "+data.products.length);
60 | }
61 | }
62 | }
63 |
64 |
65 | async function viewProductByCat(){
66 | let key=document.getElementById("catId1").value;
67 |
68 | fetch(`http://localhost:8888/category/viewProductByCategory/${key}`)
69 | .then((response) => response.json())
70 | .then((data) => displayData2(data));
71 | }
72 |
73 |
74 | async function deleteCat(){
75 | let key=document.getElementById("catId2").value;
76 | let uuid=admin.uuid;
77 |
78 | let api_link=`http://localhost:8888/category/delete/${key}/${uuid}`
79 | let response=await fetch(api_link,{
80 | method:"DELETE",
81 | headers:{
82 | 'Content-Type':'application/json'
83 | }
84 | })
85 | let data=await response.json()
86 | if(data.message!=null){
87 | alert(data.message);
88 | }
89 | else{
90 | alert("categoryId: "+data.categoryId+" name: "+data.name+" deleted successfully");
91 | }
92 |
93 | }
94 |
95 |
96 | function displayData1(data){
97 |
98 | let cont=document.getElementById("display")
99 | cont.innerHTML=null;
100 |
101 | let table=document.createElement("table");
102 | let p=document.createElement("p");
103 | p.setAttribute("class","proCat")
104 | p.innerText="Product Categories"
105 |
106 | let thead=document.createElement("thead");
107 | let tr1=document.createElement("tr");
108 | let th1=document.createElement("th");
109 | th1.innerText="Id";
110 | let th2=document.createElement("th");
111 | th2.setAttribute("class","mid")
112 | th2.innerText="Name"
113 | let th3=document.createElement("th");
114 | th3.innerText="Total Products"
115 | tr1.append(th1,th2,th3);
116 | thead.append(tr1);
117 | let tbody=document.createElement("tbody");
118 | tbody.setAttribute("id","tab1")
119 | table.append(thead,tbody)
120 | cont.append(p,table);
121 |
122 | data.forEach(function(ele){
123 | let tr=document.createElement("tr")
124 | let td1=document.createElement("td")
125 | td1.innerText=ele.categoryId;
126 | let td2=document.createElement("td")
127 | td2.setAttribute("class","mid")
128 | td2.innerText=ele.name
129 | let td3=document.createElement("td")
130 | td3.innerText=ele.products.length
131 |
132 | tr.append(td1,td2,td3)
133 | document.getElementById("tab1").append(tr)
134 |
135 | });
136 |
137 | }
138 |
139 |
140 | function displayData2(data){
141 |
142 | let cont=document.getElementById("display")
143 | cont.innerHTML=null;
144 |
145 | let table=document.createElement("table");
146 | let p=document.createElement("p");
147 | p.setAttribute("class","proCat")
148 | p.innerText="Products"
149 |
150 | let thead=document.createElement("thead");
151 |
152 | let tr1=document.createElement("tr");
153 |
154 | let th0=document.createElement("th");
155 | th0.innerText="Image"
156 | let th1=document.createElement("th");
157 | th1.innerText="Id";
158 | let th2=document.createElement("th");
159 | th2.innerText="Name"
160 | let th3=document.createElement("th");
161 | th3.innerText="Description"
162 | let th4=document.createElement("th");
163 | th4.innerText="Price"
164 | let th5=document.createElement("th");
165 | th5.innerText="Quantity"
166 | let th6=document.createElement("th");
167 | th6.innerText="Rating"
168 | let th7=document.createElement("th");
169 | th7.innerText="Sold"
170 |
171 | tr1.append(th0,th1,th2,th3,th4,th5,th6,th7);
172 | thead.append(tr1);
173 |
174 | let tbody=document.createElement("tbody");
175 | tbody.setAttribute("id","tab1")
176 | table.append(thead,tbody)
177 | cont.append(p,table);
178 |
179 | data.forEach(function(ele){
180 | let tr=document.createElement("tr")
181 | let td1=document.createElement("td")
182 | td1.innerText=ele.productId;
183 | let td2=document.createElement("td")
184 | td2.innerText=ele.productName
185 | let td3=document.createElement("td")
186 | td3.innerText=ele.description
187 | let td4=document.createElement("td")
188 | td4.innerText=ele.price;
189 | let td5=document.createElement("td")
190 | td5.innerText=ele.quantity
191 | let td6=document.createElement("td")
192 | td6.innerText=ele.rating
193 | let td7=document.createElement("td")
194 | td7.innerText=ele.soldCount
195 | let td0=document.createElement("td")
196 | let img=document.createElement("img")
197 | img.setAttribute("src",ele.url)
198 | td0.append(img)
199 |
200 | tr.append(td0,td1,td2,td3,td4,td5,td6,td7)
201 | document.getElementById("tab1").append(tr)
202 |
203 | });
204 |
205 |
206 | }
207 |
--------------------------------------------------------------------------------
/frontend/js/index.js:
--------------------------------------------------------------------------------
1 | async function Register(){
2 | let key=document.getElementById("key").value;
3 | let signup_data={
4 | adminEmail:document.getElementById("email").value,
5 | adminPassword:document.getElementById("password").value,
6 | adminMobile:document.getElementById("mobile").value,
7 | }
8 |
9 | signup_data=JSON.stringify(signup_data)
10 |
11 | let signup_api_link=`http://localhost:8888/admin/register?validationKey=${key}`
12 | let response=await fetch(signup_api_link,{
13 | method:"POST",
14 | body:signup_data,
15 | headers:{
16 | 'Content-Type':'application/json'
17 | }
18 | })
19 | let data=await response.json()
20 | console.log(data)
21 | }
22 |
23 |
24 | async function Login(){
25 |
26 | let login_data={
27 | mobile:document.getElementById("mobile1").value,
28 | password:document.getElementById("password1").value,
29 | }
30 |
31 | login_data=JSON.stringify(login_data)
32 |
33 | let login_api_link=`http://localhost:8888/adminlogin/login`
34 | let response=await fetch(login_api_link,{
35 | method:"POST",
36 | body:login_data,
37 | headers:{
38 | 'Content-Type':'application/json'
39 | }
40 | })
41 |
42 | let data=await response.json()
43 | fun(data)
44 |
45 | // localDateTime : "2022-11-27T17:11:33.0402306"
46 | // userId : 24
47 | // uuid : "mZKfT0"
48 |
49 | }
50 |
51 |
52 | function fun(data){
53 | if(data.uuid!=null){
54 | localStorage.setItem("admin",JSON.stringify(data))
55 | window.location.href="admin.html"
56 | }
57 | else{
58 | alert(data.message)
59 | }
60 | }
61 |
62 |
63 | async function Register1(){
64 | let signup_data={
65 | customerName:document.getElementById("name2").value,
66 | email:document.getElementById("email2").value,
67 | password:document.getElementById("password2").value,
68 | mobile:document.getElementById("mobile2").value,
69 | address: {
70 | city: "",
71 | country: "",
72 | id: 0,
73 | pincode: "",
74 | state: ""
75 | },
76 | }
77 |
78 | signup_data=JSON.stringify(signup_data)
79 |
80 | let signup_api_link=`http://localhost:8888/customer/register`
81 | let response=await fetch(signup_api_link,{
82 | method:"POST",
83 | body:signup_data,
84 | headers:{
85 | 'Content-Type':'application/json'
86 | }
87 | })
88 | let data=await response.json()
89 | console.log(data)
90 | }
91 |
92 |
93 | async function Login1(){
94 |
95 | let login_data={
96 | mobile:document.getElementById("mobile3").value,
97 | password:document.getElementById("password3").value,
98 | }
99 |
100 | login_data=JSON.stringify(login_data)
101 |
102 | let login_api_link=`http://localhost:8888/userlogin/login`
103 | let response=await fetch(login_api_link,{
104 | method:"POST",
105 | body:login_data,
106 | headers:{
107 | 'Content-Type':'application/json'
108 | }
109 | })
110 |
111 | let data=await response.json()
112 | fun1(data)
113 | }
114 |
115 |
116 | function fun1(data){
117 | if(data.uuid!=null){
118 | localStorage.setItem("user",JSON.stringify(data))
119 | window.location.href="user.html"
120 | }
121 | else{
122 | alert(data.message)
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/frontend/js/order.js:
--------------------------------------------------------------------------------
1 |
2 | let admin=JSON.parse(localStorage.getItem("admin"))
3 | if(admin==null){
4 | alert("please login")
5 | window.location.href="index.html"
6 | }
7 |
8 |
9 | async function viewOrdersByDate(){
10 | let s=document.getElementById("startdate").value;
11 | let e=document.getElementById("enddate").value;
12 |
13 | fetch(`http://localhost:8888/order/viewOrdersByDate/${s}/${e}`)
14 | .then((response) => response.json())
15 | .then((data) => displayOrd(data));
16 | }
17 |
18 | async function viewAllOrder(){
19 | fetch(`http://localhost:8888/order/viewAllOrder`)
20 | .then((response) => response.json())
21 | .then((data) => displayOrd(data));
22 | }
23 |
24 | function displayOrd(data){
25 | console.log(data)
26 | if(data.message!=null){
27 | alert(data.message)
28 | }
29 | else{
30 | let cont=document.getElementById("parent")
31 | cont.innerHTML=null;
32 | data.forEach(el => {
33 | console.log(el)
34 | let div=document.createElement("div");
35 | let p1=document.createElement("p");
36 | p1.innerText="order date : "+el.orderDate
37 | let p2=document.createElement("p");
38 | p2.innerText="order time : "+el.orderTime
39 | let p3=document.createElement("p");
40 | p3.innerText="order status : "+el.status
41 |
42 | let btn=document.createElement("button")
43 | btn.innerText="update status"
44 | btn.addEventListener("click",function(){
45 | updateStatus(el);
46 | })
47 |
48 | let p4=document.createElement("p");
49 | p4.innerText="customer name : "+el.customer.customerName
50 |
51 | let p5=document.createElement("p");
52 | p5.innerText="customer mobile : "+el.customer.mobile
53 |
54 | let p6=document.createElement("p");
55 | p6.innerText="customer email : "+el.customer.email
56 |
57 | div.addEventListener("click",function(){
58 | displayData2(el.products);
59 | })
60 |
61 | div.append(p1,p2,p3,btn,p4,p5,p6)
62 | cont.append(div)
63 | });
64 | }
65 | }
66 |
67 | async function updateStatus(el){
68 | let status = prompt("enter status", "confirmed");
69 |
70 | let api_link=`http://localhost:8888/order/updateOrderStatus/${el.orderId}/${status}`
71 |
72 | let response=await fetch(api_link,{
73 | method:"PUT",
74 | headers:{
75 | 'Content-Type':'application/json'
76 | }
77 | })
78 | let data=await response.json()
79 |
80 | if(data.message!=null){
81 | alert(data.message);
82 | }
83 | else{
84 | console.log(data)
85 | window.location.reload();
86 | }
87 | }
88 |
89 |
90 | function displayData2(data){
91 |
92 | console.log(data)
93 |
94 | let cont=document.getElementById("display")
95 | cont.innerHTML=null;
96 |
97 | let table=document.createElement("table");
98 | let p=document.createElement("p");
99 | p.setAttribute("class","proCat")
100 | p.innerText="Products"
101 |
102 | let thead=document.createElement("thead");
103 |
104 | let tr1=document.createElement("tr");
105 |
106 | let th0=document.createElement("th");
107 | th0.innerText="Image"
108 | let th1=document.createElement("th");
109 | th1.innerText="Id";
110 | let th2=document.createElement("th");
111 | th2.innerText="Name"
112 | let th3=document.createElement("th");
113 | th3.innerText="Description"
114 | let th4=document.createElement("th");
115 | th4.innerText="Price"
116 | let th5=document.createElement("th");
117 | th5.innerText="Quantity"
118 |
119 | tr1.append(th0,th1,th2,th3,th4,th5);
120 | thead.append(tr1);
121 |
122 | let tbody=document.createElement("tbody");
123 | tbody.setAttribute("id","tab1")
124 | table.append(thead,tbody)
125 | cont.append(p,table);
126 |
127 | data.forEach(function(ele){
128 | let tr=document.createElement("tr")
129 | let td1=document.createElement("td")
130 | td1.innerText=ele.productId;
131 | let td2=document.createElement("td")
132 | td2.innerText=ele.productName
133 | let td3=document.createElement("td")
134 | td3.innerText=ele.description
135 | let td4=document.createElement("td")
136 | td4.innerText=ele.price;
137 | let td5=document.createElement("td")
138 | td5.innerText=ele.quantity
139 |
140 | let td0=document.createElement("td")
141 | let img=document.createElement("img")
142 | img.setAttribute("src",ele.url)
143 | td0.append(img)
144 |
145 | tr.append(td0,td1,td2,td3,td4,td5)
146 | document.getElementById("tab1").append(tr)
147 |
148 | });
149 |
150 |
151 | }
152 |
153 | viewAllOrder();
--------------------------------------------------------------------------------
/frontend/js/product.js:
--------------------------------------------------------------------------------
1 |
2 | let admin=JSON.parse(localStorage.getItem("admin"))
3 | if(admin==null){
4 | alert("please login")
5 | window.location.href="index.html"
6 | }
7 |
8 | async function addProduct(){
9 |
10 | let key=admin.uuid;
11 | let cat_id=document.getElementById("catid").value;
12 |
13 | let pro_data={
14 | productName:document.getElementById("name").value,
15 | description:document.getElementById("desc").value,
16 | price:document.getElementById("price").value,
17 | quantity:document.getElementById("quan").value,
18 | url:document.getElementById("url").value,
19 | rating: 0,
20 | ratingCount: 0,
21 | soldCount: 0,
22 | }
23 |
24 | pro_data=JSON.stringify(pro_data)
25 |
26 | let api_link=`http://localhost:8888/product/add/${cat_id}/${key}`
27 | let response=await fetch(api_link,{
28 | method:"POST",
29 | body:pro_data,
30 | headers:{
31 | 'Content-Type':'application/json'
32 | }
33 | })
34 | let data=await response.json()
35 |
36 | if(data.message!=null){
37 | alert(data.message);
38 | }
39 | else{
40 | displayData1(data)
41 | }
42 | }
43 |
44 | async function deletePro(){
45 | let key=document.getElementById("proId2").value;
46 | let uuid=admin.uuid;
47 |
48 | let api_link=`http://localhost:8888/product/delete/${key}/${uuid}`
49 | let response=await fetch(api_link,{
50 | method:"DELETE",
51 | headers:{
52 | 'Content-Type':'application/json'
53 | }
54 | })
55 | let data=await response.json()
56 |
57 | if(data.message!=null){
58 | alert(data.message);
59 | }
60 | else{
61 | displayData1(data)
62 | }
63 |
64 | }
65 |
66 | async function viewAllPro(){
67 |
68 | fetch('http://localhost:8888/product/viewAllProduct')
69 | .then((response) => response.json())
70 | .then((data) => displayData2(data));
71 |
72 | }
73 |
74 | async function viewProByName(){
75 | let key=document.getElementById("pro").value;
76 |
77 | fetch(`http://localhost:8888/product/productByName/${key}`)
78 | .then((response) => response.json())
79 | .then((data) => displayData2(data));
80 | }
81 |
82 | async function viewProById(){
83 | let key=document.getElementById("proId").value;
84 |
85 | fetch(`http://localhost:8888/product/view/${key}`)
86 | .then((response) => response.json())
87 | .then((data) => displayData1(data));
88 | }
89 |
90 | async function updateProduct(){
91 |
92 | let key=admin.uuid;
93 |
94 | let pro_data={
95 | productId:document.getElementById("proId1").value,
96 | productName:document.getElementById("name1").value,
97 | description:document.getElementById("desc1").value,
98 | price:document.getElementById("price1").value,
99 | quantity:document.getElementById("quan1").value,
100 | url:document.getElementById("url1").value,
101 | }
102 |
103 | pro_data=JSON.stringify(pro_data)
104 |
105 | let api_link=`http://localhost:8888/product/update/${key}`
106 | let response=await fetch(api_link,{
107 | method:"PUT",
108 | body:pro_data,
109 | headers:{
110 | 'Content-Type':'application/json'
111 | }
112 | })
113 | let data=await response.json()
114 |
115 |
116 | if(data.message!=null){
117 | alert(data.message);
118 | }
119 | else{
120 | displayData1(data)
121 | }
122 | }
123 |
124 |
125 |
126 | function displayData2(data){
127 |
128 | let cont=document.getElementById("display")
129 | cont.innerHTML=null;
130 |
131 | let table=document.createElement("table");
132 | let p=document.createElement("p");
133 | p.setAttribute("class","proCat")
134 | p.innerText="Products"
135 |
136 | let thead=document.createElement("thead");
137 |
138 | let tr1=document.createElement("tr");
139 |
140 | let th0=document.createElement("th");
141 | th0.innerText="Image"
142 | let th1=document.createElement("th");
143 | th1.innerText="Id";
144 | let th2=document.createElement("th");
145 | th2.innerText="Name"
146 | let th3=document.createElement("th");
147 | th3.innerText="Description"
148 | let th4=document.createElement("th");
149 | th4.innerText="Price"
150 | let th5=document.createElement("th");
151 | th5.innerText="Quantity"
152 | let th6=document.createElement("th");
153 | th6.innerText="Rating"
154 | let th7=document.createElement("th");
155 | th7.innerText="Sold"
156 |
157 | tr1.append(th0,th1,th2,th3,th4,th5,th6,th7);
158 | thead.append(tr1);
159 |
160 | let tbody=document.createElement("tbody");
161 | tbody.setAttribute("id","tab1")
162 | table.append(thead,tbody)
163 | cont.append(p,table);
164 |
165 | data.forEach(function(ele){
166 | let tr=document.createElement("tr")
167 | let td1=document.createElement("td")
168 | td1.innerText=ele.productId;
169 | let td2=document.createElement("td")
170 | td2.innerText=ele.productName
171 | let td3=document.createElement("td")
172 | td3.innerText=ele.description
173 | let td4=document.createElement("td")
174 | td4.innerText=ele.price;
175 | let td5=document.createElement("td")
176 | td5.innerText=ele.quantity
177 | let td6=document.createElement("td")
178 | td6.innerText=ele.rating
179 | let td7=document.createElement("td")
180 | td7.innerText=ele.soldCount
181 | let td0=document.createElement("td")
182 | let img=document.createElement("img")
183 | img.setAttribute("src",ele.url)
184 | td0.append(img)
185 |
186 | tr.append(td0,td1,td2,td3,td4,td5,td6,td7)
187 | document.getElementById("tab1").append(tr)
188 |
189 | });
190 |
191 |
192 | }
193 |
194 | function displayData1(ele){
195 |
196 | let cont=document.getElementById("display")
197 | cont.innerHTML=null;
198 |
199 | let table=document.createElement("table");
200 | let p=document.createElement("p");
201 | p.setAttribute("class","proCat")
202 | p.innerText="Product"
203 |
204 | let thead=document.createElement("thead");
205 |
206 | let tr1=document.createElement("tr");
207 |
208 | let th0=document.createElement("th");
209 | th0.innerText="Image"
210 | let th1=document.createElement("th");
211 | th1.innerText="Id";
212 | let th2=document.createElement("th");
213 | th2.innerText="Name"
214 | let th3=document.createElement("th");
215 | th3.innerText="Description"
216 | let th4=document.createElement("th");
217 | th4.innerText="Price"
218 | let th5=document.createElement("th");
219 | th5.innerText="Quantity"
220 | let th6=document.createElement("th");
221 | th6.innerText="Rating"
222 | let th7=document.createElement("th");
223 | th7.innerText="Sold"
224 |
225 | tr1.append(th0,th1,th2,th3,th4,th5,th6,th7);
226 | thead.append(tr1);
227 |
228 | let tbody=document.createElement("tbody");
229 | tbody.setAttribute("id","tab1")
230 | table.append(thead,tbody)
231 | cont.append(p,table);
232 |
233 | // data.forEach(function(ele){
234 | let tr=document.createElement("tr")
235 | let td1=document.createElement("td")
236 | td1.innerText=ele.productId;
237 | let td2=document.createElement("td")
238 | td2.innerText=ele.productName
239 | let td3=document.createElement("td")
240 | td3.innerText=ele.description
241 | let td4=document.createElement("td")
242 | td4.innerText=ele.price;
243 | let td5=document.createElement("td")
244 | td5.innerText=ele.quantity
245 | let td6=document.createElement("td")
246 | td6.innerText=ele.rating
247 | let td7=document.createElement("td")
248 | td7.innerText=ele.soldCount
249 | let td0=document.createElement("td")
250 | let img=document.createElement("img")
251 | img.setAttribute("src",ele.url)
252 | td0.append(img)
253 |
254 | tr.append(td0,td1,td2,td3,td4,td5,td6,td7)
255 | document.getElementById("tab1").append(tr)
256 |
257 | // });
258 |
259 |
260 | }
261 |
--------------------------------------------------------------------------------
/frontend/js/user.js:
--------------------------------------------------------------------------------
1 | let user=JSON.parse(localStorage.getItem("user"))
2 | if(user==null){
3 | alert("please login")
4 | window.location.href="index.html"
5 | }
6 |
7 |
8 | async function viewProByName(){
9 | event.preventDefault()
10 | let key=document.getElementById("pro").value;
11 |
12 | fetch(`http://localhost:8888/product/productByName/${key}`)
13 | .then((response) => response.json())
14 | .then((data) => displaymens(data));
15 | }
16 |
17 |
18 | async function viewAllPro(){
19 |
20 | fetch('http://localhost:8888/product/viewAllProduct')
21 | .then((response) => response.json())
22 | .then((data) => displaymens(data));
23 |
24 | }
25 |
26 |
27 | viewAllPro()
28 |
29 |
30 | function displaymens(mensData){
31 | document.querySelector("#parent").innerHTML="";
32 | mensData.forEach(function(el){
33 |
34 | let div=document.createElement("div")
35 | div.setAttribute("class","product")
36 |
37 | let imag=document.createElement("img")
38 | imag.setAttribute("src",el.url)
39 | imag.setAttribute("class","image")
40 |
41 | let name=document.createElement("h3")
42 | name.innerText=el.productName;
43 | name.setAttribute("class","name")
44 |
45 | let desc=document.createElement("p")
46 | desc.innerText=el.description;
47 | desc.setAttribute("class","desc")
48 |
49 | let price=document.createElement("p")
50 | price.innerText="₹"+el.price
51 | price.setAttribute("class","price")
52 |
53 | let btn=document.createElement("button")
54 | btn.innerText="Add to Cart"
55 | btn.setAttribute("class","add_to_cart")
56 | btn.addEventListener("click",function(){
57 | btn.disabled=true
58 | btn.innerText="Go to Cart"
59 | addToCart(el)
60 | })
61 |
62 | div.append(imag,name,desc,price,btn)
63 | document.querySelector("#parent").append(div)
64 | })
65 | }
66 |
67 |
68 | async function addToCart(el){
69 |
70 | let pid=el.productId;
71 | let uuid=user.uuid;
72 |
73 | let api_link=`http://localhost:8888/cart/addItemIntoCart/${pid}/${uuid}`
74 |
75 | let response=await fetch(api_link,{
76 | method:"PUT",
77 | headers:{
78 | 'Content-Type':'application/json'
79 | }
80 | })
81 | let data=await response.json()
82 |
83 | if(data.message!=null){
84 | alert(data.message);
85 | }
86 | else{
87 | console.log(data)
88 | }
89 |
90 | }
91 |
92 |
93 | async function viewAllCat(){
94 | fetch('http://localhost:8888/category/viewAll')
95 | .then((response) => response.json())
96 | .then((data) => discat(data));
97 | }
98 |
99 |
100 | function discat(data){
101 | document.querySelector("#parent").innerHTML="";
102 | data.forEach(e => {
103 | let div=document.createElement("div");
104 | div.innerText=e.name
105 |
106 | div.addEventListener("click",function(){
107 | displaymens(e.products);
108 | })
109 |
110 | document.getElementById("parent").append(div)
111 | });
112 | }
113 |
114 |
115 | async function viewOrder(){
116 | let uuid=user.uuid;
117 | fetch(`http://localhost:8888/customer/viewOrders/${uuid}`)
118 | .then((response) => response.json())
119 | .then((data) => disOrder(data));
120 | }
121 |
122 |
123 | function disOrder(data){
124 | console.log(data)
125 | document.querySelector("#parent").innerHTML="";
126 | data.forEach(e => {
127 | let div=document.createElement("div");
128 | let p1=document.createElement("p");
129 | p1.innerText="Order date : "+e.orderDate
130 | let p2=document.createElement("p");
131 | p2.innerText="Order time : "+e.orderTime
132 | let p3=document.createElement("p");
133 | p3.innerText="Order status : "+e.status
134 | let p4=document.createElement("p");
135 | p4.innerText="total products : "+e.products.length
136 | div.append(p1,p2,p3,p4)
137 |
138 | div.addEventListener("click",function(){
139 | displayOrder(e.products);
140 | })
141 |
142 | document.getElementById("parent").append(div)
143 | });
144 | }
145 |
146 |
147 | function displayOrder(mensData){
148 | console.log(mensData)
149 | document.querySelector("#parent").innerHTML="";
150 | mensData.forEach(function(el){
151 |
152 | let div=document.createElement("div")
153 | let imag=document.createElement("img")
154 | imag.setAttribute("src",el.url)
155 | imag.setAttribute("class","image")
156 |
157 | let name=document.createElement("p")
158 | name.innerText=el.productName;
159 | name.setAttribute("class","name")
160 |
161 | let price=document.createElement("p")
162 | price.innerText="₹"+el.price
163 | price.setAttribute("class","price")
164 |
165 | let q=document.createElement("p")
166 | q.innerText="quantity "+el.quantity
167 | q.setAttribute("class","price")
168 |
169 | let btn=document.createElement("button")
170 |
171 | div.append(imag,name,price,q,btn)
172 | document.querySelector("#parent").append(div)
173 | })
174 | }
175 |
--------------------------------------------------------------------------------
/frontend/nav.css:
--------------------------------------------------------------------------------
1 |
2 | /* ===========css for navbar=========== */
3 | .top-nav {
4 | /* font-family: 'Exo Space'; */
5 | width: 100%;
6 | height: 50px;
7 | display: flex;
8 | flex-direction: row;
9 | align-items: center;
10 | justify-content: space-between;
11 | background-color: #E0E0E0;
12 | color: #001C55;
13 | padding: 1em;
14 | position:fixed;
15 | z-index: 1;
16 | top: 0;
17 | }
18 |
19 | .menu {
20 | display: flex;
21 | flex-direction: row;
22 | list-style-type: none;
23 | margin: 0;
24 | padding: 0;
25 | }
26 |
27 | .menu > li {
28 | margin: 0 1rem;
29 | overflow: hidden;
30 | }
31 |
32 | .menu-button-container {
33 | display: none;
34 | width: 30px;
35 | cursor: pointer;
36 | flex-direction: column;
37 | justify-content: center;
38 | align-items: center;
39 | }
40 |
41 | #menu-toggle {
42 | display: none;
43 | }
44 |
45 | .menu-button,
46 | .menu-button::before,
47 | .menu-button::after {
48 | display: block;
49 | background-color: black;
50 | position: absolute;
51 | height: 4px;
52 | width: 30px;
53 | transition: transform 400ms cubic-bezier(0.23, 1, 0.32, 1);
54 | border-radius: 2px;
55 | }
56 |
57 | .menu-button::before {
58 | content: '';
59 | margin-top: -8px;
60 | }
61 |
62 | .menu-button::after {
63 | content: '';
64 | margin-top: 8px;
65 | }
66 |
67 | #menu-toggle:checked + .menu-button-container .menu-button::before {
68 | margin-top: 0px;
69 | transform: rotate(405deg);
70 | }
71 |
72 | #menu-toggle:checked + .menu-button-container .menu-button {
73 | background: rgba(255, 255, 255, 0);
74 | }
75 |
76 | #menu-toggle:checked + .menu-button-container .menu-button::after {
77 | margin-top: 0px;
78 | transform: rotate(-405deg);
79 | }
80 |
81 |
82 | .tdn{
83 | text-decoration: none;
84 | color: #001C55;
85 | }
86 |
87 | .menu>li{
88 | font-weight: bold;
89 | }
90 |
91 |
92 |
93 | /* -----------------------------------media query for nav bar--------------------------------- */
94 | /* -----------------------------------media query for nav bar--------------------------------- */
95 | @media (max-width: 878px) {
96 | .menu-button-container {
97 | display: flex;
98 | }
99 | .menu {
100 | position: absolute;
101 | top: 0;
102 | margin-top: 50px;
103 | left: 0;
104 | flex-direction: column;
105 | width: 100%;
106 | justify-content: center;
107 | align-items: center;
108 | }
109 | #menu-toggle ~ .menu li {
110 | height: 0;
111 | margin: 0;
112 | padding: 0;
113 | border: 0;
114 | transition: height 400ms cubic-bezier(0.23, 1, 0.32, 1);
115 | }
116 | #menu-toggle:checked ~ .menu li {
117 | height: 2.5em;
118 | padding: 0.5em;
119 | transition: height 400ms cubic-bezier(0.23, 1, 0.32, 1);
120 | }
121 | .menu > li {
122 | display: flex;
123 | justify-content: center;
124 | margin: 0;
125 | padding: 0.5em 0;
126 | width: 100%;
127 | color: black;
128 | background-color: #fff;
129 | }
130 | }
131 |
132 |
--------------------------------------------------------------------------------
/frontend/order.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
90 |
91 |
92 |
93 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/frontend/product.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
75 |
76 |
77 |
78 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
Add Product
111 |
121 |
122 |
123 |
124 |
125 |
Update Product
126 |
135 |
136 |
137 |
138 |
139 |
View all Products
140 |
141 |
142 |
143 |
144 |
Search Product
145 |
148 |
149 |
150 |
151 |
152 |
View Product
153 |
156 |
157 |
158 |
159 |
160 |
Delete Product
161 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
--------------------------------------------------------------------------------
/frontend/style.css:
--------------------------------------------------------------------------------
1 |
2 | * {
3 | font-family: sans-serif;
4 | box-sizing: border-box;
5 | }
6 |
7 | body {
8 | margin: 0;
9 | background: #f3f5fb;
10 | }
11 |
12 | .flex-page {
13 | display: flex;
14 | }
15 |
16 |
17 | .side-nav {
18 | background: #FFFFFF;
19 | position: sticky;
20 | top: 0;
21 | left: 0;
22 | height: 100vh;
23 | }
24 |
25 | .side-nav ul {
26 | margin: 0;
27 | padding: 0;
28 | }
29 |
30 | .side-nav ul li a {
31 | padding: 0.75rem 1rem;
32 | color: black;
33 | text-decoration: none;
34 | cursor: pointer;
35 | display: block;
36 | border-top: 1px solid rgb(187, 224, 235);
37 | border-bottom: 1px solid rgb(187, 224, 235);
38 | }
39 | .side-nav ul li a svg{
40 | width: 99%;
41 | margin: auto;
42 | }
43 |
44 | .side-nav ul li a p{
45 | text-align: center;
46 | }
47 |
48 | .now{
49 | background-color: rgb(246, 248, 252);
50 | border: 1px solid rgb(187, 224, 235);
51 | }
52 |
53 | #right{
54 | padding: 20px;
55 | display: flex;
56 | gap: 20px;
57 | }
58 |
--------------------------------------------------------------------------------
/frontend/user.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |