|
|
@@ -3,6 +3,7 @@
|
|
|
import { goto } from '$app/navigation';
|
|
|
import { page } from '$app/stores';
|
|
|
import { browser } from '$app/environment';
|
|
|
+ import save_icon from '$lib/assets/save_icon.svg';
|
|
|
|
|
|
import trash_icon from '$lib/assets/trash_white.svg';
|
|
|
import arrow_back from '$lib/assets/arrow_back.svg';
|
|
|
@@ -13,6 +14,9 @@
|
|
|
let company = null;
|
|
|
let orderId = null;
|
|
|
let tableIdNum = null;
|
|
|
+ let kitchenNote = '';
|
|
|
+ let showKitchenNoteModal = false;
|
|
|
+ let selectedProduct = [];
|
|
|
|
|
|
if (browser) {
|
|
|
token = localStorage.getItem('token');
|
|
|
@@ -88,12 +92,31 @@
|
|
|
: products;
|
|
|
|
|
|
function handleAddItem(product) {
|
|
|
+ if (product.product_is_kitchen) {
|
|
|
+ selectedProduct = product;
|
|
|
+ showKitchenNoteModal = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ addItemToOrder(product, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ function confirmKitchenNote() {
|
|
|
+ addItemToOrder(selectedProduct, kitchenNote);
|
|
|
+ showKitchenNoteModal = false;
|
|
|
+ kitchenNote = '';
|
|
|
+ selectedProduct = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ function addItemToOrder(product, note) {
|
|
|
const newItem = {
|
|
|
- order_item_id: Date.now(), // Temporary ID for local use
|
|
|
+ order_item_id: Date.now(),
|
|
|
product_details: product,
|
|
|
- quantity: 1
|
|
|
+ quantity: 1,
|
|
|
+ kitchen_note: note
|
|
|
};
|
|
|
- localOrderItems = [...localOrderItems, newItem]; // Update localOrderItems
|
|
|
+
|
|
|
+ localOrderItems = [...localOrderItems, newItem];
|
|
|
}
|
|
|
|
|
|
function removeItemFromOrder(itemId) {
|
|
|
@@ -252,4 +275,36 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ {#if showKitchenNoteModal}
|
|
|
+ <div class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
|
|
|
+ <div class="w-full max-w-md rounded-lg bg-gray-800 p-6 shadow-lg">
|
|
|
+ <h2 class="mb-4 text-lg font-semibold">Anotações para o produto</h2>
|
|
|
+ <form on:submit={confirmKitchenNote} class="space-y-4">
|
|
|
+ <div>
|
|
|
+ <p class="mb-1 block text-sm text-gray-400">Anotações</p>
|
|
|
+ <input
|
|
|
+ bind:value={kitchenNote}
|
|
|
+ placeholder="Detalhes do pedido"
|
|
|
+ class="w-full rounded-md border border-gray-600 bg-gray-700 px-3 py-2 focus:ring-emerald-500"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="flex space-x-2">
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ on:click={() => ((showKitchenNoteModal = false), (kitchenNote = ''))}
|
|
|
+ class="rounded-lg bg-gray-700 px-4 py-2 hover:bg-gray-600"
|
|
|
+ >
|
|
|
+ Cancelar
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ type="submit"
|
|
|
+ class="flex items-center rounded-lg bg-emerald-600 px-4 py-2 hover:bg-emerald-700"
|
|
|
+ >
|
|
|
+ <img src={save_icon} alt="Salvar" class="mr-2 h-4 w-4" /> Salvar
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ {/if}
|
|
|
</div>
|