File size: 21,522 Bytes
cfd7e45
6cca62e
cfd7e45
6cca62e
 
cfd7e45
6cca62e
 
5808600
89e45dd
 
50dcf8a
 
89e45dd
 
50dcf8a
89e45dd
 
 
50dcf8a
 
 
 
 
 
 
 
 
 
 
 
 
 
89e45dd
50dcf8a
 
 
 
89e45dd
50dcf8a
 
 
 
89e45dd
50dcf8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89e45dd
50dcf8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89e45dd
50dcf8a
 
 
 
 
 
89e45dd
50dcf8a
89e45dd
50dcf8a
89e45dd
 
50dcf8a
89e45dd
50dcf8a
89e45dd
50dcf8a
 
 
89e45dd
50dcf8a
89e45dd
 
50dcf8a
89e45dd
50dcf8a
89e45dd
50dcf8a
 
 
 
 
 
89e45dd
50dcf8a
89e45dd
50dcf8a
 
89e45dd
50dcf8a
89e45dd
 
 
 
 
 
50dcf8a
89e45dd
50dcf8a
89e45dd
50dcf8a
 
89e45dd
50dcf8a
89e45dd
50dcf8a
 
89e45dd
50dcf8a
89e45dd
50dcf8a
89e45dd
50dcf8a
 
 
 
 
89e45dd
50dcf8a
 
 
 
 
 
 
 
 
 
89e45dd
50dcf8a
 
 
89e45dd
50dcf8a
 
 
89e45dd
50dcf8a
 
 
 
 
 
89e45dd
 
50dcf8a
 
 
 
 
 
89e45dd
50dcf8a
 
 
 
 
 
 
 
89e45dd
 
50dcf8a
 
 
 
89e45dd
50dcf8a
89e45dd
50dcf8a
 
 
89e45dd
50dcf8a
 
 
 
 
 
 
 
 
89e45dd
50dcf8a
 
 
 
 
89e45dd
 
cfd7e45
 
50dcf8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53c7c69
50dcf8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53c7c69
50dcf8a
53c7c69
50dcf8a
 
53c7c69
50dcf8a
 
 
 
 
53c7c69
6cca62e
89e45dd
50dcf8a
89e45dd
 
50dcf8a
89e45dd
 
 
50dcf8a
 
 
 
 
 
 
 
89e45dd
50dcf8a
 
 
 
89e45dd
50dcf8a
89e45dd
 
50dcf8a
 
 
 
 
 
89e45dd
 
 
 
 
50dcf8a
36d46f9
50dcf8a
36d46f9
 
50dcf8a
36d46f9
 
