lokesh341 commited on
Commit
51e9210
·
verified ·
1 Parent(s): ff499d1

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +548 -5
templates/index.html CHANGED
@@ -4,7 +4,331 @@
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="/static/styles.css">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </head>
9
  <body>
10
  <div class="chat-container">
@@ -12,13 +336,232 @@
12
  <div class="chat-messages" id="chatMessages">
13
  <div class="bot-message">Hello! I’m Chef Bot, your culinary assistant! What’s your name?</div>
14
  </div>
15
- <div class="suggestions-list" id="suggestionsList"></div>
16
- <div class="ingredients-list" id="menuItemsList"></div>
17
  <div class="chat-input">
18
- <input type="text" id="userInput" placeholder="Type here (e.g., paneer, chicken)...">
19
  <button onclick="sendMessage()">Send</button>
20
  </div>
21
  </div>
22
- <script src="/static/script.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  </body>
24
  </html>
 
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
+ body {
9
+ font-family: 'Segoe UI', Arial, sans-serif;
10
+ margin: 0;
11
+ padding: 0;
12
+ background-color: #f4f6f8;
13
+ overflow-x: hidden;
14
+ }
15
+
16
+ .chat-container {
17
+ width: 100%;
18
+ max-width: 800px;
19
+ height: 100vh;
20
+ margin: 0 auto;
21
+ border: 1px solid #ddd;
22
+ border-radius: 10px;
23
+ background-color: #fff;
24
+ display: flex;
25
+ flex-direction: column;
26
+ box-sizing: border-box;
27
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
28
+ }
29
+
30
+ .chat-header {
31
+ background-color: #0288d1;
32
+ color: white;
33
+ padding: 12px;
34
+ text-align: center;
35
+ font-size: 20px;
36
+ font-weight: bold;
37
+ flex-shrink: 0;
38
+ border-radius: 10px 10px 0 0;
39
+ }
40
+
41
+ .chat-messages {
42
+ flex: 1;
43
+ overflow-y: auto;
44
+ padding: 10px;
45
+ box-sizing: border-box;
46
+ scroll-behavior: smooth;
47
+ }
48
+
49
+ .bot-message, .user-message {
50
+ padding: 10px;
51
+ margin: 8px 0;
52
+ border-radius: 8px;
53
+ max-width: 80%;
54
+ word-wrap: break-word;
55
+ font-size: 14px;
56
+ line-height: 1.4;
57
+ }
58
+
59
+ .bot-message {
60
+ background-color: #e3f2fd;
61
+ margin-right: 10%;
62
+ }
63
+
64
+ .user-message {
65
+ background-color: #ffebee;
66
+ margin-left: auto;
67
+ text-align: right;
68
+ }
69
+
70
+ .chat-input {
71
+ display: flex;
72
+ padding: 10px;
73
+ border-top: 1px solid #ddd;
74
+ flex-shrink: 0;
75
+ background-color: #fff;
76
+ box-sizing: border-box;
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
+ min-height: 40px;
86
+ box-sizing: border-box;
87
+ }
88
+
89
+ .chat-input button {
90
+ padding: 10px 16px;
91
+ margin-left: 10px;
92
+ background-color: #ff8f00;
93
+ color: white;
94
+ border: none;
95
+ border-radius: 8px;
96
+ cursor: pointer;
97
+ font-size: 14px;
98
+ min-height: 40px;
99
+ min-width: 80px;
100
+ }
101
+
102
+ .chat-input button:hover {
103
+ background-color: #f57c00;
104
+ }
105
+
106
+ .items-grid {
107
+ display: grid;
108
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
109
+ gap: 12px;
110
+ padding: 10px;
111
+ margin: 10px 0;
112
+ background-color: #f9f9f9;
113
+ border-radius: 8px;
114
+ }
115
+
116
+ .item-card {
117
+ background-color: white;
118
+ border: 1px solid #ddd;
119
+ border-radius: 8px;
120
+ padding: 10px;
121
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
122
+ transition: transform 0.2s;
123
+ }
124
+
125
+ .item-card:hover {
126
+ transform: translateY(-3px);
127
+ }
128
+
129
+ .item-image {
130
+ width: 100%;
131
+ height: 120px;
132
+ object-fit: cover;
133
+ border-radius: 6px;
134
+ margin-bottom: 8px;
135
+ }
136
+
137
+ .item-name {
138
+ font-size: 16px;
139
+ font-weight: bold;
140
+ color: #333;
141
+ margin-bottom: 6px;
142
+ }
143
+
144
+ .item-field {
145
+ font-size: 12px;
146
+ margin: 4px 0;
147
+ color: #555;
148
+ }
149
+
150
+ .item-field strong {
151
+ color: #0288d1;
152
+ }
153
+
154
+ .add-button {
155
+ width: 100%;
156
+ padding: 8px;
157
+ background-color: #4caf50;
158
+ color: white;
159
+ border: none;
160
+ border-radius: 6px;
161
+ cursor: pointer;
162
+ font-size: 14px;
163
+ margin-top: 8px;
164
+ }
165
+
166
+ .add-button:hover {
167
+ background-color: #45a049;
168
+ }
169
+
170
+ .selection-box {
171
+ background-color: #e1f5fe;
172
+ padding: 10px;
173
+ border: 1px solid #0288d1;
174
+ border-radius: 8px;
175
+ margin: 10px 0;
176
+ font-size: 14px;
177
+ display: flex;
178
+ flex-wrap: wrap;
179
+ gap: 8px;
180
+ align-items: center;
181
+ }
182
+
183
+ .selected-item {
184
+ display: flex;
185
+ align-items: center;
186
+ background-color: #bbdefb;
187
+ padding: 6px 10px;
188
+ border-radius: 6px;
189
+ font-size: 13px;
190
+ }
191
+
192
+ .selected-item-image {
193
+ width: 30px;
194
+ height: 30px;
195
+ object-fit: cover;
196
+ border-radius: 6px;
197
+ margin-right: 8px;
198
+ }
199
+
200
+ .remove-button {
201
+ padding: 4px 8px;
202
+ margin-left: 8px;
203
+ background-color: #d32f2f;
204
+ color: white;
205
+ border: none;
206
+ border-radius: 6px;
207
+ cursor: pointer;
208
+ font-size: 12px;
209
+ }
210
+
211
+ .remove-button:hover {
212
+ background-color: #b71c1c;
213
+ }
214
+
215
+ .submit-button {
216
+ padding: 10px 16px;
217
+ background-color: #0288d1;
218
+ color: white;
219
+ border: none;
220
+ border-radius: 8px;
221
+ cursor: pointer;
222
+ font-size: 14px;
223
+ min-width: 80px;
224
+ }
225
+
226
+ .submit-button:hover {
227
+ background-color: #0277bd;
228
+ }
229
+
230
+ .manual-input, .order-name-input {
231
+ padding: 8px;
232
+ border: 1px solid #0288d1;
233
+ border-radius: 6px;
234
+ font-size: 14px;
235
+ width: 120px;
236
+ }
237
+
238
+ .quantity-input {
239
+ padding: 8px;
240
+ border: 1px solid #0288d1;
241
+ border-radius: 6px;
242
+ font-size: 14px;
243
+ width: 60px;
244
+ }
245
+
246
+ @media (max-width: 480px) {
247
+ .chat-container {
248
+ border-radius: 0;
249
+ box-shadow: none;
250
+ }
251
+
252
+ .chat-header {
253
+ font-size: 16px;
254
+ padding: 10px;
255
+ }
256
+
257
+ .chat-messages {
258
+ padding: 8px;
259
+ }
260
+
261
+ .bot-message, .user-message {
262
+ font-size: 12px;
263
+ padding: 8px;
264
+ margin: 6px 0;
265
+ }
266
+
267
+ .chat-input input {
268
+ font-size: 12px;
269
+ min-height: 36px;
270
+ }
271
+
272
+ .chat-input button {
273
+ font-size: 12px;
274
+ min-height: 36px;
275
+ padding: 8px 12px;
276
+ min-width: 70px;
277
+ }
278
+
279
+ .items-grid {
280
+ grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
281
+ gap: 10px;
282
+ }
283
+
284
+ .item-image {
285
+ height: 100px;
286
+ }
287
+
288
+ .item-name {
289
+ font-size: 14px;
290
+ }
291
+
292
+ .item-field {
293
+ font-size: 11px;
294
+ }
295
+
296
+ .add-button {
297
+ font-size: 12px;
298
+ padding: 6px;
299
+ }
300
+
301
+ .selection-box {
302
+ padding: 8px;
303
+ gap: 6px;
304
+ }
305
+
306
+ .selected-item {
307
+ font-size: 12px;
308
+ padding: 4px 8px;
309
+ }
310
+
311
+ .selected-item-image {
312
+ width: 25px;
313
+ height: 25px;
314
+ }
315
+
316
+ .remove-button {
317
+ font-size: 10px;
318
+ padding: 3px 6px;
319
+ }
320
+
321
+ .manual-input, .order-name-input {
322
+ width: 100px;
323
+ font-size: 12px;
324
+ }
325
+
326
+ .quantity-input {
327
+ width: 50px;
328
+ font-size: 12px;
329
+ }
330
+ }
331
+ </style>
332
  </head>
