@aglyn/plugins-commerce 1.0.0-beta.232 → 1.0.0-beta.234
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/package.json +13 -13
- package/src/lib/components/cart-extras.d.ts +6 -0
- package/src/lib/components/cart-extras.js +4 -1
- package/src/lib/components/cart-extras.js.map +1 -1
- package/src/lib/components/cart-fulfillment.d.ts +117 -0
- package/src/lib/components/cart-fulfillment.js +367 -0
- package/src/lib/components/cart-fulfillment.js.map +1 -0
- package/src/lib/components/cart.js +52 -10
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +42 -1
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/console/host-orders-card.component.js +38 -10
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/local-delivery-settings-card.component.d.ts +37 -0
- package/src/lib/components/console/local-delivery-settings-card.component.js +542 -0
- package/src/lib/components/console/local-delivery-settings-card.component.js.map +1 -0
- package/src/lib/components/console/locations-card.component.js +177 -3
- package/src/lib/components/console/locations-card.component.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +10 -0
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/order-local-fulfillment-panel.component.d.ts +44 -0
- package/src/lib/components/console/order-local-fulfillment-panel.component.js +265 -0
- package/src/lib/components/console/order-local-fulfillment-panel.component.js.map +1 -0
- package/src/lib/components/console/order-offline-notice.component.d.ts +12 -0
- package/src/lib/components/console/order-offline-notice.component.js +53 -0
- package/src/lib/components/console/order-offline-notice.component.js.map +1 -0
- package/src/lib/components/console/pickup-delivery-queue-card.component.d.ts +35 -0
- package/src/lib/components/console/pickup-delivery-queue-card.component.js +222 -0
- package/src/lib/components/console/pickup-delivery-queue-card.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-api.d.ts +24 -1
- package/src/lib/components/console/pos/pos-api.js +13 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +12 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js +10 -8
- package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-kiosk-queue.component.d.ts +22 -0
- package/src/lib/components/console/pos/pos-kiosk-queue.component.js +168 -0
- package/src/lib/components/console/pos/pos-kiosk-queue.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +18 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +116 -1
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +8 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js +77 -18
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -1
- package/src/lib/components/console/pos/use-pos-display.d.ts +5 -2
- package/src/lib/components/console/pos/use-pos-display.js +3 -2
- package/src/lib/components/console/pos/use-pos-display.js.map +1 -1
- package/src/lib/components/console/pos-devices-card.component.js +2 -2
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
- package/src/lib/components/console/pos-display/pairing-screen.d.ts +5 -2
- package/src/lib/components/console/pos-display/pairing-screen.js +7 -5
- package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -1
- package/src/lib/components/console/pos-display/pos-display-api.d.ts +7 -1
- package/src/lib/components/console/pos-display/pos-display-api.js +7 -2
- package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -1
- package/src/lib/components/console/pos-kiosk/kiosk-checkout.d.ts +41 -0
- package/src/lib/components/console/pos-kiosk/kiosk-checkout.js +275 -0
- package/src/lib/components/console/pos-kiosk/kiosk-checkout.js.map +1 -0
- package/src/lib/components/console/pos-kiosk/kiosk-menu.d.ts +32 -0
- package/src/lib/components/console/pos-kiosk/kiosk-menu.js +344 -0
- package/src/lib/components/console/pos-kiosk/kiosk-menu.js.map +1 -0
- package/src/lib/components/console/pos-kiosk/kiosk-staff.d.ts +12 -0
- package/src/lib/components/console/pos-kiosk/kiosk-staff.js +257 -0
- package/src/lib/components/console/pos-kiosk/kiosk-staff.js.map +1 -0
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.d.ts +114 -0
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js +189 -0
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js.map +1 -0
- package/src/lib/components/console/pos-kiosk/use-kiosk-idle.d.ts +16 -0
- package/src/lib/components/console/pos-kiosk/use-kiosk-idle.js +80 -0
- package/src/lib/components/console/pos-kiosk/use-kiosk-idle.js.map +1 -0
- package/src/lib/components/console/pos-kiosk-page.component.d.ts +28 -0
- package/src/lib/components/console/pos-kiosk-page.component.js +791 -0
- package/src/lib/components/console/pos-kiosk-page.component.js.map +1 -0
- package/src/lib/components/console/pos-offline/pos-offline-api.d.ts +44 -0
- package/src/lib/components/console/pos-offline/pos-offline-api.js +69 -0
- package/src/lib/components/console/pos-offline/pos-offline-api.js.map +1 -0
- package/src/lib/components/console/pos-offline/pos-offline-banner.component.d.ts +7 -0
- package/src/lib/components/console/pos-offline/pos-offline-banner.component.js +135 -0
- package/src/lib/components/console/pos-offline/pos-offline-banner.component.js.map +1 -0
- package/src/lib/components/console/pos-offline/pos-offline-checkout.component.d.ts +32 -0
- package/src/lib/components/console/pos-offline/pos-offline-checkout.component.js +287 -0
- package/src/lib/components/console/pos-offline/pos-offline-checkout.component.js.map +1 -0
- package/src/lib/components/console/pos-offline/pos-offline-store.d.ts +63 -0
- package/src/lib/components/console/pos-offline/pos-offline-store.js +145 -0
- package/src/lib/components/console/pos-offline/pos-offline-store.js.map +1 -0
- package/src/lib/components/console/pos-offline/register-offline.d.ts +24 -0
- package/src/lib/components/console/pos-offline/register-offline.js +24 -0
- package/src/lib/components/console/pos-offline/register-offline.js.map +1 -0
- package/src/lib/components/console/pos-offline/use-pos-offline.d.ts +85 -0
- package/src/lib/components/console/pos-offline/use-pos-offline.js +542 -0
- package/src/lib/components/console/pos-offline/use-pos-offline.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +72 -17
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -1
- package/src/lib/components/console/pos-page.component.js +174 -27
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +35 -10
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/shipping-settings-card.component.js +1 -1
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/stock-movements-card.component.js +48 -16
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
- package/src/lib/components/console/store-zones.d.ts +8 -1
- package/src/lib/components/console/store-zones.js +11 -1
- package/src/lib/components/console/store-zones.js.map +1 -1
- package/src/lib/components/order-status.js +66 -0
- package/src/lib/components/order-status.js.map +1 -1
- package/src/lib/components/product-detail.js +42 -15
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/constants/local-fulfillment-list-query.d.ts +48 -0
- package/src/lib/constants/local-fulfillment-list-query.js +84 -0
- package/src/lib/constants/local-fulfillment-list-query.js.map +1 -0
- package/src/lib/constants/orders-list-query.d.ts +7 -2
- package/src/lib/constants/orders-list-query.js +89 -8
- package/src/lib/constants/orders-list-query.js.map +1 -1
- package/src/lib/constants/pos-shift-list-query.d.ts +22 -0
- package/src/lib/constants/pos-shift-list-query.js +115 -0
- package/src/lib/constants/pos-shift-list-query.js.map +1 -0
- package/src/lib/constants/product-list-query.d.ts +6 -1
- package/src/lib/constants/product-list-query.js +77 -8
- package/src/lib/constants/product-list-query.js.map +1 -1
- package/src/lib/constants/stock-movement-query.d.ts +3 -2
- package/src/lib/constants/stock-movement-query.js +52 -8
- package/src/lib/constants/stock-movement-query.js.map +1 -1
- package/src/lib/model/buyer-notifications.d.ts +5 -3
- package/src/lib/model/buyer-notifications.js +25 -4
- package/src/lib/model/buyer-notifications.js.map +1 -1
- package/src/lib/model/commerce-orders.d.ts +59 -0
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-pos-kiosk.d.ts +175 -0
- package/src/lib/model/commerce-pos-kiosk.js +147 -0
- package/src/lib/model/commerce-pos-kiosk.js.map +1 -0
- package/src/lib/model/commerce-pos-offline.d.ts +234 -0
- package/src/lib/model/commerce-pos-offline.js +301 -0
- package/src/lib/model/commerce-pos-offline.js.map +1 -0
- package/src/lib/model/commerce-pos-ops.d.ts +16 -6
- package/src/lib/model/commerce-pos-ops.js +12 -4
- package/src/lib/model/commerce-pos-ops.js.map +1 -1
- package/src/lib/model/commerce-pos.d.ts +13 -1
- package/src/lib/model/commerce-pos.js +5 -4
- package/src/lib/model/commerce-pos.js.map +1 -1
- package/src/lib/model/commerce-stock-holds.d.ts +24 -3
- package/src/lib/model/commerce-stock-holds.js +26 -8
- package/src/lib/model/commerce-stock-holds.js.map +1 -1
- package/src/lib/model/commerce.d.ts +3 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +4 -0
- package/src/lib/model/index.js +4 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/local-fulfillment-settings.d.ts +178 -0
- package/src/lib/model/local-fulfillment-settings.js +361 -0
- package/src/lib/model/local-fulfillment-settings.js.map +1 -0
- package/src/lib/model/order-list-fields.d.ts +10 -1
- package/src/lib/model/order-list-fields.js +1 -0
- package/src/lib/model/order-list-fields.js.map +1 -1
- package/src/lib/model/order-local-fulfillment.d.ts +131 -0
- package/src/lib/model/order-local-fulfillment.js +125 -0
- package/src/lib/model/order-local-fulfillment.js.map +1 -0
- package/src/lib/model/order-shipping-export.js +4 -0
- package/src/lib/model/order-shipping-export.js.map +1 -1
- package/src/lib/model/order-status-view.d.ts +20 -1
- package/src/lib/model/order-status-view.js +60 -6
- package/src/lib/model/order-status-view.js.map +1 -1
- package/src/lib/plugin-config.js +6 -2
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +8 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/pos-kiosk-config.d.ts +26 -0
- package/src/lib/pos-kiosk-config.js +59 -0
- package/src/lib/pos-kiosk-config.js.map +1 -0
- package/src/lib/server/api-v1/openapi.js +8 -0
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/api-v1/order-view.d.ts +19 -0
- package/src/lib/server/api-v1/order-view.js +35 -0
- package/src/lib/server/api-v1/order-view.js.map +1 -1
- package/src/lib/server/billing-webhook.js +238 -87
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cart-checkout.d.ts +2 -0
- package/src/lib/server/cart-checkout.js +173 -13
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/checkout-extras.js +18 -4
- package/src/lib/server/checkout-extras.js.map +1 -1
- package/src/lib/server/checkout.js +71 -14
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/local-fulfillment-status.d.ts +86 -0
- package/src/lib/server/local-fulfillment-status.js +379 -0
- package/src/lib/server/local-fulfillment-status.js.map +1 -0
- package/src/lib/server/local-fulfillment.d.ts +190 -0
- package/src/lib/server/local-fulfillment.js +580 -0
- package/src/lib/server/local-fulfillment.js.map +1 -0
- package/src/lib/server/membership-register.js +3 -1
- package/src/lib/server/membership-register.js.map +1 -1
- package/src/lib/server/order-notifications.js +61 -0
- package/src/lib/server/order-notifications.js.map +1 -1
- package/src/lib/server/pos-display.d.ts +27 -1
- package/src/lib/server/pos-display.js +50 -9
- package/src/lib/server/pos-display.js.map +1 -1
- package/src/lib/server/pos-kiosk-principal.d.ts +29 -0
- package/src/lib/server/pos-kiosk-principal.js +42 -0
- package/src/lib/server/pos-kiosk-principal.js.map +1 -0
- package/src/lib/server/pos-kiosk.d.ts +54 -0
- package/src/lib/server/pos-kiosk.js +972 -0
- package/src/lib/server/pos-kiosk.js.map +1 -0
- package/src/lib/server/pos-offline-sync.d.ts +85 -0
- package/src/lib/server/pos-offline-sync.js +765 -0
- package/src/lib/server/pos-offline-sync.js.map +1 -0
- package/src/lib/server/pos-order.js +22 -4
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.d.ts +6 -0
- package/src/lib/server/pos-payment.js +225 -6
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-print.js +5 -0
- package/src/lib/server/pos-print.js.map +1 -1
- package/src/lib/server/pos-return.js +27 -0
- package/src/lib/server/pos-return.js.map +1 -1
- package/src/lib/server/pos-sale.d.ts +6 -0
- package/src/lib/server/pos-sale.js +2 -0
- package/src/lib/server/pos-sale.js.map +1 -1
- package/src/lib/server/pos-shift.js +8 -1
- package/src/lib/server/pos-shift.js.map +1 -1
- package/src/lib/server/refund.js +3 -0
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/stock-hold.d.ts +9 -1
- package/src/lib/server/stock-hold.js +15 -7
- package/src/lib/server/stock-hold.js.map +1 -1
- package/src/lib/server.js +16 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tenant-emails.js +161 -0
- package/src/lib/tenant-emails.js.map +1 -1
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
+
import * as CommerceModel from "../../model/index.js";
|
|
20
|
+
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
21
|
+
import { Alert, Button, Chip, Divider, Stack, TextField, Typography } from "@mui/material";
|
|
22
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
23
|
+
import { useCallback, useState } from "react";
|
|
24
|
+
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
25
|
+
const STEP_DONE = {
|
|
26
|
+
ready: 'Marked ready — the buyer has been told',
|
|
27
|
+
preparing: 'Back to preparing',
|
|
28
|
+
picked_up: 'Marked picked up',
|
|
29
|
+
out_for_delivery: 'Out for delivery — the buyer has been told',
|
|
30
|
+
delivered: 'Marked delivered',
|
|
31
|
+
delivery_failed: 'Delivery marked failed'
|
|
32
|
+
};
|
|
33
|
+
/** Posts one step. Resolves `true` when the order moved (or already had). */ export function useLocalFulfillmentStep(hostId) {
|
|
34
|
+
const { data: user } = useUser();
|
|
35
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
36
|
+
const [busy, setBusy] = useState(false);
|
|
37
|
+
const run = useCallback(async (orderId, action, extra = {})=>{
|
|
38
|
+
setBusy(true);
|
|
39
|
+
try {
|
|
40
|
+
const response = await authorizedFetch(user, '/api/commerce/local-fulfillment', {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: {
|
|
43
|
+
'Content-Type': 'application/json'
|
|
44
|
+
},
|
|
45
|
+
body: JSON.stringify(_extends({
|
|
46
|
+
hostId,
|
|
47
|
+
orderId,
|
|
48
|
+
action
|
|
49
|
+
}, extra))
|
|
50
|
+
});
|
|
51
|
+
const payload = await response.json().catch(()=>({}));
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
var _ref;
|
|
54
|
+
enqueueSnackbar((_ref = payload == null ? void 0 : payload.error) != null ? _ref : `The update failed (${response.status}) and it is not known whether it landed. Reopen the order to check.`, {
|
|
55
|
+
variant: response.status === 409 ? 'warning' : 'error',
|
|
56
|
+
allowDuplicate: true
|
|
57
|
+
});
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
enqueueSnackbar((payload == null ? void 0 : payload.already) ? 'Already done' : STEP_DONE[action], {
|
|
61
|
+
variant: 'success',
|
|
62
|
+
persist: false
|
|
63
|
+
});
|
|
64
|
+
return true;
|
|
65
|
+
} catch (unused) {
|
|
66
|
+
enqueueSnackbar('The request did not complete. Reopen the order to check — retrying is safe.', {
|
|
67
|
+
variant: 'error',
|
|
68
|
+
allowDuplicate: true
|
|
69
|
+
});
|
|
70
|
+
return false;
|
|
71
|
+
} finally{
|
|
72
|
+
setBusy(false);
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
enqueueSnackbar,
|
|
76
|
+
hostId,
|
|
77
|
+
user
|
|
78
|
+
]);
|
|
79
|
+
return {
|
|
80
|
+
run,
|
|
81
|
+
busy
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** The steps an order can take next, in the order a person takes them. */ export function nextLocalFulfillmentSteps(order) {
|
|
85
|
+
if ([
|
|
86
|
+
'cancelled',
|
|
87
|
+
'refunded',
|
|
88
|
+
'pending'
|
|
89
|
+
].includes(order.status)) return [];
|
|
90
|
+
if (order.fulfillmentMethod === 'pickup' && order.pickup) {
|
|
91
|
+
const status = CommerceModel.orderPickupStatus(order.pickup.status);
|
|
92
|
+
if (status === 'preparing') {
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
step: 'ready',
|
|
96
|
+
label: 'Mark ready',
|
|
97
|
+
primary: true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
step: 'picked_up',
|
|
101
|
+
label: 'Picked up'
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
if (status === 'ready') {
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
step: 'picked_up',
|
|
109
|
+
label: 'Picked up',
|
|
110
|
+
primary: true
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
step: 'preparing',
|
|
114
|
+
label: 'Not ready yet'
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
if (order.fulfillmentMethod === 'local_delivery' && order.localDelivery) {
|
|
121
|
+
const status = CommerceModel.orderLocalDeliveryStatus(order.localDelivery.status);
|
|
122
|
+
if (status === 'scheduled' || status === 'failed') {
|
|
123
|
+
return [
|
|
124
|
+
{
|
|
125
|
+
step: 'out_for_delivery',
|
|
126
|
+
label: 'Out for delivery',
|
|
127
|
+
primary: true
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
step: 'delivered',
|
|
131
|
+
label: 'Delivered'
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
if (status === 'out_for_delivery') {
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
step: 'delivered',
|
|
139
|
+
label: 'Delivered',
|
|
140
|
+
primary: true
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
step: 'delivery_failed',
|
|
144
|
+
label: 'Couldn’t deliver'
|
|
145
|
+
}
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
export function OrderLocalFulfillmentPanel(props) {
|
|
152
|
+
const { hostId, orderId, order } = props;
|
|
153
|
+
const { run, busy } = useLocalFulfillmentStep(hostId);
|
|
154
|
+
const [failing, setFailing] = useState(false);
|
|
155
|
+
const [reason, setReason] = useState('');
|
|
156
|
+
if (!CommerceModel.orderIsLocallyFulfilled(order)) return null;
|
|
157
|
+
const steps = nextLocalFulfillmentSteps(order);
|
|
158
|
+
const take = (step)=>{
|
|
159
|
+
if (step === 'delivery_failed' && !failing) return setFailing(true);
|
|
160
|
+
void run(orderId, step, step === 'delivery_failed' && reason.trim() ? {
|
|
161
|
+
reason: reason.trim()
|
|
162
|
+
} : {}).then((moved)=>{
|
|
163
|
+
if (moved) {
|
|
164
|
+
setFailing(false);
|
|
165
|
+
setReason('');
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
const pickup = order.fulfillmentMethod === 'pickup' ? order.pickup : undefined;
|
|
170
|
+
const delivery = order.fulfillmentMethod === 'local_delivery' ? order.localDelivery : undefined;
|
|
171
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
172
|
+
children: [
|
|
173
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
174
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
175
|
+
spacing: 0.75,
|
|
176
|
+
children: [
|
|
177
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
178
|
+
direction: "row",
|
|
179
|
+
spacing: 1,
|
|
180
|
+
sx: {
|
|
181
|
+
alignItems: 'center'
|
|
182
|
+
},
|
|
183
|
+
children: [
|
|
184
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
185
|
+
variant: "subtitle2",
|
|
186
|
+
sx: {
|
|
187
|
+
flex: 1
|
|
188
|
+
},
|
|
189
|
+
children: pickup ? 'Pickup' : 'Local delivery'
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ _jsx(Chip, {
|
|
192
|
+
size: "small",
|
|
193
|
+
variant: "outlined",
|
|
194
|
+
label: pickup ? CommerceModel.ORDER_PICKUP_STATUS_LABELS[CommerceModel.orderPickupStatus(pickup.status)] : CommerceModel.ORDER_LOCAL_DELIVERY_STATUS_LABELS[CommerceModel.orderLocalDeliveryStatus(delivery == null ? void 0 : delivery.status)]
|
|
195
|
+
})
|
|
196
|
+
]
|
|
197
|
+
}),
|
|
198
|
+
pickup ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
199
|
+
children: [
|
|
200
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
201
|
+
variant: "body2",
|
|
202
|
+
children: [
|
|
203
|
+
pickup.locationName,
|
|
204
|
+
pickup.address ? ` — ${pickup.address}` : ''
|
|
205
|
+
]
|
|
206
|
+
}),
|
|
207
|
+
pickup.pickedUpBy ? /*#__PURE__*/ _jsx(Typography, {
|
|
208
|
+
variant: "caption",
|
|
209
|
+
color: "text.secondary",
|
|
210
|
+
children: `Collected by ${pickup.pickedUpBy}`
|
|
211
|
+
}) : null
|
|
212
|
+
]
|
|
213
|
+
}) : null,
|
|
214
|
+
delivery ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
215
|
+
children: [
|
|
216
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
217
|
+
variant: "body2",
|
|
218
|
+
children: [
|
|
219
|
+
delivery.windowLabel,
|
|
220
|
+
delivery.zoneName,
|
|
221
|
+
delivery.postalCode
|
|
222
|
+
].filter(Boolean).join(' · ')
|
|
223
|
+
}),
|
|
224
|
+
delivery.addressOutsideZone ? /*#__PURE__*/ _jsx(Alert, {
|
|
225
|
+
severity: "warning",
|
|
226
|
+
children: 'The address entered at payment is outside your delivery zones. Contact the buyer, or refund the delivery.'
|
|
227
|
+
}) : null,
|
|
228
|
+
delivery.failedReason ? /*#__PURE__*/ _jsx(Typography, {
|
|
229
|
+
variant: "caption",
|
|
230
|
+
color: "text.secondary",
|
|
231
|
+
children: `Last attempt: ${delivery.failedReason}`
|
|
232
|
+
}) : null
|
|
233
|
+
]
|
|
234
|
+
}) : null,
|
|
235
|
+
failing ? /*#__PURE__*/ _jsx(TextField, {
|
|
236
|
+
label: "What happened (optional)",
|
|
237
|
+
value: reason,
|
|
238
|
+
onChange: (event)=>setReason(event.target.value),
|
|
239
|
+
size: "small",
|
|
240
|
+
slotProps: {
|
|
241
|
+
htmlInput: {
|
|
242
|
+
maxLength: 200
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}) : null,
|
|
246
|
+
steps.length ? /*#__PURE__*/ _jsx(Stack, {
|
|
247
|
+
direction: "row",
|
|
248
|
+
spacing: 1,
|
|
249
|
+
children: steps.map((entry)=>/*#__PURE__*/ _jsx(Button, {
|
|
250
|
+
size: "small",
|
|
251
|
+
variant: entry.primary ? 'contained' : 'text',
|
|
252
|
+
disabled: busy,
|
|
253
|
+
onClick: ()=>take(entry.step),
|
|
254
|
+
children: entry.step === 'delivery_failed' && failing ? 'Save' : entry.label
|
|
255
|
+
}, entry.step))
|
|
256
|
+
}) : null
|
|
257
|
+
]
|
|
258
|
+
})
|
|
259
|
+
]
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
OrderLocalFulfillmentPanel.displayName = 'OrderLocalFulfillmentPanel';
|
|
263
|
+
export default OrderLocalFulfillmentPanel;
|
|
264
|
+
|
|
265
|
+
//# sourceMappingURL=order-local-fulfillment-panel.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/order-local-fulfillment-panel.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Alert, Button, Chip, Divider, Stack, TextField, Typography } from '@mui/material'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useCallback, useState } from 'react'\nimport { useUser } from '@aglyn/tenant-feature-instance'\n\n/**\n * The pickup or local delivery of one order (AGL-3624), and the next step\n * the store can take with it, posted to `/api/commerce/local-fulfillment`.\n * Shared by the order dialog and the pickup and delivery queue, so both say\n * the same thing and take the same steps.\n */\n\nexport type LocalFulfillmentStep =\n | 'ready'\n | 'preparing'\n | 'picked_up'\n | 'out_for_delivery'\n | 'delivered'\n | 'delivery_failed'\n\nconst STEP_DONE: Record<LocalFulfillmentStep, string> = {\n ready: 'Marked ready — the buyer has been told',\n preparing: 'Back to preparing',\n picked_up: 'Marked picked up',\n out_for_delivery: 'Out for delivery — the buyer has been told',\n delivered: 'Marked delivered',\n delivery_failed: 'Delivery marked failed',\n}\n\n/** Posts one step. Resolves `true` when the order moved (or already had). */\nexport function useLocalFulfillmentStep(hostId: string) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [busy, setBusy] = useState(false)\n const run = useCallback(\n async (orderId: string, action: LocalFulfillmentStep, extra: Record<string, unknown> = {}) => {\n setBusy(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/local-fulfillment', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, orderId, action, ...extra }),\n })\n const payload: any = await response.json().catch(() => ({}))\n if (!response.ok) {\n enqueueSnackbar(\n payload?.error ??\n `The update failed (${response.status}) and it is not known whether it landed. Reopen the order to check.`,\n { variant: response.status === 409 ? 'warning' : 'error', allowDuplicate: true },\n )\n return false\n }\n enqueueSnackbar(payload?.already ? 'Already done' : STEP_DONE[action], {\n variant: 'success',\n persist: false,\n })\n return true\n } catch {\n enqueueSnackbar('The request did not complete. Reopen the order to check — retrying is safe.', {\n variant: 'error',\n allowDuplicate: true,\n })\n return false\n } finally {\n setBusy(false)\n }\n },\n [enqueueSnackbar, hostId, user],\n )\n return { run, busy }\n}\n\n/** The steps an order can take next, in the order a person takes them. */\nexport function nextLocalFulfillmentSteps(\n order: Pick<CommerceModel.HostOrder, 'fulfillmentMethod' | 'pickup' | 'localDelivery' | 'status'>,\n): Array<{ step: LocalFulfillmentStep; label: string; primary?: boolean }> {\n if (['cancelled', 'refunded', 'pending'].includes(order.status)) return []\n if (order.fulfillmentMethod === 'pickup' && order.pickup) {\n const status = CommerceModel.orderPickupStatus(order.pickup.status)\n if (status === 'preparing') {\n return [\n { step: 'ready', label: 'Mark ready', primary: true },\n { step: 'picked_up', label: 'Picked up' },\n ]\n }\n if (status === 'ready') {\n return [\n { step: 'picked_up', label: 'Picked up', primary: true },\n { step: 'preparing', label: 'Not ready yet' },\n ]\n }\n return []\n }\n if (order.fulfillmentMethod === 'local_delivery' && order.localDelivery) {\n const status = CommerceModel.orderLocalDeliveryStatus(order.localDelivery.status)\n if (status === 'scheduled' || status === 'failed') {\n return [\n { step: 'out_for_delivery', label: 'Out for delivery', primary: true },\n { step: 'delivered', label: 'Delivered' },\n ]\n }\n if (status === 'out_for_delivery') {\n return [\n { step: 'delivered', label: 'Delivered', primary: true },\n { step: 'delivery_failed', label: 'Couldn’t deliver' },\n ]\n }\n }\n return []\n}\n\nexport function OrderLocalFulfillmentPanel(props: {\n hostId: string\n orderId: string\n order: CommerceModel.HostOrder\n}) {\n const { hostId, orderId, order } = props\n const { run, busy } = useLocalFulfillmentStep(hostId)\n const [failing, setFailing] = useState(false)\n const [reason, setReason] = useState('')\n if (!CommerceModel.orderIsLocallyFulfilled(order)) return null\n const steps = nextLocalFulfillmentSteps(order)\n const take = (step: LocalFulfillmentStep) => {\n if (step === 'delivery_failed' && !failing) return setFailing(true)\n void run(orderId, step, step === 'delivery_failed' && reason.trim() ? { reason: reason.trim() } : {}).then(\n (moved) => {\n if (moved) {\n setFailing(false)\n setReason('')\n }\n },\n )\n }\n const pickup = order.fulfillmentMethod === 'pickup' ? order.pickup : undefined\n const delivery = order.fulfillmentMethod === 'local_delivery' ? order.localDelivery : undefined\n return (\n <>\n <Divider />\n <Stack spacing={0.75}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"subtitle2\" sx={{ flex: 1 }}>\n {pickup ? 'Pickup' : 'Local delivery'}\n </Typography>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={\n pickup\n ? CommerceModel.ORDER_PICKUP_STATUS_LABELS[CommerceModel.orderPickupStatus(pickup.status)]\n : CommerceModel.ORDER_LOCAL_DELIVERY_STATUS_LABELS[\n CommerceModel.orderLocalDeliveryStatus(delivery?.status)\n ]\n }\n />\n </Stack>\n {pickup ? (\n <>\n <Typography variant=\"body2\">\n {pickup.locationName}\n {pickup.address ? ` — ${pickup.address}` : ''}\n </Typography>\n {pickup.pickedUpBy ? (\n <Typography variant=\"caption\" color=\"text.secondary\">{`Collected by ${pickup.pickedUpBy}`}</Typography>\n ) : null}\n </>\n ) : null}\n {delivery ? (\n <>\n <Typography variant=\"body2\">\n {[delivery.windowLabel, delivery.zoneName, delivery.postalCode].filter(Boolean).join(' · ')}\n </Typography>\n {delivery.addressOutsideZone ? (\n <Alert severity=\"warning\">\n {'The address entered at payment is outside your delivery zones. Contact the buyer, or refund the delivery.'}\n </Alert>\n ) : null}\n {delivery.failedReason ? (\n <Typography variant=\"caption\" color=\"text.secondary\">{`Last attempt: ${delivery.failedReason}`}</Typography>\n ) : null}\n </>\n ) : null}\n {failing ? (\n <TextField\n label=\"What happened (optional)\"\n value={reason}\n onChange={(event) => setReason(event.target.value)}\n size=\"small\"\n slotProps={{ htmlInput: { maxLength: 200 } }}\n />\n ) : null}\n {steps.length ? (\n <Stack direction=\"row\" spacing={1}>\n {steps.map((entry) => (\n <Button\n key={entry.step}\n size=\"small\"\n variant={entry.primary ? 'contained' : 'text'}\n disabled={busy}\n onClick={() => take(entry.step)}\n >\n {entry.step === 'delivery_failed' && failing ? 'Save' : entry.label}\n </Button>\n ))}\n </Stack>\n ) : null}\n </Stack>\n </>\n )\n}\nOrderLocalFulfillmentPanel.displayName = 'OrderLocalFulfillmentPanel'\n\nexport default OrderLocalFulfillmentPanel\n"],"names":["CommerceModel","useSnackbar","Alert","Button","Chip","Divider","Stack","TextField","Typography","authorizedFetch","useCallback","useState","useUser","STEP_DONE","ready","preparing","picked_up","out_for_delivery","delivered","delivery_failed","useLocalFulfillmentStep","hostId","data","user","enqueueSnackbar","busy","setBusy","run","orderId","action","extra","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","status","variant","allowDuplicate","already","persist","nextLocalFulfillmentSteps","order","includes","fulfillmentMethod","pickup","orderPickupStatus","step","label","primary","localDelivery","orderLocalDeliveryStatus","OrderLocalFulfillmentPanel","props","failing","setFailing","reason","setReason","orderIsLocallyFulfilled","steps","take","trim","then","moved","undefined","delivery","spacing","direction","sx","alignItems","flex","size","ORDER_PICKUP_STATUS_LABELS","ORDER_LOCAL_DELIVERY_STATUS_LABELS","locationName","address","pickedUpBy","color","windowLabel","zoneName","postalCode","filter","Boolean","join","addressOutsideZone","severity","failedReason","value","onChange","event","target","slotProps","htmlInput","maxLength","length","map","entry","disabled","onClick","displayName"],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as CommerceModel from '../../model';
|
|
2
|
+
/**
|
|
3
|
+
* A register sale rung offline (AGL-3625), said on its order: when it was
|
|
4
|
+
* rung and synced, and what the sync found that the merchant should check —
|
|
5
|
+
* stock that went short above all. Nothing on any other order.
|
|
6
|
+
*/
|
|
7
|
+
export declare function OrderOfflineNotice(props: {
|
|
8
|
+
order: Pick<CommerceModel.HostOrder, 'offline'>;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
export declare namespace OrderOfflineNotice {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { Alert, AlertTitle, Typography } from "@mui/material";
|
|
19
|
+
import { posOfflineFlagLabels } from "../../model/commerce-pos-offline.js";
|
|
20
|
+
/**
|
|
21
|
+
* A register sale rung offline (AGL-3625), said on its order: when it was
|
|
22
|
+
* rung and synced, and what the sync found that the merchant should check —
|
|
23
|
+
* stock that went short above all. Nothing on any other order.
|
|
24
|
+
*/ export function OrderOfflineNotice(props) {
|
|
25
|
+
var _stamp_stockConflicts, _stamp_flags;
|
|
26
|
+
const stamp = props.order.offline;
|
|
27
|
+
if (!stamp) return null;
|
|
28
|
+
const conflicts = (_stamp_stockConflicts = stamp.stockConflicts) != null ? _stamp_stockConflicts : [];
|
|
29
|
+
const flags = ((_stamp_flags = stamp.flags) != null ? _stamp_flags : []).filter((flag)=>flag !== 'stock-short');
|
|
30
|
+
const checks = [
|
|
31
|
+
...conflicts.map((conflict)=>`${conflict.shortUnits} of ${conflict.requested}× ${conflict.name} not in stock`),
|
|
32
|
+
...posOfflineFlagLabels(flags)
|
|
33
|
+
];
|
|
34
|
+
return /*#__PURE__*/ _jsxs(Alert, {
|
|
35
|
+
severity: checks.length ? 'warning' : 'info',
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ _jsx(AlertTitle, {
|
|
38
|
+
children: 'Rung while the register was offline'
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
41
|
+
variant: "body2",
|
|
42
|
+
children: `Rung ${new Date(stamp.soldAtMs).toLocaleString()}, synced ${new Date(stamp.syncedAtMs).toLocaleString()}.`
|
|
43
|
+
}),
|
|
44
|
+
checks.map((check)=>/*#__PURE__*/ _jsx(Typography, {
|
|
45
|
+
variant: "body2",
|
|
46
|
+
children: check
|
|
47
|
+
}, check))
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
OrderOfflineNotice.displayName = 'OrderOfflineNotice';
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=order-offline-notice.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/order-offline-notice.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { Alert, AlertTitle, Typography } from '@mui/material'\nimport type * as CommerceModel from '../../model'\nimport { posOfflineFlagLabels } from '../../model/commerce-pos-offline'\n\n/**\n * A register sale rung offline (AGL-3625), said on its order: when it was\n * rung and synced, and what the sync found that the merchant should check —\n * stock that went short above all. Nothing on any other order.\n */\nexport function OrderOfflineNotice(props: { order: Pick<CommerceModel.HostOrder, 'offline'> }) {\n const stamp = props.order.offline\n if (!stamp) return null\n const conflicts = stamp.stockConflicts ?? []\n const flags = (stamp.flags ?? []).filter((flag) => flag !== 'stock-short')\n const checks = [\n ...conflicts.map((conflict) => `${conflict.shortUnits} of ${conflict.requested}× ${conflict.name} not in stock`),\n ...posOfflineFlagLabels(flags),\n ]\n return (\n <Alert severity={checks.length ? 'warning' : 'info'}>\n <AlertTitle>{'Rung while the register was offline'}</AlertTitle>\n <Typography variant=\"body2\">\n {`Rung ${new Date(stamp.soldAtMs).toLocaleString()}, synced ${new Date(stamp.syncedAtMs).toLocaleString()}.`}\n </Typography>\n {checks.map((check) => (\n <Typography key={check} variant=\"body2\">\n {check}\n </Typography>\n ))}\n </Alert>\n )\n}\nOrderOfflineNotice.displayName = 'OrderOfflineNotice'\n"],"names":["Alert","AlertTitle","Typography","posOfflineFlagLabels","OrderOfflineNotice","props","stamp","order","offline","conflicts","stockConflicts","flags","filter","flag","checks","map","conflict","shortUnits","requested","name","severity","length","variant","Date","soldAtMs","toLocaleString","syncedAtMs","check","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,KAAK,EAAEC,UAAU,EAAEC,UAAU,QAAQ,gBAAe;AAE7D,SAASC,oBAAoB,QAAQ,sCAAkC;AAEvE;;;;CAIC,GACD,OAAO,SAASC,mBAAmBC,KAA0D;QAGzEC,uBACHA;IAHf,MAAMA,QAAQD,MAAME,KAAK,CAACC,OAAO;IACjC,IAAI,CAACF,OAAO,OAAO;IACnB,MAAMG,aAAYH,wBAAAA,MAAMI,cAAc,YAApBJ,wBAAwB,EAAE;IAC5C,MAAMK,QAAQ,EAACL,eAAAA,MAAMK,KAAK,YAAXL,eAAe,EAAE,EAAEM,MAAM,CAAC,CAACC,OAASA,SAAS;IAC5D,MAAMC,SAAS;WACVL,UAAUM,GAAG,CAAC,CAACC,WAAa,GAAGA,SAASC,UAAU,CAAC,IAAI,EAAED,SAASE,SAAS,CAAC,EAAE,EAAEF,SAASG,IAAI,CAAC,aAAa,CAAC;WAC5GhB,qBAAqBQ;KACzB;IACD,qBACE,MAACX;QAAMoB,UAAUN,OAAOO,MAAM,GAAG,YAAY;;0BAC3C,KAACpB;0BAAY;;0BACb,KAACC;gBAAWoB,SAAQ;0BACjB,CAAC,KAAK,EAAE,IAAIC,KAAKjB,MAAMkB,QAAQ,EAAEC,cAAc,GAAG,SAAS,EAAE,IAAIF,KAAKjB,MAAMoB,UAAU,EAAED,cAAc,GAAG,CAAC,CAAC;;YAE7GX,OAAOC,GAAG,CAAC,CAACY,sBACX,KAACzB;oBAAuBoB,SAAQ;8BAC7BK;mBADcA;;;AAMzB;AACAvB,mBAAmBwB,WAAW,GAAG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export interface PickupDeliveryQueueCardProps {
|
|
18
|
+
hostId: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The pickup and local delivery queue (AGL-3624): what to prepare, what is
|
|
22
|
+
* waiting at the counter, and what the store's driver takes out, per
|
|
23
|
+
* location, soonest first — each tab ONE Firestore query on the fields every
|
|
24
|
+
* pickup and delivery writer stamps (`constants/local-fulfillment-list-query`),
|
|
25
|
+
* which the native Aglyn app runs too. A row's next step is one click; the
|
|
26
|
+
* order opens for anything more.
|
|
27
|
+
*
|
|
28
|
+
* Draws nothing for a store with no pickup location and no local delivery
|
|
29
|
+
* switched on, so a store that only ships never sees it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function PickupDeliveryQueueCard(props: PickupDeliveryQueueCardProps): import("react").JSX.Element;
|
|
32
|
+
export declare namespace PickupDeliveryQueueCard {
|
|
33
|
+
var displayName: string;
|
|
34
|
+
}
|
|
35
|
+
export default PickupDeliveryQueueCard;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
import * as CommerceModel from "../../model/index.js";
|
|
20
|
+
import { LOCAL_FULFILLMENT_QUEUE_TABS, localFulfillmentQueueQuery } from "../../constants/local-fulfillment-list-query.js";
|
|
21
|
+
import { CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
22
|
+
import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
23
|
+
import { Button, MenuItem, Stack, Tab, Tabs, TextField, Typography } from "@mui/material";
|
|
24
|
+
import { collection, doc, limit, orderBy, query, where } from "firebase/firestore";
|
|
25
|
+
import { useMemo, useState } from "react";
|
|
26
|
+
import { useFirestore, useFirestoreCollection, useFirestoreDoc, usePagedCollection } from "@aglyn/tenant-feature-instance";
|
|
27
|
+
import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
|
|
28
|
+
import OrderDetailDialog from "./order-detail-dialog.component.js";
|
|
29
|
+
import { nextLocalFulfillmentSteps, useLocalFulfillmentStep } from "./order-local-fulfillment-panel.component.js";
|
|
30
|
+
/**
|
|
31
|
+
* The pickup and local delivery queue (AGL-3624): what to prepare, what is
|
|
32
|
+
* waiting at the counter, and what the store's driver takes out, per
|
|
33
|
+
* location, soonest first — each tab ONE Firestore query on the fields every
|
|
34
|
+
* pickup and delivery writer stamps (`constants/local-fulfillment-list-query`),
|
|
35
|
+
* which the native Aglyn app runs too. A row's next step is one click; the
|
|
36
|
+
* order opens for anything more.
|
|
37
|
+
*
|
|
38
|
+
* Draws nothing for a store with no pickup location and no local delivery
|
|
39
|
+
* switched on, so a store that only ships never sees it.
|
|
40
|
+
*/ export function PickupDeliveryQueueCard(props) {
|
|
41
|
+
var _ref;
|
|
42
|
+
var _tabs_;
|
|
43
|
+
const { hostId } = props;
|
|
44
|
+
const firestore = useFirestore();
|
|
45
|
+
const [tab, setTab] = useState('pickup_preparing');
|
|
46
|
+
const [locationId, setLocationId] = useState('');
|
|
47
|
+
const [open, setOpen] = useState(null);
|
|
48
|
+
const { run, busy } = useLocalFulfillmentStep(hostId);
|
|
49
|
+
const { data: locationDocs } = useFirestoreCollection(()=>query(collection(firestore, 'hosts', hostId, 'locations'), limit(25)), [
|
|
50
|
+
firestore,
|
|
51
|
+
hostId
|
|
52
|
+
], {
|
|
53
|
+
idField: '$id'
|
|
54
|
+
});
|
|
55
|
+
const { data: settings } = useFirestoreDoc(()=>doc(firestore, 'hosts', hostId, 'settings', 'store'), [
|
|
56
|
+
firestore,
|
|
57
|
+
hostId
|
|
58
|
+
]);
|
|
59
|
+
const pickupOn = (locationDocs != null ? locationDocs : []).some((location)=>CommerceModel.normalizePickupSettings(location == null ? void 0 : location.pickup).enabled);
|
|
60
|
+
const deliveryOn = Boolean(CommerceModel.normalizeLocalDeliverySettings(settings == null ? void 0 : settings.localDelivery).enabled);
|
|
61
|
+
const tabs = LOCAL_FULFILLMENT_QUEUE_TABS.filter((entry)=>entry.method === 'pickup' ? pickupOn : deliveryOn);
|
|
62
|
+
const active = tabs.some((entry)=>entry.key === tab) ? tab : (_ref = (_tabs_ = tabs[0]) == null ? void 0 : _tabs_.key) != null ? _ref : tab;
|
|
63
|
+
const plan = useMemo(()=>localFulfillmentQueueQuery(active, locationId || null), [
|
|
64
|
+
active,
|
|
65
|
+
locationId
|
|
66
|
+
]);
|
|
67
|
+
const anyOn = tabs.length > 0;
|
|
68
|
+
// Paged like every list of something that grows: one tab's query, a page
|
|
69
|
+
// at a time (the native app pages it by `plan.limit`).
|
|
70
|
+
const { rows, status, page, setPage, pageSize, setPageSize, hasMore } = usePagedCollection((pageLimit)=>anyOn ? query(collection(firestore, 'hosts', hostId, 'orders'), ...plan.where.map((clause)=>where(clause.field, clause.op, clause.value)), orderBy(plan.orderBy.field, plan.orderBy.direction), limit(pageLimit)) : null, [
|
|
71
|
+
firestore,
|
|
72
|
+
hostId,
|
|
73
|
+
active,
|
|
74
|
+
locationId,
|
|
75
|
+
anyOn
|
|
76
|
+
], {
|
|
77
|
+
idField: '$id'
|
|
78
|
+
});
|
|
79
|
+
if (!tabs.length) return null;
|
|
80
|
+
const orders = (rows != null ? rows : []).map((row)=>_extends({}, CommerceModel.liftLegacyOrder(row), {
|
|
81
|
+
$id: String(row.$id)
|
|
82
|
+
}));
|
|
83
|
+
const locations = [
|
|
84
|
+
...locationDocs != null ? locationDocs : []
|
|
85
|
+
].sort((a, b)=>{
|
|
86
|
+
var _a_name, _b_name;
|
|
87
|
+
return String((_a_name = a.name) != null ? _a_name : '').localeCompare(String((_b_name = b.name) != null ? _b_name : ''));
|
|
88
|
+
});
|
|
89
|
+
return /*#__PURE__*/ _jsxs(CardDisplay, {
|
|
90
|
+
header: 'Pickup & delivery',
|
|
91
|
+
help: pluginDocsHelp('commerce', {
|
|
92
|
+
anchor: '#pickup-and-local-delivery'
|
|
93
|
+
}),
|
|
94
|
+
HeaderProps: {
|
|
95
|
+
action: locations.length > 1 ? /*#__PURE__*/ _jsxs(TextField, {
|
|
96
|
+
select: true,
|
|
97
|
+
label: "Location",
|
|
98
|
+
value: locationId,
|
|
99
|
+
onChange: (event)=>setLocationId(event.target.value),
|
|
100
|
+
size: "small",
|
|
101
|
+
sx: {
|
|
102
|
+
minWidth: 160
|
|
103
|
+
},
|
|
104
|
+
children: [
|
|
105
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
106
|
+
value: "",
|
|
107
|
+
children: 'All locations'
|
|
108
|
+
}),
|
|
109
|
+
locations.map((location)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
110
|
+
value: location.$id,
|
|
111
|
+
children: location.name
|
|
112
|
+
}, location.$id))
|
|
113
|
+
]
|
|
114
|
+
}) : null
|
|
115
|
+
},
|
|
116
|
+
contentGutterX: true,
|
|
117
|
+
contentGutterY: true,
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ _jsx(Tabs, {
|
|
120
|
+
value: active,
|
|
121
|
+
onChange: (_event, value)=>setTab(value),
|
|
122
|
+
variant: "scrollable",
|
|
123
|
+
allowScrollButtonsMobile: true,
|
|
124
|
+
children: tabs.map((entry)=>/*#__PURE__*/ _jsx(Tab, {
|
|
125
|
+
value: entry.key,
|
|
126
|
+
label: entry.label
|
|
127
|
+
}, entry.key))
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
130
|
+
spacing: 1,
|
|
131
|
+
sx: {
|
|
132
|
+
pt: 1.5
|
|
133
|
+
},
|
|
134
|
+
children: [
|
|
135
|
+
status === 'loading' ? /*#__PURE__*/ _jsx(Typography, {
|
|
136
|
+
variant: "body2",
|
|
137
|
+
color: "text.secondary",
|
|
138
|
+
children: 'Loading…'
|
|
139
|
+
}) : orders.length === 0 ? /*#__PURE__*/ _jsx(Typography, {
|
|
140
|
+
variant: "body2",
|
|
141
|
+
color: "text.secondary",
|
|
142
|
+
children: 'Nothing here right now.'
|
|
143
|
+
}) : orders.map((order)=>{
|
|
144
|
+
var _order_lineItems, _ref, _ref1;
|
|
145
|
+
var _order_localDelivery, _order_pickup, _order_shippingAddress, _order_localDelivery1;
|
|
146
|
+
const units = ((_order_lineItems = order.lineItems) != null ? _order_lineItems : []).reduce((sum, line)=>sum + (Number(line.quantity) || 0), 0);
|
|
147
|
+
const when = order.fulfillmentMethod === 'local_delivery' ? (_ref = (_order_localDelivery = order.localDelivery) == null ? void 0 : _order_localDelivery.windowLabel) != null ? _ref : '' : order.createdAtMs ? `Ordered ${new Date(order.createdAtMs).toLocaleString()}` : '';
|
|
148
|
+
const where = order.fulfillmentMethod === 'pickup' ? (_ref1 = (_order_pickup = order.pickup) == null ? void 0 : _order_pickup.locationName) != null ? _ref1 : '' : [
|
|
149
|
+
(_order_shippingAddress = order.shippingAddress) == null ? void 0 : _order_shippingAddress.line1,
|
|
150
|
+
(_order_localDelivery1 = order.localDelivery) == null ? void 0 : _order_localDelivery1.postalCode
|
|
151
|
+
].filter(Boolean).join(', ');
|
|
152
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
153
|
+
direction: {
|
|
154
|
+
xs: 'column',
|
|
155
|
+
sm: 'row'
|
|
156
|
+
},
|
|
157
|
+
spacing: 1,
|
|
158
|
+
sx: {
|
|
159
|
+
alignItems: {
|
|
160
|
+
sm: 'center'
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
children: [
|
|
164
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
165
|
+
sx: {
|
|
166
|
+
flex: 1,
|
|
167
|
+
minWidth: 0
|
|
168
|
+
},
|
|
169
|
+
children: [
|
|
170
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
171
|
+
variant: "body2",
|
|
172
|
+
noWrap: true,
|
|
173
|
+
children: `${CommerceModel.formatOrderNumber(order, order.$id)} · ${order.customerName || order.customerEmail || 'Guest buyer'} · ${units} item${units === 1 ? '' : 's'}`
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
176
|
+
variant: "caption",
|
|
177
|
+
color: "text.secondary",
|
|
178
|
+
noWrap: true,
|
|
179
|
+
children: [
|
|
180
|
+
when,
|
|
181
|
+
where
|
|
182
|
+
].filter(Boolean).join(' · ')
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
}),
|
|
186
|
+
nextLocalFulfillmentSteps(order).filter((entry)=>entry.primary).map((entry)=>/*#__PURE__*/ _jsx(Button, {
|
|
187
|
+
size: "small",
|
|
188
|
+
variant: "outlined",
|
|
189
|
+
disabled: busy,
|
|
190
|
+
onClick: ()=>void run(order.$id, entry.step),
|
|
191
|
+
children: entry.label
|
|
192
|
+
}, entry.step)),
|
|
193
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
194
|
+
size: "small",
|
|
195
|
+
onClick: ()=>setOpen(order),
|
|
196
|
+
children: 'Open'
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
}, order.$id);
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ _jsx(ListPagination, {
|
|
202
|
+
page: page,
|
|
203
|
+
pageSize: pageSize,
|
|
204
|
+
rowCount: orders.length,
|
|
205
|
+
hasMore: hasMore,
|
|
206
|
+
onPageChange: setPage,
|
|
207
|
+
onPageSizeChange: setPageSize
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
}),
|
|
211
|
+
open ? /*#__PURE__*/ _jsx(OrderDetailDialog, {
|
|
212
|
+
hostId: hostId,
|
|
213
|
+
order: open,
|
|
214
|
+
onClose: ()=>setOpen(null)
|
|
215
|
+
}) : null
|
|
216
|
+
]
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
PickupDeliveryQueueCard.displayName = 'PickupDeliveryQueueCard';
|
|
220
|
+
export default PickupDeliveryQueueCard;
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=pickup-delivery-queue-card.component.js.map
|