50dcf8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
793139a
346957f
50dcf8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ac8a7d
89e45dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Menu</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #fdf4e3;
            margin: 0;
            padding: 0;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .fixed-top-bar {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 60px;
            background-color: #FF6B35;
            color: white;
            padding: 10px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            z-index: 1000;
        }

        .search-bar-container {
            position: relative;
            width: 300px;
        }

        .search-bar-container input {
            width: 100%;
            padding: 8px 8px 8px 35px;
            border-radius: 20px;
            border: none;
        }

        .search-icon {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 18px;
            color: #888;
        }

        .avatar-dropdown-container {
            position: relative;
        }

        .avatar-icon {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #5bbfc1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 20px;
            font-weight: bold;
        }

        .dropdown-menu {
            position: absolute;
            right: 0;
            top: 100%;
            background-color: #fff;
            border-radius: 5px;
            width: 200px;
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
            display: none;
        }

        .avatar-dropdown-container:hover .dropdown-menu {
            display: block;
        }

        .dropdown-menu .dropdown-item {
            padding: 10px 15px;
            text-decoration: none;
            color: #333;
            border-bottom: 1px solid #ddd;
            display: block;
        }

        .dropdown-menu .dropdown-item:last-child {
            border-bottom: none;
        }

        .dropdown-menu .dropdown-item:hover {
            background-color: #f1f1f1;
        }

        .container {
            max-width: 900px;
            margin-top: 80px; /* Space for fixed header */
            padding: 20px;
        }

        .menu-card {
            max-width: 350px;
            border-radius: 15px;
            background-color: #fff;
            margin: 0 auto 20px;
        }

        .menu-image {
            height: 200px;
            width: 100%;
            object-fit: cover;
            border-radius: 15px 15px 0 0;
        }

        .card-title {
            font-size: 1.2rem;
            font-weight: bold;
            margin: 10px 0;
        }

        .card-text {
            font-size: 1rem;
            color: #6c757d;
        }

        .btn-primary {
            background-color: #0FAA39;
            border-color: #0FAA39;
            font-size: 13px;
            font-weight: bold;
            border-radius: 5px;
            width: 100px;
        }

        .btn-primary:hover {
            background-color: #109835;
            border-color: #109835;
        }

        .view-cart-container {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 999;
        }

        .view-cart-button {
            background-color: #0FAA39;
            color: #fff;
            padding: 10px 20px;
            border-radius: 30px;
            font-size: 1rem;
            font-weight: bold;
            text-decoration: none;
            box-shadow: 0px

        .view-cart-button:hover {
            background-color: #109835;
            text-decoration: none;
            color: #fff;
        }

        .form-check {
            display: inline-flex;
            align-items: center;
            margin: 0 15px 10px 0;
        }

        .custom-radio {
            appearance: none;
            width: 20px;
            height: 20px;
            border: 3px solid #4CAF50;
            border-radius: 50%;
            margin-right: 8px;
            cursor: pointer;
            position: relative;
        }

        .custom-radio:checked {
            background-color: #4CAF50;
        }

        .form-check-label {
            font-size: 16px;
        }

        .addon-section {
            background-color: #fff;
            border: 2px solid #6c757d;
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 10px;
        }

        .addon-section h6 {
            margin-bottom: 10px;
            font-size: 1.1rem;
            font-weight: bold;
            color: #343a40;
        }

        .addon-section .form-check-input {
            appearance: none;
            width: 20px;
            height: 20px;
            border: 2px solid #343a40;
            border-radius: 5px;
            background-color: #f0f0f0;
            margin-right: 10px;
        }

        .addon-section .form-check-input:checked {
            background-color: #006400;
            border-color: #006400;
        }

        .modal-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-footer .d-flex {
            gap: 10px;
        }

        .modal-footer .form-control {
            width: 50px;
            height: 40px;
            text-align: center;
        }

        .modal-footer .btn-primary {
            background-color: #0FAA39;
            border-color: #0FAA39;
            padding: 10px 20px;
        }
    </style>
</head>
<body>
    <div class="fixed-top-bar">
        <div class="search-bar-container">
            <input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." onkeyup="filterMenu()">
            <i class="bi bi-search search-icon"></i>
        </div>
        <div class="avatar-dropdown-container">
            <div class="avatar-icon">
                <span>{{ first_letter }}</span>
            </div>
            <div class="dropdown-menu">
                <a href="{{ url_for('customer_details') }}" class="dropdown-item">View Profile</a>
                <a href="{{ url_for('order_history') }}" class="dropdown-item">Order History</a>
                <a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
            </div>
        </div>
    </div>

    <div class="container">
        <form method="get" action="/menu" class="text-center mb-4">
            <label class="form-label fw-bold">Select a Category:</label>
            <div>
                {% for category in categories %}
                <div class="form-check form-check-inline">
                    <input type="radio" id="category-{{ category }}" name="category" value="{{ category }}" 
                        class="custom-radio" {% if selected_category == category %}checked{% endif %} 
                        onchange="this.form.submit()">
                    <label class="form-check-label" for="category-{{ category }}">{{ category }}</label>
                </div>
                {% endfor %}
                <div class="form-check form-check-inline">
                    <input type="radio" id="category-CustomizedDish" name="category" value="Customized Dish" 
                        class="custom-radio" {% if selected_category == "Customized Dish" %}checked{% endif %} 
                        onchange="this.form.submit()">
                    <label class="form-check-label" for="category-CustomizedDish">Customized Dish</label>
                </div>
            </div>
        </form>

        {% if selected_category == "Customized Dish" %}
        <div id="custom-dish-form" class="mt-4">
            <h3>Create Your Custom Dish</h3>
            <form method="POST" action="/generate_custom_dish">
                <div class="mb-3">
                    <label for="custom-dish-name" class="form-label">Dish Name</label>
                    <input type="text" class="form-control" id="custom-dish-name" name="name" required>
                </div>
                <div class="mb-3">
                    <label for="custom-dish-description" class="form-label">Dish Description</label>
                    <textarea class="form-control" id="custom-dish-description" name="description" required></textarea>
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
            </form>
        </div>
        {% else %}
        <h1 class="text-center mb-4">Menu</h1>
        {% for section, items in ordered_menu.items() %}
        <h3>{{ section }}</h3>
        <div class="row">
            {% for item in items %}
            <div class="col-md-6 mb-4">
                <div class="card menu-card">
                    <img src="{{ item.Image1__c }}" class="card-img-top menu-image" alt="{{ item.Name }}" 
                        onerror="this.src='/static/placeholder.jpg';">
                    <div class="card-body">
                        <h5 class="card-title">{{ item.Name }}</h5>
                        <p class="card-text">${{ item.Price__c }}</p>
                        <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModal"
                            onclick="showItemDetails('{{ item.Name }}', '{{ item.Price__c }}', '{{ item.Image2__c }}', 
                            '{{ item.Description__c }}', '{{ item.Section__c }}','{{ selected_category }}')">
                            Add
                        </button>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
        {% endfor %}
        {% endif %}
    </div>

    <div class="view-cart-container">
        <a href="/cart" class="view-cart-button">View Cart</a>
    </div>

    <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="itemModalLabel">Item Details</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" 
                        style="max-height: 200px; object-fit: cover;">
                    <h5 id="modal-name" class="fw-bold text-center"></h5>
                    <p id="modal-price" class="text-muted text-center"></p>
                    <p id="modal-description" class="text-secondary"></p>
                    <div id="modal-addons" class="mt-4">
                        <h6>Customization Options</h6>
                        <div id="addons-list" class="addons-container">Loading customization options...</div>
                    </div>
                    <div class="mt-4">
                        <h6>Custom Request</h6>
                        <textarea id="modal-instructions" class="form-control" 
                            placeholder="Enter any special instructions here..."></textarea>
                    </div>
                    <span id="modal-section" data-section="" data-category="" style="display: none;"></span>
                </div>
                <div class="modal-footer">
                    <div class="d-flex align-items-center">
                        <button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
                        <input type="text" class="form-control" id="quantityInput" value="1" readonly>
                        <button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
                    </div>
                    <button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // Your JavaScript remains the same
        function showItemDetails(name, price, image, description, section, selectedCategory) {
            document.getElementById('modal-name').innerText = name;
            document.getElementById('modal-price').innerText = `$${price}`;
            document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
            document.getElementById('modal-description').innerText = description || 'No description available.';
            document.getElementById('addons-list').innerHTML = 'Loading customization options...';
            document.getElementById('modal-instructions').value = '';
            document.getElementById('quantityInput').value = 1;

            const modalSectionEl = document.getElementById('modal-section');
            modalSectionEl.setAttribute('data-section', section);
            modalSectionEl.setAttribute('data-category', selectedCategory);

            fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
                .then(response => response.json())
                .then(data => {
                    const addonsList = document.getElementById('addons-list');
                    addonsList.innerHTML = '';
                    if (!data.success || !data.addons || data.addons.length === 0) {
                        addonsList.innerHTML = '<p>No customization options available.</p>';
                        return;
                    }
                    data.addons.forEach(addon => {
                        const sectionDiv = document.createElement('div');
                        sectionDiv.classList.add('addon-section');
                        const title = document.createElement('h6');
                        title.innerText = addon.name;
                        sectionDiv.appendChild(title);
                        const optionsContainer = document.createElement('div');
                        addon.options.forEach((option, index) => {
                            const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
                            const listItem = document.createElement('div');
                            listItem.classList.add('form-check');
                            listItem.innerHTML = `
                                <input type="checkbox" class="form-check-input addon-option" id="${optionId}" 
                                    value="${option}" data-name="${option}" data-group="${addon.name}" 
                                    data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
                                <label class="form-check-label" for="${optionId}">
                                    ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
                                </label>
                            `;
                            optionsContainer.appendChild(listItem);
                        });
                        sectionDiv.appendChild(optionsContainer);
                        addonsList.appendChild(sectionDiv);
                    });
                })
                .catch(err => {
                    console.error('Error fetching add-ons:', err);
                    document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
                });
        }

        document.addEventListener('click', function(event) {
            if (event.target.classList.contains('addon-option')) {
                handleAddonClick(event.target);
            }
        });

        function handleAddonClick(checkbox) {
            const groupName = checkbox.getAttribute('data-group');
            const isMultiSelectGroup = ["Extra Toppings", "Choose Raita/Sides", "Select Dip/Sauce", 
                "Extra Add-ons", "Make it a Combo"].includes(groupName);
            
            if (!isMultiSelectGroup) {
                const checkboxes = document.querySelectorAll(`.addon-option[data-group="${groupName}"]`);
                checkboxes.forEach(otherCheckbox => {
                    if (otherCheckbox !== checkbox) {
                        otherCheckbox.checked = false;
                    }
                });
            }
        }

        function filterMenu() {
            let input = document.getElementById('searchBar').value.toLowerCase();
            let sections = document.querySelectorAll('h3');
            let items = document.querySelectorAll('.menu-card');
            let matchedSections = new Set();
            
            items.forEach(item => {
                let itemName = item.querySelector('.card-title').innerText.toLowerCase();
                let itemSection = item.closest('.row').previousElementSibling.innerText.toLowerCase();
                
                if (itemName.includes(input) || (itemSection && itemSection.includes(input))) {
                    item.style.display = 'block';
                    matchedSections.add(item.closest('.row'));
                } else {
                    item.style.display = 'none';
                }
            });
            
            sections.forEach(section => {
                let sectionRow = section.nextElementSibling;
                if (matchedSections.has(sectionRow)) {
                    section.style.display = 'block';
                    sectionRow.style.display = 'flex';
                } else {
                    section.style.display = 'none';
                    sectionRow.style.display = 'none';
                }
            });
        }

        function addToCartFromModal() {
            const itemName = document.getElementById('modal-name').innerText;
            let itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
            const itemImage = document.getElementById('modal-img').src;
            const modalSectionEl = document.getElementById('modal-section');
            const section = modalSectionEl.getAttribute('data-section');
            const selectedCategory = modalSectionEl.getAttribute('data-category');
            const quantity = parseInt(document.getElementById('quantityInput').value) || 1;
            const instructions = document.getElementById('modal-instructions').value;

            if (isNaN(itemPrice)) {
                alert('Invalid price for the item.');
                return;
            }

            let selectedAddOns = Array.from(
                document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
            ).map(addon => ({
                name: addon.getAttribute('data-name'),
                price: parseFloat(addon.getAttribute('data-price') || 0)
            }));

            const cartPayload = {
                itemName,
                itemPrice,
                itemImage,
                section,
                category: selectedCategory,
                addons: selectedAddOns,
                instructions,
                quantity
            };

            fetch('/cart/add', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify(cartPayload)
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert('Item added to cart successfully!');
                    const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
                    modal.hide();
                } else {
                    alert(data.error || 'Failed to add item to cart.');
                }
            })
            .catch(err => {
                console.error('Error adding item to cart:', err);
                alert('An error occurred while adding the item to the cart.');
            });
        }

        document.addEventListener('DOMContentLoaded', function () {
            const decreaseBtn = document.getElementById('decreaseQuantity');
            const increaseBtn = document.getElementById('increaseQuantity');
            const quantityInput = document.getElementById('quantityInput');

            decreaseBtn.addEventListener('click', function () {
                let currentQuantity = parseInt(quantityInput.value);
                if (currentQuantity > 1) {
                    quantityInput.value = currentQuantity - 1;
                }
            });

            increaseBtn.addEventListener('click', function () {
                let currentQuantity = parseInt(quantityInput.value);
                quantityInput.value = currentQuantity + 1;
            });
        });
    </script>
</body>
</html>