333
  <body>
334
  <div class="chat-container">
 
336
  <div class="chat-messages" id="chatMessages">
337
  <div class="bot-message">Hello! I’m Chef Bot, your culinary assistant! What’s your name?</div>
338
  </div>
 
 
339
  <div class="chat-input">
340
+ <input type="text" id="userInput" placeholder="Type here (e.g., chicken, paneer)...">
341
  <button onclick="sendMessage()">Send</button>
342
  </div>
343
  </div>
344
+ <script>
345
+ let conversation = [
346
+ { role: 'bot', message: 'Hello! I’m Chef Bot, your culinary assistant! What’s your name?' }
347
+ ];
348
+ let selectedItems = [];
349
+
350
+ function addMessage(role, message) {
351
+ const chatMessages = document.getElementById('chatMessages');
352
+ const messageDiv = document.createElement('div');
353
+ messageDiv.className = role === 'bot' ? 'bot-message' : 'user-message';
354
+ messageDiv.textContent = message;
355
+ chatMessages.appendChild(messageDiv);
356
+ chatMessages.scrollTop = chatMessages.scrollHeight;
357
+ }
358
+
359
+ function sendMessage() {
360
+ const userInput = document.getElementById('userInput');
361
+ const message = userInput.value.trim();
362
+ if (message) {
363
+ addMessage('user', message);
364
+ conversation.push({ role: 'user', message });
365
+ handleResponse(message);
366
+ } else {
367
+ addMessage('bot', 'Please type a dish or ingredient! 😄');
368
+ }
369
+ userInput.value = '';
370
+ updateSelectionBox();
371
+ }
372
+
373
+ function handleResponse(userInput) {
374
+ const lowerInput = userInput.toLowerCase();
375
+ let botResponse = '';
376
+
377
+ if (conversation.length === 2) {
378
+ botResponse = `Hi ${userInput}! 🍳 Search for a dish or ingredient (e.g., chicken)!`;
379
+ addMessage('bot', botResponse);
380
+ } else {
381
+ botResponse = `Looking for "${userInput}" dishes...`;
382
+ addMessage('bot', botResponse);
383
+ fetchMenuItems(null, userInput);
384
+ }
385
+ }
386
+
387
+ function fetchMenuItems(dietaryPreference = '', searchTerm = '') {
388
+ // Mock API response for chicken
389
+ const mockData = {
390
+ menu_items: [
391
+ {
392
+ name: 'Chicken Curry',
393
+ image_url: 'https://example.com/chicken_curry.jpg',
394
+ category: 'Main Course',
395
+ description: 'Spicy chicken curry with rich flavors.',
396
+ source: 'Menu',
397
+ price: 12.99,
398
+ veg_nonveg: 'Non-Vegetarian',
399
+ spice_levels: 'Medium',
400
+ ingredients: 'Chicken, spices, tomatoes',
401
+ nutritional_info: '500 kcal',
402
+ sector: 'Indian'
403
+ },
404
+ {
405
+ name: 'Grilled Chicken',
406
+ image_url: 'https://example.com/grilled_chicken.jpg',
407
+ category: 'Main Course',
408
+ description: 'Juicy grilled chicken breast.',
409
+ source: 'Menu',
410
+ price: 10.99,
411
+ veg_nonveg: 'Non-Vegetarian',
412
+ spice_levels: 'Low',
413
+ ingredients: 'Chicken, herbs',
414
+ nutritional_info: '400 kcal',
415
+ sector: 'Western'
416
+ }
417
+ ]
418
+ };
419
+
420
+ const data = mockData;
421
+ if (data.menu_items.length > 0) {
422
+ addMessage('bot', `--- Found ${data.menu_items.length} item${data.menu_items.length > 1 ? 's' : ''} ---`);
423
+ displayItemsList(data.menu_items);
424
+ if (searchTerm.toLowerCase() === 'chicken') {
425
+ fetchSectorItemDetails(searchTerm);
426
+ }
427
+ } else {
428
+ addMessage('bot', `No matches for "${searchTerm}". Try "chicken"!`);
429
+ }
430
+ }
431
+
432
+ function fetchSectorItemDetails(itemName) {
433
+ // Mock sector item details for chicken
434
+ const mockSectorData = {
435
+ item_details: {
436
+ name: 'Chicken Masala Powder',
437
+ image_url: 'https://example.com/masala.jpg',
438
+ category: 'Spice',
439
+ description: 'Perfect spice mix for chicken dishes.',
440
+ source: 'Sector_Detail__c',
441
+ quantity: 1
442
+ }
443
+ };
444
+
445
+ const details = mockSectorData.item_details;
446
+ if (!selectedItems.some(item => item.name === details.name)) {
447
+ selectedItems.push({ ...details, quantity: 1 });
448
+ addMessage('bot', `Added complementary "${details.name}"!`);
449
+ updateSelectionBox();
450
+ }
451
+ }
452
+
453
+ function displayItemsList(items) {
454
+ const chatMessages = document.getElementById('chatMessages');
455
+ const itemsGrid = document.createElement('div');
456
+ itemsGrid.className = 'items-grid';
457
+
458
+ items.forEach(item => {
459
+ const itemDiv = document.createElement('div');
460
+ itemDiv.className = 'item-card';
461
+
462
+ const img = document.createElement('img');
463
+ img.src = item.image_url || 'https://via.placeholder.com/120';
464
+ img.alt = item.name;
465
+ img.className = 'item-image';
466
+ itemDiv.appendChild(img);
467
+
468
+ const nameDiv = document.createElement('div');
469
+ nameDiv.textContent = item.name;
470
+ nameDiv.className = 'item-name';
471
+ itemDiv.appendChild(nameDiv);
472
+
473
+ const fields = [
474
+ { label: 'Price', value: item.price ? `$${item.price.toFixed(2)}` : 'N/A' },
475
+ { label: 'Category', value: item.category },
476
+ { label: 'Spice', value: item.spice_levels },
477
+ { label: 'Ingredients', value: item.ingredients }
478
+ ];
479
+ fields.forEach(field => {
480
+ if (field.value) {
481
+ const p = document.createElement('p');
482
+ p.className = 'item-field';
483
+ p.innerHTML = `<strong>${field.label}:</strong> ${field.value}`;
484
+ itemDiv.appendChild(p);
485
+ }
486
+ });
487
+
488
+ const addButton = document.createElement('button');
489
+ addButton.textContent = 'Add';
490
+ addButton.className = 'add-button';
491
+ addButton.onclick = () => {
492
+ if (!selectedItems.some(existing => existing.name === item.name)) {
493
+ selectedItems.push({ ...item, quantity: 1 });
494
+ addMessage('bot', `Added "${item.name}"!`);
495
+ updateSelectionBox();
496
+ } else {
497
+ addMessage('bot', `"${item.name}" already selected!`);
498
+ }
499
+ };
500
+ itemDiv.appendChild(addButton);
501
+
502
+ itemsGrid.appendChild(itemDiv);
503
+ });
504
+
505
+ chatMessages.appendChild(itemsGrid);
506
+ chatMessages.scrollTop = chatMessages.scrollHeight;
507
+ }
508
+
509
+ function updateSelectionBox() {
510
+ const chatMessages = document.getElementById('chatMessages');
511
+ const existingBox = document.querySelector('.selection-box');
512
+ if (existingBox) existingBox.remove();
513
+
514
+ if (selectedItems.length === 0) return;
515
+
516
+ const selectionBox = document.createElement('div');
517
+ selectionBox.className = 'selection-box';
518
+
519
+ selectedItems.forEach((item, index) => {
520
+ const itemContainer = document.createElement('div');
521
+ itemContainer.className = 'selected-item';
522
+
523
+ const img = document.createElement('img');
524
+ img.src = item.image_url || 'https://via.placeholder.com/30';
525
+ img.alt = item.name;
526
+ img.className = 'selected-item-image';
527
+ itemContainer.appendChild(img);
528
+
529
+ const itemSpan = document.createElement('span');
530
+ itemSpan.textContent = `${item.name} (Qty: ${item.quantity})`;
531
+ itemContainer.appendChild(itemSpan);
532
+
533
+ const removeButton = document.createElement('button');
534
+ removeButton.textContent = 'X';
535
+ removeButton.className = 'remove-button';
536
+ removeButton.onclick = () => {
537
+ selectedItems.splice(index, 1);
538
+ addMessage('bot', `Removed "${item.name}".`);
539
+ updateSelectionBox();
540
+ };
541
+ itemContainer.appendChild(removeButton);
542
+
543
+ selectionBox.appendChild(itemContainer);
544
+ });
545
+
546
+ const submitButton = document.createElement('button');
547
+ submitButton.textContent = 'Submit Order';
548
+ submitButton.className = 'submit-button';
549
+ submitButton.onclick = () => {
550
+ if (selectedItems.length > 0) {
551
+ addMessage('bot', `Order submitted with ${selectedItems.length} items!`);
552
+ selectedItems = [];
553
+ updateSelectionBox();
554
+ }
555
+ };
556
+ selectionBox.appendChild(submitButton);
557
+
558
+ chatMessages.appendChild(selectionBox);
559
+ chatMessages.scrollTop = chatMessages.scrollHeight;
560
+ }
561
+
562
+ document.getElementById('userInput').addEventListener('keypress', (e) => {
563
+ if (e.key === 'Enter') sendMessage();
564
+ });
565
+ </script>
566
  </body>
567
  </html>