|
@@ -90,6 +90,33 @@
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ function cancelCommand(order_Id) {
|
|
|
|
|
+ const myHeaders = new Headers();
|
|
|
|
|
+ myHeaders.append('Authorization', `Bearer ${token}`);
|
|
|
|
|
+ myHeaders.append('Content-Type', 'application/json');
|
|
|
|
|
+
|
|
|
|
|
+ const raw = JSON.stringify({
|
|
|
|
|
+ order_id: order_Id,
|
|
|
|
|
+ company_id: companyId,
|
|
|
|
|
+ cancel: true
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const requestOptions = {
|
|
|
|
|
+ method: 'POST',
|
|
|
|
|
+ headers: myHeaders,
|
|
|
|
|
+ body: raw,
|
|
|
|
|
+ redirect: 'follow'
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ fetch('https://dev2.mixtech.dev.br/order/delete', requestOptions)
|
|
|
|
|
+ .then((response) => response.json())
|
|
|
|
|
+ .then((result) => {
|
|
|
|
|
+ (console.log('Pedido cancelado com sucesso:', order_Id, companyId, result),
|
|
|
|
|
+ location.reload());
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => console.error('Erro ao cancelar comanda:', error));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const getElapsedTime = (createdAt) => {
|
|
const getElapsedTime = (createdAt) => {
|
|
|
if (!createdAt || createdAt.trim() === '') return '';
|
|
if (!createdAt || createdAt.trim() === '') return '';
|
|
|
const start = new Date(createdAt.replace(' ', 'T'));
|
|
const start = new Date(createdAt.replace(' ', 'T'));
|
|
@@ -155,10 +182,7 @@
|
|
|
{#if flag == 'admin' || flag == 'cashier'}
|
|
{#if flag == 'admin' || flag == 'cashier'}
|
|
|
<button
|
|
<button
|
|
|
class="w-full rounded bg-red-600 py-2 hover:bg-red-700"
|
|
class="w-full rounded bg-red-600 py-2 hover:bg-red-700"
|
|
|
- on:click={() => {
|
|
|
|
|
- orderToCancel = order.name;
|
|
|
|
|
- showConfirmCancel = true;
|
|
|
|
|
- }}
|
|
|
|
|
|
|
+ on:click={cancelCommand(order.id)}
|
|
|
>
|
|
>
|
|
|
Cancelar
|
|
Cancelar
|
|
|
</button>
|
|
</button>
|