Spaces:
Sleeping
Sleeping
Update templates/menu_page.html
Browse files- templates/menu_page.html +76 -107
templates/menu_page.html
CHANGED
@@ -59,22 +59,7 @@
|
|
59 |
#appetizer-btn:hover {
|
60 |
background-color: #ff7f00;
|
61 |
}
|
62 |
-
|
63 |
-
/* Cart page styling */
|
64 |
-
.cart-page {
|
65 |
-
background-color: #4169E1;
|
66 |
-
padding: 20px;
|
67 |
-
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
68 |
-
margin-top: 50px;
|
69 |
-
border-radius: 8px;
|
70 |
-
}
|
71 |
-
|
72 |
-
.cart-total {
|
73 |
-
font-size: 1.5rem;
|
74 |
-
font-weight: bold;
|
75 |
-
margin-top: 10px;
|
76 |
-
}
|
77 |
-
|
78 |
input, textarea {
|
79 |
width: 100%;
|
80 |
padding: 8px;
|
@@ -82,27 +67,37 @@
|
|
82 |
border-radius: 4px;
|
83 |
border: 1px solid #ccc;
|
84 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
</style>
|
86 |
</head>
|
87 |
<body>
|
88 |
|
89 |
-
<!-- Page
|
90 |
-
<div id="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
<h1>Welcome to Biryani Hub Menu</h1>
|
92 |
-
<h3
|
93 |
<button id="main-course-btn">Main Course</button>
|
94 |
<button id="appetizer-btn">Appetizers</button>
|
95 |
</div>
|
96 |
|
97 |
-
<!-- Page 2: Cart Summary -->
|
98 |
-
<div id="cart-page" class="cart-page" style="display: none;">
|
99 |
-
<h1>Your Cart</h1>
|
100 |
-
<div id="cart-items"></div>
|
101 |
-
<h3 id="cart-total"></h3>
|
102 |
-
<button id="back-to-menu-btn" class="order-btn">Back to Menu</button>
|
103 |
-
<button id="place-order-btn" class="order-btn">Place Order</button>
|
104 |
-
</div>
|
105 |
-
|
106 |
<script>
|
107 |
// Sample menu data
|
108 |
const menuData = {
|
@@ -117,94 +112,68 @@
|
|
117 |
]
|
118 |
};
|
119 |
|
120 |
-
//
|
121 |
-
let
|
122 |
-
|
123 |
-
const cartPage = document.getElementById('cart-page');
|
124 |
|
125 |
-
//
|
126 |
-
|
127 |
-
|
128 |
-
if (item) {
|
129 |
-
const cartItem = cart.find(ci => ci.name.toLowerCase() === itemName.toLowerCase());
|
130 |
-
if (cartItem) {
|
131 |
-
cartItem.quantity += quantity;
|
132 |
-
} else {
|
133 |
-
cart.push({ name: item.name, price: item.price, quantity: quantity });
|
134 |
-
}
|
135 |
-
alert(item.name + " added to cart!");
|
136 |
-
}
|
137 |
-
}
|
138 |
|
139 |
-
//
|
140 |
-
function
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
}
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
} else {
|
156 |
-
|
157 |
-
const itemDiv = document.createElement('div');
|
158 |
-
itemDiv.classList.add('menu-item');
|
159 |
-
itemDiv.innerHTML = `
|
160 |
-
<div class="details">
|
161 |
-
<h3>${item.name}</h3>
|
162 |
-
<p>Price: ₹${item.price} x ${item.quantity}</p>
|
163 |
-
</div>
|
164 |
-
`;
|
165 |
-
cartItemsContainer.appendChild(itemDiv);
|
166 |
-
total += item.price * item.quantity;
|
167 |
-
});
|
168 |
}
|
169 |
-
|
170 |
-
}
|
171 |
-
|
172 |
-
// Function to handle order placement and sending data to Salesforce
|
173 |
-
document.getElementById("place-order-btn").addEventListener("click", function() {
|
174 |
-
// Assume login info is already available (email and phone number)
|
175 |
-
const loginEmail = "[email protected]"; // Replace with actual login email
|
176 |
-
const loginPhone = "1234567890"; // Replace with actual login phone
|
177 |
|
178 |
-
|
179 |
-
|
|
|
|
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
items: cart,
|
185 |
-
totalAmount: total
|
186 |
-
};
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
console.error("Error placing order:", error);
|
205 |
-
alert("There was an error placing your order. Please try again.");
|
206 |
});
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
</script>
|
209 |
|
210 |
</body>
|
|
|
59 |
#appetizer-btn:hover {
|
60 |
background-color: #ff7f00;
|
61 |
}
|
62 |
+
/* Additional styling for pages */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
input, textarea {
|
64 |
width: 100%;
|
65 |
padding: 8px;
|
|
|
67 |
border-radius: 4px;
|
68 |
border: 1px solid #ccc;
|
69 |
}
|
70 |
+
/* Login styling */
|
71 |
+
.login-container {
|
72 |
+
text-align: center;
|
73 |
+
margin-top: 50px;
|
74 |
+
}
|
75 |
+
.login-container input {
|
76 |
+
width: 300px;
|
77 |
+
margin-bottom: 20px;
|
78 |
+
}
|
79 |
</style>
|
80 |
</head>
|
81 |
<body>
|
82 |
|
83 |
+
<!-- Login Page -->
|
84 |
+
<div id="login-page" class="login-container">
|
85 |
+
<h1>Biryani Hub - Login</h1>
|
86 |
+
<form id="login-form">
|
87 |
+
<input type="email" id="login-email" placeholder="Enter your email" required />
|
88 |
+
<input type="tel" id="login-phone" placeholder="Enter your phone number" required />
|
89 |
+
<button type="submit" class="order-btn">Login</button>
|
90 |
+
</form>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<!-- Menu Page -->
|
94 |
+
<div id="menu-page" class="menu-container" style="display: none;">
|
95 |
<h1>Welcome to Biryani Hub Menu</h1>
|
96 |
+
<h3>Please select a category:</h3>
|
97 |
<button id="main-course-btn">Main Course</button>
|
98 |
<button id="appetizer-btn">Appetizers</button>
|
99 |
</div>
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
<script>
|
102 |
// Sample menu data
|
103 |
const menuData = {
|
|
|
112 |
]
|
113 |
};
|
114 |
|
115 |
+
// User info storage
|
116 |
+
let userEmail = "";
|
117 |
+
let userPhone = "";
|
|
|
118 |
|
119 |
+
// Select page elements
|
120 |
+
const loginPage = document.getElementById('login-page');
|
121 |
+
const menuPage = document.getElementById('menu-page');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
+
// Login form submission
|
124 |
+
document.getElementById('login-form').addEventListener('submit', function(e) {
|
125 |
+
e.preventDefault();
|
126 |
+
|
127 |
+
// Get login input values
|
128 |
+
userEmail = document.getElementById('login-email').value;
|
129 |
+
userPhone = document.getElementById('login-phone').value;
|
|
|
130 |
|
131 |
+
// Simple validation (you can expand this)
|
132 |
+
if (userEmail && userPhone) {
|
133 |
+
console.log(`Login successful! Email: ${userEmail}, Phone: ${userPhone}`);
|
134 |
+
|
135 |
+
// Show menu page after successful login
|
136 |
+
loginPage.style.display = 'none';
|
137 |
+
menuPage.style.display = 'block';
|
138 |
} else {
|
139 |
+
alert("Please provide both email and phone number.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
+
// Menu page logic
|
144 |
+
document.getElementById("main-course-btn").addEventListener("click", () => {
|
145 |
+
displayMenuItems('Main Course');
|
146 |
+
});
|
147 |
|
148 |
+
document.getElementById("appetizer-btn").addEventListener("click", () => {
|
149 |
+
displayMenuItems('Appetizers');
|
150 |
+
});
|
|
|
|
|
|
|
151 |
|
152 |
+
// Function to display menu items based on category
|
153 |
+
function displayMenuItems(category) {
|
154 |
+
const menuContainer = document.createElement('div');
|
155 |
+
menuContainer.classList.add('menu-items');
|
156 |
+
const selectedCategoryData = menuData[category];
|
157 |
+
selectedCategoryData.forEach(item => {
|
158 |
+
const itemElement = document.createElement('div');
|
159 |
+
itemElement.classList.add('menu-item');
|
160 |
+
itemElement.innerHTML = `
|
161 |
+
<div class="details">
|
162 |
+
<h3>${item.name}</h3>
|
163 |
+
<p class="price">Price: ₹${item.price}</p>
|
164 |
+
</div>
|
165 |
+
<button class="order-btn" onclick="addToCart('${item.name}', ${item.price}, 1)">Add to Cart</button>
|
166 |
+
`;
|
167 |
+
menuContainer.appendChild(itemElement);
|
|
|
|
|
168 |
});
|
169 |
+
menuPage.appendChild(menuContainer);
|
170 |
+
}
|
171 |
+
|
172 |
+
// Function to add an item to the cart
|
173 |
+
function addToCart(name, price, quantity) {
|
174 |
+
alert(`${name} added to cart!`);
|
175 |
+
// Logic to add item to cart
|
176 |
+
}
|
177 |
</script>
|
178 |
|
179 |
</body>
|