forked from Sanaullah-Turab/Amazon-Clone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
114 lines (107 loc) · 3.86 KB
/
admin.html
File metadata and controls
114 lines (107 loc) · 3.86 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Admin - Add Product</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles/shared/general.css" />
<link rel="stylesheet" href="styles/shared/amazon-header.css" />
<link rel="stylesheet" href="styles/pages/admin.css" />
</head>
<body>
<div class="amazon-header">
<div class="amazon-header-left-section">
<a href="amazon.html" class="header-link">
<img
class="amazon-logo"
src="images/amazon-logo-white.png"
alt="Amazon Logo"
/>
<img
class="amazon-mobile-logo"
src="images/amazon-mobile-logo-white.png"
alt="Amazon Mobile Logo"
/>
</a>
</div>
<div class="amazon-header-middle-section">
<input class="search-bar" type="text" placeholder="Search" />
<button class="search-button">
<img
class="search-icon"
src="images/icons/search-icon.png"
alt="Search Icon"
/>
</button>
</div>
<div class="ld-btn"></div>
<div class="amazon-header-right-section">
<a class="orders-link header-link" href="orders.html">
<span class="returns-text">Returns</span>
<span class="orders-text">& Orders</span>
</a>
<a class="cart-link header-link" href="checkout.html">
<img
class="cart-icon"
src="images/icons/cart-icon.png"
alt="Cart Icon"
/>
<div class="cart-quantity js-cart-quantity">0</div>
<div class="cart-text">Cart</div>
</a>
</div>
</div>
<div class="form-wrapper">
<div class="form-container">
<div class="form-left">
<h2>Add New Product</h2>
<form id="add-product-form">
<input type="text" id="name" placeholder="Product Name" required />
<textarea id="description" placeholder="Description"></textarea>
<input type="number" id="price" placeholder="Price" required />
<input type="text" id="image_path" placeholder="Image URL" />
<button type="submit" class="submit-button">Add Product</button>
</form>
</div>
<div class="form-right">
<h1>Welcome, Admin!</h1>
<p>Manage your store efficiently and add new products with ease.</p>
</div>
</div>
</div>
<script>
document
.getElementById("add-product-form")
.addEventListener("submit", async (e) => {
e.preventDefault();
const name = document.getElementById("name").value;
const description = document.getElementById("description").value;
const price = parseFloat(document.getElementById("price").value);
const image_path = document.getElementById("image_path").value;
try {
const response = await fetch("http://localhost:3000/add-product", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ name, description, price, image_path }),
});
if (response.ok) {
alert("Product added successfully!");
document.getElementById("add-product-form").reset();
} else {
alert("Error adding product");
}
} catch (error) {
console.error("Error adding product:", error);
}
});
</script>
</body>
</html>