@teincfood/core 0.9.24 → 0.9.25
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/db/migrations.js +25 -0
- package/dist/db/operations.d.ts +7 -0
- package/dist/db/operations.js +95 -17
- package/dist/domain/orders/order-flow.d.ts +41 -0
- package/dist/domain/orders/order-flow.js +66 -0
- package/dist/domain/orders/service.js +7 -2
- package/dist/hooks/delivery.hooks.d.ts +24 -24
- package/dist/hooks/rider.hooks.d.ts +48 -48
- package/dist/hooks/use-infinite-list.d.ts +24 -24
- package/dist/hooks/wallet.hooks.d.ts +24 -24
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sync/order-merge.js +7 -2
- package/dist/sync/order-snapshots.service.js +17 -1
- package/dist/test-helpers/memory-driver.js +17 -10
- package/dist/types/api/business.api.d.ts +7 -0
- package/package.json +2 -2
package/dist/db/migrations.js
CHANGED
|
@@ -423,4 +423,29 @@ export const MIGRATIONS = [
|
|
|
423
423
|
`);
|
|
424
424
|
},
|
|
425
425
|
},
|
|
426
|
+
{
|
|
427
|
+
version: 12,
|
|
428
|
+
up: async (db) => {
|
|
429
|
+
// Payment timestamp at the top level of the order.
|
|
430
|
+
//
|
|
431
|
+
// The server returns `paid_at` on the order and (for cash sales taken at
|
|
432
|
+
// the till) no payment transaction at all. Keeping the timestamp only
|
|
433
|
+
// inside the `payment` JSON blob meant every pull overwrote a locally
|
|
434
|
+
// paid cash order with the server's `{is_paid:false, paid_at:null}`,
|
|
435
|
+
// so the row read back as UNPAID. One column, backfilled from the blob,
|
|
436
|
+
// is the single local source of truth.
|
|
437
|
+
await db.execAsync(`
|
|
438
|
+
ALTER TABLE orders ADD COLUMN paid_at TEXT;
|
|
439
|
+
`);
|
|
440
|
+
try {
|
|
441
|
+
await db.execAsync(`
|
|
442
|
+
UPDATE orders
|
|
443
|
+
SET paid_at = json_extract(payment, '$.paid_at')
|
|
444
|
+
WHERE paid_at IS NULL
|
|
445
|
+
AND json_extract(payment, '$.paid_at') IS NOT NULL;
|
|
446
|
+
`);
|
|
447
|
+
}
|
|
448
|
+
catch { }
|
|
449
|
+
},
|
|
450
|
+
},
|
|
426
451
|
];
|
package/dist/db/operations.d.ts
CHANGED
|
@@ -66,10 +66,17 @@ export interface OrderRow {
|
|
|
66
66
|
inserted_at: string;
|
|
67
67
|
updated_at: string | null;
|
|
68
68
|
hlc: string | null;
|
|
69
|
+
paid_at?: string | null;
|
|
69
70
|
deleted_at: string | null;
|
|
70
71
|
sync_failed_at?: string | null;
|
|
71
72
|
sync_error?: string | null;
|
|
72
73
|
}
|
|
74
|
+
/** True when the order has any recorded payment. */
|
|
75
|
+
export declare function isOrderPaid(order: {
|
|
76
|
+
is_paid?: boolean;
|
|
77
|
+
paid_at?: string | null;
|
|
78
|
+
payment?: unknown;
|
|
79
|
+
} | null | undefined): boolean;
|
|
73
80
|
export declare function insertOrder(db: SQLiteDatabase, order: import("../types/api/seller.api").SellerOrder & {
|
|
74
81
|
hlc?: string;
|
|
75
82
|
}): Promise<void>;
|
package/dist/db/operations.js
CHANGED
|
@@ -198,7 +198,47 @@ function rowToDomainEvent(row) {
|
|
|
198
198
|
timestamp: row.timestamp,
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
+
const EMPTY_PAYMENT = {
|
|
202
|
+
is_paid: false,
|
|
203
|
+
reference: null,
|
|
204
|
+
amount_minor: null,
|
|
205
|
+
currency: null,
|
|
206
|
+
paid_at: null,
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Effective payment of a stored order.
|
|
210
|
+
*
|
|
211
|
+
* `payment` (server payment summary) is the primary shape, but the order's
|
|
212
|
+
* own `paid_at` column wins when the server did not report a payment. Cash
|
|
213
|
+
* sales taken at a POS terminal only carry `paid_at` — no payment
|
|
214
|
+
* transaction — so reading the blob alone made them look unpaid.
|
|
215
|
+
*/
|
|
216
|
+
function paymentStateOf(row) {
|
|
217
|
+
let parsed = {};
|
|
218
|
+
if (row.payment) {
|
|
219
|
+
try {
|
|
220
|
+
const value = JSON.parse(row.payment);
|
|
221
|
+
if (value && typeof value === "object")
|
|
222
|
+
parsed = value;
|
|
223
|
+
}
|
|
224
|
+
catch { }
|
|
225
|
+
}
|
|
226
|
+
const payment = { ...EMPTY_PAYMENT, ...parsed };
|
|
227
|
+
const paidAt = payment.paid_at ?? row.paid_at ?? null;
|
|
228
|
+
const isPaid = payment.is_paid === true || !!paidAt;
|
|
229
|
+
return { payment: { ...payment, paid_at: paidAt, is_paid: isPaid }, isPaid, paidAt };
|
|
230
|
+
}
|
|
231
|
+
/** True when the order has any recorded payment. */
|
|
232
|
+
export function isOrderPaid(order) {
|
|
233
|
+
if (!order)
|
|
234
|
+
return false;
|
|
235
|
+
if (order.is_paid === true || order.paid_at)
|
|
236
|
+
return true;
|
|
237
|
+
const payment = order.payment;
|
|
238
|
+
return payment?.is_paid === true || !!payment?.paid_at;
|
|
239
|
+
}
|
|
201
240
|
function orderRowToSellerOrder(row) {
|
|
241
|
+
const { payment, isPaid, paidAt } = paymentStateOf(row);
|
|
202
242
|
return {
|
|
203
243
|
id: row.id,
|
|
204
244
|
business_id: row.business_id,
|
|
@@ -212,7 +252,7 @@ function orderRowToSellerOrder(row) {
|
|
|
212
252
|
total_minor: row.total_minor,
|
|
213
253
|
tax_minor: row.tax_minor,
|
|
214
254
|
tax_lines: row.tax_lines ? JSON.parse(row.tax_lines) : [],
|
|
215
|
-
payment
|
|
255
|
+
payment,
|
|
216
256
|
customer_name: row.customer_name,
|
|
217
257
|
customer_phone: row.customer_phone,
|
|
218
258
|
pos_payment_method: row.pos_payment_method,
|
|
@@ -222,15 +262,15 @@ function orderRowToSellerOrder(row) {
|
|
|
222
262
|
delivery_lat: null,
|
|
223
263
|
delivery_lng: null,
|
|
224
264
|
user: row.user ? JSON.parse(row.user) : null,
|
|
225
|
-
currency:
|
|
226
|
-
currency_code:
|
|
265
|
+
currency: payment.currency ?? "GHS",
|
|
266
|
+
currency_code: payment.currency ?? "GHS",
|
|
227
267
|
discount_minor: 0,
|
|
228
268
|
promo_code: null,
|
|
229
269
|
tip_minor: null,
|
|
230
270
|
delivery_fee_minor: 0,
|
|
231
271
|
delivery_status: null,
|
|
232
|
-
is_paid:
|
|
233
|
-
paid_at:
|
|
272
|
+
is_paid: isPaid,
|
|
273
|
+
paid_at: paidAt,
|
|
234
274
|
inserted_at: row.inserted_at,
|
|
235
275
|
updated_at: row.updated_at ?? row.inserted_at,
|
|
236
276
|
sync_failed_at: row.sync_failed_at ?? null,
|
|
@@ -240,10 +280,13 @@ function orderRowToSellerOrder(row) {
|
|
|
240
280
|
export async function insertOrder(db, order) {
|
|
241
281
|
const hlc = order.hlc ?? new Date().toISOString();
|
|
242
282
|
const updatedAt = order.updated_at ?? order.inserted_at;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
283
|
+
const paidAt = order.paid_at ??
|
|
284
|
+
order.payment?.paid_at ??
|
|
285
|
+
(isOrderPaid(order) ? updatedAt : null);
|
|
286
|
+
await db.runAsync(`INSERT INTO orders (id, business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, paid_at, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, updated_at, hlc)
|
|
287
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
288
|
+
ON CONFLICT(id) DO UPDATE SET business_id=excluded.business_id, order_number=excluded.order_number, callout_number=excluded.callout_number, status=excluded.status, order_type=excluded.order_type, is_pos=excluded.is_pos, items=excluded.items, subtotal_minor=excluded.subtotal_minor, total_minor=excluded.total_minor, tax_minor=excluded.tax_minor, tax_lines=excluded.tax_lines, payment=excluded.payment, paid_at=COALESCE(excluded.paid_at, orders.paid_at), customer_name=excluded.customer_name, customer_phone=excluded.customer_phone, pos_payment_method=excluded.pos_payment_method, delivery_id=excluded.delivery_id, business=excluded.business, user=excluded.user, updated_at=excluded.updated_at, hlc=excluded.hlc, sync_failed_at=NULL, sync_error=NULL
|
|
289
|
+
WHERE excluded.hlc >= orders.hlc OR orders.hlc IS NULL;`, order.id, order.business_id, order.order_number, order.callout_number, order.status, order.order_type, order.is_pos ? 1 : 0, JSON.stringify(order.items), order.subtotal_minor, order.total_minor, order.tax_minor, JSON.stringify(order.tax_lines), JSON.stringify(order.payment), paidAt, order.customer_name, order.customer_phone, order.pos_payment_method, order.delivery_id, order.business ? JSON.stringify(order.business) : null, order.user ? JSON.stringify(order.user) : null, order.inserted_at, updatedAt, hlc);
|
|
247
290
|
notifyDbChange(order.business_id, "orders");
|
|
248
291
|
}
|
|
249
292
|
export async function getOrderById(db, businessId, idOrNumber) {
|
|
@@ -253,7 +296,7 @@ export async function getOrderById(db, businessId, idOrNumber) {
|
|
|
253
296
|
export async function getPendingOrderIntent(db, businessId, orderId) {
|
|
254
297
|
const empty = { status: null, isPaid: false, hasPending: false };
|
|
255
298
|
try {
|
|
256
|
-
const rows = await db.getAllAsync(`SELECT command_type FROM sync_jobs WHERE business_id = ? AND entity_id = ? AND status = 'pending' ORDER BY created_at ASC, rowid ASC;`, businessId, orderId);
|
|
299
|
+
const rows = await db.getAllAsync(`SELECT command_type, payload FROM sync_jobs WHERE business_id = ? AND entity_id = ? AND status = 'pending' ORDER BY created_at ASC, rowid ASC;`, businessId, orderId);
|
|
257
300
|
if (!rows.length)
|
|
258
301
|
return empty;
|
|
259
302
|
let status = null;
|
|
@@ -266,6 +309,19 @@ export async function getPendingOrderIntent(db, businessId, orderId) {
|
|
|
266
309
|
if (commandType === "payment:confirm_cash" || commandType === "order:confirm_cash") {
|
|
267
310
|
isPaid = true;
|
|
268
311
|
}
|
|
312
|
+
// A cash sale is paid at the moment it is rung up — the queued create
|
|
313
|
+
// itself is the record of that intent. Without this, a pull landing
|
|
314
|
+
// before the create reaches the backend replaces the paid local row
|
|
315
|
+
// with the server's (older, unpaid) copy.
|
|
316
|
+
if (commandType === "order:create") {
|
|
317
|
+
try {
|
|
318
|
+
const payload = row.payload ? JSON.parse(row.payload) : null;
|
|
319
|
+
const method = payload?.pos_payment_method ?? "cash";
|
|
320
|
+
if (method === "cash")
|
|
321
|
+
isPaid = true;
|
|
322
|
+
}
|
|
323
|
+
catch { }
|
|
324
|
+
}
|
|
269
325
|
}
|
|
270
326
|
return { status, isPaid, hasPending: true };
|
|
271
327
|
}
|
|
@@ -289,15 +345,35 @@ export async function upsertServerOrder(db, order, opts = {}) {
|
|
|
289
345
|
return;
|
|
290
346
|
const existing = await getOrderById(db, order.business_id, order.id);
|
|
291
347
|
const status = opts.preserveStatus && existing ? existing.status : order.status;
|
|
292
|
-
const
|
|
348
|
+
const serverPayment = (order.payment ?? {});
|
|
349
|
+
const serverPaidAt = order.paid_at ?? serverPayment.paid_at ?? null;
|
|
350
|
+
const serverIsPaid = order.is_paid === true || !!serverPaidAt || serverPayment.is_paid === true;
|
|
351
|
+
let payment;
|
|
352
|
+
if (existing &&
|
|
353
|
+
(opts.preservePayment || (!serverIsPaid && isOrderPaid(existing)))) {
|
|
354
|
+
// Keep the device's payment. A pull must never un-pay an order: the
|
|
355
|
+
// server copy of a cash sale rung up moments ago can lag behind, and it
|
|
356
|
+
// used to reset the row to UNPAID until the create finished syncing.
|
|
357
|
+
payment = { ...existing.payment };
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
payment = {
|
|
361
|
+
...serverPayment,
|
|
362
|
+
is_paid: serverIsPaid,
|
|
363
|
+
paid_at: serverPaidAt,
|
|
364
|
+
amount_minor: serverPayment.amount_minor ?? order.total_minor ?? null,
|
|
365
|
+
currency: serverPayment.currency ?? order.currency_code ?? null,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const paidAt = payment.paid_at ?? null;
|
|
293
369
|
const hlc = order.hlc ??
|
|
294
370
|
order.updated_at ??
|
|
295
371
|
order.inserted_at ??
|
|
296
372
|
new Date().toISOString();
|
|
297
373
|
const updatedAt = order.updated_at ?? order.inserted_at;
|
|
298
|
-
await db.runAsync(`INSERT INTO orders (id, business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, updated_at, hlc)
|
|
299
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
300
|
-
ON CONFLICT(id) DO UPDATE SET business_id=excluded.business_id, order_number=excluded.order_number, callout_number=excluded.callout_number, status=excluded.status, order_type=excluded.order_type, is_pos=excluded.is_pos, items=excluded.items, subtotal_minor=excluded.subtotal_minor, total_minor=excluded.total_minor, tax_minor=excluded.tax_minor, tax_lines=excluded.tax_lines, payment=excluded.payment, customer_name=excluded.customer_name, customer_phone=excluded.customer_phone, pos_payment_method=excluded.pos_payment_method, delivery_id=excluded.delivery_id, business=excluded.business, user=excluded.user, updated_at=excluded.updated_at, hlc=excluded.hlc, sync_failed_at=NULL, sync_error=NULL;`, order.id, order.business_id, order.order_number, order.callout_number, status, order.order_type, order.is_pos ? 1 : 0, JSON.stringify(order.items ?? []), order.subtotal_minor ?? 0, order.total_minor ?? 0, order.tax_minor ?? 0, JSON.stringify(order.tax_lines ?? []), JSON.stringify(payment), order.customer_name, order.customer_phone, order.pos_payment_method, order.delivery_id, order.business ? JSON.stringify(order.business) : null, order.user ? JSON.stringify(order.user) : null, order.inserted_at, updatedAt, hlc);
|
|
374
|
+
await db.runAsync(`INSERT INTO orders (id, business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, paid_at, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, updated_at, hlc)
|
|
375
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
376
|
+
ON CONFLICT(id) DO UPDATE SET business_id=excluded.business_id, order_number=excluded.order_number, callout_number=excluded.callout_number, status=excluded.status, order_type=excluded.order_type, is_pos=excluded.is_pos, items=excluded.items, subtotal_minor=excluded.subtotal_minor, total_minor=excluded.total_minor, tax_minor=excluded.tax_minor, tax_lines=excluded.tax_lines, payment=excluded.payment, paid_at=COALESCE(excluded.paid_at, orders.paid_at), customer_name=excluded.customer_name, customer_phone=excluded.customer_phone, pos_payment_method=excluded.pos_payment_method, delivery_id=excluded.delivery_id, business=excluded.business, user=excluded.user, updated_at=excluded.updated_at, hlc=excluded.hlc, sync_failed_at=NULL, sync_error=NULL;`, order.id, order.business_id, order.order_number, order.callout_number, status, order.order_type, order.is_pos ? 1 : 0, JSON.stringify(order.items ?? []), order.subtotal_minor ?? 0, order.total_minor ?? 0, order.tax_minor ?? 0, JSON.stringify(order.tax_lines ?? []), JSON.stringify(payment), paidAt, order.customer_name, order.customer_phone, order.pos_payment_method, order.delivery_id, order.business ? JSON.stringify(order.business) : null, order.user ? JSON.stringify(order.user) : null, order.inserted_at, updatedAt, hlc);
|
|
301
377
|
notifyDbChange(order.business_id, "orders");
|
|
302
378
|
}
|
|
303
379
|
export async function listOrders(db, businessId, filters, page = 1, pageSize = 20) {
|
|
@@ -318,11 +394,13 @@ export async function listOrders(db, businessId, filters, page = 1, pageSize = 2
|
|
|
318
394
|
where.push("order_type = ?");
|
|
319
395
|
args.push(filters.order_type);
|
|
320
396
|
}
|
|
397
|
+
// Paid means "the order has a payment timestamp" (cash at the till) or the
|
|
398
|
+
// payment blob says so (gateway payment) — mirroring the backend filter.
|
|
321
399
|
if (filters?.is_paid === "paid") {
|
|
322
|
-
where.push("json_extract(payment, '$.is_paid') = 1");
|
|
400
|
+
where.push("(json_extract(payment, '$.is_paid') = 1 OR paid_at IS NOT NULL)");
|
|
323
401
|
}
|
|
324
402
|
else if (filters?.is_paid === "unpaid") {
|
|
325
|
-
where.push("(json_extract(payment, '$.is_paid')
|
|
403
|
+
where.push("(COALESCE(json_extract(payment, '$.is_paid'), 0) = 0 AND paid_at IS NULL)");
|
|
326
404
|
}
|
|
327
405
|
if (filters?.q) {
|
|
328
406
|
where.push("(order_number LIKE ? OR customer_name LIKE ? OR customer_phone LIKE ?)");
|
|
@@ -366,7 +444,7 @@ export async function updateOrderPayment(db, businessId, orderId, patch) {
|
|
|
366
444
|
if (!row)
|
|
367
445
|
return;
|
|
368
446
|
const payment = { ...row.payment, is_paid: patch.is_paid, paid_at: patch.paid_at };
|
|
369
|
-
await db.runAsync(`UPDATE orders SET payment = ?, hlc = ? WHERE business_id = ? AND (id = ? OR order_number = ?);`, JSON.stringify(payment), new Date().toISOString(), businessId, orderId, orderId);
|
|
447
|
+
await db.runAsync(`UPDATE orders SET payment = ?, paid_at = COALESCE(?, paid_at), hlc = ? WHERE business_id = ? AND (id = ? OR order_number = ?);`, JSON.stringify(payment), patch.is_paid ? patch.paid_at : null, new Date().toISOString(), businessId, orderId, orderId);
|
|
370
448
|
notifyDbChange(businessId, "orders");
|
|
371
449
|
}
|
|
372
450
|
/**
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business-configurable fulfilment flow for terminal / business-app orders.
|
|
3
|
+
*
|
|
4
|
+
* Buyer-placed online orders always use the full pipeline
|
|
5
|
+
* (accept → preparing → ready → completed). Orders rung up on a POS terminal
|
|
6
|
+
* or in the business app follow the business setting:
|
|
7
|
+
*
|
|
8
|
+
* "staged" (default) — same pipeline as online orders.
|
|
9
|
+
* "direct" — the sale is completed the moment it is taken, so the
|
|
10
|
+
* order is born `delivered` and no pipeline buttons are
|
|
11
|
+
* offered.
|
|
12
|
+
*
|
|
13
|
+
* The setting lives on the business (`businesses.pos_order_flow`) and is
|
|
14
|
+
* cached in the `business:profile` reference record, so it is readable while
|
|
15
|
+
* offline.
|
|
16
|
+
*/
|
|
17
|
+
import type { SQLiteDatabase } from "../../adapters/sqlite";
|
|
18
|
+
export type OrderFlowMode = "staged" | "direct";
|
|
19
|
+
export declare const DEFAULT_ORDER_FLOW_MODE: OrderFlowMode;
|
|
20
|
+
/** Coerce any server/local value into a known mode. */
|
|
21
|
+
export declare function normalizeOrderFlowMode(value: unknown): OrderFlowMode;
|
|
22
|
+
export declare function isDirectOrderFlow(value: unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Read `pos_order_flow` out of a `business:profile` payload. Accepts both the
|
|
25
|
+
* reference-data envelope (`{ data: {...} }`) and a bare profile object.
|
|
26
|
+
*/
|
|
27
|
+
export declare function orderFlowModeFromProfile(payload: unknown): OrderFlowMode;
|
|
28
|
+
/**
|
|
29
|
+
* Cached business flow mode (works fully offline). Falls back to "staged" when
|
|
30
|
+
* the profile has never been synced — the safe, full-pipeline default.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getBusinessOrderFlowMode(businessId: string, db?: SQLiteDatabase): Promise<OrderFlowMode>;
|
|
33
|
+
/**
|
|
34
|
+
* Status a POS/business-app order starts in.
|
|
35
|
+
*
|
|
36
|
+
* Cash sales in direct flow are complete on creation. Anything that still
|
|
37
|
+
* needs money (mobile money / card) must stay `awaiting_payment` first — the
|
|
38
|
+
* backend moves it to `accepted` (staged) or `delivered` (direct) once the
|
|
39
|
+
* payment lands.
|
|
40
|
+
*/
|
|
41
|
+
export declare function initialPosOrderStatus(paymentMethod: string | null | undefined, mode: OrderFlowMode): "accepted" | "awaiting_payment" | "delivered";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business-configurable fulfilment flow for terminal / business-app orders.
|
|
3
|
+
*
|
|
4
|
+
* Buyer-placed online orders always use the full pipeline
|
|
5
|
+
* (accept → preparing → ready → completed). Orders rung up on a POS terminal
|
|
6
|
+
* or in the business app follow the business setting:
|
|
7
|
+
*
|
|
8
|
+
* "staged" (default) — same pipeline as online orders.
|
|
9
|
+
* "direct" — the sale is completed the moment it is taken, so the
|
|
10
|
+
* order is born `delivered` and no pipeline buttons are
|
|
11
|
+
* offered.
|
|
12
|
+
*
|
|
13
|
+
* The setting lives on the business (`businesses.pos_order_flow`) and is
|
|
14
|
+
* cached in the `business:profile` reference record, so it is readable while
|
|
15
|
+
* offline.
|
|
16
|
+
*/
|
|
17
|
+
import { openSyncDatabase } from "../../db/connection";
|
|
18
|
+
import { getReferenceData } from "../../reference/operations";
|
|
19
|
+
export const DEFAULT_ORDER_FLOW_MODE = "staged";
|
|
20
|
+
/** Coerce any server/local value into a known mode. */
|
|
21
|
+
export function normalizeOrderFlowMode(value) {
|
|
22
|
+
return value === "direct" ? "direct" : DEFAULT_ORDER_FLOW_MODE;
|
|
23
|
+
}
|
|
24
|
+
export function isDirectOrderFlow(value) {
|
|
25
|
+
return normalizeOrderFlowMode(value) === "direct";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Read `pos_order_flow` out of a `business:profile` payload. Accepts both the
|
|
29
|
+
* reference-data envelope (`{ data: {...} }`) and a bare profile object.
|
|
30
|
+
*/
|
|
31
|
+
export function orderFlowModeFromProfile(payload) {
|
|
32
|
+
if (!payload || typeof payload !== "object")
|
|
33
|
+
return DEFAULT_ORDER_FLOW_MODE;
|
|
34
|
+
const record = payload;
|
|
35
|
+
return normalizeOrderFlowMode(record.data?.pos_order_flow ?? record.pos_order_flow);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Cached business flow mode (works fully offline). Falls back to "staged" when
|
|
39
|
+
* the profile has never been synced — the safe, full-pipeline default.
|
|
40
|
+
*/
|
|
41
|
+
export async function getBusinessOrderFlowMode(businessId, db) {
|
|
42
|
+
if (!businessId)
|
|
43
|
+
return DEFAULT_ORDER_FLOW_MODE;
|
|
44
|
+
try {
|
|
45
|
+
const connection = db ?? (await openSyncDatabase());
|
|
46
|
+
const record = await getReferenceData(connection, businessId, "business:profile");
|
|
47
|
+
return orderFlowModeFromProfile(record?.payload);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return DEFAULT_ORDER_FLOW_MODE;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Status a POS/business-app order starts in.
|
|
55
|
+
*
|
|
56
|
+
* Cash sales in direct flow are complete on creation. Anything that still
|
|
57
|
+
* needs money (mobile money / card) must stay `awaiting_payment` first — the
|
|
58
|
+
* backend moves it to `accepted` (staged) or `delivered` (direct) once the
|
|
59
|
+
* payment lands.
|
|
60
|
+
*/
|
|
61
|
+
export function initialPosOrderStatus(paymentMethod, mode) {
|
|
62
|
+
const method = paymentMethod ?? "cash";
|
|
63
|
+
if (method !== "cash")
|
|
64
|
+
return "awaiting_payment";
|
|
65
|
+
return mode === "direct" ? "delivered" : "accepted";
|
|
66
|
+
}
|
|
@@ -15,6 +15,7 @@ import { canTransition } from "../../utils/order-transitions";
|
|
|
15
15
|
import { TRANSITION_ERROR_CODES, TransitionError } from "../../sync/transition-errors";
|
|
16
16
|
import { validateOrderCreateInput } from "../../validation/offline";
|
|
17
17
|
import { buildItemSnapshots, snapshotsToOrderLines } from "./snapshots";
|
|
18
|
+
import { getBusinessOrderFlowMode, initialPosOrderStatus } from "./order-flow";
|
|
18
19
|
import { drainOne, pullRemoteOrders } from "../../sync/sync-jobs.service";
|
|
19
20
|
import { getAuthToken } from "../../adapters/auth";
|
|
20
21
|
import { canBusinessSync } from "../../sync/sync-guard";
|
|
@@ -78,6 +79,10 @@ export async function createLocalOrder(businessId, input) {
|
|
|
78
79
|
// Offline validation mirror — backend Order.changeset rules, pre-commit.
|
|
79
80
|
validateOrderCreateInput(input);
|
|
80
81
|
const method = input.pos_payment_method ?? "cash";
|
|
82
|
+
// Business-configurable fulfilment flow (cached business profile, offline).
|
|
83
|
+
// "direct" completes walk-in sales the moment they are rung up; "staged"
|
|
84
|
+
// keeps accept → preparing → ready → completed.
|
|
85
|
+
const flowMode = await getBusinessOrderFlowMode(businessId);
|
|
81
86
|
// Operating-hours gate (fail-closed, offline-first): matches backend
|
|
82
87
|
// validate_business_open. Throws BUSINESS_CLOSED / HOURS_NOT_SYNCED before
|
|
83
88
|
// anything is written, so a doomed order never enters SQLite/sync_jobs.
|
|
@@ -128,7 +133,7 @@ export async function createLocalOrder(businessId, input) {
|
|
|
128
133
|
id,
|
|
129
134
|
order_number: orderNumber,
|
|
130
135
|
callout_number: callout,
|
|
131
|
-
status: isPos ?
|
|
136
|
+
status: isPos ? initialPosOrderStatus(method, flowMode) : "pending",
|
|
132
137
|
order_type: input.order_type ?? "takeout",
|
|
133
138
|
is_pos: isPos,
|
|
134
139
|
customer_name: input.customer_name ?? null,
|
|
@@ -161,7 +166,7 @@ export async function createLocalOrder(businessId, input) {
|
|
|
161
166
|
};
|
|
162
167
|
const db = await openSyncDatabase();
|
|
163
168
|
await insertOrder(db, order);
|
|
164
|
-
syncLogger.debug("DomainOrders", "createLocalOrder inserted", { businessId, id, orderNumber, isPos, connectivity: getConnectivityState(), hasToken: !!getAuthToken(), deviceNumber: dd });
|
|
169
|
+
syncLogger.debug("DomainOrders", "createLocalOrder inserted", { businessId, id, orderNumber, isPos, flowMode, status: order.status, connectivity: getConnectivityState(), hasToken: !!getAuthToken(), deviceNumber: dd });
|
|
165
170
|
try {
|
|
166
171
|
await db.runAsync(`INSERT OR IGNORE INTO sync_jobs (id, business_id, command_type, entity_id, payload, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, 'pending', ?, ?);`, id, businessId, "order:create", id, JSON.stringify({ ...input, order_number: orderNumber, id }), now, now);
|
|
167
172
|
syncLogger.debug("DomainOrders", "sync_jobs enqueued", { businessId, id, command_type: "order:create" });
|
|
@@ -36,10 +36,10 @@ export declare function useBusinessDeliveriesQuery(enabled?: boolean, filters?:
|
|
|
36
36
|
isRefetching: boolean;
|
|
37
37
|
isStale: boolean;
|
|
38
38
|
isEnabled: boolean;
|
|
39
|
-
refetch: (options?: import("@tanstack/query
|
|
40
|
-
fetchStatus: import("@tanstack/query
|
|
41
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
42
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
39
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
40
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
41
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
42
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
43
43
|
hasNextPage: boolean;
|
|
44
44
|
hasPreviousPage: boolean;
|
|
45
45
|
isFetchingNextPage: boolean;
|
|
@@ -70,10 +70,10 @@ export declare function useBusinessDeliveriesQuery(enabled?: boolean, filters?:
|
|
|
70
70
|
isRefetching: boolean;
|
|
71
71
|
isStale: boolean;
|
|
72
72
|
isEnabled: boolean;
|
|
73
|
-
refetch: (options?: import("@tanstack/query
|
|
74
|
-
fetchStatus: import("@tanstack/query
|
|
75
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
76
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
73
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
74
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
75
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
76
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
77
77
|
hasNextPage: boolean;
|
|
78
78
|
hasPreviousPage: boolean;
|
|
79
79
|
isFetchingNextPage: boolean;
|
|
@@ -105,10 +105,10 @@ export declare function useBusinessDeliveriesQuery(enabled?: boolean, filters?:
|
|
|
105
105
|
isRefetching: boolean;
|
|
106
106
|
isStale: boolean;
|
|
107
107
|
isEnabled: boolean;
|
|
108
|
-
refetch: (options?: import("@tanstack/query
|
|
109
|
-
fetchStatus: import("@tanstack/query
|
|
110
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
111
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
108
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
109
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
110
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
111
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
112
112
|
hasNextPage: boolean;
|
|
113
113
|
hasPreviousPage: boolean;
|
|
114
114
|
isFetchingNextPage: boolean;
|
|
@@ -138,10 +138,10 @@ export declare function useBusinessDeliveriesQuery(enabled?: boolean, filters?:
|
|
|
138
138
|
isRefetching: boolean;
|
|
139
139
|
isStale: boolean;
|
|
140
140
|
isEnabled: boolean;
|
|
141
|
-
refetch: (options?: import("@tanstack/query
|
|
142
|
-
fetchStatus: import("@tanstack/query
|
|
143
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
144
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
141
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
142
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
143
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
144
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
145
145
|
hasNextPage: boolean;
|
|
146
146
|
hasPreviousPage: boolean;
|
|
147
147
|
isFetchingNextPage: boolean;
|
|
@@ -172,10 +172,10 @@ export declare function useBusinessDeliveriesQuery(enabled?: boolean, filters?:
|
|
|
172
172
|
isRefetching: boolean;
|
|
173
173
|
isStale: boolean;
|
|
174
174
|
isEnabled: boolean;
|
|
175
|
-
refetch: (options?: import("@tanstack/query
|
|
176
|
-
fetchStatus: import("@tanstack/query
|
|
177
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
178
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
175
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
176
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
177
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
178
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
179
179
|
hasNextPage: boolean;
|
|
180
180
|
hasPreviousPage: boolean;
|
|
181
181
|
isFetchNextPageError: boolean;
|
|
@@ -206,10 +206,10 @@ export declare function useBusinessDeliveriesQuery(enabled?: boolean, filters?:
|
|
|
206
206
|
isRefetching: boolean;
|
|
207
207
|
isStale: boolean;
|
|
208
208
|
isEnabled: boolean;
|
|
209
|
-
refetch: (options?: import("@tanstack/query
|
|
210
|
-
fetchStatus: import("@tanstack/query
|
|
211
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
212
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
209
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
210
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
211
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
212
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<BusinessDelivery>, unknown>, Error>>;
|
|
213
213
|
hasNextPage: boolean;
|
|
214
214
|
hasPreviousPage: boolean;
|
|
215
215
|
isFetchingNextPage: boolean;
|
|
@@ -47,10 +47,10 @@ export declare function useRiderDeliveriesQuery(enabled?: boolean, filters?: {
|
|
|
47
47
|
isRefetching: boolean;
|
|
48
48
|
isStale: boolean;
|
|
49
49
|
isEnabled: boolean;
|
|
50
|
-
refetch: (options?: import("@tanstack/query
|
|
51
|
-
fetchStatus: import("@tanstack/query
|
|
52
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
53
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
50
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
51
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
52
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
53
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
54
54
|
hasNextPage: boolean;
|
|
55
55
|
hasPreviousPage: boolean;
|
|
56
56
|
isFetchingNextPage: boolean;
|
|
@@ -81,10 +81,10 @@ export declare function useRiderDeliveriesQuery(enabled?: boolean, filters?: {
|
|
|
81
81
|
isRefetching: boolean;
|
|
82
82
|
isStale: boolean;
|
|
83
83
|
isEnabled: boolean;
|
|
84
|
-
refetch: (options?: import("@tanstack/query
|
|
85
|
-
fetchStatus: import("@tanstack/query
|
|
86
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
87
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
84
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
85
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
86
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
87
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
88
88
|
hasNextPage: boolean;
|
|
89
89
|
hasPreviousPage: boolean;
|
|
90
90
|
isFetchingNextPage: boolean;
|
|
@@ -116,10 +116,10 @@ export declare function useRiderDeliveriesQuery(enabled?: boolean, filters?: {
|
|
|
116
116
|
isRefetching: boolean;
|
|
117
117
|
isStale: boolean;
|
|
118
118
|
isEnabled: boolean;
|
|
119
|
-
refetch: (options?: import("@tanstack/query
|
|
120
|
-
fetchStatus: import("@tanstack/query
|
|
121
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
122
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
119
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
120
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
121
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
122
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
123
123
|
hasNextPage: boolean;
|
|
124
124
|
hasPreviousPage: boolean;
|
|
125
125
|
isFetchingNextPage: boolean;
|
|
@@ -149,10 +149,10 @@ export declare function useRiderDeliveriesQuery(enabled?: boolean, filters?: {
|
|
|
149
149
|
isRefetching: boolean;
|
|
150
150
|
isStale: boolean;
|
|
151
151
|
isEnabled: boolean;
|
|
152
|
-
refetch: (options?: import("@tanstack/query
|
|
153
|
-
fetchStatus: import("@tanstack/query
|
|
154
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
155
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
152
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
153
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
154
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
155
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
156
156
|
hasNextPage: boolean;
|
|
157
157
|
hasPreviousPage: boolean;
|
|
158
158
|
isFetchingNextPage: boolean;
|
|
@@ -183,10 +183,10 @@ export declare function useRiderDeliveriesQuery(enabled?: boolean, filters?: {
|
|
|
183
183
|
isRefetching: boolean;
|
|
184
184
|
isStale: boolean;
|
|
185
185
|
isEnabled: boolean;
|
|
186
|
-
refetch: (options?: import("@tanstack/query
|
|
187
|
-
fetchStatus: import("@tanstack/query
|
|
188
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
189
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
186
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
187
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
188
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
189
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
190
190
|
hasNextPage: boolean;
|
|
191
191
|
hasPreviousPage: boolean;
|
|
192
192
|
isFetchNextPageError: boolean;
|
|
@@ -217,10 +217,10 @@ export declare function useRiderDeliveriesQuery(enabled?: boolean, filters?: {
|
|
|
217
217
|
isRefetching: boolean;
|
|
218
218
|
isStale: boolean;
|
|
219
219
|
isEnabled: boolean;
|
|
220
|
-
refetch: (options?: import("@tanstack/query
|
|
221
|
-
fetchStatus: import("@tanstack/query
|
|
222
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
223
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
220
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
221
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
222
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
223
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<RiderDelivery>, unknown>, Error>>;
|
|
224
224
|
hasNextPage: boolean;
|
|
225
225
|
hasPreviousPage: boolean;
|
|
226
226
|
isFetchingNextPage: boolean;
|
|
@@ -261,10 +261,10 @@ export declare function useRiderWalletHistoryQuery(enabled?: boolean): {
|
|
|
261
261
|
isRefetching: boolean;
|
|
262
262
|
isStale: boolean;
|
|
263
263
|
isEnabled: boolean;
|
|
264
|
-
refetch: (options?: import("@tanstack/query
|
|
265
|
-
fetchStatus: import("@tanstack/query
|
|
266
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
267
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
264
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
265
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
266
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
267
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
268
268
|
hasNextPage: boolean;
|
|
269
269
|
hasPreviousPage: boolean;
|
|
270
270
|
isFetchingNextPage: boolean;
|
|
@@ -295,10 +295,10 @@ export declare function useRiderWalletHistoryQuery(enabled?: boolean): {
|
|
|
295
295
|
isRefetching: boolean;
|
|
296
296
|
isStale: boolean;
|
|
297
297
|
isEnabled: boolean;
|
|
298
|
-
refetch: (options?: import("@tanstack/query
|
|
299
|
-
fetchStatus: import("@tanstack/query
|
|
300
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
301
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
298
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
299
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
300
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
301
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
302
302
|
hasNextPage: boolean;
|
|
303
303
|
hasPreviousPage: boolean;
|
|
304
304
|
isFetchingNextPage: boolean;
|
|
@@ -330,10 +330,10 @@ export declare function useRiderWalletHistoryQuery(enabled?: boolean): {
|
|
|
330
330
|
isRefetching: boolean;
|
|
331
331
|
isStale: boolean;
|
|
332
332
|
isEnabled: boolean;
|
|
333
|
-
refetch: (options?: import("@tanstack/query
|
|
334
|
-
fetchStatus: import("@tanstack/query
|
|
335
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
336
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
333
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
334
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
335
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
336
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
337
337
|
hasNextPage: boolean;
|
|
338
338
|
hasPreviousPage: boolean;
|
|
339
339
|
isFetchingNextPage: boolean;
|
|
@@ -363,10 +363,10 @@ export declare function useRiderWalletHistoryQuery(enabled?: boolean): {
|
|
|
363
363
|
isRefetching: boolean;
|
|
364
364
|
isStale: boolean;
|
|
365
365
|
isEnabled: boolean;
|
|
366
|
-
refetch: (options?: import("@tanstack/query
|
|
367
|
-
fetchStatus: import("@tanstack/query
|
|
368
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
369
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
366
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
367
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
368
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
369
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
370
370
|
hasNextPage: boolean;
|
|
371
371
|
hasPreviousPage: boolean;
|
|
372
372
|
isFetchingNextPage: boolean;
|
|
@@ -397,10 +397,10 @@ export declare function useRiderWalletHistoryQuery(enabled?: boolean): {
|
|
|
397
397
|
isRefetching: boolean;
|
|
398
398
|
isStale: boolean;
|
|
399
399
|
isEnabled: boolean;
|
|
400
|
-
refetch: (options?: import("@tanstack/query
|
|
401
|
-
fetchStatus: import("@tanstack/query
|
|
402
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
403
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
400
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
401
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
402
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
403
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
404
404
|
hasNextPage: boolean;
|
|
405
405
|
hasPreviousPage: boolean;
|
|
406
406
|
isFetchNextPageError: boolean;
|
|
@@ -431,10 +431,10 @@ export declare function useRiderWalletHistoryQuery(enabled?: boolean): {
|
|
|
431
431
|
isRefetching: boolean;
|
|
432
432
|
isStale: boolean;
|
|
433
433
|
isEnabled: boolean;
|
|
434
|
-
refetch: (options?: import("@tanstack/query
|
|
435
|
-
fetchStatus: import("@tanstack/query
|
|
436
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
437
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
434
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
435
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
436
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
437
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<Record<string, unknown>>, unknown>, Error>>;
|
|
438
438
|
hasNextPage: boolean;
|
|
439
439
|
hasPreviousPage: boolean;
|
|
440
440
|
isFetchingNextPage: boolean;
|
|
@@ -50,10 +50,10 @@ export declare function useInfiniteList<T>(options: InfiniteListOptions<T>): {
|
|
|
50
50
|
isRefetching: boolean;
|
|
51
51
|
isStale: boolean;
|
|
52
52
|
isEnabled: boolean;
|
|
53
|
-
refetch: (options?: import("@tanstack/query
|
|
54
|
-
fetchStatus: import("@tanstack/query
|
|
55
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
56
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
53
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
54
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
55
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
56
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
57
57
|
hasNextPage: boolean;
|
|
58
58
|
hasPreviousPage: boolean;
|
|
59
59
|
isFetchingNextPage: boolean;
|
|
@@ -84,10 +84,10 @@ export declare function useInfiniteList<T>(options: InfiniteListOptions<T>): {
|
|
|
84
84
|
isRefetching: boolean;
|
|
85
85
|
isStale: boolean;
|
|
86
86
|
isEnabled: boolean;
|
|
87
|
-
refetch: (options?: import("@tanstack/query
|
|
88
|
-
fetchStatus: import("@tanstack/query
|
|
89
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
90
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
87
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
88
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
89
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
90
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
91
91
|
hasNextPage: boolean;
|
|
92
92
|
hasPreviousPage: boolean;
|
|
93
93
|
isFetchingNextPage: boolean;
|
|
@@ -119,10 +119,10 @@ export declare function useInfiniteList<T>(options: InfiniteListOptions<T>): {
|
|
|
119
119
|
isRefetching: boolean;
|
|
120
120
|
isStale: boolean;
|
|
121
121
|
isEnabled: boolean;
|
|
122
|
-
refetch: (options?: import("@tanstack/query
|
|
123
|
-
fetchStatus: import("@tanstack/query
|
|
124
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
125
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
122
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
123
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
124
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
125
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
126
126
|
hasNextPage: boolean;
|
|
127
127
|
hasPreviousPage: boolean;
|
|
128
128
|
isFetchingNextPage: boolean;
|
|
@@ -152,10 +152,10 @@ export declare function useInfiniteList<T>(options: InfiniteListOptions<T>): {
|
|
|
152
152
|
isRefetching: boolean;
|
|
153
153
|
isStale: boolean;
|
|
154
154
|
isEnabled: boolean;
|
|
155
|
-
refetch: (options?: import("@tanstack/query
|
|
156
|
-
fetchStatus: import("@tanstack/query
|
|
157
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
158
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
155
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
156
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
157
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
158
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
159
159
|
hasNextPage: boolean;
|
|
160
160
|
hasPreviousPage: boolean;
|
|
161
161
|
isFetchingNextPage: boolean;
|
|
@@ -186,10 +186,10 @@ export declare function useInfiniteList<T>(options: InfiniteListOptions<T>): {
|
|
|
186
186
|
isRefetching: boolean;
|
|
187
187
|
isStale: boolean;
|
|
188
188
|
isEnabled: boolean;
|
|
189
|
-
refetch: (options?: import("@tanstack/query
|
|
190
|
-
fetchStatus: import("@tanstack/query
|
|
191
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
192
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
189
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
190
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
191
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
192
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
193
193
|
hasNextPage: boolean;
|
|
194
194
|
hasPreviousPage: boolean;
|
|
195
195
|
isFetchNextPageError: boolean;
|
|
@@ -220,10 +220,10 @@ export declare function useInfiniteList<T>(options: InfiniteListOptions<T>): {
|
|
|
220
220
|
isRefetching: boolean;
|
|
221
221
|
isStale: boolean;
|
|
222
222
|
isEnabled: boolean;
|
|
223
|
-
refetch: (options?: import("@tanstack/query
|
|
224
|
-
fetchStatus: import("@tanstack/query
|
|
225
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
226
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
223
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
224
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
225
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
226
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<ListPage<T>, unknown>, Error>>;
|
|
227
227
|
hasNextPage: boolean;
|
|
228
228
|
hasPreviousPage: boolean;
|
|
229
229
|
isFetchingNextPage: boolean;
|
|
@@ -26,10 +26,10 @@ export declare function useWalletHistoryQuery(enabled?: boolean): {
|
|
|
26
26
|
isRefetching: boolean;
|
|
27
27
|
isStale: boolean;
|
|
28
28
|
isEnabled: boolean;
|
|
29
|
-
refetch: (options?: import("@tanstack/query
|
|
30
|
-
fetchStatus: import("@tanstack/query
|
|
31
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
32
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
29
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
30
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
31
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
32
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
33
33
|
hasNextPage: boolean;
|
|
34
34
|
hasPreviousPage: boolean;
|
|
35
35
|
isFetchingNextPage: boolean;
|
|
@@ -60,10 +60,10 @@ export declare function useWalletHistoryQuery(enabled?: boolean): {
|
|
|
60
60
|
isRefetching: boolean;
|
|
61
61
|
isStale: boolean;
|
|
62
62
|
isEnabled: boolean;
|
|
63
|
-
refetch: (options?: import("@tanstack/query
|
|
64
|
-
fetchStatus: import("@tanstack/query
|
|
65
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
66
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
63
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
64
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
65
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
66
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
67
67
|
hasNextPage: boolean;
|
|
68
68
|
hasPreviousPage: boolean;
|
|
69
69
|
isFetchingNextPage: boolean;
|
|
@@ -95,10 +95,10 @@ export declare function useWalletHistoryQuery(enabled?: boolean): {
|
|
|
95
95
|
isRefetching: boolean;
|
|
96
96
|
isStale: boolean;
|
|
97
97
|
isEnabled: boolean;
|
|
98
|
-
refetch: (options?: import("@tanstack/query
|
|
99
|
-
fetchStatus: import("@tanstack/query
|
|
100
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
101
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
98
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
99
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
100
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
101
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
102
102
|
hasNextPage: boolean;
|
|
103
103
|
hasPreviousPage: boolean;
|
|
104
104
|
isFetchingNextPage: boolean;
|
|
@@ -128,10 +128,10 @@ export declare function useWalletHistoryQuery(enabled?: boolean): {
|
|
|
128
128
|
isRefetching: boolean;
|
|
129
129
|
isStale: boolean;
|
|
130
130
|
isEnabled: boolean;
|
|
131
|
-
refetch: (options?: import("@tanstack/query
|
|
132
|
-
fetchStatus: import("@tanstack/query
|
|
133
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
134
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
131
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
132
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
133
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
134
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
135
135
|
hasNextPage: boolean;
|
|
136
136
|
hasPreviousPage: boolean;
|
|
137
137
|
isFetchingNextPage: boolean;
|
|
@@ -162,10 +162,10 @@ export declare function useWalletHistoryQuery(enabled?: boolean): {
|
|
|
162
162
|
isRefetching: boolean;
|
|
163
163
|
isStale: boolean;
|
|
164
164
|
isEnabled: boolean;
|
|
165
|
-
refetch: (options?: import("@tanstack/query
|
|
166
|
-
fetchStatus: import("@tanstack/query
|
|
167
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
168
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
165
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
166
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
167
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
168
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
169
169
|
hasNextPage: boolean;
|
|
170
170
|
hasPreviousPage: boolean;
|
|
171
171
|
isFetchNextPageError: boolean;
|
|
@@ -196,10 +196,10 @@ export declare function useWalletHistoryQuery(enabled?: boolean): {
|
|
|
196
196
|
isRefetching: boolean;
|
|
197
197
|
isStale: boolean;
|
|
198
198
|
isEnabled: boolean;
|
|
199
|
-
refetch: (options?: import("@tanstack/query
|
|
200
|
-
fetchStatus: import("@tanstack/query
|
|
201
|
-
fetchNextPage: (options?: import("@tanstack/query
|
|
202
|
-
fetchPreviousPage: (options?: import("@tanstack/query
|
|
199
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
200
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
201
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
202
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<import("./use-infinite-list").ListPage<WalletEntry>, unknown>, Error>>;
|
|
203
203
|
hasNextPage: boolean;
|
|
204
204
|
hasPreviousPage: boolean;
|
|
205
205
|
isFetchingNextPage: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -144,6 +144,7 @@ export * from "./sync/transition-endpoints";
|
|
|
144
144
|
export * from "./utils/business-hours";
|
|
145
145
|
export * from "./hooks/business-hours.hooks";
|
|
146
146
|
export * from "./domain/orders/service";
|
|
147
|
+
export * from "./domain/orders/order-flow";
|
|
147
148
|
export * from "./domain/orders/snapshots";
|
|
148
149
|
export { phoenixSocket } from "./realtime/phoenix-socket";
|
|
149
150
|
export { eventsService } from "./realtime/events.service";
|
package/dist/index.js
CHANGED
|
@@ -156,6 +156,7 @@ export * from "./hooks/business-hours.hooks";
|
|
|
156
156
|
// components/OrderStatusCard was folded into order-transitions (compat re-export lives in apps)
|
|
157
157
|
// ── Domain (offline-first primary DB) ──
|
|
158
158
|
export * from "./domain/orders/service";
|
|
159
|
+
export * from "./domain/orders/order-flow";
|
|
159
160
|
export * from "./domain/orders/snapshots";
|
|
160
161
|
// ── Realtime (single source — PHX WebSocket + business:{id}) ──
|
|
161
162
|
export { phoenixSocket } from "./realtime/phoenix-socket";
|
package/dist/sync/order-merge.js
CHANGED
|
@@ -27,14 +27,19 @@ export async function mergeOrderFromServer(db, businessId, serverOrder) {
|
|
|
27
27
|
return false;
|
|
28
28
|
try {
|
|
29
29
|
const intent = await getPendingOrderIntent(db, businessId, serverOrder.id);
|
|
30
|
+
// Capture the local payment BEFORE the server copy overwrites the row —
|
|
31
|
+
// a queued cash sale carries the paid timestamp only on the device.
|
|
32
|
+
const beforeMerge = intent.hasPending
|
|
33
|
+
? await getOrderById(db, businessId, serverOrder.id)
|
|
34
|
+
: null;
|
|
30
35
|
await upsertServerOrder(db, { ...serverOrder, business_id: businessId });
|
|
31
36
|
if (intent.hasPending) {
|
|
32
37
|
if (intent.status) {
|
|
33
38
|
await updateOrderStatus(db, businessId, serverOrder.id, intent.status);
|
|
34
39
|
}
|
|
35
40
|
if (intent.isPaid) {
|
|
36
|
-
const
|
|
37
|
-
|
|
41
|
+
const paidAt = beforeMerge?.payment?.paid_at ??
|
|
42
|
+
beforeMerge?.paid_at ??
|
|
38
43
|
new Date().toISOString();
|
|
39
44
|
await updateOrderPayment(db, businessId, serverOrder.id, {
|
|
40
45
|
is_paid: true,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* exact list last seen while online is available offline.
|
|
15
15
|
*/
|
|
16
16
|
import { openSyncDatabase } from "../db/connection";
|
|
17
|
-
import { insertEvent, upsertEntitySnapshot, getEntitySnapshot, getEntitySnapshotsByType, pruneEntitySnapshots, } from "../db/operations";
|
|
17
|
+
import { insertEvent, upsertEntitySnapshot, getEntitySnapshot, getEntitySnapshotsByType, pruneEntitySnapshots, updateOrderPayment, } from "../db/operations";
|
|
18
18
|
import { syncLogger } from "../utils/sync-logger";
|
|
19
19
|
const RETAIN_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
|
|
20
20
|
const ORDER_EVENT_TYPES = new Set([
|
|
@@ -119,6 +119,22 @@ class OrderSnapshotsService {
|
|
|
119
119
|
const db = await openSyncDatabase();
|
|
120
120
|
await insertEvent(db, { event, origin });
|
|
121
121
|
const businessId = payload?.business_id ?? payload?.businessId ?? null;
|
|
122
|
+
// Dual-write the canonical orders row: POS/Orders screens read payment
|
|
123
|
+
// from there, not from the snapshot. Without this a mobile-money sale
|
|
124
|
+
// stayed UNPAID (and kept offering "Collect cash") after its payment
|
|
125
|
+
// completed, because only the snapshot list was patched.
|
|
126
|
+
if (businessId) {
|
|
127
|
+
await updateOrderPayment(db, businessId, orderId, { is_paid: true, paid_at: paidAt });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
try {
|
|
131
|
+
const row = await db.getFirstAsync(`SELECT business_id FROM orders WHERE id = ? OR order_number = ? LIMIT 1;`, orderId, payload?.order_number ?? orderId);
|
|
132
|
+
if (row?.business_id) {
|
|
133
|
+
await updateOrderPayment(db, row.business_id, orderId, { is_paid: true, paid_at: paidAt });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch { }
|
|
137
|
+
}
|
|
122
138
|
const lists = businessId
|
|
123
139
|
? await getEntitySnapshotsByType(db, "seller_orders", businessId)
|
|
124
140
|
: await getEntitySnapshotsByType(db, "seller_orders");
|
|
@@ -189,7 +189,7 @@ export function createMemoryDriver() {
|
|
|
189
189
|
}
|
|
190
190
|
// orders insert (primary DB)
|
|
191
191
|
if (s.includes("INSERT INTO orders")) {
|
|
192
|
-
const [id, business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, hlc] = args;
|
|
192
|
+
const [id, business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, paid_at, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, updated_at, hlc] = args;
|
|
193
193
|
const existing = tables.orders.find((r) => r.id === id);
|
|
194
194
|
// LWW check via hlc (if existing and incoming older, skip) — only for
|
|
195
195
|
// the local/LAN write path. The server write path (`upsertServerOrder`)
|
|
@@ -198,10 +198,10 @@ export function createMemoryDriver() {
|
|
|
198
198
|
if (existing) {
|
|
199
199
|
if (lwwGuarded && hlc && existing.hlc && hlc < existing.hlc)
|
|
200
200
|
return { lastInsertRowId: 0, changes: 0 };
|
|
201
|
-
Object.assign(existing, { business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, hlc });
|
|
201
|
+
Object.assign(existing, { business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, paid_at: paid_at ?? existing.paid_at ?? null, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, updated_at, hlc });
|
|
202
202
|
return { lastInsertRowId: 0, changes: 1 };
|
|
203
203
|
}
|
|
204
|
-
tables.orders.push({ id, business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, hlc, deleted_at: null });
|
|
204
|
+
tables.orders.push({ id, business_id, order_number, callout_number, status, order_type, is_pos, items, subtotal_minor, total_minor, tax_minor, tax_lines, payment, paid_at: paid_at ?? null, customer_name, customer_phone, pos_payment_method, delivery_id, business, user, inserted_at, updated_at, hlc, deleted_at: null });
|
|
205
205
|
return { lastInsertRowId: 1, changes: 1 };
|
|
206
206
|
}
|
|
207
207
|
// sync_jobs insert
|
|
@@ -263,10 +263,11 @@ export function createMemoryDriver() {
|
|
|
263
263
|
return { lastInsertRowId: 0, changes: 1 };
|
|
264
264
|
}
|
|
265
265
|
if (s.includes("UPDATE orders SET payment = ?")) {
|
|
266
|
-
const [payment, hlc, business_id, id1, id2] = args;
|
|
266
|
+
const [payment, paid_at, hlc, business_id, id1, id2] = args;
|
|
267
267
|
const row = tables.orders.find((r) => r.business_id === business_id && (r.id === id1 || r.order_number === id2));
|
|
268
268
|
if (row) {
|
|
269
269
|
row.payment = payment;
|
|
270
|
+
row.paid_at = row.paid_at ?? paid_at ?? null;
|
|
270
271
|
row.hlc = hlc;
|
|
271
272
|
}
|
|
272
273
|
return { lastInsertRowId: 0, changes: 1 };
|
|
@@ -356,6 +357,12 @@ export function createMemoryDriver() {
|
|
|
356
357
|
const row = tables.orders.find((r) => r.business_id === business_id && (r.id === id1 || r.order_number === id2));
|
|
357
358
|
return row ?? null;
|
|
358
359
|
}
|
|
360
|
+
// orders business lookup by id/number (payment event with no business_id)
|
|
361
|
+
if (s.includes("SELECT business_id FROM orders WHERE id = ? OR order_number = ?")) {
|
|
362
|
+
const [id1, id2] = args;
|
|
363
|
+
const row = tables.orders.find((r) => r.id === id1 || r.order_number === id2);
|
|
364
|
+
return (row ? { business_id: row.business_id } : null);
|
|
365
|
+
}
|
|
359
366
|
// orders hlc probe (absorb-if-applied touch detection)
|
|
360
367
|
if (s.includes("SELECT hlc FROM orders WHERE business_id = ? AND id = ?")) {
|
|
361
368
|
const [business_id, id] = args;
|
|
@@ -446,20 +453,20 @@ export function createMemoryDriver() {
|
|
|
446
453
|
if (s.includes("json_extract(payment, '$.is_paid') = 1")) {
|
|
447
454
|
rows = rows.filter((r) => {
|
|
448
455
|
try {
|
|
449
|
-
return JSON.parse(r.payment ?? "{}").is_paid === true;
|
|
456
|
+
return JSON.parse(r.payment ?? "{}").is_paid === true || r.paid_at != null;
|
|
450
457
|
}
|
|
451
458
|
catch {
|
|
452
|
-
return
|
|
459
|
+
return r.paid_at != null;
|
|
453
460
|
}
|
|
454
461
|
});
|
|
455
462
|
}
|
|
456
|
-
else if (s.includes("json_extract(payment, '$.is_paid')
|
|
463
|
+
else if (s.includes("json_extract(payment, '$.is_paid'), 0) = 0")) {
|
|
457
464
|
rows = rows.filter((r) => {
|
|
458
465
|
try {
|
|
459
|
-
return JSON.parse(r.payment ?? "{}").is_paid !== true;
|
|
466
|
+
return JSON.parse(r.payment ?? "{}").is_paid !== true && r.paid_at == null;
|
|
460
467
|
}
|
|
461
468
|
catch {
|
|
462
|
-
return
|
|
469
|
+
return r.paid_at == null;
|
|
463
470
|
}
|
|
464
471
|
});
|
|
465
472
|
}
|
|
@@ -501,7 +508,7 @@ export function createMemoryDriver() {
|
|
|
501
508
|
const rows = tables.sync_jobs
|
|
502
509
|
.filter((r) => r.business_id === business_id && r.entity_id === entity_id && r.status === "pending")
|
|
503
510
|
.sort((a, b) => (a.created_at < b.created_at ? -1 : a.created_at > b.created_at ? 1 : a.rowid - b.rowid))
|
|
504
|
-
.map((r) => ({ command_type: r.command_type }));
|
|
511
|
+
.map((r) => ({ command_type: r.command_type, payload: r.payload }));
|
|
505
512
|
return rows;
|
|
506
513
|
}
|
|
507
514
|
if (s.includes("SELECT * FROM sync_jobs WHERE") || s.includes("SELECT id, command_type, status, created_at FROM sync_jobs")) {
|
|
@@ -10,6 +10,13 @@ export interface Business {
|
|
|
10
10
|
is_open: boolean;
|
|
11
11
|
/** Seller-facing open/close toggle (present when backend serializes it). */
|
|
12
12
|
manually_closed?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Fulfilment flow for orders taken on a terminal / in the business app.
|
|
15
|
+
* "staged" (default) = accept → preparing → ready → completed;
|
|
16
|
+
* "direct" = completed the moment the sale is rung up.
|
|
17
|
+
* Buyer-placed online orders always keep the staged pipeline.
|
|
18
|
+
*/
|
|
19
|
+
pos_order_flow?: "staged" | "direct";
|
|
13
20
|
owner_id: string;
|
|
14
21
|
business_number: string;
|
|
15
22
|
latitude: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teincfood/core",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "TeincFood shared offline-first core
|
|
3
|
+
"version": "0.9.25",
|
|
4
|
+
"description": "TeincFood shared offline-first core — types, sync engine, local DB, reference data, and repositories for mobile + desktop",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|