@fayz-ai/plugin-orders 0.12.28 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OrderDetailRoute-LTPDQXQU.js +193 -0
- package/dist/OrderDetailRoute-LTPDQXQU.js.map +1 -0
- package/dist/OrdersPage-5326V62H.js +291 -0
- package/dist/OrdersPage-5326V62H.js.map +1 -0
- package/dist/chunk-YVC7R552.js +6 -0
- package/dist/chunk-YVC7R552.js.map +1 -0
- package/dist/context.d.ts +0 -46
- package/dist/context.d.ts.map +1 -1
- package/dist/data/core-supabase.d.ts.map +1 -1
- package/dist/index.d.ts +4 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +891 -934
- package/dist/index.js.map +1 -1
- package/dist/lib/detail-slot.d.ts +13 -0
- package/dist/lib/detail-slot.d.ts.map +1 -0
- package/dist/lib/list-query.d.ts +21 -0
- package/dist/lib/list-query.d.ts.map +1 -0
- package/dist/types.d.ts +10 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/views/OrderDetailRoute.d.ts +12 -0
- package/dist/views/OrderDetailRoute.d.ts.map +1 -0
- package/dist/views/OrdersPage.d.ts +1 -7
- package/dist/views/OrdersPage.d.ts.map +1 -1
- package/dist/views/OrdersScreen.d.ts.map +1 -1
- package/package.json +7 -9
- package/dist/OrdersPage-QV2YWARF.js +0 -483
- package/dist/OrdersPage-QV2YWARF.js.map +0 -1
- package/dist/chunk-TYS3LCKX.js +0 -57
- package/dist/chunk-TYS3LCKX.js.map +0 -1
- package/dist/lib/floor-plan-id.d.ts +0 -13
- package/dist/lib/floor-plan-id.d.ts.map +0 -1
- package/dist/views/CommercialOrdersScreen.d.ts +0 -3
- package/dist/views/CommercialOrdersScreen.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,428 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import React2__default from 'react';
|
|
5
|
-
import { fayzConnectorOAuth, OrderDetailPage, orderIsEditable, PageActions, adminNavigateTo, PluginSettingsPanel, dedup, usePermissionOptional, useConnectors, useConnectorsPanelAvailable, openConnectorsPanel, SettingsGroup, ToggleRow, AddConnectorButton, ConnectorRow, AddConnectorPanel, ConnectorDetail, TextRow } from '@fayz-ai/admin';
|
|
6
|
-
import { Pencil, AlertTriangle, Loader2, Check } from 'lucide-react';
|
|
7
|
-
import { createConnectionStore, connectionRuns, connectionSettings, connectionStatus, settingsStatus, getSupabaseClientOptional, usePluginRuntimeOptional, emitDomainEvent, errorMessage, describeError } from '@fayz-ai/core';
|
|
1
|
+
export { ORDER_DETAIL_COMPONENT_ID } from './chunk-YVC7R552.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createConnectionStore, connectionRuns, connectionSettings, connectionStatus, settingsStatus, getSupabaseClientOptional, emitDomainEvent, errorMessage } from '@fayz-ai/core';
|
|
8
4
|
import { createStore } from 'zustand/vanilla';
|
|
5
|
+
import { fayzConnectorOAuth, PluginSettingsPanel, dedup, useConnectors, useConnectorsPanelAvailable, openConnectorsPanel, SettingsGroup, ToggleRow, AddConnectorButton, ConnectorRow, AddConnectorPanel, ConnectorDetail, TextRow } from '@fayz-ai/admin';
|
|
9
6
|
import { toast } from 'sonner';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { jsxs,
|
|
7
|
+
import { Skeleton } from '@fayz-ai/ui';
|
|
8
|
+
import { AlertTriangle, Loader2, Check } from 'lucide-react';
|
|
9
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
13
10
|
import { createFayzClient } from '@fayz-ai/sdk';
|
|
14
11
|
|
|
15
|
-
// src/data/mock.ts
|
|
16
|
-
var uid = 100;
|
|
17
|
-
function nextId(prefix) {
|
|
18
|
-
return prefix + "-" + ++uid;
|
|
19
|
-
}
|
|
20
|
-
var now = (/* @__PURE__ */ new Date()).toISOString();
|
|
21
|
-
function makeItem(orderId, name, quantity, unitPrice, sortOrder, productId) {
|
|
22
|
-
const id = nextId("item");
|
|
23
|
-
return {
|
|
24
|
-
id,
|
|
25
|
-
orderId,
|
|
26
|
-
productId,
|
|
27
|
-
name,
|
|
28
|
-
quantity,
|
|
29
|
-
unitPrice,
|
|
30
|
-
discount: 0,
|
|
31
|
-
total: quantity * unitPrice,
|
|
32
|
-
sortOrder,
|
|
33
|
-
createdAt: now
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function createSeedOrders() {
|
|
37
|
-
const order1Id = nextId("order");
|
|
38
|
-
const order1Items = [
|
|
39
|
-
makeItem(order1Id, "Classic Burger", 1, 32, 0, "prod-burger-classic"),
|
|
40
|
-
makeItem(order1Id, "Fries", 1, 15, 1, "prod-fries")
|
|
41
|
-
];
|
|
42
|
-
const order1 = {
|
|
43
|
-
id: order1Id,
|
|
44
|
-
referenceNumber: "ORD-0001",
|
|
45
|
-
kind: "dine_in",
|
|
46
|
-
status: "preparing",
|
|
47
|
-
source: "pos",
|
|
48
|
-
tableId: "table-3",
|
|
49
|
-
tableName: "Table 3",
|
|
50
|
-
subtotal: 47,
|
|
51
|
-
discount: 0,
|
|
52
|
-
tax: 0,
|
|
53
|
-
total: 47,
|
|
54
|
-
currency: "BRL",
|
|
55
|
-
tags: [],
|
|
56
|
-
items: order1Items,
|
|
57
|
-
tenantId: "tenant-mock",
|
|
58
|
-
createdAt: now,
|
|
59
|
-
updatedAt: now
|
|
60
|
-
};
|
|
61
|
-
const order2Id = nextId("order");
|
|
62
|
-
const order2Items = [
|
|
63
|
-
makeItem(order2Id, "Cheese Burger", 1, 36, 0, "prod-burger-cheese")
|
|
64
|
-
];
|
|
65
|
-
const order2 = {
|
|
66
|
-
id: order2Id,
|
|
67
|
-
referenceNumber: "ORD-0002",
|
|
68
|
-
kind: "takeout",
|
|
69
|
-
status: "ready",
|
|
70
|
-
source: "pos",
|
|
71
|
-
subtotal: 36,
|
|
72
|
-
discount: 0,
|
|
73
|
-
tax: 0,
|
|
74
|
-
total: 36,
|
|
75
|
-
currency: "BRL",
|
|
76
|
-
tags: [],
|
|
77
|
-
items: order2Items,
|
|
78
|
-
tenantId: "tenant-mock",
|
|
79
|
-
createdAt: now,
|
|
80
|
-
updatedAt: now
|
|
81
|
-
};
|
|
82
|
-
const order3Id = nextId("order");
|
|
83
|
-
const order3Items = [
|
|
84
|
-
makeItem(order3Id, "Margherita Pizza", 1, 38, 0, "prod-pizza-margherita"),
|
|
85
|
-
makeItem(order3Id, "Caesar Salad", 1, 22, 1, "prod-salad-caesar"),
|
|
86
|
-
makeItem(order3Id, "Soda 350ml", 1, 12, 2, "prod-soda")
|
|
87
|
-
];
|
|
88
|
-
const order3 = {
|
|
89
|
-
id: order3Id,
|
|
90
|
-
referenceNumber: "ORD-0003",
|
|
91
|
-
kind: "delivery",
|
|
92
|
-
status: "confirmed",
|
|
93
|
-
source: "ifood",
|
|
94
|
-
subtotal: 72,
|
|
95
|
-
discount: 0,
|
|
96
|
-
tax: 0,
|
|
97
|
-
total: 72,
|
|
98
|
-
currency: "BRL",
|
|
99
|
-
tags: [],
|
|
100
|
-
items: order3Items,
|
|
101
|
-
tenantId: "tenant-mock",
|
|
102
|
-
createdAt: now,
|
|
103
|
-
updatedAt: now
|
|
104
|
-
};
|
|
105
|
-
const order4Id = nextId("order");
|
|
106
|
-
const order4Items = [
|
|
107
|
-
makeItem(order4Id, "BBQ Bacon Burger", 1, 42, 0, "prod-burger-bbq")
|
|
108
|
-
];
|
|
109
|
-
const order4 = {
|
|
110
|
-
id: order4Id,
|
|
111
|
-
referenceNumber: "ORD-0004",
|
|
112
|
-
kind: "dine_in",
|
|
113
|
-
status: "new",
|
|
114
|
-
source: "pos",
|
|
115
|
-
tableId: "table-7",
|
|
116
|
-
tableName: "Table 7",
|
|
117
|
-
subtotal: 42,
|
|
118
|
-
discount: 0,
|
|
119
|
-
tax: 0,
|
|
120
|
-
total: 42,
|
|
121
|
-
currency: "BRL",
|
|
122
|
-
tags: [],
|
|
123
|
-
items: order4Items,
|
|
124
|
-
tenantId: "tenant-mock",
|
|
125
|
-
createdAt: now,
|
|
126
|
-
updatedAt: now
|
|
127
|
-
};
|
|
128
|
-
const order5Id = nextId("order");
|
|
129
|
-
const order5Items = [
|
|
130
|
-
makeItem(order5Id, "Classic Burger", 2, 32, 0, "prod-burger-classic"),
|
|
131
|
-
makeItem(order5Id, "Fries", 1, 15, 1, "prod-fries"),
|
|
132
|
-
makeItem(order5Id, "Onion Rings", 1, 18, 2, "prod-onion-rings"),
|
|
133
|
-
makeItem(order5Id, "Milkshake", 1, 23, 3, "prod-milkshake")
|
|
134
|
-
];
|
|
135
|
-
const order5 = {
|
|
136
|
-
id: order5Id,
|
|
137
|
-
referenceNumber: "ORD-0005",
|
|
138
|
-
kind: "dine_in",
|
|
139
|
-
status: "completed",
|
|
140
|
-
source: "pos",
|
|
141
|
-
tableId: "table-1",
|
|
142
|
-
tableName: "Table 1",
|
|
143
|
-
subtotal: 120,
|
|
144
|
-
discount: 0,
|
|
145
|
-
tax: 0,
|
|
146
|
-
total: 120,
|
|
147
|
-
currency: "BRL",
|
|
148
|
-
tags: [],
|
|
149
|
-
items: order5Items,
|
|
150
|
-
tenantId: "tenant-mock",
|
|
151
|
-
createdAt: now,
|
|
152
|
-
updatedAt: now,
|
|
153
|
-
completedAt: now
|
|
154
|
-
};
|
|
155
|
-
return [order1, order2, order3, order4, order5];
|
|
156
|
-
}
|
|
157
|
-
function recomputeTotals(order) {
|
|
158
|
-
order.subtotal = order.items.reduce((sum, i) => sum + i.total, 0);
|
|
159
|
-
order.total = order.subtotal - order.discount + order.tax;
|
|
160
|
-
}
|
|
161
|
-
var refCounter = 5;
|
|
162
|
-
function generateReferenceNumber() {
|
|
163
|
-
refCounter++;
|
|
164
|
-
return "ORD-" + String(refCounter).padStart(4, "0");
|
|
165
|
-
}
|
|
166
|
-
function toDateStr(d) {
|
|
167
|
-
return d.toISOString().slice(0, 10);
|
|
168
|
-
}
|
|
169
|
-
function createMockOrdersProvider() {
|
|
170
|
-
const orders = createSeedOrders();
|
|
171
|
-
function findOrder(id) {
|
|
172
|
-
return orders.find((o) => o.id === id);
|
|
173
|
-
}
|
|
174
|
-
function findItem(itemId) {
|
|
175
|
-
for (const order of orders) {
|
|
176
|
-
const index = order.items.findIndex((i) => i.id === itemId);
|
|
177
|
-
if (index !== -1) return { order, item: order.items[index], index };
|
|
178
|
-
}
|
|
179
|
-
return void 0;
|
|
180
|
-
}
|
|
181
|
-
const provider = {
|
|
182
|
-
// ------------------------------------------------------------------
|
|
183
|
-
// getOrders
|
|
184
|
-
// ------------------------------------------------------------------
|
|
185
|
-
async getOrders(query) {
|
|
186
|
-
let result = [...orders];
|
|
187
|
-
if (query.kind) {
|
|
188
|
-
const kinds = Array.isArray(query.kind) ? query.kind : [query.kind];
|
|
189
|
-
result = result.filter((o) => kinds.includes(o.kind));
|
|
190
|
-
}
|
|
191
|
-
if (query.status) {
|
|
192
|
-
const statuses = Array.isArray(query.status) ? query.status : [query.status];
|
|
193
|
-
result = result.filter((o) => statuses.includes(o.status));
|
|
194
|
-
}
|
|
195
|
-
if (query.source) {
|
|
196
|
-
result = result.filter((o) => o.source === query.source);
|
|
197
|
-
}
|
|
198
|
-
if (query.tableId) {
|
|
199
|
-
result = result.filter((o) => o.tableId === query.tableId);
|
|
200
|
-
}
|
|
201
|
-
if (query.assigneeId) {
|
|
202
|
-
result = result.filter((o) => o.assigneeId === query.assigneeId);
|
|
203
|
-
}
|
|
204
|
-
if (query.search) {
|
|
205
|
-
const q = query.search.toLowerCase();
|
|
206
|
-
result = result.filter(
|
|
207
|
-
(o) => o.referenceNumber.toLowerCase().includes(q) || o.partyName?.toLowerCase().includes(q) || o.tableName?.toLowerCase().includes(q) || o.items.some((i) => i.name.toLowerCase().includes(q))
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
if (query.dateRange) {
|
|
211
|
-
const from = query.dateRange.from;
|
|
212
|
-
const to = query.dateRange.to;
|
|
213
|
-
result = result.filter((o) => {
|
|
214
|
-
const d = o.createdAt.slice(0, 10);
|
|
215
|
-
return d >= from && d <= to;
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
result.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
219
|
-
const total = result.length;
|
|
220
|
-
const page = query.page ?? 1;
|
|
221
|
-
const pageSize = query.pageSize ?? 20;
|
|
222
|
-
const start = (page - 1) * pageSize;
|
|
223
|
-
const data = result.slice(start, start + pageSize);
|
|
224
|
-
return { data, total };
|
|
225
|
-
},
|
|
226
|
-
// ------------------------------------------------------------------
|
|
227
|
-
// getOrderById
|
|
228
|
-
// ------------------------------------------------------------------
|
|
229
|
-
async getOrderById(id) {
|
|
230
|
-
return findOrder(id) ?? null;
|
|
231
|
-
},
|
|
232
|
-
// ------------------------------------------------------------------
|
|
233
|
-
// createOrder
|
|
234
|
-
// ------------------------------------------------------------------
|
|
235
|
-
async createOrder(input) {
|
|
236
|
-
const orderId = nextId("order");
|
|
237
|
-
const items = input.items.map((item, idx) => ({
|
|
238
|
-
id: nextId("item"),
|
|
239
|
-
orderId,
|
|
240
|
-
productId: item.productId,
|
|
241
|
-
name: item.name,
|
|
242
|
-
quantity: item.quantity,
|
|
243
|
-
unitPrice: item.unitPrice,
|
|
244
|
-
discount: item.discount ?? 0,
|
|
245
|
-
total: item.quantity * item.unitPrice - (item.discount ?? 0),
|
|
246
|
-
sortOrder: idx,
|
|
247
|
-
modifiers: item.modifiers,
|
|
248
|
-
kitchenNotes: item.kitchenNotes,
|
|
249
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
250
|
-
}));
|
|
251
|
-
const subtotal = items.reduce((sum, i) => sum + i.total, 0);
|
|
252
|
-
const order = {
|
|
253
|
-
id: orderId,
|
|
254
|
-
referenceNumber: generateReferenceNumber(),
|
|
255
|
-
kind: input.kind,
|
|
256
|
-
status: "new",
|
|
257
|
-
source: input.source ?? "pos",
|
|
258
|
-
tableId: input.tableId,
|
|
259
|
-
partyId: input.partyId,
|
|
260
|
-
assigneeId: input.assigneeId,
|
|
261
|
-
notes: input.notes,
|
|
262
|
-
estimatedMinutes: input.estimatedMinutes,
|
|
263
|
-
subtotal,
|
|
264
|
-
discount: 0,
|
|
265
|
-
tax: 0,
|
|
266
|
-
total: subtotal,
|
|
267
|
-
currency: "BRL",
|
|
268
|
-
tags: [],
|
|
269
|
-
items,
|
|
270
|
-
tenantId: "tenant-mock",
|
|
271
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
272
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
273
|
-
};
|
|
274
|
-
orders.push(order);
|
|
275
|
-
return order;
|
|
276
|
-
},
|
|
277
|
-
// ------------------------------------------------------------------
|
|
278
|
-
// updateOrderStatus
|
|
279
|
-
// ------------------------------------------------------------------
|
|
280
|
-
async updateOrderStatus(input) {
|
|
281
|
-
const order = findOrder(input.orderId);
|
|
282
|
-
if (!order) throw new Error(`Order not found: ${input.orderId}`);
|
|
283
|
-
if (input.status !== "cancelled") {
|
|
284
|
-
const flow = STATUS_FLOW[order.kind];
|
|
285
|
-
const currentIdx = flow.indexOf(order.status);
|
|
286
|
-
const targetIdx = flow.indexOf(input.status);
|
|
287
|
-
if (targetIdx < 0 || targetIdx !== currentIdx && targetIdx !== currentIdx + 1) {
|
|
288
|
-
const next = getNextStatus(order.kind, order.status);
|
|
289
|
-
throw new Error(
|
|
290
|
-
`Invalid status transition: ${order.status} \u2192 ${input.status}. ` + (next ? `Expected next status: ${next}` : "Order is already in a terminal state.")
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
order.status = input.status;
|
|
295
|
-
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
296
|
-
if (input.status === "completed") {
|
|
297
|
-
order.completedAt = order.updatedAt;
|
|
298
|
-
}
|
|
299
|
-
return order;
|
|
300
|
-
},
|
|
301
|
-
// ------------------------------------------------------------------
|
|
302
|
-
// updateOrder
|
|
303
|
-
// ------------------------------------------------------------------
|
|
304
|
-
async updateOrder(id, data) {
|
|
305
|
-
const order = findOrder(id);
|
|
306
|
-
if (!order) throw new Error(`Order not found: ${id}`);
|
|
307
|
-
const { id: _id, items: _items, tenantId: _t, createdAt: _c, ...safe } = data;
|
|
308
|
-
Object.assign(order, safe);
|
|
309
|
-
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
310
|
-
return order;
|
|
311
|
-
},
|
|
312
|
-
// ------------------------------------------------------------------
|
|
313
|
-
// cancelOrder
|
|
314
|
-
// ------------------------------------------------------------------
|
|
315
|
-
async cancelOrder(id, reason) {
|
|
316
|
-
const order = findOrder(id);
|
|
317
|
-
if (!order) throw new Error(`Order not found: ${id}`);
|
|
318
|
-
order.status = "cancelled";
|
|
319
|
-
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
320
|
-
if (reason) {
|
|
321
|
-
order.notes = order.notes ? `${order.notes}
|
|
322
|
-
Cancelled: ${reason}` : `Cancelled: ${reason}`;
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
// ------------------------------------------------------------------
|
|
326
|
-
// addOrderItem
|
|
327
|
-
// ------------------------------------------------------------------
|
|
328
|
-
async addOrderItem(orderId, item) {
|
|
329
|
-
const order = findOrder(orderId);
|
|
330
|
-
if (!order) throw new Error(`Order not found: ${orderId}`);
|
|
331
|
-
const newItem = {
|
|
332
|
-
id: nextId("item"),
|
|
333
|
-
orderId,
|
|
334
|
-
productId: item.productId,
|
|
335
|
-
name: item.name,
|
|
336
|
-
quantity: item.quantity,
|
|
337
|
-
unitPrice: item.unitPrice,
|
|
338
|
-
discount: item.discount ?? 0,
|
|
339
|
-
total: item.quantity * item.unitPrice - (item.discount ?? 0),
|
|
340
|
-
sortOrder: order.items.length,
|
|
341
|
-
modifiers: item.modifiers,
|
|
342
|
-
kitchenNotes: item.kitchenNotes,
|
|
343
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
344
|
-
};
|
|
345
|
-
order.items.push(newItem);
|
|
346
|
-
recomputeTotals(order);
|
|
347
|
-
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
348
|
-
return newItem;
|
|
349
|
-
},
|
|
350
|
-
// ------------------------------------------------------------------
|
|
351
|
-
// removeOrderItem
|
|
352
|
-
// ------------------------------------------------------------------
|
|
353
|
-
async removeOrderItem(itemId) {
|
|
354
|
-
const found = findItem(itemId);
|
|
355
|
-
if (!found) throw new Error(`Order item not found: ${itemId}`);
|
|
356
|
-
found.order.items.splice(found.index, 1);
|
|
357
|
-
recomputeTotals(found.order);
|
|
358
|
-
found.order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
359
|
-
},
|
|
360
|
-
// ------------------------------------------------------------------
|
|
361
|
-
// updateOrderItem
|
|
362
|
-
// ------------------------------------------------------------------
|
|
363
|
-
async updateOrderItem(itemId, data) {
|
|
364
|
-
const found = findItem(itemId);
|
|
365
|
-
if (!found) throw new Error(`Order item not found: ${itemId}`);
|
|
366
|
-
const { id: _id, orderId: _oid, createdAt: _c, ...safe } = data;
|
|
367
|
-
Object.assign(found.item, safe);
|
|
368
|
-
found.item.total = found.item.quantity * found.item.unitPrice - found.item.discount;
|
|
369
|
-
recomputeTotals(found.order);
|
|
370
|
-
found.order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
371
|
-
return found.item;
|
|
372
|
-
},
|
|
373
|
-
// ------------------------------------------------------------------
|
|
374
|
-
// getSummary
|
|
375
|
-
// ------------------------------------------------------------------
|
|
376
|
-
async getSummary(dateRange) {
|
|
377
|
-
const today = toDateStr(/* @__PURE__ */ new Date());
|
|
378
|
-
const from = dateRange?.from ?? today;
|
|
379
|
-
const to = dateRange?.to ?? today;
|
|
380
|
-
const inRange = orders.filter((o) => {
|
|
381
|
-
const d = o.createdAt.slice(0, 10);
|
|
382
|
-
return d >= from && d <= to;
|
|
383
|
-
});
|
|
384
|
-
const completed = inRange.filter((o) => o.status !== "cancelled");
|
|
385
|
-
const revenue = completed.reduce((sum, o) => sum + o.total, 0);
|
|
386
|
-
const activeStatuses = /* @__PURE__ */ new Set(["new", "confirmed", "preparing", "ready", "served", "dispatched"]);
|
|
387
|
-
const active = orders.filter((o) => activeStatuses.has(o.status));
|
|
388
|
-
const ordersByKind = { dine_in: 0, takeout: 0, delivery: 0 };
|
|
389
|
-
const ordersByStatus = {};
|
|
390
|
-
for (const o of inRange) {
|
|
391
|
-
ordersByKind[o.kind] = (ordersByKind[o.kind] || 0) + 1;
|
|
392
|
-
ordersByStatus[o.status] = (ordersByStatus[o.status] || 0) + 1;
|
|
393
|
-
}
|
|
394
|
-
const itemMap = /* @__PURE__ */ new Map();
|
|
395
|
-
for (const o of completed) {
|
|
396
|
-
for (const item of o.items) {
|
|
397
|
-
const existing = itemMap.get(item.name);
|
|
398
|
-
if (existing) {
|
|
399
|
-
existing.quantity += item.quantity;
|
|
400
|
-
existing.revenue += item.total;
|
|
401
|
-
} else {
|
|
402
|
-
itemMap.set(item.name, { name: item.name, quantity: item.quantity, revenue: item.total });
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
const topItems = Array.from(itemMap.values()).sort((a, b) => b.quantity - a.quantity).slice(0, 5);
|
|
407
|
-
return {
|
|
408
|
-
todayOrderCount: inRange.length,
|
|
409
|
-
todayRevenue: revenue,
|
|
410
|
-
averageTicket: completed.length > 0 ? revenue / completed.length : 0,
|
|
411
|
-
activeOrderCount: active.length,
|
|
412
|
-
ordersByKind,
|
|
413
|
-
ordersByStatus,
|
|
414
|
-
topItems
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
return provider;
|
|
419
|
-
}
|
|
420
12
|
var READ_ONLY = "This provider reads the core order archetype; pass `writes` to let the app that owns the flow create and edit them.";
|
|
421
13
|
var DEFAULT_CHANNELS = {
|
|
422
14
|
dine_in: "dine_in",
|
|
423
15
|
delivery: "delivery",
|
|
424
16
|
takeout: "balcao"
|
|
425
17
|
};
|
|
18
|
+
function searchTerm(raw) {
|
|
19
|
+
return (raw ?? "").replace(/[,()%*\\"]/g, " ").trim();
|
|
20
|
+
}
|
|
426
21
|
function createCoreOrdersProvider(options) {
|
|
427
22
|
const db = () => {
|
|
428
23
|
const client = getSupabaseClientOptional();
|
|
@@ -446,11 +41,23 @@ function createCoreOrdersProvider(options) {
|
|
|
446
41
|
if (query?.status) {
|
|
447
42
|
q = Array.isArray(query.status) ? q.in("status", query.status) : q.eq("status", query.status);
|
|
448
43
|
}
|
|
44
|
+
if (query?.channel) q = q.eq("channel", query.channel);
|
|
45
|
+
if (query?.excludeKinds?.length) q = q.not("kind", "in", `(${query.excludeKinds.join(",")})`);
|
|
46
|
+
if (query?.fulfillmentStatus) q = q.eq("fulfillment_status", query.fulfillmentStatus);
|
|
449
47
|
if (query?.tableId) q = q.eq("metadata->>tableId", query.tableId);
|
|
450
48
|
if (query?.assigneeId) q = q.eq("assignee_id", query.assigneeId);
|
|
451
49
|
if (query?.dateRange) {
|
|
452
50
|
q = q.gte("created_at", query.dateRange.from).lte("created_at", query.dateRange.to);
|
|
453
51
|
}
|
|
52
|
+
const term = searchTerm(query?.search);
|
|
53
|
+
if (term) {
|
|
54
|
+
const { data: named } = await client.from("people").select("id").ilike("name", `%${term}%`).limit(50);
|
|
55
|
+
const ids2 = (named ?? []).map((p) => p.id);
|
|
56
|
+
q = q.or([
|
|
57
|
+
`reference_number.ilike.%${term}%`,
|
|
58
|
+
...ids2.length ? [`party_id.in.(${ids2.join(",")})`] : []
|
|
59
|
+
].join(","));
|
|
60
|
+
}
|
|
454
61
|
const pageSize = query?.pageSize ?? 100;
|
|
455
62
|
const from = ((query?.page ?? 1) - 1) * pageSize;
|
|
456
63
|
q = q.range(from, from + pageSize - 1);
|
|
@@ -458,11 +65,17 @@ function createCoreOrdersProvider(options) {
|
|
|
458
65
|
if (error) throw new Error(error.message);
|
|
459
66
|
const rows = data ?? [];
|
|
460
67
|
const ids = rows.map((r) => r.id);
|
|
461
|
-
const
|
|
68
|
+
const withItems = query?.withItems !== false;
|
|
69
|
+
const [{ data: people }, { data: payments }, { data: items }, { data: shipments }] = await Promise.all([
|
|
462
70
|
ids.length ? client.from("people").select("id, name").in("id", [...new Set(rows.flatMap((r) => [r.party_id, r.assignee_id]).filter(Boolean))]) : Promise.resolve({ data: [] }),
|
|
463
71
|
ids.length ? client.from("v_order_payment_status").select("order_id, status, total_amount, paid_amount").in("order_id", ids) : Promise.resolve({ data: [] }),
|
|
464
|
-
ids.length ? client.from("items").select("id, order_id, product_id, name, description, quantity, unit_price, discount, total, sort_order, metadata, created_at").in("order_id", ids).order("sort_order") : Promise.resolve({ data: [] })
|
|
72
|
+
ids.length && withItems ? client.from("items").select("id, order_id, product_id, name, description, quantity, unit_price, discount, total, sort_order, metadata, created_at").in("order_id", ids).order("sort_order") : Promise.resolve({ data: [] }),
|
|
73
|
+
ids.length ? client.from("fulfillments").select("order_id, status").in("order_id", ids).in("kind", ["shipment", "pickup"]) : Promise.resolve({ data: [] })
|
|
465
74
|
]);
|
|
75
|
+
const shipmentsByOrder = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const s of shipments ?? []) {
|
|
77
|
+
shipmentsByOrder.set(s.order_id, [...shipmentsByOrder.get(s.order_id) ?? [], s.status]);
|
|
78
|
+
}
|
|
466
79
|
const nameById = new Map((people ?? []).map((p) => [p.id, p.name]));
|
|
467
80
|
const payById = new Map((payments ?? []).map((p) => [p.order_id, p]));
|
|
468
81
|
const itemsByOrder = /* @__PURE__ */ new Map();
|
|
@@ -506,7 +119,8 @@ function createCoreOrdersProvider(options) {
|
|
|
506
119
|
fulfillmentStatus: r.fulfillment_status ?? null,
|
|
507
120
|
paymentStatus: pay?.status ?? "none",
|
|
508
121
|
invoicedAmount: Number(pay?.total_amount) || 0,
|
|
509
|
-
paidAmount: Number(pay?.paid_amount) || 0
|
|
122
|
+
paidAmount: Number(pay?.paid_amount) || 0,
|
|
123
|
+
shipmentStatuses: shipmentsByOrder.get(r.id) ?? []
|
|
510
124
|
},
|
|
511
125
|
tenantId: r.tenant_id,
|
|
512
126
|
unitId: r.unit_id ?? void 0,
|
|
@@ -727,6 +341,62 @@ function createCoreOrdersProvider(options) {
|
|
|
727
341
|
}
|
|
728
342
|
};
|
|
729
343
|
}
|
|
344
|
+
|
|
345
|
+
// src/types.ts
|
|
346
|
+
var STATUS_FLOW = {
|
|
347
|
+
dine_in: ["draft", "new", "confirmed", "preparing", "ready", "served", "completed"],
|
|
348
|
+
takeout: ["draft", "new", "confirmed", "preparing", "ready", "picked_up", "completed"],
|
|
349
|
+
delivery: ["draft", "new", "confirmed", "preparing", "ready", "dispatched", "delivered", "completed"]
|
|
350
|
+
};
|
|
351
|
+
var OUT_STATUSES = ["served", "picked_up", "dispatched", "delivered"];
|
|
352
|
+
function getNextStatus(kind, current) {
|
|
353
|
+
const flow = STATUS_FLOW[kind];
|
|
354
|
+
let idx = flow.indexOf(current);
|
|
355
|
+
if (idx === -1 && OUT_STATUSES.includes(current)) {
|
|
356
|
+
idx = flow.findIndex((status) => OUT_STATUSES.includes(status));
|
|
357
|
+
}
|
|
358
|
+
return idx >= 0 && idx < flow.length - 1 ? flow[idx + 1] : null;
|
|
359
|
+
}
|
|
360
|
+
var ADVANCE_VERB = {
|
|
361
|
+
draft: "Salvar rascunho",
|
|
362
|
+
new: "Enviar",
|
|
363
|
+
confirmed: "Confirmar",
|
|
364
|
+
preparing: "Preparar",
|
|
365
|
+
ready: "Marcar pronto",
|
|
366
|
+
served: "Servir",
|
|
367
|
+
picked_up: "Entregar",
|
|
368
|
+
dispatched: "Despachar",
|
|
369
|
+
delivered: "Confirmar entrega",
|
|
370
|
+
completed: "Concluir",
|
|
371
|
+
cancelled: "Cancelar"
|
|
372
|
+
};
|
|
373
|
+
function getPreviousStatus(kind, current) {
|
|
374
|
+
const flow = STATUS_FLOW[kind];
|
|
375
|
+
const idx = flow.indexOf(current);
|
|
376
|
+
return idx > 0 ? flow[idx - 1] : null;
|
|
377
|
+
}
|
|
378
|
+
function mapToKanbanColumn(status) {
|
|
379
|
+
if (["served", "picked_up", "dispatched", "delivered"].includes(status)) return "out";
|
|
380
|
+
if (["new", "confirmed", "preparing", "ready", "completed", "cancelled"].includes(status)) {
|
|
381
|
+
return status;
|
|
382
|
+
}
|
|
383
|
+
return "new";
|
|
384
|
+
}
|
|
385
|
+
var KANBAN_COLUMNS = ["new", "confirmed", "preparing", "ready", "out", "completed"];
|
|
386
|
+
var DEFAULT_STATUS_CONFIGS = [
|
|
387
|
+
{ value: "new", label: "New", color: "#6366f1", icon: "PlusCircle" },
|
|
388
|
+
{ value: "confirmed", label: "Confirmed", color: "#3b82f6", icon: "CheckCircle" },
|
|
389
|
+
{ value: "preparing", label: "Preparing", color: "#f59e0b", icon: "ChefHat" },
|
|
390
|
+
{ value: "ready", label: "Ready", color: "#10b981", icon: "Bell" },
|
|
391
|
+
{ value: "served", label: "Served", color: "#06b6d4", icon: "Utensils" },
|
|
392
|
+
{ value: "picked_up", label: "Picked Up", color: "#06b6d4", icon: "ShoppingBag" },
|
|
393
|
+
{ value: "dispatched", label: "Dispatched", color: "#8b5cf6", icon: "Truck" },
|
|
394
|
+
{ value: "delivered", label: "Delivered", color: "#06b6d4", icon: "PackageCheck" },
|
|
395
|
+
{ value: "completed", label: "Completed", color: "#22c55e", icon: "CircleCheck" },
|
|
396
|
+
{ value: "cancelled", label: "Cancelled", color: "#ef4444", icon: "XCircle" }
|
|
397
|
+
];
|
|
398
|
+
|
|
399
|
+
// src/store.ts
|
|
730
400
|
var ACTIVE_STATUSES = [
|
|
731
401
|
"new",
|
|
732
402
|
"confirmed",
|
|
@@ -1540,84 +1210,6 @@ var aiqfomeConnectorDef = {
|
|
|
1540
1210
|
disconnect: () => store6.disconnect(),
|
|
1541
1211
|
disconnectNote: "Desconectar para de trazer pedidos novos. Os pedidos que j\xE1 entraram continuam aqui."
|
|
1542
1212
|
};
|
|
1543
|
-
function toModalInstallment(bill) {
|
|
1544
|
-
return {
|
|
1545
|
-
id: bill.id,
|
|
1546
|
-
amount: Number(bill.amount ?? 0),
|
|
1547
|
-
paidAmount: Number(bill.paid_amount ?? 0),
|
|
1548
|
-
installmentNumber: bill.installment_number ?? 1,
|
|
1549
|
-
direction: bill.direction ?? "credit",
|
|
1550
|
-
dueDate: bill.due_date,
|
|
1551
|
-
invoiceId: bill.financial_invoice_id ?? bill.invoice_id
|
|
1552
|
-
};
|
|
1553
|
-
}
|
|
1554
|
-
function firstOpenBill(receivable) {
|
|
1555
|
-
return receivable?.bills.find(
|
|
1556
|
-
(b) => Number(b.paid_amount ?? 0) < Number(b.amount)
|
|
1557
|
-
);
|
|
1558
|
-
}
|
|
1559
|
-
function OrderReceivableActions({ orderId, orderTotal, receivable, reload }) {
|
|
1560
|
-
const [busy, setBusy] = React2.useState(false);
|
|
1561
|
-
const [paying, setPaying] = React2.useState(null);
|
|
1562
|
-
const can = usePermissionOptional();
|
|
1563
|
-
const runtime = usePluginRuntimeOptional();
|
|
1564
|
-
const hasFinancialRoute = (runtime?.activePlugins ?? []).some(
|
|
1565
|
-
(p) => p.routes?.some((r) => r.path === "/financial")
|
|
1566
|
-
);
|
|
1567
|
-
const canInvoice = can("financial", "create");
|
|
1568
|
-
const balance = receivable ? Number(receivable.balance.balance ?? 0) : 0;
|
|
1569
|
-
const cancelled = receivable?.balance.status === "cancelled";
|
|
1570
|
-
const openBill = firstOpenBill(receivable);
|
|
1571
|
-
const canReceive = receivable ? balance > 0 && !cancelled && Boolean(openBill) : canInvoice && Number(orderTotal) > 0;
|
|
1572
|
-
async function registrarRecebimento() {
|
|
1573
|
-
if (receivable) {
|
|
1574
|
-
const bill = firstOpenBill(receivable);
|
|
1575
|
-
if (bill) setPaying(toModalInstallment(bill));
|
|
1576
|
-
return;
|
|
1577
|
-
}
|
|
1578
|
-
const db = getSupabaseClientOptional();
|
|
1579
|
-
if (!db) return;
|
|
1580
|
-
setBusy(true);
|
|
1581
|
-
try {
|
|
1582
|
-
const { error } = await db.rpc("fn_invoice_from_order", { p_order_id: orderId });
|
|
1583
|
-
if (error) throw new Error(error.message ?? "Falha ao faturar o pedido");
|
|
1584
|
-
const { data } = await db.from("v_financial_bills").select("*").eq("invoice_id", orderId).order("installment_number", { ascending: true });
|
|
1585
|
-
const bill = (data ?? []).find(
|
|
1586
|
-
(b) => Number(b.paid_amount ?? 0) < Number(b.amount ?? 0)
|
|
1587
|
-
);
|
|
1588
|
-
await reload(true);
|
|
1589
|
-
if (bill) setPaying(toModalInstallment(bill));
|
|
1590
|
-
else toast$1.error("Pedido faturado, mas nenhuma parcela em aberto foi encontrada");
|
|
1591
|
-
} catch (err) {
|
|
1592
|
-
toast$1.error(describeError(err, "Falha ao faturar o pedido"));
|
|
1593
|
-
} finally {
|
|
1594
|
-
setBusy(false);
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1598
|
-
canReceive && /* @__PURE__ */ jsx(Button, { onClick: () => void registrarRecebimento(), disabled: busy, "data-testid": "order-register-receipt", children: busy ? "Abrindo\u2026" : "Registrar recebimento" }),
|
|
1599
|
-
hasFinancialRoute && /* @__PURE__ */ jsx(
|
|
1600
|
-
"button",
|
|
1601
|
-
{
|
|
1602
|
-
type: "button",
|
|
1603
|
-
onClick: () => adminNavigateTo("/financial"),
|
|
1604
|
-
className: "rounded-md border px-3 py-1.5 text-sm font-medium transition hover:bg-muted",
|
|
1605
|
-
children: "Abrir no Financeiro"
|
|
1606
|
-
}
|
|
1607
|
-
),
|
|
1608
|
-
paying != null && /* @__PURE__ */ jsx(
|
|
1609
|
-
ReceivePaymentModal,
|
|
1610
|
-
{
|
|
1611
|
-
installment: paying,
|
|
1612
|
-
onClose: () => setPaying(null),
|
|
1613
|
-
onPaid: () => {
|
|
1614
|
-
setPaying(null);
|
|
1615
|
-
void reload(true);
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
)
|
|
1619
|
-
] });
|
|
1620
|
-
}
|
|
1621
1213
|
var DEBOUNCE_MS = 400;
|
|
1622
1214
|
var KEYS = {
|
|
1623
1215
|
enabled: "delivery.enabled",
|
|
@@ -1633,14 +1225,14 @@ function message(e) {
|
|
|
1633
1225
|
return String(e);
|
|
1634
1226
|
}
|
|
1635
1227
|
function useDeliverySettings(defaults = {}) {
|
|
1636
|
-
const client =
|
|
1228
|
+
const client = React.useMemo(() => getSupabaseClientOptional(), []);
|
|
1637
1229
|
const supported = !!client;
|
|
1638
|
-
const [stored, setStored] =
|
|
1639
|
-
const [loading, setLoading] =
|
|
1640
|
-
const [saving, setSaving] =
|
|
1641
|
-
const [error, setError] =
|
|
1642
|
-
const [loadError, setLoadError] =
|
|
1643
|
-
|
|
1230
|
+
const [stored, setStored] = React.useState({});
|
|
1231
|
+
const [loading, setLoading] = React.useState(supported);
|
|
1232
|
+
const [saving, setSaving] = React.useState(false);
|
|
1233
|
+
const [error, setError] = React.useState(null);
|
|
1234
|
+
const [loadError, setLoadError] = React.useState(null);
|
|
1235
|
+
React.useEffect(() => {
|
|
1644
1236
|
if (!client) return;
|
|
1645
1237
|
let cancelled = false;
|
|
1646
1238
|
setLoading(true);
|
|
@@ -1667,12 +1259,12 @@ function useDeliverySettings(defaults = {}) {
|
|
|
1667
1259
|
cancelled = true;
|
|
1668
1260
|
};
|
|
1669
1261
|
}, [client]);
|
|
1670
|
-
const pendingRef =
|
|
1671
|
-
const timerRef =
|
|
1672
|
-
|
|
1262
|
+
const pendingRef = React.useRef({});
|
|
1263
|
+
const timerRef = React.useRef(null);
|
|
1264
|
+
React.useEffect(() => () => {
|
|
1673
1265
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1674
1266
|
}, []);
|
|
1675
|
-
const set =
|
|
1267
|
+
const set = React.useCallback((patch) => {
|
|
1676
1268
|
setStored((current) => ({ ...current, ...patch }));
|
|
1677
1269
|
if (!client) return;
|
|
1678
1270
|
setError(null);
|
|
@@ -1691,7 +1283,7 @@ function useDeliverySettings(defaults = {}) {
|
|
|
1691
1283
|
).catch((e) => setError(message(e))).finally(() => setSaving(false));
|
|
1692
1284
|
}, DEBOUNCE_MS);
|
|
1693
1285
|
}, [client]);
|
|
1694
|
-
const value =
|
|
1286
|
+
const value = React.useMemo(() => ({ ...defaults, ...stored }), [defaults, stored]);
|
|
1695
1287
|
return { value, set, loading, saving, error, loadError, supported };
|
|
1696
1288
|
}
|
|
1697
1289
|
var MARKETPLACE_CATEGORIES = ["marketplace"];
|
|
@@ -1706,9 +1298,9 @@ function amountText(value) {
|
|
|
1706
1298
|
return String(value).replace(".", ",");
|
|
1707
1299
|
}
|
|
1708
1300
|
function AmountRow({ label, description, hint, value, onCommit }) {
|
|
1709
|
-
const [text, setText] =
|
|
1710
|
-
const [invalid, setInvalid] =
|
|
1711
|
-
|
|
1301
|
+
const [text, setText] = React.useState(() => amountText(value));
|
|
1302
|
+
const [invalid, setInvalid] = React.useState(false);
|
|
1303
|
+
React.useEffect(() => {
|
|
1712
1304
|
setText(amountText(value));
|
|
1713
1305
|
}, [value]);
|
|
1714
1306
|
return /* @__PURE__ */ jsx(
|
|
@@ -1740,14 +1332,14 @@ function DeliverySettings() {
|
|
|
1740
1332
|
const settings = useDeliverySettings({ enabled: true, fee: 0, minOrder: 0, etaMinutes: 45, radiusKm: 0 });
|
|
1741
1333
|
const { value, set } = settings;
|
|
1742
1334
|
const { connectors } = useConnectors({ hostPluginId: "orders", includeGrants: false });
|
|
1743
|
-
const [adding, setAdding] =
|
|
1744
|
-
const [selected, setSelected] =
|
|
1335
|
+
const [adding, setAdding] = React.useState(false);
|
|
1336
|
+
const [selected, setSelected] = React.useState(null);
|
|
1745
1337
|
const panelAvailable = useConnectorsPanelAvailable();
|
|
1746
|
-
const openJourney =
|
|
1338
|
+
const openJourney = React.useCallback((connector) => {
|
|
1747
1339
|
if (panelAvailable) openConnectorsPanel(connector);
|
|
1748
1340
|
else setSelected(connector);
|
|
1749
1341
|
}, [panelAvailable]);
|
|
1750
|
-
const marketplaces =
|
|
1342
|
+
const marketplaces = React.useMemo(
|
|
1751
1343
|
() => (connectors ?? []).filter((c) => c.category && MARKETPLACE_CATEGORIES.includes(c.category)),
|
|
1752
1344
|
[connectors]
|
|
1753
1345
|
);
|
|
@@ -1925,409 +1517,816 @@ function numberValue(value) {
|
|
|
1925
1517
|
function dateKey(value) {
|
|
1926
1518
|
return value.slice(0, 10);
|
|
1927
1519
|
}
|
|
1928
|
-
function referenceNumber() {
|
|
1929
|
-
return `ORD-${Date.now().toString().slice(-6)}`;
|
|
1520
|
+
function referenceNumber() {
|
|
1521
|
+
return `ORD-${Date.now().toString().slice(-6)}`;
|
|
1522
|
+
}
|
|
1523
|
+
function objectValue(value) {
|
|
1524
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1525
|
+
}
|
|
1526
|
+
function canonicalStatus(status) {
|
|
1527
|
+
if (status === "new") return "draft";
|
|
1528
|
+
if (status === "completed" || status === "cancelled") return status;
|
|
1529
|
+
return "confirmed";
|
|
1530
|
+
}
|
|
1531
|
+
function restaurantStatus(rowStatus, metadata) {
|
|
1532
|
+
if (rowStatus === "completed" || rowStatus === "cancelled") return rowStatus;
|
|
1533
|
+
const stored = metadata.restaurantStatus;
|
|
1534
|
+
if (typeof stored === "string" && RESTAURANT_STATUSES.has(stored)) return stored;
|
|
1535
|
+
if (rowStatus === "draft") return "new";
|
|
1536
|
+
if (typeof rowStatus === "string" && RESTAURANT_STATUSES.has(rowStatus)) return rowStatus;
|
|
1537
|
+
return "confirmed";
|
|
1538
|
+
}
|
|
1539
|
+
function ordersMetadata(metadata) {
|
|
1540
|
+
return objectValue(metadata?.[ORDERS_METADATA_KEY]);
|
|
1541
|
+
}
|
|
1542
|
+
function mergeOrdersMetadata(metadata, patch) {
|
|
1543
|
+
const base = { ...metadata ?? {} };
|
|
1544
|
+
const current = ordersMetadata(base);
|
|
1545
|
+
const definedPatch = Object.fromEntries(
|
|
1546
|
+
Object.entries(patch).filter(([, value]) => value !== void 0)
|
|
1547
|
+
);
|
|
1548
|
+
const next = { ...current, ...definedPatch };
|
|
1549
|
+
return { ...base, [ORDERS_METADATA_KEY]: next };
|
|
1550
|
+
}
|
|
1551
|
+
function itemToRow(item, orderId, sortOrder, tenantId, unitId) {
|
|
1552
|
+
const discount = item.discount ?? 0;
|
|
1553
|
+
return {
|
|
1554
|
+
order_id: orderId,
|
|
1555
|
+
...tenantId ? { tenant_id: tenantId } : {},
|
|
1556
|
+
...unitId ? { unit_id: unitId } : {},
|
|
1557
|
+
product_id: item.productId ?? null,
|
|
1558
|
+
name: item.name,
|
|
1559
|
+
quantity: item.quantity,
|
|
1560
|
+
unit_price: item.unitPrice,
|
|
1561
|
+
discount,
|
|
1562
|
+
total: item.quantity * item.unitPrice - discount,
|
|
1563
|
+
sort_order: sortOrder,
|
|
1564
|
+
metadata: mergeOrdersMetadata(void 0, {
|
|
1565
|
+
modifiers: item.modifiers ?? null,
|
|
1566
|
+
kitchenNotes: item.kitchenNotes ?? null
|
|
1567
|
+
})
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
function rowToItem(row) {
|
|
1571
|
+
const quantity = numberValue(row.quantity);
|
|
1572
|
+
const unitPrice = numberValue(row.unit_price);
|
|
1573
|
+
const discount = numberValue(row.discount);
|
|
1574
|
+
const restaurant = ordersMetadata(row.metadata);
|
|
1575
|
+
return {
|
|
1576
|
+
id: row.id,
|
|
1577
|
+
orderId: row.order_id ?? "",
|
|
1578
|
+
productId: row.product_id ?? void 0,
|
|
1579
|
+
name: row.name ?? "Item",
|
|
1580
|
+
description: row.description ?? void 0,
|
|
1581
|
+
quantity,
|
|
1582
|
+
unitPrice,
|
|
1583
|
+
discount,
|
|
1584
|
+
total: numberValue(row.total) || quantity * unitPrice - discount,
|
|
1585
|
+
sortOrder: row.sort_order ?? 0,
|
|
1586
|
+
modifiers: row.modifiers ?? (typeof restaurant.modifiers === "string" ? restaurant.modifiers : void 0),
|
|
1587
|
+
kitchenNotes: row.kitchen_notes ?? (typeof restaurant.kitchenNotes === "string" ? restaurant.kitchenNotes : void 0),
|
|
1588
|
+
metadata: row.metadata ?? {},
|
|
1589
|
+
createdAt: row.created_at ?? nowIso()
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
function rowToOrder(row, items = []) {
|
|
1593
|
+
const subtotal = numberValue(row.subtotal) || items.reduce((sum, item) => sum + item.total, 0);
|
|
1594
|
+
const discount = numberValue(row.discount);
|
|
1595
|
+
const tax = numberValue(row.tax);
|
|
1596
|
+
const restaurant = ordersMetadata(row.metadata);
|
|
1597
|
+
return {
|
|
1598
|
+
id: row.id,
|
|
1599
|
+
referenceNumber: row.reference_number ?? row.id,
|
|
1600
|
+
kind: row.kind ?? "dine_in",
|
|
1601
|
+
status: restaurantStatus(row.status, restaurant),
|
|
1602
|
+
partyId: row.party_id ?? void 0,
|
|
1603
|
+
partyName: row.party_name ?? (typeof restaurant.partyName === "string" ? restaurant.partyName : void 0),
|
|
1604
|
+
assigneeId: row.assignee_id ?? void 0,
|
|
1605
|
+
assigneeName: row.assignee_name ?? (typeof restaurant.assigneeName === "string" ? restaurant.assigneeName : void 0),
|
|
1606
|
+
locationId: row.location_id ?? void 0,
|
|
1607
|
+
subtotal,
|
|
1608
|
+
discount,
|
|
1609
|
+
tax,
|
|
1610
|
+
total: numberValue(row.total) || subtotal - discount + tax,
|
|
1611
|
+
currency: row.currency ?? "BRL",
|
|
1612
|
+
notes: row.notes ?? void 0,
|
|
1613
|
+
tags: row.tags ?? [],
|
|
1614
|
+
source: row.source ?? (typeof restaurant.source === "string" ? restaurant.source : "pos"),
|
|
1615
|
+
tableId: row.table_id ?? (typeof restaurant.tableId === "string" ? restaurant.tableId : void 0),
|
|
1616
|
+
tableName: row.table_name ?? (typeof restaurant.tableName === "string" ? restaurant.tableName : void 0),
|
|
1617
|
+
estimatedMinutes: row.estimated_minutes ?? (typeof restaurant.estimatedMinutes === "number" ? restaurant.estimatedMinutes : void 0),
|
|
1618
|
+
items,
|
|
1619
|
+
metadata: row.metadata ?? {},
|
|
1620
|
+
tenantId: row.tenant_id ?? "runtime-tenant",
|
|
1621
|
+
unitId: row.unit_id ?? void 0,
|
|
1622
|
+
createdAt: row.created_at ?? nowIso(),
|
|
1623
|
+
updatedAt: row.updated_at ?? row.created_at ?? nowIso(),
|
|
1624
|
+
completedAt: row.completed_at ?? void 0
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
function orderPayload(input) {
|
|
1628
|
+
const subtotal = input.items.reduce((sum, item) => sum + item.quantity * item.unitPrice - (item.discount ?? 0), 0);
|
|
1629
|
+
return {
|
|
1630
|
+
reference_number: referenceNumber(),
|
|
1631
|
+
kind: input.kind,
|
|
1632
|
+
status: "draft",
|
|
1633
|
+
party_id: input.partyId ?? null,
|
|
1634
|
+
assignee_id: input.assigneeId ?? null,
|
|
1635
|
+
notes: input.notes ?? null,
|
|
1636
|
+
subtotal,
|
|
1637
|
+
discount: 0,
|
|
1638
|
+
tax: 0,
|
|
1639
|
+
total: subtotal,
|
|
1640
|
+
currency: "BRL",
|
|
1641
|
+
tags: [],
|
|
1642
|
+
metadata: mergeOrdersMetadata(void 0, {
|
|
1643
|
+
source: input.source ?? "pos",
|
|
1644
|
+
tableId: input.tableId ?? null,
|
|
1645
|
+
estimatedMinutes: input.estimatedMinutes ?? null,
|
|
1646
|
+
restaurantStatus: "new"
|
|
1647
|
+
})
|
|
1648
|
+
};
|
|
1930
1649
|
}
|
|
1931
|
-
function
|
|
1932
|
-
|
|
1650
|
+
function updatePayload(data, existingMetadata) {
|
|
1651
|
+
const payload = {};
|
|
1652
|
+
if (data.referenceNumber !== void 0) payload.reference_number = data.referenceNumber;
|
|
1653
|
+
if (data.kind !== void 0) payload.kind = data.kind;
|
|
1654
|
+
if (data.status !== void 0) payload.status = canonicalStatus(data.status);
|
|
1655
|
+
if (data.partyId !== void 0) payload.party_id = data.partyId;
|
|
1656
|
+
if (data.assigneeId !== void 0) payload.assignee_id = data.assigneeId;
|
|
1657
|
+
if (data.locationId !== void 0) payload.location_id = data.locationId;
|
|
1658
|
+
if (data.subtotal !== void 0) payload.subtotal = data.subtotal;
|
|
1659
|
+
if (data.discount !== void 0) payload.discount = data.discount;
|
|
1660
|
+
if (data.tax !== void 0) payload.tax = data.tax;
|
|
1661
|
+
if (data.total !== void 0) payload.total = data.total;
|
|
1662
|
+
if (data.currency !== void 0) payload.currency = data.currency;
|
|
1663
|
+
if (data.notes !== void 0) payload.notes = data.notes;
|
|
1664
|
+
if (data.tags !== void 0) payload.tags = data.tags;
|
|
1665
|
+
const metadataBase = data.metadata !== void 0 ? { ...existingMetadata ?? {}, ...data.metadata } : existingMetadata;
|
|
1666
|
+
const metadataPatch = {
|
|
1667
|
+
partyName: data.partyName,
|
|
1668
|
+
assigneeName: data.assigneeName,
|
|
1669
|
+
source: data.source,
|
|
1670
|
+
tableId: data.tableId,
|
|
1671
|
+
tableName: data.tableName,
|
|
1672
|
+
estimatedMinutes: data.estimatedMinutes,
|
|
1673
|
+
restaurantStatus: data.status
|
|
1674
|
+
};
|
|
1675
|
+
if (data.metadata !== void 0 || Object.values(metadataPatch).some((value) => value !== void 0)) {
|
|
1676
|
+
payload.metadata = mergeOrdersMetadata(metadataBase, metadataPatch);
|
|
1677
|
+
}
|
|
1678
|
+
if (data.completedAt !== void 0) payload.completed_at = data.completedAt;
|
|
1679
|
+
return payload;
|
|
1933
1680
|
}
|
|
1934
|
-
function
|
|
1935
|
-
|
|
1936
|
-
if (
|
|
1937
|
-
|
|
1681
|
+
function filtersFromQuery(query) {
|
|
1682
|
+
const filters = [];
|
|
1683
|
+
if (query.kind && !Array.isArray(query.kind)) filters.push({ column: "kind", operator: "eq", value: query.kind });
|
|
1684
|
+
if (query.assigneeId) filters.push({ column: "assignee_id", operator: "eq", value: query.assigneeId });
|
|
1685
|
+
return filters;
|
|
1938
1686
|
}
|
|
1939
|
-
function
|
|
1940
|
-
if (
|
|
1941
|
-
|
|
1942
|
-
if (
|
|
1943
|
-
if (
|
|
1944
|
-
if (
|
|
1945
|
-
return
|
|
1687
|
+
function matchesClientQuery(order, query) {
|
|
1688
|
+
if (Array.isArray(query.kind) && !query.kind.includes(order.kind)) return false;
|
|
1689
|
+
if (Array.isArray(query.status) && !query.status.includes(order.status)) return false;
|
|
1690
|
+
if (query.status && !Array.isArray(query.status) && order.status !== query.status) return false;
|
|
1691
|
+
if (query.source && order.source !== query.source) return false;
|
|
1692
|
+
if (query.tableId && order.tableId !== query.tableId) return false;
|
|
1693
|
+
if (query.assigneeId && order.assigneeId !== query.assigneeId) return false;
|
|
1694
|
+
if (query.dateRange) {
|
|
1695
|
+
const created = dateKey(order.createdAt);
|
|
1696
|
+
if (created < query.dateRange.from || created > query.dateRange.to) return false;
|
|
1697
|
+
}
|
|
1698
|
+
if (query.search) {
|
|
1699
|
+
const search = query.search.toLowerCase();
|
|
1700
|
+
return order.referenceNumber.toLowerCase().includes(search) || (order.partyName?.toLowerCase().includes(search) ?? false) || (order.tableName?.toLowerCase().includes(search) ?? false) || order.items.some((item) => item.name.toLowerCase().includes(search));
|
|
1701
|
+
}
|
|
1702
|
+
return true;
|
|
1946
1703
|
}
|
|
1947
|
-
function
|
|
1948
|
-
|
|
1704
|
+
function paginate(items, page, pageSize) {
|
|
1705
|
+
const currentPage = page ?? 1;
|
|
1706
|
+
const limit = pageSize ?? 20;
|
|
1707
|
+
const start = (currentPage - 1) * limit;
|
|
1708
|
+
return { data: items.slice(start, start + limit), total: items.length };
|
|
1949
1709
|
}
|
|
1950
|
-
function
|
|
1951
|
-
const
|
|
1952
|
-
const
|
|
1953
|
-
const
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1710
|
+
function summarize(orders, dateRange) {
|
|
1711
|
+
const today = dateKey(nowIso());
|
|
1712
|
+
const from = dateRange?.from ?? today;
|
|
1713
|
+
const to = dateRange?.to ?? today;
|
|
1714
|
+
const inRange = orders.filter((order) => {
|
|
1715
|
+
const created = dateKey(order.createdAt);
|
|
1716
|
+
return created >= from && created <= to;
|
|
1717
|
+
});
|
|
1718
|
+
const billable = inRange.filter((order) => order.status !== "cancelled");
|
|
1719
|
+
const revenue = billable.reduce((sum, order) => sum + order.total, 0);
|
|
1720
|
+
const ordersByKind = { dine_in: 0, takeout: 0, delivery: 0 };
|
|
1721
|
+
const ordersByStatus = {};
|
|
1722
|
+
const top = /* @__PURE__ */ new Map();
|
|
1723
|
+
for (const order of inRange) {
|
|
1724
|
+
ordersByKind[order.kind] = (ordersByKind[order.kind] ?? 0) + 1;
|
|
1725
|
+
ordersByStatus[order.status] = (ordersByStatus[order.status] ?? 0) + 1;
|
|
1726
|
+
if (order.status === "cancelled") continue;
|
|
1727
|
+
for (const item of order.items) {
|
|
1728
|
+
const current = top.get(item.name) ?? { name: item.name, quantity: 0, revenue: 0 };
|
|
1729
|
+
current.quantity += item.quantity;
|
|
1730
|
+
current.revenue += item.total;
|
|
1731
|
+
top.set(item.name, current);
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
return {
|
|
1735
|
+
todayOrderCount: inRange.length,
|
|
1736
|
+
todayRevenue: revenue,
|
|
1737
|
+
averageTicket: billable.length > 0 ? revenue / billable.length : 0,
|
|
1738
|
+
activeOrderCount: orders.filter((order) => ACTIVE_STATUSES2.has(order.status)).length,
|
|
1739
|
+
ordersByKind,
|
|
1740
|
+
ordersByStatus,
|
|
1741
|
+
topItems: [...top.values()].sort((a, b) => b.quantity - a.quantity).slice(0, 5)
|
|
1742
|
+
};
|
|
1958
1743
|
}
|
|
1959
|
-
function
|
|
1960
|
-
const
|
|
1744
|
+
function createFayzOrdersProvider(options = {}) {
|
|
1745
|
+
const client = createFayzClient(options);
|
|
1746
|
+
const ordersTable = options.ordersTable ?? DEFAULT_ORDERS_TABLE;
|
|
1747
|
+
const orderItemsTable = options.orderItemsTable ?? DEFAULT_ORDER_ITEMS_TABLE;
|
|
1748
|
+
const tableOptions = { projectId: options.projectId, schema: options.schema, runtime: options.runtime };
|
|
1749
|
+
function resolveTenant() {
|
|
1750
|
+
const value = typeof options.tenantId === "function" ? options.tenantId() : options.tenantId;
|
|
1751
|
+
return value ?? void 0;
|
|
1752
|
+
}
|
|
1753
|
+
function resolveUnit() {
|
|
1754
|
+
const value = typeof options.unitId === "function" ? options.unitId() : options.unitId;
|
|
1755
|
+
return value ?? void 0;
|
|
1756
|
+
}
|
|
1757
|
+
function withTenant(filters) {
|
|
1758
|
+
const tenantId = resolveTenant();
|
|
1759
|
+
return tenantId ? [{ column: "tenant_id", operator: "eq", value: tenantId }, ...filters] : filters;
|
|
1760
|
+
}
|
|
1761
|
+
async function listItemRows(orderIds) {
|
|
1762
|
+
if (orderIds.length === 0) return [];
|
|
1763
|
+
const rows = [];
|
|
1764
|
+
await Promise.all(orderIds.map(async (orderId) => {
|
|
1765
|
+
const response = await client.data.listRows({
|
|
1766
|
+
...tableOptions,
|
|
1767
|
+
table: orderItemsTable,
|
|
1768
|
+
filters: [{ column: "order_id", operator: "eq", value: orderId }],
|
|
1769
|
+
sortColumn: "sort_order",
|
|
1770
|
+
sortDirection: "asc",
|
|
1771
|
+
limit: 200
|
|
1772
|
+
});
|
|
1773
|
+
rows.push(...response.rows);
|
|
1774
|
+
}));
|
|
1775
|
+
return rows;
|
|
1776
|
+
}
|
|
1777
|
+
async function hydrate(rows) {
|
|
1778
|
+
const itemRows = await listItemRows(rows.map((row) => row.id));
|
|
1779
|
+
const byOrder = /* @__PURE__ */ new Map();
|
|
1780
|
+
for (const itemRow of itemRows) {
|
|
1781
|
+
const item = rowToItem(itemRow);
|
|
1782
|
+
const list = byOrder.get(item.orderId) ?? [];
|
|
1783
|
+
list.push(item);
|
|
1784
|
+
byOrder.set(item.orderId, list);
|
|
1785
|
+
}
|
|
1786
|
+
return rows.map((row) => rowToOrder(row, byOrder.get(row.id) ?? []));
|
|
1787
|
+
}
|
|
1788
|
+
async function listOrders(query = {}) {
|
|
1789
|
+
const response = await client.data.listRows({
|
|
1790
|
+
...tableOptions,
|
|
1791
|
+
table: ordersTable,
|
|
1792
|
+
filters: withTenant(filtersFromQuery(query)),
|
|
1793
|
+
sortColumn: "created_at",
|
|
1794
|
+
sortDirection: "desc",
|
|
1795
|
+
limit: 500
|
|
1796
|
+
});
|
|
1797
|
+
return (await hydrate(response.rows)).filter((order) => matchesClientQuery(order, query));
|
|
1798
|
+
}
|
|
1799
|
+
async function getById(id) {
|
|
1800
|
+
const response = await client.data.listRows({
|
|
1801
|
+
...tableOptions,
|
|
1802
|
+
table: ordersTable,
|
|
1803
|
+
filters: withTenant([{ column: "id", operator: "eq", value: id }]),
|
|
1804
|
+
limit: 1
|
|
1805
|
+
});
|
|
1806
|
+
return (await hydrate(response.rows))[0] ?? null;
|
|
1807
|
+
}
|
|
1961
1808
|
return {
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1809
|
+
async getOrders(query) {
|
|
1810
|
+
const orders = await listOrders(query);
|
|
1811
|
+
return paginate(orders, query.page, query.pageSize);
|
|
1812
|
+
},
|
|
1813
|
+
async getOrderById(id) {
|
|
1814
|
+
return getById(id);
|
|
1815
|
+
},
|
|
1816
|
+
async createOrder(input) {
|
|
1817
|
+
const tenantId = resolveTenant();
|
|
1818
|
+
const unitId = resolveUnit();
|
|
1819
|
+
const orderRow = await client.data.createRow({
|
|
1820
|
+
...tableOptions,
|
|
1821
|
+
table: ordersTable,
|
|
1822
|
+
row: {
|
|
1823
|
+
...orderPayload(input),
|
|
1824
|
+
...tenantId ? { tenant_id: tenantId } : {},
|
|
1825
|
+
...unitId ? { unit_id: unitId } : {}
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1828
|
+
await Promise.all(input.items.map((item, index) => client.data.createRow({
|
|
1829
|
+
...tableOptions,
|
|
1830
|
+
table: orderItemsTable,
|
|
1831
|
+
row: itemToRow(item, orderRow.id, index, tenantId, unitId)
|
|
1832
|
+
})));
|
|
1833
|
+
return await getById(orderRow.id) ?? rowToOrder(orderRow);
|
|
1834
|
+
},
|
|
1835
|
+
async updateOrderStatus(input) {
|
|
1836
|
+
const completedAt = input.status === "completed" ? nowIso() : void 0;
|
|
1837
|
+
return this.updateOrder(input.orderId, { status: input.status, completedAt });
|
|
1838
|
+
},
|
|
1839
|
+
async updateOrder(id, data) {
|
|
1840
|
+
const existing = await getById(id);
|
|
1841
|
+
const row = await client.data.updateRow({
|
|
1842
|
+
...tableOptions,
|
|
1843
|
+
table: ordersTable,
|
|
1844
|
+
primaryKeys: { id },
|
|
1845
|
+
row: updatePayload(data, existing?.metadata)
|
|
1846
|
+
});
|
|
1847
|
+
return await getById(row.id) ?? rowToOrder(row);
|
|
1848
|
+
},
|
|
1849
|
+
async cancelOrder(id, reason) {
|
|
1850
|
+
const order = await getById(id);
|
|
1851
|
+
await this.updateOrder(id, {
|
|
1852
|
+
status: "cancelled",
|
|
1853
|
+
notes: reason ? `${order?.notes ? `${order.notes}
|
|
1854
|
+
` : ""}Cancelled: ${reason}` : order?.notes
|
|
1855
|
+
});
|
|
1856
|
+
},
|
|
1857
|
+
async addOrderItem(orderId, item) {
|
|
1858
|
+
const order = await getById(orderId);
|
|
1859
|
+
const row = await client.data.createRow({
|
|
1860
|
+
...tableOptions,
|
|
1861
|
+
table: orderItemsTable,
|
|
1862
|
+
row: itemToRow(item, orderId, order?.items.length ?? 0, order?.tenantId, order?.unitId ?? resolveUnit())
|
|
1863
|
+
});
|
|
1864
|
+
const created = rowToItem(row);
|
|
1865
|
+
const items = [...order?.items ?? [], created];
|
|
1866
|
+
await this.updateOrder(orderId, {
|
|
1867
|
+
subtotal: items.reduce((sum, orderItem) => sum + orderItem.total, 0),
|
|
1868
|
+
total: items.reduce((sum, orderItem) => sum + orderItem.total, 0) - (order?.discount ?? 0) + (order?.tax ?? 0)
|
|
1869
|
+
});
|
|
1870
|
+
return created;
|
|
1871
|
+
},
|
|
1872
|
+
async removeOrderItem(itemId) {
|
|
1873
|
+
const orders = await listOrders();
|
|
1874
|
+
const order = orders.find((item) => item.items.some((orderItem) => orderItem.id === itemId));
|
|
1875
|
+
await client.data.deleteRows({ ...tableOptions, table: orderItemsTable, rows: [{ id: itemId }] });
|
|
1876
|
+
if (order) {
|
|
1877
|
+
const items = order.items.filter((item) => item.id !== itemId);
|
|
1878
|
+
const subtotal = items.reduce((sum, item) => sum + item.total, 0);
|
|
1879
|
+
await this.updateOrder(order.id, { subtotal, total: subtotal - order.discount + order.tax });
|
|
1880
|
+
}
|
|
1881
|
+
},
|
|
1882
|
+
async updateOrderItem(itemId, data) {
|
|
1883
|
+
const existingResult = await client.data.listRows({
|
|
1884
|
+
...tableOptions,
|
|
1885
|
+
table: orderItemsTable,
|
|
1886
|
+
filters: [{ column: "id", operator: "eq", value: itemId }],
|
|
1887
|
+
limit: 1
|
|
1888
|
+
});
|
|
1889
|
+
const existingMetadata = existingResult.rows[0]?.metadata ?? void 0;
|
|
1890
|
+
const metadataPatch = {
|
|
1891
|
+
modifiers: data.modifiers,
|
|
1892
|
+
kitchenNotes: data.kitchenNotes
|
|
1893
|
+
};
|
|
1894
|
+
const row = await client.data.updateRow({
|
|
1895
|
+
...tableOptions,
|
|
1896
|
+
table: orderItemsTable,
|
|
1897
|
+
primaryKeys: { id: itemId },
|
|
1898
|
+
row: {
|
|
1899
|
+
product_id: data.productId,
|
|
1900
|
+
name: data.name,
|
|
1901
|
+
description: data.description,
|
|
1902
|
+
quantity: data.quantity,
|
|
1903
|
+
unit_price: data.unitPrice,
|
|
1904
|
+
discount: data.discount,
|
|
1905
|
+
total: data.total,
|
|
1906
|
+
sort_order: data.sortOrder,
|
|
1907
|
+
metadata: data.metadata !== void 0 || Object.values(metadataPatch).some((value) => value !== void 0) ? mergeOrdersMetadata(
|
|
1908
|
+
data.metadata !== void 0 ? { ...existingMetadata ?? {}, ...data.metadata } : existingMetadata,
|
|
1909
|
+
metadataPatch
|
|
1910
|
+
) : void 0
|
|
1911
|
+
}
|
|
1912
|
+
});
|
|
1913
|
+
return rowToItem(row);
|
|
1914
|
+
},
|
|
1915
|
+
async getSummary(dateRange) {
|
|
1916
|
+
return summarize(await listOrders({ dateRange }), dateRange);
|
|
1917
|
+
}
|
|
1976
1918
|
};
|
|
1977
1919
|
}
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1920
|
+
|
|
1921
|
+
// src/data/mock.ts
|
|
1922
|
+
var uid = 100;
|
|
1923
|
+
function nextId(prefix) {
|
|
1924
|
+
return prefix + "-" + ++uid;
|
|
1925
|
+
}
|
|
1926
|
+
var now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1927
|
+
function makeItem(orderId, name, quantity, unitPrice, sortOrder, productId) {
|
|
1928
|
+
const id = nextId("item");
|
|
1983
1929
|
return {
|
|
1984
|
-
id
|
|
1985
|
-
orderId
|
|
1986
|
-
productId
|
|
1987
|
-
name
|
|
1988
|
-
description: row.description ?? void 0,
|
|
1930
|
+
id,
|
|
1931
|
+
orderId,
|
|
1932
|
+
productId,
|
|
1933
|
+
name,
|
|
1989
1934
|
quantity,
|
|
1990
1935
|
unitPrice,
|
|
1991
|
-
discount,
|
|
1992
|
-
total:
|
|
1993
|
-
sortOrder
|
|
1994
|
-
|
|
1995
|
-
kitchenNotes: row.kitchen_notes ?? (typeof restaurant.kitchenNotes === "string" ? restaurant.kitchenNotes : void 0),
|
|
1996
|
-
metadata: row.metadata ?? {},
|
|
1997
|
-
createdAt: row.created_at ?? nowIso()
|
|
1936
|
+
discount: 0,
|
|
1937
|
+
total: quantity * unitPrice,
|
|
1938
|
+
sortOrder,
|
|
1939
|
+
createdAt: now
|
|
1998
1940
|
};
|
|
1999
1941
|
}
|
|
2000
|
-
function
|
|
2001
|
-
const
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
tableName: row.table_name ?? (typeof restaurant.tableName === "string" ? restaurant.tableName : void 0),
|
|
2025
|
-
estimatedMinutes: row.estimated_minutes ?? (typeof restaurant.estimatedMinutes === "number" ? restaurant.estimatedMinutes : void 0),
|
|
2026
|
-
items,
|
|
2027
|
-
metadata: row.metadata ?? {},
|
|
2028
|
-
tenantId: row.tenant_id ?? "runtime-tenant",
|
|
2029
|
-
unitId: row.unit_id ?? void 0,
|
|
2030
|
-
createdAt: row.created_at ?? nowIso(),
|
|
2031
|
-
updatedAt: row.updated_at ?? row.created_at ?? nowIso(),
|
|
2032
|
-
completedAt: row.completed_at ?? void 0
|
|
1942
|
+
function createSeedOrders() {
|
|
1943
|
+
const order1Id = nextId("order");
|
|
1944
|
+
const order1Items = [
|
|
1945
|
+
makeItem(order1Id, "Classic Burger", 1, 32, 0, "prod-burger-classic"),
|
|
1946
|
+
makeItem(order1Id, "Fries", 1, 15, 1, "prod-fries")
|
|
1947
|
+
];
|
|
1948
|
+
const order1 = {
|
|
1949
|
+
id: order1Id,
|
|
1950
|
+
referenceNumber: "ORD-0001",
|
|
1951
|
+
kind: "dine_in",
|
|
1952
|
+
status: "preparing",
|
|
1953
|
+
source: "pos",
|
|
1954
|
+
tableId: "table-3",
|
|
1955
|
+
tableName: "Table 3",
|
|
1956
|
+
subtotal: 47,
|
|
1957
|
+
discount: 0,
|
|
1958
|
+
tax: 0,
|
|
1959
|
+
total: 47,
|
|
1960
|
+
currency: "BRL",
|
|
1961
|
+
tags: [],
|
|
1962
|
+
items: order1Items,
|
|
1963
|
+
tenantId: "tenant-mock",
|
|
1964
|
+
createdAt: now,
|
|
1965
|
+
updatedAt: now
|
|
2033
1966
|
};
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
subtotal,
|
|
1967
|
+
const order2Id = nextId("order");
|
|
1968
|
+
const order2Items = [
|
|
1969
|
+
makeItem(order2Id, "Cheese Burger", 1, 36, 0, "prod-burger-cheese")
|
|
1970
|
+
];
|
|
1971
|
+
const order2 = {
|
|
1972
|
+
id: order2Id,
|
|
1973
|
+
referenceNumber: "ORD-0002",
|
|
1974
|
+
kind: "takeout",
|
|
1975
|
+
status: "ready",
|
|
1976
|
+
source: "pos",
|
|
1977
|
+
subtotal: 36,
|
|
1978
|
+
discount: 0,
|
|
1979
|
+
tax: 0,
|
|
1980
|
+
total: 36,
|
|
1981
|
+
currency: "BRL",
|
|
1982
|
+
tags: [],
|
|
1983
|
+
items: order2Items,
|
|
1984
|
+
tenantId: "tenant-mock",
|
|
1985
|
+
createdAt: now,
|
|
1986
|
+
updatedAt: now
|
|
1987
|
+
};
|
|
1988
|
+
const order3Id = nextId("order");
|
|
1989
|
+
const order3Items = [
|
|
1990
|
+
makeItem(order3Id, "Margherita Pizza", 1, 38, 0, "prod-pizza-margherita"),
|
|
1991
|
+
makeItem(order3Id, "Caesar Salad", 1, 22, 1, "prod-salad-caesar"),
|
|
1992
|
+
makeItem(order3Id, "Soda 350ml", 1, 12, 2, "prod-soda")
|
|
1993
|
+
];
|
|
1994
|
+
const order3 = {
|
|
1995
|
+
id: order3Id,
|
|
1996
|
+
referenceNumber: "ORD-0003",
|
|
1997
|
+
kind: "delivery",
|
|
1998
|
+
status: "confirmed",
|
|
1999
|
+
source: "ifood",
|
|
2000
|
+
subtotal: 72,
|
|
2001
|
+
discount: 0,
|
|
2002
|
+
tax: 0,
|
|
2003
|
+
total: 72,
|
|
2004
|
+
currency: "BRL",
|
|
2005
|
+
tags: [],
|
|
2006
|
+
items: order3Items,
|
|
2007
|
+
tenantId: "tenant-mock",
|
|
2008
|
+
createdAt: now,
|
|
2009
|
+
updatedAt: now
|
|
2010
|
+
};
|
|
2011
|
+
const order4Id = nextId("order");
|
|
2012
|
+
const order4Items = [
|
|
2013
|
+
makeItem(order4Id, "BBQ Bacon Burger", 1, 42, 0, "prod-burger-bbq")
|
|
2014
|
+
];
|
|
2015
|
+
const order4 = {
|
|
2016
|
+
id: order4Id,
|
|
2017
|
+
referenceNumber: "ORD-0004",
|
|
2018
|
+
kind: "dine_in",
|
|
2019
|
+
status: "new",
|
|
2020
|
+
source: "pos",
|
|
2021
|
+
tableId: "table-7",
|
|
2022
|
+
tableName: "Table 7",
|
|
2023
|
+
subtotal: 42,
|
|
2024
|
+
discount: 0,
|
|
2025
|
+
tax: 0,
|
|
2026
|
+
total: 42,
|
|
2027
|
+
currency: "BRL",
|
|
2028
|
+
tags: [],
|
|
2029
|
+
items: order4Items,
|
|
2030
|
+
tenantId: "tenant-mock",
|
|
2031
|
+
createdAt: now,
|
|
2032
|
+
updatedAt: now
|
|
2033
|
+
};
|
|
2034
|
+
const order5Id = nextId("order");
|
|
2035
|
+
const order5Items = [
|
|
2036
|
+
makeItem(order5Id, "Classic Burger", 2, 32, 0, "prod-burger-classic"),
|
|
2037
|
+
makeItem(order5Id, "Fries", 1, 15, 1, "prod-fries"),
|
|
2038
|
+
makeItem(order5Id, "Onion Rings", 1, 18, 2, "prod-onion-rings"),
|
|
2039
|
+
makeItem(order5Id, "Milkshake", 1, 23, 3, "prod-milkshake")
|
|
2040
|
+
];
|
|
2041
|
+
const order5 = {
|
|
2042
|
+
id: order5Id,
|
|
2043
|
+
referenceNumber: "ORD-0005",
|
|
2044
|
+
kind: "dine_in",
|
|
2045
|
+
status: "completed",
|
|
2046
|
+
source: "pos",
|
|
2047
|
+
tableId: "table-1",
|
|
2048
|
+
tableName: "Table 1",
|
|
2049
|
+
subtotal: 120,
|
|
2045
2050
|
discount: 0,
|
|
2046
2051
|
tax: 0,
|
|
2047
|
-
total:
|
|
2052
|
+
total: 120,
|
|
2048
2053
|
currency: "BRL",
|
|
2049
2054
|
tags: [],
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
})
|
|
2056
|
-
};
|
|
2057
|
-
}
|
|
2058
|
-
function updatePayload(data, existingMetadata) {
|
|
2059
|
-
const payload = {};
|
|
2060
|
-
if (data.referenceNumber !== void 0) payload.reference_number = data.referenceNumber;
|
|
2061
|
-
if (data.kind !== void 0) payload.kind = data.kind;
|
|
2062
|
-
if (data.status !== void 0) payload.status = canonicalStatus(data.status);
|
|
2063
|
-
if (data.partyId !== void 0) payload.party_id = data.partyId;
|
|
2064
|
-
if (data.assigneeId !== void 0) payload.assignee_id = data.assigneeId;
|
|
2065
|
-
if (data.locationId !== void 0) payload.location_id = data.locationId;
|
|
2066
|
-
if (data.subtotal !== void 0) payload.subtotal = data.subtotal;
|
|
2067
|
-
if (data.discount !== void 0) payload.discount = data.discount;
|
|
2068
|
-
if (data.tax !== void 0) payload.tax = data.tax;
|
|
2069
|
-
if (data.total !== void 0) payload.total = data.total;
|
|
2070
|
-
if (data.currency !== void 0) payload.currency = data.currency;
|
|
2071
|
-
if (data.notes !== void 0) payload.notes = data.notes;
|
|
2072
|
-
if (data.tags !== void 0) payload.tags = data.tags;
|
|
2073
|
-
const metadataBase = data.metadata !== void 0 ? { ...existingMetadata ?? {}, ...data.metadata } : existingMetadata;
|
|
2074
|
-
const metadataPatch = {
|
|
2075
|
-
partyName: data.partyName,
|
|
2076
|
-
assigneeName: data.assigneeName,
|
|
2077
|
-
source: data.source,
|
|
2078
|
-
tableId: data.tableId,
|
|
2079
|
-
tableName: data.tableName,
|
|
2080
|
-
estimatedMinutes: data.estimatedMinutes,
|
|
2081
|
-
restaurantStatus: data.status
|
|
2055
|
+
items: order5Items,
|
|
2056
|
+
tenantId: "tenant-mock",
|
|
2057
|
+
createdAt: now,
|
|
2058
|
+
updatedAt: now,
|
|
2059
|
+
completedAt: now
|
|
2082
2060
|
};
|
|
2083
|
-
|
|
2084
|
-
payload.metadata = mergeOrdersMetadata(metadataBase, metadataPatch);
|
|
2085
|
-
}
|
|
2086
|
-
if (data.completedAt !== void 0) payload.completed_at = data.completedAt;
|
|
2087
|
-
return payload;
|
|
2088
|
-
}
|
|
2089
|
-
function filtersFromQuery(query) {
|
|
2090
|
-
const filters = [];
|
|
2091
|
-
if (query.kind && !Array.isArray(query.kind)) filters.push({ column: "kind", operator: "eq", value: query.kind });
|
|
2092
|
-
if (query.assigneeId) filters.push({ column: "assignee_id", operator: "eq", value: query.assigneeId });
|
|
2093
|
-
return filters;
|
|
2061
|
+
return [order1, order2, order3, order4, order5];
|
|
2094
2062
|
}
|
|
2095
|
-
function
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
if (query.status && !Array.isArray(query.status) && order.status !== query.status) return false;
|
|
2099
|
-
if (query.source && order.source !== query.source) return false;
|
|
2100
|
-
if (query.tableId && order.tableId !== query.tableId) return false;
|
|
2101
|
-
if (query.assigneeId && order.assigneeId !== query.assigneeId) return false;
|
|
2102
|
-
if (query.dateRange) {
|
|
2103
|
-
const created = dateKey(order.createdAt);
|
|
2104
|
-
if (created < query.dateRange.from || created > query.dateRange.to) return false;
|
|
2105
|
-
}
|
|
2106
|
-
if (query.search) {
|
|
2107
|
-
const search = query.search.toLowerCase();
|
|
2108
|
-
return order.referenceNumber.toLowerCase().includes(search) || (order.partyName?.toLowerCase().includes(search) ?? false) || (order.tableName?.toLowerCase().includes(search) ?? false) || order.items.some((item) => item.name.toLowerCase().includes(search));
|
|
2109
|
-
}
|
|
2110
|
-
return true;
|
|
2063
|
+
function recomputeTotals(order) {
|
|
2064
|
+
order.subtotal = order.items.reduce((sum, i) => sum + i.total, 0);
|
|
2065
|
+
order.total = order.subtotal - order.discount + order.tax;
|
|
2111
2066
|
}
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
return { data: items.slice(start, start + limit), total: items.length };
|
|
2067
|
+
var refCounter = 5;
|
|
2068
|
+
function generateReferenceNumber() {
|
|
2069
|
+
refCounter++;
|
|
2070
|
+
return "ORD-" + String(refCounter).padStart(4, "0");
|
|
2117
2071
|
}
|
|
2118
|
-
function
|
|
2119
|
-
|
|
2120
|
-
const from = dateRange?.from ?? today;
|
|
2121
|
-
const to = dateRange?.to ?? today;
|
|
2122
|
-
const inRange = orders.filter((order) => {
|
|
2123
|
-
const created = dateKey(order.createdAt);
|
|
2124
|
-
return created >= from && created <= to;
|
|
2125
|
-
});
|
|
2126
|
-
const billable = inRange.filter((order) => order.status !== "cancelled");
|
|
2127
|
-
const revenue = billable.reduce((sum, order) => sum + order.total, 0);
|
|
2128
|
-
const ordersByKind = { dine_in: 0, takeout: 0, delivery: 0 };
|
|
2129
|
-
const ordersByStatus = {};
|
|
2130
|
-
const top = /* @__PURE__ */ new Map();
|
|
2131
|
-
for (const order of inRange) {
|
|
2132
|
-
ordersByKind[order.kind] = (ordersByKind[order.kind] ?? 0) + 1;
|
|
2133
|
-
ordersByStatus[order.status] = (ordersByStatus[order.status] ?? 0) + 1;
|
|
2134
|
-
if (order.status === "cancelled") continue;
|
|
2135
|
-
for (const item of order.items) {
|
|
2136
|
-
const current = top.get(item.name) ?? { name: item.name, quantity: 0, revenue: 0 };
|
|
2137
|
-
current.quantity += item.quantity;
|
|
2138
|
-
current.revenue += item.total;
|
|
2139
|
-
top.set(item.name, current);
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
return {
|
|
2143
|
-
todayOrderCount: inRange.length,
|
|
2144
|
-
todayRevenue: revenue,
|
|
2145
|
-
averageTicket: billable.length > 0 ? revenue / billable.length : 0,
|
|
2146
|
-
activeOrderCount: orders.filter((order) => ACTIVE_STATUSES2.has(order.status)).length,
|
|
2147
|
-
ordersByKind,
|
|
2148
|
-
ordersByStatus,
|
|
2149
|
-
topItems: [...top.values()].sort((a, b) => b.quantity - a.quantity).slice(0, 5)
|
|
2150
|
-
};
|
|
2072
|
+
function toDateStr(d) {
|
|
2073
|
+
return d.toISOString().slice(0, 10);
|
|
2151
2074
|
}
|
|
2152
|
-
function
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
const tableOptions = { projectId: options.projectId, schema: options.schema, runtime: options.runtime };
|
|
2157
|
-
function resolveTenant() {
|
|
2158
|
-
const value = typeof options.tenantId === "function" ? options.tenantId() : options.tenantId;
|
|
2159
|
-
return value ?? void 0;
|
|
2160
|
-
}
|
|
2161
|
-
function resolveUnit() {
|
|
2162
|
-
const value = typeof options.unitId === "function" ? options.unitId() : options.unitId;
|
|
2163
|
-
return value ?? void 0;
|
|
2164
|
-
}
|
|
2165
|
-
function withTenant(filters) {
|
|
2166
|
-
const tenantId = resolveTenant();
|
|
2167
|
-
return tenantId ? [{ column: "tenant_id", operator: "eq", value: tenantId }, ...filters] : filters;
|
|
2168
|
-
}
|
|
2169
|
-
async function listItemRows(orderIds) {
|
|
2170
|
-
if (orderIds.length === 0) return [];
|
|
2171
|
-
const rows = [];
|
|
2172
|
-
await Promise.all(orderIds.map(async (orderId) => {
|
|
2173
|
-
const response = await client.data.listRows({
|
|
2174
|
-
...tableOptions,
|
|
2175
|
-
table: orderItemsTable,
|
|
2176
|
-
filters: [{ column: "order_id", operator: "eq", value: orderId }],
|
|
2177
|
-
sortColumn: "sort_order",
|
|
2178
|
-
sortDirection: "asc",
|
|
2179
|
-
limit: 200
|
|
2180
|
-
});
|
|
2181
|
-
rows.push(...response.rows);
|
|
2182
|
-
}));
|
|
2183
|
-
return rows;
|
|
2075
|
+
function createMockOrdersProvider() {
|
|
2076
|
+
const orders = createSeedOrders();
|
|
2077
|
+
function findOrder(id) {
|
|
2078
|
+
return orders.find((o) => o.id === id);
|
|
2184
2079
|
}
|
|
2185
|
-
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
const item = rowToItem(itemRow);
|
|
2190
|
-
const list = byOrder.get(item.orderId) ?? [];
|
|
2191
|
-
list.push(item);
|
|
2192
|
-
byOrder.set(item.orderId, list);
|
|
2080
|
+
function findItem(itemId) {
|
|
2081
|
+
for (const order of orders) {
|
|
2082
|
+
const index = order.items.findIndex((i) => i.id === itemId);
|
|
2083
|
+
if (index !== -1) return { order, item: order.items[index], index };
|
|
2193
2084
|
}
|
|
2194
|
-
return
|
|
2195
|
-
}
|
|
2196
|
-
async function listOrders(query = {}) {
|
|
2197
|
-
const response = await client.data.listRows({
|
|
2198
|
-
...tableOptions,
|
|
2199
|
-
table: ordersTable,
|
|
2200
|
-
filters: withTenant(filtersFromQuery(query)),
|
|
2201
|
-
sortColumn: "created_at",
|
|
2202
|
-
sortDirection: "desc",
|
|
2203
|
-
limit: 500
|
|
2204
|
-
});
|
|
2205
|
-
return (await hydrate(response.rows)).filter((order) => matchesClientQuery(order, query));
|
|
2206
|
-
}
|
|
2207
|
-
async function getById(id) {
|
|
2208
|
-
const response = await client.data.listRows({
|
|
2209
|
-
...tableOptions,
|
|
2210
|
-
table: ordersTable,
|
|
2211
|
-
filters: withTenant([{ column: "id", operator: "eq", value: id }]),
|
|
2212
|
-
limit: 1
|
|
2213
|
-
});
|
|
2214
|
-
return (await hydrate(response.rows))[0] ?? null;
|
|
2085
|
+
return void 0;
|
|
2215
2086
|
}
|
|
2216
|
-
|
|
2087
|
+
const provider = {
|
|
2088
|
+
// ------------------------------------------------------------------
|
|
2089
|
+
// getOrders
|
|
2090
|
+
// ------------------------------------------------------------------
|
|
2217
2091
|
async getOrders(query) {
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2092
|
+
let result = [...orders];
|
|
2093
|
+
if (query.kind) {
|
|
2094
|
+
const kinds = Array.isArray(query.kind) ? query.kind : [query.kind];
|
|
2095
|
+
result = result.filter((o) => kinds.includes(o.kind));
|
|
2096
|
+
}
|
|
2097
|
+
if (query.status) {
|
|
2098
|
+
const statuses = Array.isArray(query.status) ? query.status : [query.status];
|
|
2099
|
+
result = result.filter((o) => statuses.includes(o.status));
|
|
2100
|
+
}
|
|
2101
|
+
if (query.source) {
|
|
2102
|
+
result = result.filter((o) => o.source === query.source);
|
|
2103
|
+
}
|
|
2104
|
+
if (query.tableId) {
|
|
2105
|
+
result = result.filter((o) => o.tableId === query.tableId);
|
|
2106
|
+
}
|
|
2107
|
+
if (query.assigneeId) {
|
|
2108
|
+
result = result.filter((o) => o.assigneeId === query.assigneeId);
|
|
2109
|
+
}
|
|
2110
|
+
if (query.search) {
|
|
2111
|
+
const q = query.search.toLowerCase();
|
|
2112
|
+
result = result.filter(
|
|
2113
|
+
(o) => o.referenceNumber.toLowerCase().includes(q) || o.partyName?.toLowerCase().includes(q) || o.tableName?.toLowerCase().includes(q) || o.items.some((i) => i.name.toLowerCase().includes(q))
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
if (query.dateRange) {
|
|
2117
|
+
const from = query.dateRange.from;
|
|
2118
|
+
const to = query.dateRange.to;
|
|
2119
|
+
result = result.filter((o) => {
|
|
2120
|
+
const d = o.createdAt.slice(0, 10);
|
|
2121
|
+
return d >= from && d <= to;
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
result.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
2125
|
+
const total = result.length;
|
|
2126
|
+
const page = query.page ?? 1;
|
|
2127
|
+
const pageSize = query.pageSize ?? 20;
|
|
2128
|
+
const start = (page - 1) * pageSize;
|
|
2129
|
+
const data = result.slice(start, start + pageSize);
|
|
2130
|
+
return { data, total };
|
|
2131
|
+
},
|
|
2132
|
+
// ------------------------------------------------------------------
|
|
2133
|
+
// getOrderById
|
|
2134
|
+
// ------------------------------------------------------------------
|
|
2135
|
+
async getOrderById(id) {
|
|
2136
|
+
return findOrder(id) ?? null;
|
|
2137
|
+
},
|
|
2138
|
+
// ------------------------------------------------------------------
|
|
2139
|
+
// createOrder
|
|
2140
|
+
// ------------------------------------------------------------------
|
|
2141
|
+
async createOrder(input) {
|
|
2142
|
+
const orderId = nextId("order");
|
|
2143
|
+
const items = input.items.map((item, idx) => ({
|
|
2144
|
+
id: nextId("item"),
|
|
2145
|
+
orderId,
|
|
2146
|
+
productId: item.productId,
|
|
2147
|
+
name: item.name,
|
|
2148
|
+
quantity: item.quantity,
|
|
2149
|
+
unitPrice: item.unitPrice,
|
|
2150
|
+
discount: item.discount ?? 0,
|
|
2151
|
+
total: item.quantity * item.unitPrice - (item.discount ?? 0),
|
|
2152
|
+
sortOrder: idx,
|
|
2153
|
+
modifiers: item.modifiers,
|
|
2154
|
+
kitchenNotes: item.kitchenNotes,
|
|
2155
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2156
|
+
}));
|
|
2157
|
+
const subtotal = items.reduce((sum, i) => sum + i.total, 0);
|
|
2158
|
+
const order = {
|
|
2159
|
+
id: orderId,
|
|
2160
|
+
referenceNumber: generateReferenceNumber(),
|
|
2161
|
+
kind: input.kind,
|
|
2162
|
+
status: "new",
|
|
2163
|
+
source: input.source ?? "pos",
|
|
2164
|
+
tableId: input.tableId,
|
|
2165
|
+
partyId: input.partyId,
|
|
2166
|
+
assigneeId: input.assigneeId,
|
|
2167
|
+
notes: input.notes,
|
|
2168
|
+
estimatedMinutes: input.estimatedMinutes,
|
|
2169
|
+
subtotal,
|
|
2170
|
+
discount: 0,
|
|
2171
|
+
tax: 0,
|
|
2172
|
+
total: subtotal,
|
|
2173
|
+
currency: "BRL",
|
|
2174
|
+
tags: [],
|
|
2175
|
+
items,
|
|
2176
|
+
tenantId: "tenant-mock",
|
|
2177
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2178
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2179
|
+
};
|
|
2180
|
+
orders.push(order);
|
|
2181
|
+
return order;
|
|
2242
2182
|
},
|
|
2183
|
+
// ------------------------------------------------------------------
|
|
2184
|
+
// updateOrderStatus
|
|
2185
|
+
// ------------------------------------------------------------------
|
|
2243
2186
|
async updateOrderStatus(input) {
|
|
2244
|
-
const
|
|
2245
|
-
|
|
2187
|
+
const order = findOrder(input.orderId);
|
|
2188
|
+
if (!order) throw new Error(`Order not found: ${input.orderId}`);
|
|
2189
|
+
if (input.status !== "cancelled") {
|
|
2190
|
+
const flow = STATUS_FLOW[order.kind];
|
|
2191
|
+
const currentIdx = flow.indexOf(order.status);
|
|
2192
|
+
const targetIdx = flow.indexOf(input.status);
|
|
2193
|
+
if (targetIdx < 0 || targetIdx !== currentIdx && targetIdx !== currentIdx + 1) {
|
|
2194
|
+
const next = getNextStatus(order.kind, order.status);
|
|
2195
|
+
throw new Error(
|
|
2196
|
+
`Invalid status transition: ${order.status} \u2192 ${input.status}. ` + (next ? `Expected next status: ${next}` : "Order is already in a terminal state.")
|
|
2197
|
+
);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
order.status = input.status;
|
|
2201
|
+
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2202
|
+
if (input.status === "completed") {
|
|
2203
|
+
order.completedAt = order.updatedAt;
|
|
2204
|
+
}
|
|
2205
|
+
return order;
|
|
2246
2206
|
},
|
|
2207
|
+
// ------------------------------------------------------------------
|
|
2208
|
+
// updateOrder
|
|
2209
|
+
// ------------------------------------------------------------------
|
|
2247
2210
|
async updateOrder(id, data) {
|
|
2248
|
-
const
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
});
|
|
2255
|
-
return await getById(row.id) ?? rowToOrder(row);
|
|
2211
|
+
const order = findOrder(id);
|
|
2212
|
+
if (!order) throw new Error(`Order not found: ${id}`);
|
|
2213
|
+
const { id: _id, items: _items, tenantId: _t, createdAt: _c, ...safe } = data;
|
|
2214
|
+
Object.assign(order, safe);
|
|
2215
|
+
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2216
|
+
return order;
|
|
2256
2217
|
},
|
|
2218
|
+
// ------------------------------------------------------------------
|
|
2219
|
+
// cancelOrder
|
|
2220
|
+
// ------------------------------------------------------------------
|
|
2257
2221
|
async cancelOrder(id, reason) {
|
|
2258
|
-
const order =
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2222
|
+
const order = findOrder(id);
|
|
2223
|
+
if (!order) throw new Error(`Order not found: ${id}`);
|
|
2224
|
+
order.status = "cancelled";
|
|
2225
|
+
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2226
|
+
if (reason) {
|
|
2227
|
+
order.notes = order.notes ? `${order.notes}
|
|
2228
|
+
Cancelled: ${reason}` : `Cancelled: ${reason}`;
|
|
2229
|
+
}
|
|
2264
2230
|
},
|
|
2231
|
+
// ------------------------------------------------------------------
|
|
2232
|
+
// addOrderItem
|
|
2233
|
+
// ------------------------------------------------------------------
|
|
2265
2234
|
async addOrderItem(orderId, item) {
|
|
2266
|
-
const order =
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
total:
|
|
2277
|
-
|
|
2278
|
-
|
|
2235
|
+
const order = findOrder(orderId);
|
|
2236
|
+
if (!order) throw new Error(`Order not found: ${orderId}`);
|
|
2237
|
+
const newItem = {
|
|
2238
|
+
id: nextId("item"),
|
|
2239
|
+
orderId,
|
|
2240
|
+
productId: item.productId,
|
|
2241
|
+
name: item.name,
|
|
2242
|
+
quantity: item.quantity,
|
|
2243
|
+
unitPrice: item.unitPrice,
|
|
2244
|
+
discount: item.discount ?? 0,
|
|
2245
|
+
total: item.quantity * item.unitPrice - (item.discount ?? 0),
|
|
2246
|
+
sortOrder: order.items.length,
|
|
2247
|
+
modifiers: item.modifiers,
|
|
2248
|
+
kitchenNotes: item.kitchenNotes,
|
|
2249
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2250
|
+
};
|
|
2251
|
+
order.items.push(newItem);
|
|
2252
|
+
recomputeTotals(order);
|
|
2253
|
+
order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2254
|
+
return newItem;
|
|
2279
2255
|
},
|
|
2256
|
+
// ------------------------------------------------------------------
|
|
2257
|
+
// removeOrderItem
|
|
2258
|
+
// ------------------------------------------------------------------
|
|
2280
2259
|
async removeOrderItem(itemId) {
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
const subtotal = items.reduce((sum, item) => sum + item.total, 0);
|
|
2287
|
-
await this.updateOrder(order.id, { subtotal, total: subtotal - order.discount + order.tax });
|
|
2288
|
-
}
|
|
2260
|
+
const found = findItem(itemId);
|
|
2261
|
+
if (!found) throw new Error(`Order item not found: ${itemId}`);
|
|
2262
|
+
found.order.items.splice(found.index, 1);
|
|
2263
|
+
recomputeTotals(found.order);
|
|
2264
|
+
found.order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2289
2265
|
},
|
|
2266
|
+
// ------------------------------------------------------------------
|
|
2267
|
+
// updateOrderItem
|
|
2268
|
+
// ------------------------------------------------------------------
|
|
2290
2269
|
async updateOrderItem(itemId, data) {
|
|
2291
|
-
const
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
modifiers: data.modifiers,
|
|
2300
|
-
kitchenNotes: data.kitchenNotes
|
|
2301
|
-
};
|
|
2302
|
-
const row = await client.data.updateRow({
|
|
2303
|
-
...tableOptions,
|
|
2304
|
-
table: orderItemsTable,
|
|
2305
|
-
primaryKeys: { id: itemId },
|
|
2306
|
-
row: {
|
|
2307
|
-
product_id: data.productId,
|
|
2308
|
-
name: data.name,
|
|
2309
|
-
description: data.description,
|
|
2310
|
-
quantity: data.quantity,
|
|
2311
|
-
unit_price: data.unitPrice,
|
|
2312
|
-
discount: data.discount,
|
|
2313
|
-
total: data.total,
|
|
2314
|
-
sort_order: data.sortOrder,
|
|
2315
|
-
metadata: data.metadata !== void 0 || Object.values(metadataPatch).some((value) => value !== void 0) ? mergeOrdersMetadata(
|
|
2316
|
-
data.metadata !== void 0 ? { ...existingMetadata ?? {}, ...data.metadata } : existingMetadata,
|
|
2317
|
-
metadataPatch
|
|
2318
|
-
) : void 0
|
|
2319
|
-
}
|
|
2320
|
-
});
|
|
2321
|
-
return rowToItem(row);
|
|
2270
|
+
const found = findItem(itemId);
|
|
2271
|
+
if (!found) throw new Error(`Order item not found: ${itemId}`);
|
|
2272
|
+
const { id: _id, orderId: _oid, createdAt: _c, ...safe } = data;
|
|
2273
|
+
Object.assign(found.item, safe);
|
|
2274
|
+
found.item.total = found.item.quantity * found.item.unitPrice - found.item.discount;
|
|
2275
|
+
recomputeTotals(found.order);
|
|
2276
|
+
found.order.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2277
|
+
return found.item;
|
|
2322
2278
|
},
|
|
2279
|
+
// ------------------------------------------------------------------
|
|
2280
|
+
// getSummary
|
|
2281
|
+
// ------------------------------------------------------------------
|
|
2323
2282
|
async getSummary(dateRange) {
|
|
2324
|
-
|
|
2283
|
+
const today = toDateStr(/* @__PURE__ */ new Date());
|
|
2284
|
+
const from = dateRange?.from ?? today;
|
|
2285
|
+
const to = dateRange?.to ?? today;
|
|
2286
|
+
const inRange = orders.filter((o) => {
|
|
2287
|
+
const d = o.createdAt.slice(0, 10);
|
|
2288
|
+
return d >= from && d <= to;
|
|
2289
|
+
});
|
|
2290
|
+
const completed = inRange.filter((o) => o.status !== "cancelled");
|
|
2291
|
+
const revenue = completed.reduce((sum, o) => sum + o.total, 0);
|
|
2292
|
+
const activeStatuses = /* @__PURE__ */ new Set(["new", "confirmed", "preparing", "ready", "served", "dispatched"]);
|
|
2293
|
+
const active = orders.filter((o) => activeStatuses.has(o.status));
|
|
2294
|
+
const ordersByKind = { dine_in: 0, takeout: 0, delivery: 0 };
|
|
2295
|
+
const ordersByStatus = {};
|
|
2296
|
+
for (const o of inRange) {
|
|
2297
|
+
ordersByKind[o.kind] = (ordersByKind[o.kind] || 0) + 1;
|
|
2298
|
+
ordersByStatus[o.status] = (ordersByStatus[o.status] || 0) + 1;
|
|
2299
|
+
}
|
|
2300
|
+
const itemMap = /* @__PURE__ */ new Map();
|
|
2301
|
+
for (const o of completed) {
|
|
2302
|
+
for (const item of o.items) {
|
|
2303
|
+
const existing = itemMap.get(item.name);
|
|
2304
|
+
if (existing) {
|
|
2305
|
+
existing.quantity += item.quantity;
|
|
2306
|
+
existing.revenue += item.total;
|
|
2307
|
+
} else {
|
|
2308
|
+
itemMap.set(item.name, { name: item.name, quantity: item.quantity, revenue: item.total });
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
const topItems = Array.from(itemMap.values()).sort((a, b) => b.quantity - a.quantity).slice(0, 5);
|
|
2313
|
+
return {
|
|
2314
|
+
todayOrderCount: inRange.length,
|
|
2315
|
+
todayRevenue: revenue,
|
|
2316
|
+
averageTicket: completed.length > 0 ? revenue / completed.length : 0,
|
|
2317
|
+
activeOrderCount: active.length,
|
|
2318
|
+
ordersByKind,
|
|
2319
|
+
ordersByStatus,
|
|
2320
|
+
topItems
|
|
2321
|
+
};
|
|
2325
2322
|
}
|
|
2326
2323
|
};
|
|
2324
|
+
return provider;
|
|
2327
2325
|
}
|
|
2328
2326
|
|
|
2329
2327
|
// src/index.ts
|
|
2330
|
-
var OrdersPage =
|
|
2328
|
+
var OrdersPage = React.lazy(() => import('./OrdersPage-5326V62H.js').then((m) => ({ default: m.OrdersPage })));
|
|
2329
|
+
var OrderDetailRoute = React.lazy(() => import('./OrderDetailRoute-LTPDQXQU.js').then((m) => ({ default: m.OrderDetailRoute })));
|
|
2331
2330
|
var DEFAULT_LABELS = {
|
|
2332
2331
|
pageTitle: "Orders",
|
|
2333
2332
|
kanban: "Orders",
|
|
@@ -2355,65 +2354,29 @@ function resolveConfig(options) {
|
|
|
2355
2354
|
createRoute: options?.createRoute,
|
|
2356
2355
|
editRoute: options?.editRoute,
|
|
2357
2356
|
canEditOrder: options?.canEditOrder,
|
|
2358
|
-
orderRoute: options?.orderRoute
|
|
2359
|
-
floorView: options?.floorView !== false,
|
|
2360
|
-
boardView: options?.boardView !== false,
|
|
2361
|
-
deliveryRoute: options?.deliveryRoute,
|
|
2362
|
-
detailRail: options?.detailRail ?? "operate"
|
|
2357
|
+
orderRoute: options?.orderRoute
|
|
2363
2358
|
};
|
|
2364
2359
|
}
|
|
2365
2360
|
function createOrdersPlugin(options) {
|
|
2366
2361
|
const config = resolveConfig(options);
|
|
2367
|
-
const provider = options?.dataProvider ??
|
|
2362
|
+
const provider = options?.dataProvider ?? createCoreOrdersProvider();
|
|
2368
2363
|
const store7 = createOrdersStore(provider, {
|
|
2369
2364
|
onOrderCompleted: config.onOrderCompleted,
|
|
2370
2365
|
onOrderCancelled: config.onOrderCancelled
|
|
2371
2366
|
});
|
|
2372
|
-
const
|
|
2373
|
-
|
|
2367
|
+
const PageComponent = () => React.createElement(
|
|
2368
|
+
React.Suspense,
|
|
2374
2369
|
{ fallback: null },
|
|
2375
|
-
|
|
2376
|
-
config: extra ? { ...config, ...extra } : config,
|
|
2377
|
-
provider,
|
|
2378
|
-
store: store7,
|
|
2379
|
-
registries: ordersRegistries,
|
|
2380
|
-
variant: options?.variant ?? "restaurant"
|
|
2381
|
-
})
|
|
2370
|
+
React.createElement(OrdersPage, { config, provider, store: store7, registries: ordersRegistries })
|
|
2382
2371
|
);
|
|
2383
|
-
const
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
// always had the slot; nobody was filling it.
|
|
2390
|
-
actions: (order) => {
|
|
2391
|
-
const edit = options?.editRoute;
|
|
2392
|
-
if (!edit) return null;
|
|
2393
|
-
const allowed = options?.canEditOrder ?? orderIsEditable;
|
|
2394
|
-
if (!allowed(order)) return null;
|
|
2395
|
-
return React2__default.createElement(PageActions, {
|
|
2396
|
-
actions: [{
|
|
2397
|
-
id: "edit",
|
|
2398
|
-
testId: "order-edit",
|
|
2399
|
-
label: "Editar pedido",
|
|
2400
|
-
icon: Pencil,
|
|
2401
|
-
intent: "primary",
|
|
2402
|
-
onSelect: () => adminNavigateTo(edit(order.id))
|
|
2403
|
-
}]
|
|
2404
|
-
});
|
|
2405
|
-
},
|
|
2406
|
-
// Os verbos do dinheiro. O seam existia desde a primeira passada do
|
|
2407
|
-
// archetype e nunca foi preenchido fora da loja — entao a tela sabia
|
|
2408
|
-
// dizer "sem conta a receber" e nao oferecia como criar uma. Ver
|
|
2409
|
-
// ./views/OrderReceivableActions.
|
|
2410
|
-
receivableActions: (order, ctx) => React2__default.createElement(OrderReceivableActions, {
|
|
2411
|
-
orderId: order.id,
|
|
2412
|
-
orderTotal: order.total ?? 0,
|
|
2413
|
-
receivable: ctx.receivable,
|
|
2414
|
-
reload: ctx.reload
|
|
2372
|
+
const DetailComponent = ({ id }) => React.createElement(
|
|
2373
|
+
React.Suspense,
|
|
2374
|
+
{ fallback: null },
|
|
2375
|
+
React.createElement(OrderDetailRoute, {
|
|
2376
|
+
id,
|
|
2377
|
+
options: { editRoute: options?.editRoute, canEditOrder: options?.canEditOrder }
|
|
2415
2378
|
})
|
|
2416
|
-
|
|
2379
|
+
);
|
|
2417
2380
|
return {
|
|
2418
2381
|
id: "orders",
|
|
2419
2382
|
// Como esta conta refaz o módulo com as opções DELA. Ver PluginRebuild:
|
|
@@ -2430,7 +2393,9 @@ function createOrdersPlugin(options) {
|
|
|
2430
2393
|
scope: options?.scope ?? "vertical",
|
|
2431
2394
|
verticalId: options?.verticalId,
|
|
2432
2395
|
defaultEnabled: true,
|
|
2433
|
-
|
|
2396
|
+
// No `menu`: a sale is not a restaurant's, and a dependency lights up by
|
|
2397
|
+
// drag — every account with Orders would grow a Cardápio line.
|
|
2398
|
+
dependencies: [],
|
|
2434
2399
|
events: [
|
|
2435
2400
|
{
|
|
2436
2401
|
name: "orders.order_completed",
|
|
@@ -2487,17 +2452,9 @@ function createOrdersPlugin(options) {
|
|
|
2487
2452
|
component: PageComponent,
|
|
2488
2453
|
permission: { feature: "orders", action: "read" }
|
|
2489
2454
|
},
|
|
2490
|
-
...options?.deliveryRoute ? [{
|
|
2491
|
-
path: options.deliveryRoute,
|
|
2492
|
-
component: DeliveryRoute,
|
|
2493
|
-
permission: { feature: "orders", action: "read" }
|
|
2494
|
-
}] : [],
|
|
2495
2455
|
{
|
|
2496
|
-
// The page the rail's "Ver pedido completo" points at. It used to exist
|
|
2497
|
-
// only in plugin-shop, so the restaurant's link opened a blank screen —
|
|
2498
|
-
// the route was never mounted, not the data missing.
|
|
2499
2456
|
path: "/orders/:id",
|
|
2500
|
-
component:
|
|
2457
|
+
component: DetailComponent,
|
|
2501
2458
|
permission: { feature: "orders", action: "read" }
|
|
2502
2459
|
}
|
|
2503
2460
|
],
|
|
@@ -2568,7 +2525,7 @@ function createOrdersPlugin(options) {
|
|
|
2568
2525
|
label: config.labels.pageTitle,
|
|
2569
2526
|
icon: "ClipboardList",
|
|
2570
2527
|
component: (() => {
|
|
2571
|
-
const OrdersSettingsTab = () =>
|
|
2528
|
+
const OrdersSettingsTab = () => React.createElement(PluginSettingsPanel, {
|
|
2572
2529
|
title: "Orders Settings",
|
|
2573
2530
|
registries: ordersRegistries,
|
|
2574
2531
|
routeBase: "/settings/orders"
|
|
@@ -2588,10 +2545,10 @@ function createOrdersPlugin(options) {
|
|
|
2588
2545
|
label: "Delivery",
|
|
2589
2546
|
icon: "Bike",
|
|
2590
2547
|
component: (() => {
|
|
2591
|
-
const DeliverySettingsTab = () =>
|
|
2592
|
-
|
|
2548
|
+
const DeliverySettingsTab = () => React.createElement(
|
|
2549
|
+
React.Suspense,
|
|
2593
2550
|
{ fallback: null },
|
|
2594
|
-
|
|
2551
|
+
React.createElement(DeliverySettings)
|
|
2595
2552
|
);
|
|
2596
2553
|
DeliverySettingsTab.displayName = "DeliverySettingsTab";
|
|
2597
2554
|
return DeliverySettingsTab;
|
|
@@ -2616,6 +2573,6 @@ function createOrdersPlugin(options) {
|
|
|
2616
2573
|
};
|
|
2617
2574
|
}
|
|
2618
2575
|
|
|
2619
|
-
export { AIQFOME_CONNECTOR_ID, AIQFOME_SETTINGS, AUTO_ACCEPT_SETTING, IFOOD_CONNECTOR_ID, IFOOD_SETTINGS, KEETA_CONNECTOR_ID, KEETA_SETTINGS, NINETY_NINE_FOOD_CONNECTOR_ID, NINETY_NINE_FOOD_SETTINGS, PREP_TIME_SETTING, RAPPI_CONNECTOR_ID, RAPPI_SETTINGS, UBER_EATS_CONNECTOR_ID, UBER_EATS_SETTINGS, aiqfomeConnectorDef, createCoreOrdersProvider, createFayzOrdersProvider, createOrdersPlugin, ifoodConnectorDef, keetaConnectorDef, marketplacePermissions, nineNineFoodConnectorDef, rappiConnectorDef, uberEatsConnectorDef };
|
|
2576
|
+
export { ADVANCE_VERB, AIQFOME_CONNECTOR_ID, AIQFOME_SETTINGS, AUTO_ACCEPT_SETTING, DEFAULT_STATUS_CONFIGS, IFOOD_CONNECTOR_ID, IFOOD_SETTINGS, KANBAN_COLUMNS, KEETA_CONNECTOR_ID, KEETA_SETTINGS, NINETY_NINE_FOOD_CONNECTOR_ID, NINETY_NINE_FOOD_SETTINGS, PREP_TIME_SETTING, RAPPI_CONNECTOR_ID, RAPPI_SETTINGS, STATUS_FLOW, UBER_EATS_CONNECTOR_ID, UBER_EATS_SETTINGS, aiqfomeConnectorDef, createCoreOrdersProvider, createFayzOrdersProvider, createMockOrdersProvider, createOrdersPlugin, getNextStatus, getPreviousStatus, ifoodConnectorDef, keetaConnectorDef, mapToKanbanColumn, marketplacePermissions, nineNineFoodConnectorDef, rappiConnectorDef, uberEatsConnectorDef };
|
|
2620
2577
|
//# sourceMappingURL=index.js.map
|
|
2621
2578
|
//# sourceMappingURL=index.js.map
|