Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +2 -1103
templates/index.html
CHANGED
|
@@ -4,594 +4,7 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Chef Bot</title>
|
| 7 |
-
<
|
| 8 |
-
body {
|
| 9 |
-
font-family: 'Arial', sans-serif;
|
| 10 |
-
margin: 0;
|
| 11 |
-
padding: 0;
|
| 12 |
-
background-color: #f0f2f5;
|
| 13 |
-
overflow-x: hidden;
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
.chat-container {
|
| 17 |
-
width: 100%;
|
| 18 |
-
max-width: 1200px;
|
| 19 |
-
height: 100vh;
|
| 20 |
-
margin: 0 auto;
|
| 21 |
-
border: 1px solid #ccc;
|
| 22 |
-
border-radius: 8px;
|
| 23 |
-
background-color: white;
|
| 24 |
-
display: flex;
|
| 25 |
-
flex-direction: column;
|
| 26 |
-
box-sizing: border-box;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
.chat-header {
|
| 30 |
-
background: linear-gradient(45deg, #0288d1, #03a9f4);
|
| 31 |
-
color: white;
|
| 32 |
-
padding: 12px;
|
| 33 |
-
text-align: center;
|
| 34 |
-
font-size: 1.25rem;
|
| 35 |
-
flex-shrink: 0;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
.chat-messages {
|
| 39 |
-
flex: 1;
|
| 40 |
-
overflow-y: auto;
|
| 41 |
-
padding: 10px;
|
| 42 |
-
box-sizing: border-box;
|
| 43 |
-
scroll-behavior: smooth;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
.bot-message, .user-message {
|
| 47 |
-
padding: 10px;
|
| 48 |
-
margin: 8px 0;
|
| 49 |
-
border-radius: 8px;
|
| 50 |
-
max-width: 80%;
|
| 51 |
-
word-wrap: break-word;
|
| 52 |
-
font-size: 0.875rem;
|
| 53 |
-
animation: slideIn 0.3s ease;
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
.bot-message {
|
| 57 |
-
background-color: #e3f2fd;
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
.user-message {
|
| 61 |
-
background-color: #ffebee;
|
| 62 |
-
margin-left: auto;
|
| 63 |
-
text-align: right;
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
@keyframes slideIn {
|
| 67 |
-
from { transform: translateY(20px); opacity: 0; }
|
| 68 |
-
to { transform: translateY(0); opacity: 1; }
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
.chat-input {
|
| 72 |
-
display: flex;
|
| 73 |
-
padding: 10px;
|
| 74 |
-
border-top: 1px solid #ccc;
|
| 75 |
-
flex-shrink: 0;
|
| 76 |
-
background-color: white;
|
| 77 |
-
box-sizing: border-box;
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
.chat-input input {
|
| 81 |
-
flex: 1;
|
| 82 |
-
padding: 8px;
|
| 83 |
-
border: 1px solid #ccc;
|
| 84 |
-
border-radius: 8px;
|
| 85 |
-
font-size: 0.875rem;
|
| 86 |
-
min-height: 40px;
|
| 87 |
-
box-sizing: border-box;
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
.chat-input button {
|
| 91 |
-
padding: 8px 12px;
|
| 92 |
-
margin-left: 8px;
|
| 93 |
-
background-color: #ff8f00;
|
| 94 |
-
color: white;
|
| 95 |
-
border: none;
|
| 96 |
-
border-radius: 8px;
|
| 97 |
-
cursor: pointer;
|
| 98 |
-
font-size: 0.875rem;
|
| 99 |
-
min-height: 40px;
|
| 100 |
-
min-width: 70px;
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
.chat-input button:hover {
|
| 104 |
-
background-color: #f57c00;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
.items-grid {
|
| 108 |
-
display: grid;
|
| 109 |
-
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
| 110 |
-
gap: 12px;
|
| 111 |
-
padding: 12px;
|
| 112 |
-
margin: 8px 0;
|
| 113 |
-
background-color: #f9f9f9;
|
| 114 |
-
border-radius: 8px;
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
.item-card {
|
| 118 |
-
background-color: white;
|
| 119 |
-
border: 1px solid #ddd;
|
| 120 |
-
border-radius: 8px;
|
| 121 |
-
padding: 12px;
|
| 122 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 123 |
-
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
.item-card:hover {
|
| 127 |
-
transform: scale(1.05);
|
| 128 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
.item-image {
|
| 132 |
-
width: 100%;
|
| 133 |
-
height: 120px;
|
| 134 |
-
object-fit: cover;
|
| 135 |
-
border-radius: 8px;
|
| 136 |
-
margin-bottom: 8px;
|
| 137 |
-
loading: lazy;
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
.item-content {
|
| 141 |
-
width: 100%;
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
.item-name {
|
| 145 |
-
font-size: 0.875rem;
|
| 146 |
-
font-weight: bold;
|
| 147 |
-
color: #333;
|
| 148 |
-
margin-bottom: 5px;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.item-field {
|
| 152 |
-
font-size: 0.75rem;
|
| 153 |
-
margin: 3px 0;
|
| 154 |
-
color: #555;
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
.item-field strong {
|
| 158 |
-
color: #0288d1;
|
| 159 |
-
}
|
| 160 |
-
|
| 161 |
-
.item-description {
|
| 162 |
-
font-size: 0.75rem;
|
| 163 |
-
margin: 5px 0;
|
| 164 |
-
color: #555;
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
.button-container {
|
| 168 |
-
display: flex;
|
| 169 |
-
gap: 8px;
|
| 170 |
-
margin-top: 8px;
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
.show-button, .add-button {
|
| 174 |
-
padding: 6px;
|
| 175 |
-
border: none;
|
| 176 |
-
border-radius: 8px;
|
| 177 |
-
cursor: pointer;
|
| 178 |
-
font-size: 0.75rem;
|
| 179 |
-
flex: 1;
|
| 180 |
-
min-width: 50px;
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
.show-button {
|
| 184 |
-
background-color: #0288d1;
|
| 185 |
-
color: white;
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
.show-button:hover {
|
| 189 |
-
background-color: #0277bd;
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
.add-button {
|
| 193 |
-
background-color: #4caf50;
|
| 194 |
-
color: white;
|
| 195 |
-
}
|
| 196 |
-
|
| 197 |
-
.add-button:hover {
|
| 198 |
-
background-color: #45a049;
|
| 199 |
-
}
|
| 200 |
-
|
| 201 |
-
.options-container {
|
| 202 |
-
display: flex;
|
| 203 |
-
flex-wrap: wrap;
|
| 204 |
-
gap: 8px;
|
| 205 |
-
margin: 8px 0;
|
| 206 |
-
}
|
| 207 |
-
|
| 208 |
-
.option-button {
|
| 209 |
-
padding: 8px 12px;
|
| 210 |
-
background-color: #7b1fa2;
|
| 211 |
-
color: white;
|
| 212 |
-
border: none;
|
| 213 |
-
border-radius: 8px;
|
| 214 |
-
cursor: pointer;
|
| 215 |
-
font-size: 0.875rem;
|
| 216 |
-
min-width: 70px;
|
| 217 |
-
}
|
| 218 |
-
|
| 219 |
-
.option-button.green { background-color: #4caf50; }
|
| 220 |
-
.option-button.red { background-color: #d32f2f; }
|
| 221 |
-
.option-button.gray { background-color: #616161; }
|
| 222 |
-
.option-button:hover { opacity: 0.9; }
|
| 223 |
-
|
| 224 |
-
.selection-box {
|
| 225 |
-
background-color: #e1f5fe;
|
| 226 |
-
padding: 12px;
|
| 227 |
-
border: 1px solid #0288d1;
|
| 228 |
-
border-radius: 8px;
|
| 229 |
-
margin: 8px 0;
|
| 230 |
-
font-size: 0.875rem;
|
| 231 |
-
display: flex;
|
| 232 |
-
flex-wrap: wrap;
|
| 233 |
-
align-items: center;
|
| 234 |
-
gap: 8px;
|
| 235 |
-
position: relative;
|
| 236 |
-
}
|
| 237 |
-
|
| 238 |
-
.selection-box::before {
|
| 239 |
-
content: "Selected Items";
|
| 240 |
-
position: sticky;
|
| 241 |
-
top: 0;
|
| 242 |
-
background: #0288d1;
|
| 243 |
-
color: white;
|
| 244 |
-
padding: 8px;
|
| 245 |
-
border-radius: 8px 8px 0 0;
|
| 246 |
-
font-size: 0.875rem;
|
| 247 |
-
width: 100%;
|
| 248 |
-
box-sizing: border-box;
|
| 249 |
-
}
|
| 250 |
-
|
| 251 |
-
.selection-box span {
|
| 252 |
-
background-color: #bbdefb;
|
| 253 |
-
padding: 4px 10px;
|
| 254 |
-
border-radius: 8px;
|
| 255 |
-
font-size: 0.875rem;
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
.selected-item {
|
| 259 |
-
display: flex;
|
| 260 |
-
align-items: center;
|
| 261 |
-
background-color: #bbdefb;
|
| 262 |
-
padding: 4px 10px;
|
| 263 |
-
border-radius: 8px;
|
| 264 |
-
font-size: 0.75rem;
|
| 265 |
-
}
|
| 266 |
-
|
| 267 |
-
.selected-item-image {
|
| 268 |
-
width: 30px;
|
| 269 |
-
height: 30px;
|
| 270 |
-
object-fit: cover;
|
| 271 |
-
border-radius: 8px;
|
| 272 |
-
margin-right: 8px;
|
| 273 |
-
loading: lazy;
|
| 274 |
-
}
|
| 275 |
-
|
| 276 |
-
.submit-button {
|
| 277 |
-
padding: 8px 12px;
|
| 278 |
-
background-color: #0288d1;
|
| 279 |
-
color: white;
|
| 280 |
-
border: none;
|
| 281 |
-
border-radius: 8px;
|
| 282 |
-
cursor: pointer;
|
| 283 |
-
font-size: 0.875rem;
|
| 284 |
-
min-width: 70px;
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
.submit-button:hover {
|
| 288 |
-
background-color: #0277bd;
|
| 289 |
-
}
|
| 290 |
-
|
| 291 |
-
.remove-button {
|
| 292 |
-
padding: 4px 8px;
|
| 293 |
-
margin-left: 8px;
|
| 294 |
-
background-color: #d32f2f;
|
| 295 |
-
color: white;
|
| 296 |
-
border: none;
|
| 297 |
-
border-radius: 8px;
|
| 298 |
-
cursor: pointer;
|
| 299 |
-
font-size: 0.75rem;
|
| 300 |
-
}
|
| 301 |
-
|
| 302 |
-
.remove-button:hover {
|
| 303 |
-
background-color: #b71c1c;
|
| 304 |
-
}
|
| 305 |
-
|
| 306 |
-
.manual-input, .order-name-input {
|
| 307 |
-
padding: 6px;
|
| 308 |
-
border: 1px solid #0288d1;
|
| 309 |
-
border-radius: 8px;
|
| 310 |
-
font-size: 0.875rem;
|
| 311 |
-
width: 120px;
|
| 312 |
-
}
|
| 313 |
-
|
| 314 |
-
.quantity-input {
|
| 315 |
-
padding: 6px;
|
| 316 |
-
border: 1px solid #0288d1;
|
| 317 |
-
border-radius: 8px;
|
| 318 |
-
font-size: 0.875rem;
|
| 319 |
-
width: 60px;
|
| 320 |
-
}
|
| 321 |
-
|
| 322 |
-
.spinner {
|
| 323 |
-
border: 4px solid #0288d1;
|
| 324 |
-
border-top: 4px solid transparent;
|
| 325 |
-
border-radius: 50%;
|
| 326 |
-
width: 24px;
|
| 327 |
-
height: 24px;
|
| 328 |
-
animation: spin 1s linear infinite;
|
| 329 |
-
margin: 10px auto;
|
| 330 |
-
}
|
| 331 |
-
|
| 332 |
-
@keyframes spin {
|
| 333 |
-
to { transform: rotate(360deg); }
|
| 334 |
-
}
|
| 335 |
-
|
| 336 |
-
.toast {
|
| 337 |
-
position: fixed;
|
| 338 |
-
bottom: 20px;
|
| 339 |
-
right: 20px;
|
| 340 |
-
background: #4caf50;
|
| 341 |
-
color: white;
|
| 342 |
-
padding: 10px;
|
| 343 |
-
border-radius: 8px;
|
| 344 |
-
font-size: 0.875rem;
|
| 345 |
-
animation: fadeInOut 3s ease forwards;
|
| 346 |
-
z-index: 1000;
|
| 347 |
-
}
|
| 348 |
-
|
| 349 |
-
@keyframes fadeInOut {
|
| 350 |
-
0% { opacity: 0; transform: translateY(20px); }
|
| 351 |
-
10%, 90% { opacity: 1; transform: translateY(0); }
|
| 352 |
-
100% { opacity: 0; transform: translateY(20px); }
|
| 353 |
-
}
|
| 354 |
-
|
| 355 |
-
@media (max-width: 480px) {
|
| 356 |
-
.chat-container {
|
| 357 |
-
border-radius: 0;
|
| 358 |
-
height: calc(100vh - env(safe-area-inset-bottom));
|
| 359 |
-
}
|
| 360 |
-
|
| 361 |
-
.chat-header {
|
| 362 |
-
font-size: 1rem;
|
| 363 |
-
padding: 8px;
|
| 364 |
-
}
|
| 365 |
-
|
| 366 |
-
.chat-messages {
|
| 367 |
-
padding: 6px;
|
| 368 |
-
}
|
| 369 |
-
|
| 370 |
-
.bot-message, .user-message {
|
| 371 |
-
font-size: 0.75rem;
|
| 372 |
-
padding: 8px;
|
| 373 |
-
margin: 6px 0;
|
| 374 |
-
}
|
| 375 |
-
|
| 376 |
-
.chat-input input {
|
| 377 |
-
font-size: 0.75rem;
|
| 378 |
-
min-height: 36px;
|
| 379 |
-
padding: 6px;
|
| 380 |
-
}
|
| 381 |
-
|
| 382 |
-
.chat-input button {
|
| 383 |
-
font-size: 0.75rem;
|
| 384 |
-
min-height: 36px;
|
| 385 |
-
padding: 6px 10px;
|
| 386 |
-
min-width: 60px;
|
| 387 |
-
}
|
| 388 |
-
|
| 389 |
-
.items-grid {
|
| 390 |
-
grid-template-columns: 1fr;
|
| 391 |
-
gap: 8px;
|
| 392 |
-
padding: 8px;
|
| 393 |
-
}
|
| 394 |
-
|
| 395 |
-
.item-card {
|
| 396 |
-
max-width: 100%;
|
| 397 |
-
}
|
| 398 |
-
|
| 399 |
-
.item-image {
|
| 400 |
-
height: 100px;
|
| 401 |
-
}
|
| 402 |
-
|
| 403 |
-
.item-name {
|
| 404 |
-
font-size: 0.75rem;
|
| 405 |
-
}
|
| 406 |
-
|
| 407 |
-
.item-field, .item-description {
|
| 408 |
-
font-size: 0.625rem;
|
| 409 |
-
}
|
| 410 |
-
|
| 411 |
-
.show-button, .add-button {
|
| 412 |
-
font-size: 0.625rem;
|
| 413 |
-
padding: 4px;
|
| 414 |
-
min-width: 40px;
|
| 415 |
-
}
|
| 416 |
-
|
| 417 |
-
.options-container {
|
| 418 |
-
flex-direction: column;
|
| 419 |
-
align-items: stretch;
|
| 420 |
-
gap: 6px;
|
| 421 |
-
}
|
| 422 |
-
|
| 423 |
-
.option-button {
|
| 424 |
-
font-size: 0.75rem;
|
| 425 |
-
padding: 6px 10px;
|
| 426 |
-
min-width: 100%;
|
| 427 |
-
}
|
| 428 |
-
|
| 429 |
-
.selection-box {
|
| 430 |
-
padding: 8px;
|
| 431 |
-
gap: 6px;
|
| 432 |
-
}
|
| 433 |
-
|
| 434 |
-
.selection-box::before {
|
| 435 |
-
font-size: 0.75rem;
|
| 436 |
-
padding: 6px;
|
| 437 |
-
}
|
| 438 |
-
|
| 439 |
-
.selection-box span {
|
| 440 |
-
font-size: 0.75rem;
|
| 441 |
-
padding: 3px 8px;
|
| 442 |
-
}
|
| 443 |
-
|
| 444 |
-
.selected-item {
|
| 445 |
-
font-size: 0.625rem;
|
| 446 |
-
padding: 3px 8px;
|
| 447 |
-
}
|
| 448 |
-
|
| 449 |
-
.selected-item-image {
|
| 450 |
-
width: 24px;
|
| 451 |
-
height: 24px;
|
| 452 |
-
}
|
| 453 |
-
|
| 454 |
-
.submit-button {
|
| 455 |
-
font-size: 0.75rem;
|
| 456 |
-
padding: 6px 10px;
|
| 457 |
-
min-width: 60px;
|
| 458 |
-
}
|
| 459 |
-
|
| 460 |
-
.remove-button {
|
| 461 |
-
font-size: 0.625rem;
|
| 462 |
-
padding: 3px 6px;
|
| 463 |
-
}
|
| 464 |
-
|
| 465 |
-
.manual-input, .order-name-input {
|
| 466 |
-
width: 100px;
|
| 467 |
-
font-size: 0.75rem;
|
| 468 |
-
padding: 4px;
|
| 469 |
-
}
|
| 470 |
-
|
| 471 |
-
.quantity-input {
|
| 472 |
-
width: 50px;
|
| 473 |
-
font-size: 0.75rem;
|
| 474 |
-
padding: 4px;
|
| 475 |
-
}
|
| 476 |
-
}
|
| 477 |
-
|
| 478 |
-
@media (min-width: 481px) and (max-width: 768px) {
|
| 479 |
-
.chat-container {
|
| 480 |
-
max-width: 100%;
|
| 481 |
-
}
|
| 482 |
-
|
| 483 |
-
.chat-header {
|
| 484 |
-
font-size: 1.125rem;
|
| 485 |
-
}
|
| 486 |
-
|
| 487 |
-
.chat-messages {
|
| 488 |
-
padding: 8px;
|
| 489 |
-
}
|
| 490 |
-
|
| 491 |
-
.bot-message, .user-message {
|
| 492 |
-
font-size: 0.875rem;
|
| 493 |
-
padding: 9px;
|
| 494 |
-
}
|
| 495 |
-
|
| 496 |
-
.chat-input input {
|
| 497 |
-
font-size: 0.875rem;
|
| 498 |
-
min-height: 38px;
|
| 499 |
-
}
|
| 500 |
-
|
| 501 |
-
.chat-input button {
|
| 502 |
-
font-size: 0.875rem;
|
| 503 |
-
min-height: 38px;
|
| 504 |
-
padding: 7px 11px;
|
| 505 |
-
}
|
| 506 |
-
|
| 507 |
-
.items-grid {
|
| 508 |
-
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
| 509 |
-
gap: 10px;
|
| 510 |
-
}
|
| 511 |
-
|
| 512 |
-
.item-image {
|
| 513 |
-
height: 110px;
|
| 514 |
-
}
|
| 515 |
-
|
| 516 |
-
.item-name {
|
| 517 |
-
font-size: 0.875rem;
|
| 518 |
-
}
|
| 519 |
-
|
| 520 |
-
.item-field, .item-description {
|
| 521 |
-
font-size: 0.75rem;
|
| 522 |
-
}
|
| 523 |
-
|
| 524 |
-
.show-button, .add-button {
|
| 525 |
-
font-size: 0.75rem;
|
| 526 |
-
padding: 5px;
|
| 527 |
-
min-width: 45px;
|
| 528 |
-
}
|
| 529 |
-
|
| 530 |
-
.option-button {
|
| 531 |
-
font-size: 0.875rem;
|
| 532 |
-
padding: 7px 11px;
|
| 533 |
-
}
|
| 534 |
-
|
| 535 |
-
.selection-box {
|
| 536 |
-
padding: 10px;
|
| 537 |
-
gap: 7px;
|
| 538 |
-
}
|
| 539 |
-
|
| 540 |
-
.selection-box span {
|
| 541 |
-
font-size: 0.875rem;
|
| 542 |
-
}
|
| 543 |
-
|
| 544 |
-
.selected-item {
|
| 545 |
-
font-size: 0.75rem;
|
| 546 |
-
}
|
| 547 |
-
|
| 548 |
-
.selected-item-image {
|
| 549 |
-
width: 28px;
|
| 550 |
-
height: 28px;
|
| 551 |
-
}
|
| 552 |
-
|
| 553 |
-
.submit-button {
|
| 554 |
-
font-size: 0.875rem;
|
| 555 |
-
padding: 7px 11px;
|
| 556 |
-
}
|
| 557 |
-
|
| 558 |
-
.remove-button {
|
| 559 |
-
font-size: 0.75rem;
|
| 560 |
-
padding: 4px 7px;
|
| 561 |
-
}
|
| 562 |
-
|
| 563 |
-
.manual-input, .order-name-input {
|
| 564 |
-
width: 110px;
|
| 565 |
-
font-size: 0.875rem;
|
| 566 |
-
}
|
| 567 |
-
|
| 568 |
-
.quantity-input {
|
| 569 |
-
width: 55px;
|
| 570 |
-
font-size: 0.875rem;
|
| 571 |
-
}
|
| 572 |
-
}
|
| 573 |
-
|
| 574 |
-
@media (min-width: 769px) {
|
| 575 |
-
.chat-container {
|
| 576 |
-
display: grid;
|
| 577 |
-
grid-template-columns: 1fr 1fr;
|
| 578 |
-
gap: 10px;
|
| 579 |
-
}
|
| 580 |
-
|
| 581 |
-
.chat-messages, .chat-input {
|
| 582 |
-
grid-column: 1 / 2;
|
| 583 |
-
}
|
| 584 |
-
|
| 585 |
-
.suggestions-list, .ingredients-list {
|
| 586 |
-
grid-column: 2 / 3;
|
| 587 |
-
}
|
| 588 |
-
|
| 589 |
-
.selection-box {
|
| 590 |
-
grid-column: 2 / 3;
|
| 591 |
-
grid-row: 1 / 3;
|
| 592 |
-
}
|
| 593 |
-
}
|
| 594 |
-
</style>
|
| 595 |
</head>
|
| 596 |
<body>
|
| 597 |
<div class="chat-container">
|
|
@@ -606,520 +19,6 @@
|
|
| 606 |
<button onclick="sendMessage()" aria-label="Send message">Send</button>
|
| 607 |
</div>
|
| 608 |
</div>
|
| 609 |
-
<script>
|
| 610 |
-
let conversation = [
|
| 611 |
-
{ role: 'bot', message: 'Hello! I’m Chef Bot, your culinary assistant! What’s your name?' }
|
| 612 |
-
];
|
| 613 |
-
let selectedItems = [];
|
| 614 |
-
let selectionBoxVisible = false;
|
| 615 |
-
|
| 616 |
-
function addMessage(role, message) {
|
| 617 |
-
const chatMessages = document.getElementById('chatMessages');
|
| 618 |
-
if (!chatMessages) {
|
| 619 |
-
console.error('Chat messages container not found!');
|
| 620 |
-
return;
|
| 621 |
-
}
|
| 622 |
-
const messageDiv = document.createElement('div');
|
| 623 |
-
messageDiv.className = role === 'bot' ? 'bot-message' : 'user-message';
|
| 624 |
-
messageDiv.textContent = message;
|
| 625 |
-
chatMessages.appendChild(messageDiv);
|
| 626 |
-
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 627 |
-
console.log(`Added ${role} message: ${message}`);
|
| 628 |
-
}
|
| 629 |
-
|
| 630 |
-
function showToast(message) {
|
| 631 |
-
const toast = document.createElement('div');
|
| 632 |
-
toast.className = 'toast';
|
| 633 |
-
toast.textContent = message;
|
| 634 |
-
document.body.appendChild(toast);
|
| 635 |
-
setTimeout(() => toast.remove(), 3000);
|
| 636 |
-
}
|
| 637 |
-
|
| 638 |
-
function sendMessage() {
|
| 639 |
-
const userInput = document.getElementById('userInput');
|
| 640 |
-
if (!userInput) {
|
| 641 |
-
console.error('User input field not found!');
|
| 642 |
-
return;
|
| 643 |
-
}
|
| 644 |
-
const message = userInput.value.trim();
|
| 645 |
-
if (message) {
|
| 646 |
-
addMessage('user', message);
|
| 647 |
-
conversation.push({ role: 'user', message: message });
|
| 648 |
-
selectionBoxVisible = true;
|
| 649 |
-
handleResponse(message);
|
| 650 |
-
showToast(`Sent: "${message}"`);
|
| 651 |
-
} else {
|
| 652 |
-
addMessage('bot', 'Please type a dish or preference! 😄');
|
| 653 |
-
showToast('Input is empty!');
|
| 654 |
-
}
|
| 655 |
-
userInput.value = '';
|
| 656 |
-
updateSelectionBox();
|
| 657 |
-
}
|
| 658 |
-
|
| 659 |
-
function handleResponse(userInput) {
|
| 660 |
-
const lowerInput = userInput.toLowerCase();
|
| 661 |
-
let botResponse = '';
|
| 662 |
-
|
| 663 |
-
if (conversation.length === 2) {
|
| 664 |
-
botResponse = `Hi ${userInput}! 🍳 Search for a dish or choose a preference below!`;
|
| 665 |
-
displayOptions([
|
| 666 |
-
{ text: 'Vegetarian', class: 'green' },
|
| 667 |
-
{ text: 'Non-Vegetarian', class: 'red' },
|
| 668 |
-
{ text: 'Both', class: 'gray' }
|
| 669 |
-
]);
|
| 670 |
-
addMessage('bot', botResponse);
|
| 671 |
-
} else if (lowerInput === 'vegetarian' || lowerInput === 'non-vegetarian' || lowerInput === 'both') {
|
| 672 |
-
botResponse = `Fetching ${lowerInput} dishes...`;
|
| 673 |
-
addMessage('bot', botResponse);
|
| 674 |
-
fetchMenuItems(lowerInput);
|
| 675 |
-
} else {
|
| 676 |
-
botResponse = `Looking for "${userInput}"...`;
|
| 677 |
-
addMessage('bot', botResponse);
|
| 678 |
-
fetchMenuItems(null, userInput);
|
| 679 |
-
}
|
| 680 |
-
}
|
| 681 |
-
|
| 682 |
-
function debounce(func, wait) {
|
| 683 |
-
let timeout;
|
| 684 |
-
return function (...args) {
|
| 685 |
-
clearTimeout(timeout);
|
| 686 |
-
timeout = setTimeout(() => func.apply(this, args), wait);
|
| 687 |
-
};
|
| 688 |
-
}
|
| 689 |
-
|
| 690 |
-
function updateSelectionBox() {
|
| 691 |
-
const chatMessages = document.getElementById('chatMessages');
|
| 692 |
-
if (!chatMessages) return;
|
| 693 |
-
|
| 694 |
-
const existingBox = document.querySelector('.selection-box');
|
| 695 |
-
if (existingBox) existingBox.remove();
|
| 696 |
-
|
| 697 |
-
if (!selectionBoxVisible && selectedItems.length === 0) return;
|
| 698 |
-
|
| 699 |
-
const selectionBox = document.createElement('div');
|
| 700 |
-
selectionBox.className = 'selection-box';
|
| 701 |
-
|
| 702 |
-
const clearAllButton = document.createElement('button');
|
| 703 |
-
clearAllButton.textContent = 'Clear All';
|
| 704 |
-
clearAllButton.className = 'remove-button';
|
| 705 |
-
clearAllButton.onclick = () => {
|
| 706 |
-
selectedItems = [];
|
| 707 |
-
addMessage('bot', 'Cleared all items.');
|
| 708 |
-
showToast('All items cleared!');
|
| 709 |
-
updateSelectionBox();
|
| 710 |
-
};
|
| 711 |
-
selectionBox.appendChild(clearAllButton);
|
| 712 |
-
|
| 713 |
-
const vegButton = document.createElement('button');
|
| 714 |
-
vegButton.textContent = 'Veg';
|
| 715 |
-
vegButton.className = 'option-button green';
|
| 716 |
-
vegButton.onclick = () => {
|
| 717 |
-
addMessage('user', 'Vegetarian');
|
| 718 |
-
conversation.push({ role: 'user', message: 'Vegetarian' });
|
| 719 |
-
handleResponse('vegetarian');
|
| 720 |
-
showToast('Selected Vegetarian');
|
| 721 |
-
};
|
| 722 |
-
selectionBox.appendChild(vegButton);
|
| 723 |
-
|
| 724 |
-
const nonVegButton = document.createElement('button');
|
| 725 |
-
nonVegButton.textContent = 'Non-Veg';
|
| 726 |
-
nonVegButton.className = 'option-button red';
|
| 727 |
-
nonVegButton.onclick = () => {
|
| 728 |
-
addMessage('user', 'Non-Vegetarian');
|
| 729 |
-
conversation.push({ role: 'user', message: 'Non-Vegetarian' });
|
| 730 |
-
handleResponse('non-vegetarian');
|
| 731 |
-
showToast('Selected Non-Vegetarian');
|
| 732 |
-
};
|
| 733 |
-
selectionBox.appendChild(nonVegButton);
|
| 734 |
-
|
| 735 |
-
const bothButton = document.createElement('button');
|
| 736 |
-
bothButton.textContent = 'Both';
|
| 737 |
-
bothButton.className = 'option-button gray';
|
| 738 |
-
bothButton.onclick = () => {
|
| 739 |
-
addMessage('user', 'Both');
|
| 740 |
-
conversation.push({ role: 'user', message: 'Both' });
|
| 741 |
-
handleResponse('both');
|
| 742 |
-
showToast('Selected Both');
|
| 743 |
-
};
|
| 744 |
-
selectionBox.appendChild(bothButton);
|
| 745 |
-
|
| 746 |
-
const label = document.createElement('span');
|
| 747 |
-
label.textContent = 'Selected:';
|
| 748 |
-
selectionBox.appendChild(label);
|
| 749 |
-
|
| 750 |
-
selectedItems.forEach((item, index) => {
|
| 751 |
-
const itemContainer = document.createElement('div');
|
| 752 |
-
itemContainer.className = 'selected-item';
|
| 753 |
-
itemContainer.dataset.hidden = item.source === 'Sector_Detail__c' ? 'true' : 'false';
|
| 754 |
-
|
| 755 |
-
const img = document.createElement('img');
|
| 756 |
-
img.src = item.image_url || 'https://via.placeholder.com/30';
|
| 757 |
-
img.alt = item.name;
|
| 758 |
-
img.className = 'selected-item-image';
|
| 759 |
-
itemContainer.appendChild(img);
|
| 760 |
-
|
| 761 |
-
const contentDiv = document.createElement('div');
|
| 762 |
-
contentDiv.className = 'selected-item-content';
|
| 763 |
-
|
| 764 |
-
const itemSpan = document.createElement('span');
|
| 765 |
-
itemSpan.textContent = `${item.name} (Qty: ${item.quantity || 1})`;
|
| 766 |
-
contentDiv.appendChild(itemSpan);
|
| 767 |
-
|
| 768 |
-
if (item.source === 'Sector_Detail__c') {
|
| 769 |
-
const showButton = document.createElement('button');
|
| 770 |
-
showButton.textContent = 'Show';
|
| 771 |
-
showButton.className = 'show-button';
|
| 772 |
-
showButton.onclick = () => toggleDescription(itemContainer, item.description, item.name);
|
| 773 |
-
contentDiv.appendChild(showButton);
|
| 774 |
-
}
|
| 775 |
-
|
| 776 |
-
itemContainer.appendChild(contentDiv);
|
| 777 |
-
|
| 778 |
-
const removeButton = document.createElement('button');
|
| 779 |
-
removeButton.textContent = 'X';
|
| 780 |
-
removeButton.className = 'remove-button';
|
| 781 |
-
removeButton.onclick = () => {
|
| 782 |
-
selectedItems.splice(index, 1);
|
| 783 |
-
addMessage('bot', `Removed "${item.name}".`);
|
| 784 |
-
showToast(`Removed "${item.name}"`);
|
| 785 |
-
updateSelectionBox();
|
| 786 |
-
};
|
| 787 |
-
itemContainer.appendChild(removeButton);
|
| 788 |
-
|
| 789 |
-
selectionBox.appendChild(itemContainer);
|
| 790 |
-
});
|
| 791 |
-
|
| 792 |
-
const textInput = document.createElement('input');
|
| 793 |
-
textInput.type = 'text';
|
| 794 |
-
textInput.placeholder = 'Add item...';
|
| 795 |
-
textInput.className = 'manual-input';
|
| 796 |
-
textInput.addEventListener('keypress', debounce((e) => {
|
| 797 |
-
if (e.key === 'Enter' && textInput.value.trim()) {
|
| 798 |
-
const itemName = textInput.value.trim();
|
| 799 |
-
fetchSectorItemDetails(itemName);
|
| 800 |
-
textInput.value = '';
|
| 801 |
-
showToast(`Searching for "${itemName}"...`);
|
| 802 |
-
}
|
| 803 |
-
}, 300));
|
| 804 |
-
selectionBox.appendChild(textInput);
|
| 805 |
-
|
| 806 |
-
if (selectedItems.length > 0) {
|
| 807 |
-
const quantityInput = document.createElement('input');
|
| 808 |
-
quantityInput.type = 'number';
|
| 809 |
-
quantityInput.min = '1';
|
| 810 |
-
quantityInput.value = '1';
|
| 811 |
-
quantityInput.placeholder = 'Qty';
|
| 812 |
-
quantityInput.className = 'quantity-input';
|
| 813 |
-
selectionBox.appendChild(quantityInput);
|
| 814 |
-
|
| 815 |
-
const submitButton = document.createElement('button');
|
| 816 |
-
submitButton.textContent = 'Submit';
|
| 817 |
-
submitButton.className = 'submit-button';
|
| 818 |
-
submitButton.onclick = () => promptAndSubmit(quantityInput.value);
|
| 819 |
-
selectionBox.appendChild(submitButton);
|
| 820 |
-
|
| 821 |
-
const orderNameInput = document.createElement('input');
|
| 822 |
-
orderNameInput.type = 'text';
|
| 823 |
-
orderNameInput.placeholder = 'Order Name';
|
| 824 |
-
orderNameInput.className = 'order-name-input';
|
| 825 |
-
selectionBox.appendChild(orderNameInput);
|
| 826 |
-
}
|
| 827 |
-
|
| 828 |
-
chatMessages.appendChild(selectionBox);
|
| 829 |
-
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 830 |
-
console.log('Updated selection box:', selectedItems.map(item => ({ name: item.name, category: item.category })));
|
| 831 |
-
}
|
| 832 |
-
|
| 833 |
-
function fetchMenuItems(dietaryPreference = '', searchTerm = '') {
|
| 834 |
-
const payload = {};
|
| 835 |
-
if (dietaryPreference) payload.dietary_preference = dietaryPreference;
|
| 836 |
-
if (searchTerm) payload.search_term = searchTerm;
|
| 837 |
-
|
| 838 |
-
const chatMessages = document.getElementById('chatMessages');
|
| 839 |
-
const spinner = document.createElement('div');
|
| 840 |
-
spinner.className = 'spinner';
|
| 841 |
-
chatMessages.appendChild(spinner);
|
| 842 |
-
|
| 843 |
-
fetch('/get_menu_items', {
|
| 844 |
-
method: 'POST',
|
| 845 |
-
headers: { 'Content-Type': 'application/json' },
|
| 846 |
-
body: JSON.stringify(payload)
|
| 847 |
-
})
|
| 848 |
-
.then(response => response.json())
|
| 849 |
-
.then(data => {
|
| 850 |
-
spinner.remove();
|
| 851 |
-
if (data.error) {
|
| 852 |
-
addMessage('bot', `Error: ${data.error}. Try again!`);
|
| 853 |
-
showToast(`Error: ${data.error}`);
|
| 854 |
-
} else if (data.menu_items.length > 0) {
|
| 855 |
-
addMessage('bot', `--- Found ${data.menu_items.length} item${data.menu_items.length > 1 ? 's' : ''} ---`);
|
| 856 |
-
displayItemsList(data.menu_items);
|
| 857 |
-
} else {
|
| 858 |
-
addMessage('bot', `No matches for "${searchTerm || dietaryPreference}". Try "paneer" or "chicken curry"!`);
|
| 859 |
-
showToast('No items found!');
|
| 860 |
-
}
|
| 861 |
-
console.log(`Fetched items for ${searchTerm || dietaryPreference}:`, data.menu_items);
|
| 862 |
-
})
|
| 863 |
-
.catch(error => {
|
| 864 |
-
spinner.remove();
|
| 865 |
-
addMessage('bot', `Connection issue: ${error.message}. Retrying...`);
|
| 866 |
-
showToast('Connection issue!');
|
| 867 |
-
setTimeout(() => fetchMenuItems(dietaryPreference, searchTerm), 2000);
|
| 868 |
-
});
|
| 869 |
-
}
|
| 870 |
-
|
| 871 |
-
function fetchSectorItemDetails(itemName) {
|
| 872 |
-
fetch('/get_sector_item_details', {
|
| 873 |
-
method: 'POST',
|
| 874 |
-
headers: { 'Content-Type': 'application/json' },
|
| 875 |
-
body: JSON.stringify({ item_name: itemName })
|
| 876 |
-
})
|
| 877 |
-
.then(response => response.json())
|
| 878 |
-
.then(data => {
|
| 879 |
-
if (data.error) {
|
| 880 |
-
addMessage('bot', `No "${itemName}" found. Try another!`);
|
| 881 |
-
showToast(`No "${itemName}" found`);
|
| 882 |
-
} else {
|
| 883 |
-
const details = data.item_details;
|
| 884 |
-
if (selectedItems.some(item => item.name === details.name)) {
|
| 885 |
-
addMessage('bot', `"${details.name}" already selected!`);
|
| 886 |
-
showToast(`"${details.name}" already selected`);
|
| 887 |
-
} else {
|
| 888 |
-
selectedItems.push({ ...details, quantity: 1 });
|
| 889 |
-
addMessage('bot', `Added "${details.name}"!`);
|
| 890 |
-
showToast(`Added "${details.name}"`);
|
| 891 |
-
updateSelectionBox();
|
| 892 |
-
}
|
| 893 |
-
}
|
| 894 |
-
})
|
| 895 |
-
.catch(error => {
|
| 896 |
-
addMessage('bot', `Error for "${itemName}". Retrying...`);
|
| 897 |
-
showToast(`Error fetching "${itemName}"`);
|
| 898 |
-
setTimeout(() => fetchSectorItemDetails(itemName), 2000);
|
| 899 |
-
});
|
| 900 |
-
}
|
| 901 |
-
|
| 902 |
-
function toggleDescription(itemContainer, description, itemName) {
|
| 903 |
-
let descElement = itemContainer.querySelector('.item-description');
|
| 904 |
-
if (!descElement) {
|
| 905 |
-
descElement = document.createElement('p');
|
| 906 |
-
descElement.className = 'item-description';
|
| 907 |
-
descElement.textContent = description;
|
| 908 |
-
itemContainer.querySelector('.selected-item-content').appendChild(descElement);
|
| 909 |
-
itemContainer.dataset.hidden = 'false';
|
| 910 |
-
console.log(`Showed description for ${itemName}`);
|
| 911 |
-
showToast(`Showing details for ${itemName}`);
|
| 912 |
-
} else {
|
| 913 |
-
descElement.remove();
|
| 914 |
-
itemContainer.dataset.hidden = 'true';
|
| 915 |
-
console.log(`Hid description for ${itemName}`);
|
| 916 |
-
showToast(`Hid details for ${itemName}`);
|
| 917 |
-
}
|
| 918 |
-
}
|
| 919 |
-
|
| 920 |
-
function displayItemsList(items) {
|
| 921 |
-
const chatMessages = document.getElementById('chatMessages');
|
| 922 |
-
if (!chatMessages) {
|
| 923 |
-
console.error('Chat messages container not found!');
|
| 924 |
-
addMessage('bot', 'Display issue. Try again?');
|
| 925 |
-
showToast('Display issue!');
|
| 926 |
-
return;
|
| 927 |
-
}
|
| 928 |
-
|
| 929 |
-
const itemsGrid = document.createElement('div');
|
| 930 |
-
itemsGrid.className = 'items-grid';
|
| 931 |
-
|
| 932 |
-
items.forEach(item => {
|
| 933 |
-
const itemDiv = document.createElement('div');
|
| 934 |
-
itemDiv.className = 'item-card';
|
| 935 |
-
|
| 936 |
-
const img = document.createElement('img');
|
| 937 |
-
img.src = item.image_url || 'https://via.placeholder.com/120';
|
| 938 |
-
img.alt = item.name;
|
| 939 |
-
img.className = 'item-image';
|
| 940 |
-
itemDiv.appendChild(img);
|
| 941 |
-
|
| 942 |
-
const contentDiv = document.createElement('div');
|
| 943 |
-
contentDiv.className = 'item-content';
|
| 944 |
-
|
| 945 |
-
const nameDiv = document.createElement('div');
|
| 946 |
-
nameDiv.textContent = item.name;
|
| 947 |
-
nameDiv.className = 'item-name';
|
| 948 |
-
contentDiv.appendChild(nameDiv);
|
| 949 |
-
|
| 950 |
-
const fields = [
|
| 951 |
-
{ label: 'Price', value: item.price ? `$${item.price.toFixed(2)}` : 'N/A' },
|
| 952 |
-
{ label: 'Veg/Non-Veg', value: item.veg_nonveg },
|
| 953 |
-
{ label: 'Spice', value: item.spice_levels },
|
| 954 |
-
{ label: 'Category', value: item.category },
|
| 955 |
-
{ label: 'Ingredients', value: item.ingredients },
|
| 956 |
-
{ label: 'Nutrition', value: item.nutritional_info },
|
| 957 |
-
{ label: 'Sector', value: item.sector },
|
| 958 |
-
{ label: 'Dynamic', value: item.dynamic_dish ? 'Yes' : 'No' }
|
| 959 |
-
];
|
| 960 |
-
fields.forEach(field => {
|
| 961 |
-
if (field.value) {
|
| 962 |
-
const p = document.createElement('p');
|
| 963 |
-
p.className = 'item-field';
|
| 964 |
-
p.innerHTML = `<strong>${field.label}:</strong> ${field.value}`;
|
| 965 |
-
contentDiv.appendChild(p);
|
| 966 |
-
}
|
| 967 |
-
});
|
| 968 |
-
|
| 969 |
-
itemDiv.appendChild(contentDiv);
|
| 970 |
-
|
| 971 |
-
const buttonContainer = document.createElement('div');
|
| 972 |
-
buttonContainer.className = 'button-container';
|
| 973 |
-
|
| 974 |
-
const addButton = document.createElement('button');
|
| 975 |
-
addButton.textContent = 'Add';
|
| 976 |
-
addButton.className = 'add-button';
|
| 977 |
-
addButton.onclick = () => {
|
| 978 |
-
const selectedItem = {
|
| 979 |
-
name: item.name,
|
| 980 |
-
image_url: item.image_url || '',
|
| 981 |
-
category: item.category || 'Not specified',
|
| 982 |
-
description: item.description || 'No description available',
|
| 983 |
-
source: item.source,
|
| 984 |
-
quantity: 1,
|
| 985 |
-
ingredients: item.ingredients,
|
| 986 |
-
nutritional_info: item.nutritional_info,
|
| 987 |
-
price: item.price,
|
| 988 |
-
sector: item.sector,
|
| 989 |
-
spice_levels: item.spice_levels,
|
| 990 |
-
veg_nonveg: item.veg_nonveg,
|
| 991 |
-
dynamic_dish: item.dynamic_dish
|
| 992 |
-
};
|
| 993 |
-
if (selectedItems.some(existing => existing.name === selectedItem.name)) {
|
| 994 |
-
addMessage('bot', `"${selectedItem.name}" already selected!`);
|
| 995 |
-
showToast(`"${selectedItem.name}" already selected`);
|
| 996 |
-
} else {
|
| 997 |
-
selectedItems.push(selectedItem);
|
| 998 |
-
addMessage('bot', `Added "${selectedItem.name}"!`);
|
| 999 |
-
showToast(`Added "${selectedItem.name}"`);
|
| 1000 |
-
updateSelectionBox();
|
| 1001 |
-
}
|
| 1002 |
-
};
|
| 1003 |
-
buttonContainer.appendChild(addButton);
|
| 1004 |
-
|
| 1005 |
-
itemDiv.appendChild(buttonContainer);
|
| 1006 |
-
itemsGrid.appendChild(itemDiv);
|
| 1007 |
-
});
|
| 1008 |
-
|
| 1009 |
-
chatMessages.appendChild(itemsGrid);
|
| 1010 |
-
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 1011 |
-
}
|
| 1012 |
-
|
| 1013 |
-
function displayOptions(options) {
|
| 1014 |
-
const chatMessages = document.getElementById('chatMessages');
|
| 1015 |
-
if (!chatMessages) {
|
| 1016 |
-
console.error('Chat messages container not found!');
|
| 1017 |
-
return;
|
| 1018 |
-
}
|
| 1019 |
-
const optionsDiv = document.createElement('div');
|
| 1020 |
-
optionsDiv.className = 'options-container';
|
| 1021 |
-
|
| 1022 |
-
options.forEach(opt => {
|
| 1023 |
-
const button = document.createElement('button');
|
| 1024 |
-
button.textContent = opt.text;
|
| 1025 |
-
button.className = `option-button ${opt.class}`;
|
| 1026 |
-
button.onclick = () => {
|
| 1027 |
-
addMessage('user', opt.text);
|
| 1028 |
-
conversation.push({ role: 'user', message: opt.text });
|
| 1029 |
-
selectionBoxVisible = true;
|
| 1030 |
-
handleResponse(opt.text);
|
| 1031 |
-
updateSelectionBox();
|
| 1032 |
-
showToast(`Selected ${opt.text}`);
|
| 1033 |
-
};
|
| 1034 |
-
optionsDiv.appendChild(button);
|
| 1035 |
-
});
|
| 1036 |
-
|
| 1037 |
-
const backButton = document.createElement('button');
|
| 1038 |
-
backButton.textContent = 'Back';
|
| 1039 |
-
backButton.className = 'option-button';
|
| 1040 |
-
backButton.onclick = () => resetConversation();
|
| 1041 |
-
optionsDiv.appendChild(backButton);
|
| 1042 |
-
|
| 1043 |
-
chatMessages.appendChild(optionsDiv);
|
| 1044 |
-
}
|
| 1045 |
-
|
| 1046 |
-
function promptAndSubmit(quantity) {
|
| 1047 |
-
const orderNameInput = document.querySelector('.order-name-input');
|
| 1048 |
-
const customOrderName = orderNameInput ? orderNameInput.value.trim() : '';
|
| 1049 |
-
if (confirm(`Submit ${selectedItems.length} items (Qty: ${quantity})?`)) {
|
| 1050 |
-
submitToSalesforce(customOrderName, quantity);
|
| 1051 |
-
showToast('Submitting order...');
|
| 1052 |
-
} else {
|
| 1053 |
-
addMessage('bot', 'Cancelled. Add more items?');
|
| 1054 |
-
showToast('Order cancelled');
|
| 1055 |
-
}
|
| 1056 |
-
}
|
| 1057 |
-
|
| 1058 |
-
function submitToSalesforce(customOrderName, quantity) {
|
| 1059 |
-
if (selectedItems.length === 0) {
|
| 1060 |
-
addMessage('bot', 'No items selected! Add some dishes! 😊');
|
| 1061 |
-
showToast('No items selected');
|
| 1062 |
-
return;
|
| 1063 |
-
}
|
| 1064 |
-
|
| 1065 |
-
const itemsToSubmit = selectedItems.map(item => ({
|
| 1066 |
-
name: item.name,
|
| 1067 |
-
category: item.category || 'Not specified',
|
| 1068 |
-
description: item.description || 'No description available',
|
| 1069 |
-
image_url: item.image_url || '',
|
| 1070 |
-
quantity: parseInt(quantity) || 1
|
| 1071 |
-
}));
|
| 1072 |
-
|
| 1073 |
-
fetch('/submit_items', {
|
| 1074 |
-
method: 'POST',
|
| 1075 |
-
headers: { 'Content-Type': 'application/json' },
|
| 1076 |
-
body: JSON.stringify({ items: itemsToSubmit, custom_order_name: customOrderName })
|
| 1077 |
-
})
|
| 1078 |
-
.then(response => response.json())
|
| 1079 |
-
.then(data => {
|
| 1080 |
-
if (data.error) {
|
| 1081 |
-
addMessage('bot', `Submission failed: ${data.error}. Try again?`);
|
| 1082 |
-
showToast(`Submission failed: ${data.error}`);
|
| 1083 |
-
} else {
|
| 1084 |
-
addMessage('bot', `Submitted ${data.ingredient_name}! What's next?`);
|
| 1085 |
-
selectedItems = [];
|
| 1086 |
-
updateSelectionBox();
|
| 1087 |
-
showToast('Order submitted!');
|
| 1088 |
-
}
|
| 1089 |
-
})
|
| 1090 |
-
.catch(error => {
|
| 1091 |
-
addMessage('bot', `Submission error: ${error.message}. Retrying...`);
|
| 1092 |
-
showToast('Submission error!');
|
| 1093 |
-
setTimeout(() => submitToSalesforce(customOrderName, quantity), 2000);
|
| 1094 |
-
});
|
| 1095 |
-
}
|
| 1096 |
-
|
| 1097 |
-
function resetConversation() {
|
| 1098 |
-
const userName = conversation.length > 1 ? conversation[1].message : 'Friend';
|
| 1099 |
-
conversation = [
|
| 1100 |
-
{ role: 'bot', message: `Hello! I’m Chef Bot, your culinary assistant! What’s your name?` },
|
| 1101 |
-
{ role: 'user', message: userName },
|
| 1102 |
-
{ role: 'bot', message: `Hi ${userName}! 🍳 Search for a dish or choose a preference below!` }
|
| 1103 |
-
];
|
| 1104 |
-
selectedItems = [];
|
| 1105 |
-
selectionBoxVisible = true;
|
| 1106 |
-
const chatMessages = document.getElementById('chatMessages');
|
| 1107 |
-
chatMessages.innerHTML = '';
|
| 1108 |
-
conversation.forEach(msg => addMessage(msg.role, msg.message));
|
| 1109 |
-
displayOptions([
|
| 1110 |
-
{ text: 'Vegetarian', class: 'green' },
|
| 1111 |
-
{ text: 'Non-Vegetarian', class: 'red' },
|
| 1112 |
-
{ text: 'Both', class: 'gray' }
|
| 1113 |
-
]);
|
| 1114 |
-
updateSelectionBox();
|
| 1115 |
-
showToast('Conversation reset');
|
| 1116 |
-
}
|
| 1117 |
-
|
| 1118 |
-
document.getElementById('userInput').addEventListener('keypress', (e) => {
|
| 1119 |
-
if (e.key === 'Enter') sendMessage();
|
| 1120 |
-
});
|
| 1121 |
-
|
| 1122 |
-
console.log('Chef Bot script loaded!');
|
| 1123 |
-
</script>
|
| 1124 |
</body>
|
| 1125 |
</html>
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Chef Bot</title>
|
| 7 |
+
<link rel="stylesheet" href="styles.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
</head>
|
| 9 |
<body>
|
| 10 |
<div class="chat-container">
|
|
|
|
| 19 |
<button onclick="sendMessage()" aria-label="Send message">Send</button>
|
| 20 |
</div>
|
| 21 |
</div>
|
| 22 |
+
<script src="script.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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