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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Chef Bot</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
box-sizing: border-box;
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Segoe UI', Arial, sans-serif;
|
| 16 |
+
background-color: #f4f7fa;
|
| 17 |
+
overflow-x: hidden;
|
| 18 |
+
line-height: 1.5;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.chat-container {
|
| 22 |
+
width: 100%;
|
| 23 |
+
max-width: 800px;
|
| 24 |
+
height: 100vh;
|
| 25 |
+
margin: 0 auto;
|
| 26 |
+
background-color: #ffffff;
|
| 27 |
+
border-radius: 12px;
|
| 28 |
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
| 29 |
+
display: flex;
|
| 30 |
+
flex-direction: column;
|
| 31 |
+
overflow: hidden;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.chat-header {
|
| 35 |
+
background-color: #0078d4;
|
| 36 |
+
color: #ffffff;
|
| 37 |
+
padding: 12px;
|
| 38 |
+
text-align: center;
|
| 39 |
+
font-size: 18px;
|
| 40 |
+
font-weight: 600;
|
| 41 |
+
flex-shrink: 0;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.chat-messages {
|
| 45 |
+
flex: 1;
|
| 46 |
+
overflow-y: auto;
|
| 47 |
+
padding: 15px;
|
| 48 |
+
scroll-behavior: smooth;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.bot-message, .user-message {
|
| 52 |
+
padding: 10px 15px;
|
| 53 |
+
margin: 8px 0;
|
| 54 |
+
border-radius: 12px;
|
| 55 |
+
max-width: 80%;
|
| 56 |
+
font-size: 14px;
|
| 57 |
+
line-height: 1.4;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.bot-message {
|
| 61 |
+
background-color: #e8f0fe;
|
| 62 |
+
color: #333;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.user-message {
|
| 66 |
+
background-color: #0078d4;
|
| 67 |
+
color: #ffffff;
|
| 68 |
+
margin-left: auto;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.chat-input {
|
| 72 |
+
display: flex;
|
| 73 |
+
padding: 10px;
|
| 74 |
+
border-top: 1px solid #e0e0e0;
|
| 75 |
+
background-color: #f9f9f9;
|
| 76 |
+
flex-shrink: 0;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.chat-input input {
|
| 80 |
+
flex: 1;
|
| 81 |
+
padding: 10px;
|
| 82 |
+
border: 1px solid #ccc;
|
| 83 |
+
border-radius: 8px;
|
| 84 |
+
font-size: 14px;
|
| 85 |
+
outline: none;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.chat-input button {
|
| 89 |
+
padding: 10px 20px;
|
| 90 |
+
margin-left: 10px;
|
| 91 |
+
background-color: #0078d4;
|
| 92 |
+
color: #ffffff;
|
| 93 |
+
border: none;
|
| 94 |
+
border-radius: 8px;
|
| 95 |
+
cursor: pointer;
|
| 96 |
+
font-size: 14px;
|
| 97 |
+
transition: background-color 0.2s;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.chat-input button:hover {
|
| 101 |
+
background-color: #005ea2;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.ingredients-list, .menu-items-list, .customization-ingredients-list {
|
| 105 |
+
display: flex;
|
| 106 |
+
flex-wrap: nowrap;
|
| 107 |
+
overflow-x: auto;
|
| 108 |
+
padding: 10px;
|
| 109 |
+
margin: 10px 0;
|
| 110 |
+
background-color: #f5f7fa;
|
| 111 |
+
border-radius: 10px;
|
| 112 |
+
gap: 15px;
|
| 113 |
+
scroll-behavior: smooth;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.ingredient-item, .menu-item {
|
| 117 |
+
flex: 0 0 200px;
|
| 118 |
+
background-color: #ffffff;
|
| 119 |
+
border: 1px solid #e0e0e0;
|
| 120 |
+
border-radius: 10px;
|
| 121 |
+
padding: 10px;
|
| 122 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
| 123 |
+
transition: transform 0.2s;
|
| 124 |
+
text-align: center;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.ingredient-item:hover, .menu-item:hover {
|
| 128 |
+
transform: translateY(-2px);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.ingredient-item img, .menu-item img {
|
| 132 |
+
width: 100%;
|
| 133 |
+
height: 120px;
|
| 134 |
+
object-fit: cover;
|
| 135 |
+
border-radius: 8px;
|
| 136 |
+
margin-bottom: 8px;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
.ingredient-item div, .menu-item div {
|
| 140 |
+
font-size: 14px;
|
| 141 |
+
font-weight: 600;
|
| 142 |
+
color: #333;
|
| 143 |
+
margin-bottom: 5px;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
.ingredient-item button, .menu-item button {
|
| 147 |
+
padding: 8px;
|
| 148 |
+
background-color: #28a745;
|
| 149 |
+
color: #ffffff;
|
| 150 |
+
border: none;
|
| 151 |
+
border-radius: 6px;
|
| 152 |
+
cursor: pointer;
|
| 153 |
+
font-size: 12px;
|
| 154 |
+
width: 100%;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
.ingredient-item button:hover, .menu-item button:hover {
|
| 158 |
+
background-color: #218838;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.selected-ingredients, .selected-customization-ingredients {
|
| 162 |
+
background-color: #f1f8ff;
|
| 163 |
+
padding: 15px;
|
| 164 |
+
border: 1px solid #b3d7ff;
|
| 165 |
+
border-radius: 10px;
|
| 166 |
+
margin: 10px 0;
|
| 167 |
+
font-size: 14px;
|
| 168 |
+
display: flex;
|
| 169 |
+
flex-wrap: wrap;
|
| 170 |
+
gap: 10px;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.selected-ingredients div, .selected-customization-ingredients div {
|
| 174 |
+
background-color: #d6e9ff;
|
| 175 |
+
padding: 5px 10px;
|
| 176 |
+
border-radius: 6px;
|
| 177 |
+
font-size: 13px;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.customization-input {
|
| 181 |
+
margin: 10px 0;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
.customization-input textarea, .selected-customization-ingredients textarea {
|
| 185 |
+
width: 100%;
|
| 186 |
+
padding: 8px;
|
| 187 |
+
border: 1px solid #b3d7ff;
|
| 188 |
+
border-radius: 6px;
|
| 189 |
+
font-size: 14px;
|
| 190 |
+
outline: none;
|
| 191 |
+
margin-bottom: 10px;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
.customization-input button, .submit-button, .submit-customization-button, .submit-cart-button {
|
| 195 |
+
padding: 10px 20px;
|
| 196 |
+
background-color: #0078d4;
|
| 197 |
+
color: #ffffff;
|
| 198 |
+
border: none;
|
| 199 |
+
border-radius: 8px;
|
| 200 |
+
cursor: pointer;
|
| 201 |
+
font-size: 14px;
|
| 202 |
+
transition: background-color 0.2s;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
.customization-input button:hover, .submit-button:hover, .submit-customization-button:hover, .submit-cart-button:hover {
|
| 206 |
+
background-color: #005ea2;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.option-button {
|
| 210 |
+
padding: 10px 20px;
|
| 211 |
+
color: #ffffff;
|
| 212 |
+
border: none;
|
| 213 |
+
border-radius: 8px;
|
| 214 |
+
cursor: pointer;
|
| 215 |
+
font-size: 14px;
|
| 216 |
+
margin: 5px;
|
| 217 |
+
transition: background-color 0.2s;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
.option-button.green {
|
| 221 |
+
background-color: #28a745;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
.option-button.green:hover {
|
| 225 |
+
background-color: #218838;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
.option-button.red {
|
| 229 |
+
background-color: #dc3545;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.option-button.red:hover {
|
| 233 |
+
background-color: #c82333;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
.cart-items {
|
| 237 |
+
background-color: #f1f8ff;
|
| 238 |
+
padding: 15px;
|
| 239 |
+
border: 1px solid #b3d7ff;
|
| 240 |
+
border-radius: 10px;
|
| 241 |
+
margin: 10px 0;
|
| 242 |
+
font-size: 14px;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
.cart-item {
|
| 246 |
+
display: flex;
|
| 247 |
+
align-items: center;
|
| 248 |
+
background-color: #d6e9ff;
|
| 249 |
+
padding: 5px 10px;
|
| 250 |
+
border-radius: 6px;
|
| 251 |
+
font-size: 13px;
|
| 252 |
+
margin: 5px 0;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.cart-item img {
|
| 256 |
+
width: 30px;
|
| 257 |
+
height: 30px;
|
| 258 |
+
object-fit: cover;
|
| 259 |
+
border-radius: 6px;
|
| 260 |
+
margin-right: 8px;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
.cart-item .remove-button {
|
| 264 |
+
padding: 5px 10px;
|
| 265 |
+
margin-left: 8px;
|
| 266 |
+
background-color: #dc3545;
|
| 267 |
+
color: #ffffff;
|
| 268 |
+
border: none;
|
| 269 |
+
border-radius: 6px;
|
| 270 |
+
cursor: pointer;
|
| 271 |
+
font-size: 12px;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.cart-item .remove-button:hover {
|
| 275 |
+
background-color: #c82333;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
/* Responsive Design */
|
| 279 |
+
@media (max-width: 480px) {
|
| 280 |
+
.chat-container {
|
| 281 |
+
border-radius: 0;
|
| 282 |
+
box-shadow: none;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
.chat-header {
|
| 286 |
+
font-size: 16px;
|
| 287 |
+
padding: 10px;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.chat-messages {
|
| 291 |
+
padding: 10px;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.bot-message, .user-message {
|
| 295 |
+
font-size: 13px;
|
| 296 |
+
padding: 8px 12px;
|
| 297 |
+
margin: 5px 0;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
.chat-input input {
|
| 301 |
+
font-size: 13px;
|
| 302 |
+
padding: 8px;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
.chat-input button {
|
| 306 |
+
font-size: 13px;
|
| 307 |
+
padding: 8px 15px;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.ingredients-list, .menu-items-list, .customization-ingredients-list {
|
| 311 |
+
flex-direction: column;
|
| 312 |
+
gap: 10px;
|
| 313 |
+
padding: 8px;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
.ingredient-item, .menu-item {
|
| 317 |
+
flex: 0 0 auto;
|
| 318 |
+
width: 100%;
|
| 319 |
+
max-width: 250px;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
.ingredient-item img, .menu-item img {
|
| 323 |
+
height: 100px;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
.ingredient-item div, .menu-item div {
|
| 327 |
+
font-size: 13px;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
.ingredient-item button, .menu-item button {
|
| 331 |
+
font-size: 11px;
|
| 332 |
+
padding: 6px;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
.option-button {
|
| 336 |
+
font-size: 13px;
|
| 337 |
+
padding: 8px 15px;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
.selected-ingredients, .selected-customization-ingredients, .cart-items {
|
| 341 |
+
padding: 10px;
|
| 342 |
+
gap: 8px;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
.cart-item {
|
| 346 |
+
font-size: 12px;
|
| 347 |
+
padding: 4px 8px;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
.cart-item img {
|
| 351 |
+
width: 25px;
|
| 352 |
+
height: 25px;
|
| 353 |
+
}
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
@media (min-width: 481px) and (max-width: 768px) {
|
| 357 |
+
.chat-container {
|
| 358 |
+
max-width: 600px;
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
.chat-header {
|
| 362 |
+
font-size: 17px;
|
| 363 |
+
padding: 11px;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
.chat-messages {
|
| 367 |
+
padding: 12px;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
.ingredient-item, .menu-item {
|
| 371 |
+
flex: 0 0 180px;
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
.ingredient-item img, .menu-item img {
|
| 375 |
+
height: 110px;
|
| 376 |
+
}
|
| 377 |
+
}
|
| 378 |
+
</style>
|
| 379 |
+
</head>
|
| 380 |
+
<body>
|
| 381 |
+
<div class="chat-container">
|
| 382 |
+
<div class="chat-header">🍳 Chef Bot</div>
|
| 383 |
+
<div class="chat-messages" id="chatMessages">
|
| 384 |
+
<!-- Bot messages will appear here -->
|
| 385 |
+
</div>
|
| 386 |
+
<div class="chat-input">
|
| 387 |
+
<input type="text" id="userInput" placeholder="Type your message...">
|
| 388 |
+
<button onclick="sendMessage()">Send</button>
|
| 389 |
+
</div>
|
| 390 |
+
</div>
|
| 391 |
+
|
| 392 |
+
<script>
|
| 393 |
+
let currentStep = 'food_type'; // Starting directly at the food_type step
|
| 394 |
+
let userName = ''; // This will store the user's name after login
|
| 395 |
+
let conversation = [];
|
| 396 |
+
let selectedIngredients = [];
|
| 397 |
+
let selectedMenuItem = null;
|
| 398 |
+
let cart = [];
|
| 399 |
+
|
| 400 |
+
// Simulate the login and fetch the user's name
|
| 401 |
+
function loginUser() {
|
| 402 |
+
// Example: Fetch the user's name from session or login API (hardcoded for now)
|
| 403 |
+
userName = session['user_name']; // Replace with actual dynamic name fetching logic
|
| 404 |
+
|
| 405 |
+
// Start the conversation once the user is logged in
|
| 406 |
+
startConversation();
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
// Start the conversation directly
|
| 410 |
+
function startConversation() {
|
| 411 |
+
if (userName) {
|
| 412 |
+
addMessage('bot', `Nice to meet you, ${userName}! 😊 Let's create your perfect meal! What type of food would you prefer?`);
|
| 413 |
+
displayOptions([
|
| 414 |
+
{ text: 'Vegetarian', class: 'green' },
|
| 415 |
+
{ text: 'Non-Vegetarian', class: 'red' }
|
| 416 |
+
]);
|
| 417 |
+
} else {
|
| 418 |
+
addMessage('bot', 'Hi! Please log in to continue.');
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
// Function to add messages to the chat container
|
| 423 |
+
function addMessage(role, message) {
|
| 424 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 425 |
+
if (!chatMessages) {
|
| 426 |
+
console.error('Chat messages container not found!');
|
| 427 |
+
return;
|
| 428 |
+
}
|
| 429 |
+
const messageDiv = document.createElement('div');
|
| 430 |
+
messageDiv.className = role === 'bot' ? 'bot-message' : 'user-message';
|
| 431 |
+
messageDiv.textContent = message;
|
| 432 |
+
chatMessages.appendChild(messageDiv);
|
| 433 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 434 |
+
console.log(`Added ${role} message: ${message}`);
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
// Function to send user input
|
| 438 |
+
function sendMessage() {
|
| 439 |
+
const userInput = document.getElementById('userInput');
|
| 440 |
+
if (!userInput) {
|
| 441 |
+
console.error('User input field not found!');
|
| 442 |
+
return;
|
| 443 |
+
}
|
| 444 |
+
const message = userInput.value.trim();
|
| 445 |
+
if (message) {
|
| 446 |
+
addMessage('user', message);
|
| 447 |
+
conversation.push({ role: 'user', message: message });
|
| 448 |
+
userInput.value = '';
|
| 449 |
+
setTimeout(() => handleResponse(message), 500);
|
| 450 |
+
} else {
|
| 451 |
+
console.warn('Empty message!');
|
| 452 |
+
}
|
| 453 |
+
displayCart();
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
// Handle the response based on the user input
|
| 457 |
+
function handleResponse(userInput) {
|
| 458 |
+
const lastMessage = userInput.toLowerCase();
|
| 459 |
+
let botResponse = '';
|
| 460 |
+
let options = [];
|
| 461 |
+
|
| 462 |
+
if (lastMessage.includes('non-vegetarian')) {
|
| 463 |
+
conversation.push({ role: 'user', message: 'Non-Vegetarian' });
|
| 464 |
+
console.log("Food preference selected: Non-Vegetarian");
|
| 465 |
+
botResponse = `Great choice, ${userName}! 🍽️ Please select a non-vegetarian option:`;
|
| 466 |
+
fetchIngredients('non-vegetarian');
|
| 467 |
+
return;
|
| 468 |
+
} else if (lastMessage.includes('vegetarian')) {
|
| 469 |
+
conversation.push({ role: 'user', message: 'Vegetarian' });
|
| 470 |
+
console.log("Food preference selected: Vegetarian");
|
| 471 |
+
botResponse = `Great choice, ${userName}! 🍽️ Here are some vegetarian ingredients:`;
|
| 472 |
+
fetchIngredients('vegetarian');
|
| 473 |
+
return;
|
| 474 |
+
} else if (lastMessage.includes('chicken') || lastMessage.includes('beef') || lastMessage.includes('lamb')) {
|
| 475 |
+
conversation.push({ role: 'user', message: lastMessage });
|
| 476 |
+
console.log(`Non-veg option selected: ${lastMessage}`);
|
| 477 |
+
botResponse = `Great! Here are some ${lastMessage} ingredients available:`;
|
| 478 |
+
fetchIngredients(lastMessage.toLowerCase());
|
| 479 |
+
return;
|
| 480 |
+
} else if (lastMessage.includes('yes') && selectedMenuItem) {
|
| 481 |
+
botResponse = 'Here are some ingredients to customize your dish:';
|
| 482 |
+
handleYesResponse();
|
| 483 |
+
return;
|
| 484 |
+
} else if (lastMessage.includes('no') && selectedMenuItem) {
|
| 485 |
+
// Submit the dish without customization
|
| 486 |
+
submitCustomizationIngredients();
|
| 487 |
+
return;
|
| 488 |
+
} else if (lastMessage.includes('yes') && currentStep === 'post_cart') {
|
| 489 |
+
// After user says 'yes', ask again for food preference (veg or non-veg)
|
| 490 |
+
botResponse = `Let's get started again! What type of food would you prefer this time?`;
|
| 491 |
+
options = [
|
| 492 |
+
{ text: 'Vegetarian', class: 'green' },
|
| 493 |
+
{ text: 'Non-Vegetarian', class: 'red' }
|
| 494 |
+
];
|
| 495 |
+
currentStep = 'food_type';
|
| 496 |
+
addMessage('bot', botResponse);
|
| 497 |
+
displayOptions(options);
|
| 498 |
+
return;
|
| 499 |
+
} else if (lastMessage.includes('non-vegetarian') && currentStep === 'food_type') {
|
| 500 |
+
// Handle non-vegetarian selection
|
| 501 |
+
conversation.push({ role: 'user', message: 'Non-Vegetarian' });
|
| 502 |
+
console.log("Food preference selected: Non-Vegetarian");
|
| 503 |
+
botResponse = `Great choice, ${userName}! 🍽️ Please select a non-vegetarian option:`;
|
| 504 |
+
fetchIngredients('non-vegetarian');
|
| 505 |
+
return;
|
| 506 |
+
} else if (lastMessage.includes('vegetarian') && currentStep === 'food_type') {
|
| 507 |
+
// Handle vegetarian selection
|
| 508 |
+
conversation.push({ role: 'user', message: 'Vegetarian' });
|
| 509 |
+
console.log("Food preference selected: Vegetarian");
|
| 510 |
+
botResponse = `Great choice, ${userName}! 🍽️ Here are some vegetarian ingredients:`;
|
| 511 |
+
fetchIngredients('vegetarian');
|
| 512 |
+
return;
|
| 513 |
+
} else if (lastMessage.includes('no') && currentStep === 'post_cart') {
|
| 514 |
+
addMessage('bot', 'Awesome! 🧾 Here’s your final cart:');
|
| 515 |
+
displayCart(); // Optional: show final cart again
|
| 516 |
+
addMessage('bot', 'Thank you for your order! 👨🍳🍲');
|
| 517 |
+
currentStep = 'end';
|
| 518 |
+
return;
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
addMessage('bot', botResponse);
|
| 522 |
+
if (options.length > 0) {
|
| 523 |
+
displayOptions(options);
|
| 524 |
+
}
|
| 525 |
+
displayCart();
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
|
| 531 |
+
function handleYesResponse() {
|
| 532 |
+
if (!selectedMenuItem) {
|
| 533 |
+
addMessage('bot', 'No dish selected. Please choose a dish first.');
|
| 534 |
+
return;
|
| 535 |
+
}
|
| 536 |
+
const botResponse = `Here is your selected dish: ${selectedMenuItem.name}`;
|
| 537 |
+
addMessage('bot', botResponse);
|
| 538 |
+
|
| 539 |
+
// Display selected menu item
|
| 540 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 541 |
+
const menuItemDiv = document.createElement('div');
|
| 542 |
+
menuItemDiv.className = 'menu-item';
|
| 543 |
+
const img = document.createElement('img');
|
| 544 |
+
img.src = selectedMenuItem.image_url || 'https://via.placeholder.com/120';
|
| 545 |
+
img.alt = selectedMenuItem.name;
|
| 546 |
+
const name = document.createElement('div');
|
| 547 |
+
name.textContent = selectedMenuItem.name;
|
| 548 |
+
menuItemDiv.appendChild(img);
|
| 549 |
+
menuItemDiv.appendChild(name);
|
| 550 |
+
chatMessages.appendChild(menuItemDiv);
|
| 551 |
+
|
| 552 |
+
// Fetch ingredients for customization
|
| 553 |
+
fetchIngredientsForCustomization('both');
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
function fetchIngredientsForCustomization(foodPreference) {
|
| 557 |
+
fetch('/get_ingredients', { // Reuse existing endpoint
|
| 558 |
+
method: 'POST',
|
| 559 |
+
headers: { 'Content-Type': 'application/json' },
|
| 560 |
+
body: JSON.stringify({ dietary_preference: foodPreference })
|
| 561 |
+
})
|
| 562 |
+
.then(response => response.json())
|
| 563 |
+
.then(data => {
|
| 564 |
+
if (data.error) {
|
| 565 |
+
addMessage('bot', `Sorry, there was an error fetching ingredients: ${data.error}`);
|
| 566 |
+
} else {
|
| 567 |
+
const ingredients = data.ingredients || [];
|
| 568 |
+
addMessage('bot', 'Please select ingredients to customize:');
|
| 569 |
+
displayCustomizationIngredients(ingredients);
|
| 570 |
+
}
|
| 571 |
+
})
|
| 572 |
+
.catch(error => {
|
| 573 |
+
addMessage('bot', `Error: Unable to connect to the ingredient database. ${error.message}`);
|
| 574 |
+
});
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
function displayCustomizationIngredients(ingredients) {
|
| 578 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 579 |
+
if (!chatMessages) {
|
| 580 |
+
console.error('Chat messages container not found for customization ingredients!');
|
| 581 |
+
return;
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
let ingredientsList = document.querySelector('.customization-ingredients-list');
|
| 585 |
+
if (!ingredientsList) {
|
| 586 |
+
ingredientsList = document.createElement('div');
|
| 587 |
+
ingredientsList.className = 'customization-ingredients-list';
|
| 588 |
+
chatMessages.appendChild(ingredientsList);
|
| 589 |
+
} else {
|
| 590 |
+
ingredientsList.innerHTML = '';
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
ingredients.forEach(ingredient => {
|
| 594 |
+
const item = document.createElement('div');
|
| 595 |
+
item.className = 'ingredient-item';
|
| 596 |
+
const img = document.createElement('img');
|
| 597 |
+
img.src = ingredient.image_url || 'https://via.placeholder.com/120';
|
| 598 |
+
img.alt = ingredient.name;
|
| 599 |
+
const name = document.createElement('div');
|
| 600 |
+
name.textContent = ingredient.name;
|
| 601 |
+
const button = document.createElement('button');
|
| 602 |
+
button.textContent = 'Add';
|
| 603 |
+
button.onclick = () => {
|
| 604 |
+
if (!selectedIngredients.some(item => item.name === ingredient.name)) {
|
| 605 |
+
selectedIngredients.push({ name: ingredient.name, image_url: ingredient.image_url });
|
| 606 |
+
displaySelectedCustomizationIngredients();
|
| 607 |
+
}
|
| 608 |
+
};
|
| 609 |
+
item.appendChild(img);
|
| 610 |
+
item.appendChild(name);
|
| 611 |
+
item.appendChild(button);
|
| 612 |
+
ingredientsList.appendChild(item);
|
| 613 |
+
});
|
| 614 |
+
|
| 615 |
+
displaySelectedCustomizationIngredients();
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
function displaySelectedCustomizationIngredients() {
|
| 619 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 620 |
+
if (!chatMessages) {
|
| 621 |
+
console.error('Chat messages container not found for selected customization ingredients!');
|
| 622 |
+
return;
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
let selectedArea = document.querySelector('.selected-customization-ingredients');
|
| 626 |
+
if (!selectedArea) {
|
| 627 |
+
selectedArea = document.createElement('div');
|
| 628 |
+
selectedArea.className = 'selected-customization-ingredients';
|
| 629 |
+
chatMessages.appendChild(selectedArea);
|
| 630 |
+
} else {
|
| 631 |
+
selectedArea.innerHTML = '';
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
const selectedIngredientsText = selectedIngredients.length > 0
|
| 635 |
+
? `${selectedMenuItem.name} with ${selectedIngredients.map(ingredient => ingredient.name).join(', ')}`
|
| 636 |
+
: selectedMenuItem.name;
|
| 637 |
+
|
| 638 |
+
const ingredientsDiv = document.createElement('div');
|
| 639 |
+
ingredientsDiv.textContent = selectedIngredientsText;
|
| 640 |
+
selectedArea.appendChild(ingredientsDiv);
|
| 641 |
+
|
| 642 |
+
selectedIngredients.forEach(ingredient => {
|
| 643 |
+
const div = document.createElement('div');
|
| 644 |
+
div.textContent = ingredient.name;
|
| 645 |
+
const removeButton = document.createElement('button');
|
| 646 |
+
removeButton.textContent = 'X';
|
| 647 |
+
removeButton.style.marginLeft = '5px';
|
| 648 |
+
removeButton.style.padding = '2px 5px';
|
| 649 |
+
removeButton.style.backgroundColor = '#dc3545';
|
| 650 |
+
removeButton.style.color = '#ffffff';
|
| 651 |
+
removeButton.style.border = 'none';
|
| 652 |
+
removeButton.style.borderRadius = '4px';
|
| 653 |
+
removeButton.style.cursor = 'pointer';
|
| 654 |
+
removeButton.onclick = () => {
|
| 655 |
+
selectedIngredients = selectedIngredients.filter(item => item.name !== ingredient.name);
|
| 656 |
+
displaySelectedCustomizationIngredients();
|
| 657 |
+
};
|
| 658 |
+
div.appendChild(removeButton);
|
| 659 |
+
selectedArea.appendChild(div);
|
| 660 |
+
});
|
| 661 |
+
|
| 662 |
+
if (!document.querySelector('.submit-customization-button')) {
|
| 663 |
+
const textarea = document.createElement('textarea');
|
| 664 |
+
textarea.placeholder = 'Enter any special instructions...';
|
| 665 |
+
selectedArea.appendChild(textarea);
|
| 666 |
+
|
| 667 |
+
const submitButton = document.createElement('button');
|
| 668 |
+
submitButton.className = 'submit-customization-button';
|
| 669 |
+
submitButton.textContent = 'Submit Customization';
|
| 670 |
+
submitButton.onclick = submitCustomizationIngredients;
|
| 671 |
+
selectedArea.appendChild(submitButton);
|
| 672 |
+
}
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
function submitCustomizationIngredients() {
|
| 676 |
+
if (!selectedMenuItem) {
|
| 677 |
+
addMessage('bot', 'No dish selected. Please choose a dish first.');
|
| 678 |
+
return;
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
const textarea = document.querySelector('.selected-customization-ingredients textarea');
|
| 682 |
+
const instructions = textarea ? textarea.value.trim() : '';
|
| 683 |
+
|
| 684 |
+
|
| 685 |
+
fetch('/submit_customization_ingredients', {
|
| 686 |
+
method: 'POST',
|
| 687 |
+
headers: { 'Content-Type': 'application/json' },
|
| 688 |
+
body: JSON.stringify({
|
| 689 |
+
menu_item: selectedMenuItem,
|
| 690 |
+
ingredients: selectedIngredients,
|
| 691 |
+
instructions: instructions
|
| 692 |
+
})
|
| 693 |
+
})
|
| 694 |
+
.then(response => response.json())
|
| 695 |
+
.then(data => {
|
| 696 |
+
if (data.success) {
|
| 697 |
+
addToCart({ ...selectedMenuItem, instructions, ingredients: selectedIngredients });
|
| 698 |
+
currentStep = 'post_cart';
|
| 699 |
+
addMessage('bot', 'Customization submitted successfully! Item added to cart. Would you like to order more?');
|
| 700 |
+
const options = [
|
| 701 |
+
{ text: 'Yes', class: 'green' },
|
| 702 |
+
{ text: 'No', class: 'red' }
|
| 703 |
+
];
|
| 704 |
+
displayOptions(options);
|
| 705 |
+
selectedMenuItem = null;
|
| 706 |
+
selectedIngredients = [];
|
| 707 |
+
displayCart();
|
| 708 |
+
} else {
|
| 709 |
+
addMessage('bot', `Error: ${data.error}`);
|
| 710 |
+
}
|
| 711 |
+
})
|
| 712 |
+
.catch(error => {
|
| 713 |
+
addMessage('bot', `Error submitting customization: ${error.message}`);
|
| 714 |
+
});
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
function fetchIngredients(foodPreference) {
|
| 718 |
+
fetch('/get_ingredients', {
|
| 719 |
+
method: 'POST',
|
| 720 |
+
headers: { 'Content-Type': 'application/json' },
|
| 721 |
+
body: JSON.stringify({ dietary_preference: foodPreference })
|
| 722 |
+
})
|
| 723 |
+
.then(response => response.json())
|
| 724 |
+
.then(data => {
|
| 725 |
+
if (data.error) {
|
| 726 |
+
addMessage('bot', `Sorry, there was an error fetching ingredients: ${data.error}`);
|
| 727 |
+
} else {
|
| 728 |
+
const ingredients = data.ingredients || [];
|
| 729 |
+
addMessage('bot', 'Please select ingredients:');
|
| 730 |
+
displayIngredientsList(ingredients);
|
| 731 |
+
displaySelectedIngredients();
|
| 732 |
+
}
|
| 733 |
+
})
|
| 734 |
+
.catch(error => {
|
| 735 |
+
addMessage('bot', `Error: Unable to connect to the ingredient database. ${error.message}`);
|
| 736 |
+
});
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
function fetchMenuItems(params) {
|
| 740 |
+
fetch('/get_menu_items', {
|
| 741 |
+
method: 'POST',
|
| 742 |
+
headers: { 'Content-Type': 'application/json' },
|
| 743 |
+
body: JSON.stringify(params)
|
| 744 |
+
})
|
| 745 |
+
.then(response => response.json())
|
| 746 |
+
.then(data => {
|
| 747 |
+
if (data.error) {
|
| 748 |
+
addMessage('bot', `Sorry, there was an error fetching menu items: ${data.error}`);
|
| 749 |
+
} else {
|
| 750 |
+
const menuItems = data.menu_items || [];
|
| 751 |
+
addMessage('bot', 'Here are some dishes based on your selection:');
|
| 752 |
+
displayMenuItems(menuItems);
|
| 753 |
+
}
|
| 754 |
+
})
|
| 755 |
+
.catch(error => {
|
| 756 |
+
addMessage('bot', `Error: Unable to connect to the menu database. ${error.message}`);
|
| 757 |
+
});
|
| 758 |
+
}
|
| 759 |
+
|
| 760 |
+
function displayIngredientsList(ingredients) {
|
| 761 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 762 |
+
if (!chatMessages) {
|
| 763 |
+
console.error('Chat messages container not found for ingredients!');
|
| 764 |
+
return;
|
| 765 |
+
}
|
| 766 |
+
|
| 767 |
+
let ingredientsList = document.querySelector('.ingredients-list');
|
| 768 |
+
if (!ingredientsList) {
|
| 769 |
+
ingredientsList = document.createElement('div');
|
| 770 |
+
ingredientsList.className = 'ingredients-list';
|
| 771 |
+
chatMessages.appendChild(ingredientsList);
|
| 772 |
+
} else {
|
| 773 |
+
ingredientsList.innerHTML = '';
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
ingredients.forEach(ingredient => {
|
| 777 |
+
const item = document.createElement('div');
|
| 778 |
+
item.className = 'ingredient-item';
|
| 779 |
+
const img = document.createElement('img');
|
| 780 |
+
img.src = ingredient.image_url || 'https://via.placeholder.com/120';
|
| 781 |
+
img.alt = ingredient.name;
|
| 782 |
+
const name = document.createElement('div');
|
| 783 |
+
name.textContent = ingredient.name;
|
| 784 |
+
const button = document.createElement('button');
|
| 785 |
+
button.textContent = 'Add';
|
| 786 |
+
button.onclick = () => {
|
| 787 |
+
if (!selectedIngredients.some(item => item.name === ingredient.name)) {
|
| 788 |
+
selectedIngredients.push(ingredient);
|
| 789 |
+
displaySelectedIngredients();
|
| 790 |
+
}
|
| 791 |
+
};
|
| 792 |
+
item.appendChild(img);
|
| 793 |
+
item.appendChild(name);
|
| 794 |
+
item.appendChild(button);
|
| 795 |
+
ingredientsList.appendChild(item);
|
| 796 |
+
});
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
function displayMenuItems(menuItems) {
|
| 800 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 801 |
+
if (!chatMessages) {
|
| 802 |
+
console.error('Chat messages container not found for menu items!');
|
| 803 |
+
return;
|
| 804 |
+
}
|
| 805 |
+
|
| 806 |
+
let menuItemsList = document.querySelector('.menu-items-list');
|
| 807 |
+
if (!menuItemsList) {
|
| 808 |
+
menuItemsList = document.createElement('div');
|
| 809 |
+
menuItemsList.className = 'menu-items-list';
|
| 810 |
+
chatMessages.appendChild(menuItemsList);
|
| 811 |
+
} else {
|
| 812 |
+
menuItemsList.innerHTML = '';
|
| 813 |
+
}
|
| 814 |
+
|
| 815 |
+
menuItems.forEach(item => {
|
| 816 |
+
const menuItem = document.createElement('div');
|
| 817 |
+
menuItem.className = 'menu-item';
|
| 818 |
+
const img = document.createElement('img');
|
| 819 |
+
img.src = item.image_url || 'https://via.placeholder.com/120';
|
| 820 |
+
img.alt = item.name;
|
| 821 |
+
const name = document.createElement('div');
|
| 822 |
+
name.textContent = item.name;
|
| 823 |
+
const button = document.createElement('button');
|
| 824 |
+
button.textContent = 'Add to Cart';
|
| 825 |
+
button.onclick = () => {
|
| 826 |
+
selectedMenuItem = item;
|
| 827 |
+
addMessage('bot', `World-class selection! Would you like to customize your dish further?`);
|
| 828 |
+
const options = [
|
| 829 |
+
{ text: 'Yes', class: 'green' },
|
| 830 |
+
{ text: 'No', class: 'red' }
|
| 831 |
+
];
|
| 832 |
+
displayOptions(options);
|
| 833 |
+
};
|
| 834 |
+
menuItem.appendChild(img);
|
| 835 |
+
menuItem.appendChild(name);
|
| 836 |
+
menuItem.appendChild(button);
|
| 837 |
+
menuItemsList.appendChild(menuItem);
|
| 838 |
+
});
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
function displaySelectedIngredients() {
|
| 842 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 843 |
+
if (!chatMessages) {
|
| 844 |
+
console.error('Chat messages container not found for selected ingredients!');
|
| 845 |
+
return;
|
| 846 |
+
}
|
| 847 |
+
|
| 848 |
+
let selectedArea = document.querySelector('.selected-ingredients');
|
| 849 |
+
if (!selectedArea) {
|
| 850 |
+
selectedArea = document.createElement('div');
|
| 851 |
+
selectedArea.className = 'selected-ingredients';
|
| 852 |
+
chatMessages.appendChild(selectedArea);
|
| 853 |
+
} else {
|
| 854 |
+
selectedArea.innerHTML = '';
|
| 855 |
+
}
|
| 856 |
+
|
| 857 |
+
selectedIngredients.forEach(ingredient => {
|
| 858 |
+
const div = document.createElement('div');
|
| 859 |
+
div.textContent = ingredient.name;
|
| 860 |
+
const removeButton = document.createElement('button');
|
| 861 |
+
removeButton.textContent = 'X';
|
| 862 |
+
removeButton.style.marginLeft = '5px';
|
| 863 |
+
removeButton.style.padding = '2px 5px';
|
| 864 |
+
removeButton.style.backgroundColor = '#dc3545';
|
| 865 |
+
removeButton.style.color = '#ffffff';
|
| 866 |
+
removeButton.style.border = 'none';
|
| 867 |
+
removeButton.style.borderRadius = '4px';
|
| 868 |
+
removeButton.style.cursor = 'pointer';
|
| 869 |
+
removeButton.onclick = () => {
|
| 870 |
+
selectedIngredients = selectedIngredients.filter(item => item.name !== ingredient.name);
|
| 871 |
+
displaySelectedIngredients();
|
| 872 |
+
};
|
| 873 |
+
div.appendChild(removeButton);
|
| 874 |
+
selectedArea.appendChild(div);
|
| 875 |
+
});
|
| 876 |
+
|
| 877 |
+
if (selectedIngredients.length > 0) {
|
| 878 |
+
let submitButton = document.querySelector('.submit-button');
|
| 879 |
+
if (!submitButton) {
|
| 880 |
+
submitButton = document.createElement('button');
|
| 881 |
+
submitButton.className = 'submit-button';
|
| 882 |
+
submitButton.textContent = 'Submit Ingredients';
|
| 883 |
+
submitButton.onclick = submitIngredients;
|
| 884 |
+
chatMessages.appendChild(submitButton);
|
| 885 |
+
}
|
| 886 |
+
}
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
function submitIngredients() {
|
| 890 |
+
if (selectedIngredients.length === 0) {
|
| 891 |
+
addMessage('bot', 'No ingredients selected. Please choose some ingredients.');
|
| 892 |
+
return;
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
const ingredientNames = selectedIngredients.map(ingredient => ingredient.name.toLowerCase()).join(' ');
|
| 896 |
+
fetchMenuItems({ ingredient_names: ingredientNames });
|
| 897 |
+
}
|
| 898 |
+
|
| 899 |
+
function addToCart(item) {
|
| 900 |
+
cart.push(item);
|
| 901 |
+
console.log('Cart:', cart);
|
| 902 |
+
displayCart();
|
| 903 |
+
}
|
| 904 |
+
|
| 905 |
+
function displayCart() {
|
| 906 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 907 |
+
if (!chatMessages) {
|
| 908 |
+
console.error('Chat messages container not found for cart!');
|
| 909 |
+
return;
|
| 910 |
+
}
|
| 911 |
+
|
| 912 |
+
let cartArea = document.querySelector('.cart-items');
|
| 913 |
+
if (!cartArea) {
|
| 914 |
+
cartArea = document.createElement('div');
|
| 915 |
+
cartArea.className = 'cart-items';
|
| 916 |
+
chatMessages.appendChild(cartArea);
|
| 917 |
+
} else {
|
| 918 |
+
cartArea.innerHTML = '';
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
if (cart.length > 0) {
|
| 922 |
+
const label = document.createElement('div');
|
| 923 |
+
label.textContent = 'Cart:';
|
| 924 |
+
cartArea.appendChild(label);
|
| 925 |
+
|
| 926 |
+
cart.forEach((item, index) => {
|
| 927 |
+
const itemDiv = document.createElement('div');
|
| 928 |
+
itemDiv.className = 'cart-item';
|
| 929 |
+
const img = document.createElement('img');
|
| 930 |
+
img.src = item.image_url || 'https://via.placeholder.com/30';
|
| 931 |
+
img.alt = item.name;
|
| 932 |
+
const name = document.createElement('div');
|
| 933 |
+
const text = item.instructions
|
| 934 |
+
? `${item.name} (${item.instructions})`
|
| 935 |
+
: item.name;
|
| 936 |
+
name.textContent = item.ingredients.length > 0
|
| 937 |
+
? `${text} with ${item.ingredients.map(i => i.name).join(', ')}`
|
| 938 |
+
: text;
|
| 939 |
+
const removeButton = document.createElement('button');
|
| 940 |
+
removeButton.className = 'remove-button';
|
| 941 |
+
removeButton.textContent = 'X';
|
| 942 |
+
removeButton.onclick = () => {
|
| 943 |
+
cart.splice(index, 1);
|
| 944 |
+
displayCart();
|
| 945 |
+
};
|
| 946 |
+
itemDiv.appendChild(img);
|
| 947 |
+
itemDiv.appendChild(name);
|
| 948 |
+
itemDiv.appendChild(removeButton);
|
| 949 |
+
cartArea.appendChild(itemDiv);
|
| 950 |
+
});
|
| 951 |
+
|
| 952 |
+
let submitCartButton = document.querySelector('.submit-cart-button');
|
| 953 |
+
if (!submitCartButton) {
|
| 954 |
+
submitCartButton = document.createElement('button');
|
| 955 |
+
submitCartButton.className = 'submit-cart-button';
|
| 956 |
+
submitCartButton.textContent = 'Submit Cart';
|
| 957 |
+
submitCartButton.onclick = submitCart;
|
| 958 |
+
cartArea.appendChild(submitCartButton);
|
| 959 |
+
}
|
| 960 |
+
}
|
| 961 |
+
}
|
| 962 |
+
|
| 963 |
+
function submitCart() {
|
| 964 |
+
if (cart.length === 0) {
|
| 965 |
+
addMessage('bot', 'Your cart is empty!');
|
| 966 |
+
return;
|
| 967 |
+
}
|
| 968 |
+
|
| 969 |
+
fetch('/submit_customization_ingredients', {
|
| 970 |
+
method: 'POST',
|
| 971 |
+
headers: { 'Content-Type': 'application/json' },
|
| 972 |
+
body: JSON.stringify({ items: cart })
|
| 973 |
+
})
|
| 974 |
+
.then(response => response.json())
|
| 975 |
+
.then(data => {
|
| 976 |
+
if (data.success) {
|
| 977 |
+
addMessage('bot', 'Cart submitted successfully!');
|
| 978 |
+
cart = [];
|
| 979 |
+
displayCart();
|
| 980 |
+
} else {
|
| 981 |
+
addMessage('bot', `Error submitting cart: ${data.error}`);
|
| 982 |
+
}
|
| 983 |
+
})
|
| 984 |
+
.catch(error => {
|
| 985 |
+
addMessage('bot', `Error submitting cart: ${error.message}`);
|
| 986 |
+
});
|
| 987 |
+
}
|
| 988 |
+
|
| 989 |
+
function displayOptions(options) {
|
| 990 |
+
const chatMessages = document.getElementById('chatMessages');
|
| 991 |
+
if (!chatMessages) {
|
| 992 |
+
console.error('Chat messages container not found for options!');
|
| 993 |
+
return;
|
| 994 |
+
}
|
| 995 |
+
options.forEach(opt => {
|
| 996 |
+
const button = document.createElement('button');
|
| 997 |
+
button.textContent = opt.text;
|
| 998 |
+
button.className = `option-button ${opt.class}`;
|
| 999 |
+
button.onclick = () => {
|
| 1000 |
+
addMessage('user', opt.text);
|
| 1001 |
+
conversation.push({ role: 'user', message: opt.text });
|
| 1002 |
+
setTimeout(() => handleResponse(opt.text), 500);
|
| 1003 |
+
};
|
| 1004 |
+
chatMessages.appendChild(button);
|
| 1005 |
+
});
|
| 1006 |
+
chatMessages.appendChild(document.createElement('br'));
|
| 1007 |
+
const backButton = document.createElement('button');
|
| 1008 |
+
backButton.textContent = 'Go Back';
|
| 1009 |
+
backButton.className = 'option-button';
|
| 1010 |
+
backButton.onclick = () => {
|
| 1011 |
+
conversation.pop();
|
| 1012 |
+
selectedIngredients = [];
|
| 1013 |
+
selectedMenuItem = null;
|
| 1014 |
+
setTimeout(() => handleResponse(conversation[conversation.length - 1].message), 500);
|
| 1015 |
+
};
|
| 1016 |
+
chatMessages.appendChild(backButton);
|
| 1017 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 1018 |
+
}
|
| 1019 |
+
|
| 1020 |
+
document.getElementById('userInput').addEventListener('keypress', function(e) {
|
| 1021 |
+
if (e.key === 'Enter') {
|
| 1022 |
+
sendMessage();
|
| 1023 |
+
}
|
| 1024 |
+
});
|
| 1025 |
+
|
| 1026 |
+
console.log('Script loaded successfully');
|
| 1027 |
+
</script>
|
| 1028 |
+
<script src="{{ url_for('static', filename='script.js') }}"></script>
|
| 1029 |
+
|
| 1030 |
+
</body>
|
| 1031 |
+
</html>
|