|
@@ -24,6 +24,7 @@
|
|
|
|
|
|
|
|
let selectedCategory = null;
|
|
let selectedCategory = null;
|
|
|
let isPaymentModalOpen = false;
|
|
let isPaymentModalOpen = false;
|
|
|
|
|
+ let itemsOnKitchen = false;
|
|
|
|
|
|
|
|
let orderItems = [];
|
|
let orderItems = [];
|
|
|
let products = [];
|
|
let products = [];
|
|
@@ -144,21 +145,36 @@
|
|
|
console.warn('Selecione uma forma de pagamento');
|
|
console.warn('Selecione uma forma de pagamento');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const myHeaders = new Headers();
|
|
|
|
|
- myHeaders.append('Authorization', `Bearer ${token}`);
|
|
|
|
|
- myHeaders.append('Content-Type', 'application/json');
|
|
|
|
|
- await fetch('https://dev2.mixtech.dev.br/order/update', {
|
|
|
|
|
- method: 'POST',
|
|
|
|
|
- headers: myHeaders,
|
|
|
|
|
- body: JSON.stringify({
|
|
|
|
|
- company_id: company,
|
|
|
|
|
- order_id: orderId,
|
|
|
|
|
- order_flag: selectedPaymentMethod,
|
|
|
|
|
- status_status: 'Finalizada'
|
|
|
|
|
- })
|
|
|
|
|
- });
|
|
|
|
|
- isPaymentModalOpen = false;
|
|
|
|
|
- goto('/dashboard/tables');
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const myHeaders = new Headers();
|
|
|
|
|
+ myHeaders.append('Authorization', `Bearer ${token}`);
|
|
|
|
|
+ myHeaders.append('Content-Type', 'application/json');
|
|
|
|
|
+ const response = await fetch('https://dev2.mixtech.dev.br/order/update', {
|
|
|
|
|
+ method: 'POST',
|
|
|
|
|
+ headers: myHeaders,
|
|
|
|
|
+ body: JSON.stringify({
|
|
|
|
|
+ company_id: company,
|
|
|
|
|
+ order_id: orderId,
|
|
|
|
|
+ order_flag: selectedPaymentMethod,
|
|
|
|
|
+ status_status: 'Finalizada'
|
|
|
|
|
+ })
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ if (!response.ok) {
|
|
|
|
|
+ const errorData = await response.json().catch(() => null);
|
|
|
|
|
+ if (errorData.msg == 'Comanda possui itens de cozinha não finalizados.') {
|
|
|
|
|
+ itemsOnKitchen = true;
|
|
|
|
|
+ setInterval(() => {
|
|
|
|
|
+ itemsOnKitchen = false;
|
|
|
|
|
+ }, 7000);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ isPaymentModalOpen = false;
|
|
|
|
|
+ goto('/dashboard/tables');
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ console.log('deu erro');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
@@ -273,6 +289,11 @@
|
|
|
>
|
|
>
|
|
|
Fechar Atendimento
|
|
Fechar Atendimento
|
|
|
</button>
|
|
</button>
|
|
|
|
|
+ {#if itemsOnKitchen}
|
|
|
|
|
+ <div class="mt-2 flex justify-center rounded-md bg-yellow-600 text-center">
|
|
|
|
|
+ <h1>Existe items em andamento na cozinha</h1>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {/if}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -323,10 +344,12 @@
|
|
|
<span>{method}</span>
|
|
<span>{method}</span>
|
|
|
</label>
|
|
</label>
|
|
|
{/each}
|
|
{/each}
|
|
|
-
|
|
|
|
|
- <p>Método selecionado: {selectedPaymentMethod}</p>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
-
|
|
|
|
|
|
|
+ {#if itemsOnKitchen}
|
|
|
|
|
+ <div class="mb-4 mt-2 w-full rounded-md bg-yellow-600 text-center">
|
|
|
|
|
+ <h1>Existe items em andamento na cozinha</h1>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {/if}
|
|
|
<div class="flex space-x-3">
|
|
<div class="flex space-x-3">
|
|
|
<button
|
|
<button
|
|
|
on:click={() => (isPaymentModalOpen = false)}
|
|
on:click={() => (isPaymentModalOpen = false)}
|