@aglyn/plugins-commerce 1.26.6 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/src/lib/components/console/pos-hardware-card.component.js +70 -67
- package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-waiting-card.component.js +19 -17
- package/src/lib/components/console/pos-hardware-waiting-card.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +4 -43
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/contracts.d.ts +7 -0
- package/src/lib/contracts.js.map +1 -1
- package/src/lib/model/pos-hardware-shop.d.ts +152 -0
- package/src/lib/model/pos-hardware-shop.js +152 -0
- package/src/lib/model/pos-hardware-shop.js.map +1 -0
- package/src/lib/model/product-write.d.ts +29 -8
- package/src/lib/model/product-write.js +64 -2
- package/src/lib/model/product-write.js.map +1 -1
- package/src/lib/native-nav.js +13 -1
- package/src/lib/native-nav.js.map +1 -1
- package/src/lib/server/api-v1/openapi.d.ts +6 -6
- package/src/lib/server/api-v1/openapi.js +203 -16
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/api-v1/order-view.d.ts +8 -0
- package/src/lib/server/api-v1/order-view.js +21 -4
- package/src/lib/server/api-v1/order-view.js.map +1 -1
- package/src/lib/server/api-v1/orders-and-products.js +46 -59
- package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
- package/src/lib/server/api-v1/product-view.d.ts +76 -0
- package/src/lib/server/api-v1/product-view.js +86 -0
- package/src/lib/server/api-v1/product-view.js.map +1 -0
- package/src/lib/server/api-v1/product-writes.d.ts +149 -0
- package/src/lib/server/api-v1/product-writes.js +673 -0
- package/src/lib/server/api-v1/product-writes.js.map +1 -0
- package/src/lib/server/products-write.d.ts +94 -2
- package/src/lib/server/products-write.js +171 -112
- package/src/lib/server/products-write.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-commerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
31
|
-
"@aglyn/shared-ui-next": "1.
|
|
32
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
33
|
-
"@aglyn/shared-util-email": "1.
|
|
34
|
-
"@aglyn/shared-util-http": "1.
|
|
35
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
36
|
-
"@aglyn/shared-util-tools": "1.
|
|
37
|
-
"@aglyn/tenant-data-admin": "1.
|
|
38
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
39
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.28.0",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.28.0",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.28.0",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.28.0",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.28.0",
|
|
33
|
+
"@aglyn/shared-util-email": "1.28.0",
|
|
34
|
+
"@aglyn/shared-util-http": "1.28.0",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.28.0",
|
|
36
|
+
"@aglyn/shared-util-tools": "1.28.0",
|
|
37
|
+
"@aglyn/tenant-data-admin": "1.28.0",
|
|
38
|
+
"@aglyn/tenant-feature-instance": "1.28.0",
|
|
39
|
+
"@aglyn/tenant-runtime": "1.28.0",
|
|
40
40
|
"@stripe/react-stripe-js": "^7.0.1",
|
|
41
41
|
"@stripe/stripe-js": "^10.2.1",
|
|
42
42
|
"@swc/helpers": "0.5.24",
|
|
@@ -25,7 +25,8 @@ import { useUser } from "@aglyn/tenant-feature-instance";
|
|
|
25
25
|
import { Alert, Box, Button, Card, CardContent, Checkbox, Chip, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Link, MenuItem, Stack, TextField, Typography } from "@mui/material";
|
|
26
26
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
27
27
|
import { formatPosHardwareCents, POS_HARDWARE_ANCHOR, POS_HARDWARE_MAX_PER_LINE, POS_HARDWARE_STATUS_LABELS, posPlanPrompt } from "../../model/pos-hardware.js";
|
|
28
|
-
import {
|
|
28
|
+
import { posHardwareTermsUrl } from "../../model/pos-hardware-terms.js";
|
|
29
|
+
import { POS_HARDWARE_RETURN_LABELS as RETURN_LABELS, POS_HARDWARE_SHOP_TEXT as TEXT, posHardwareArrivedNumbers, posHardwareBasket, posHardwareCheckoutState, posHardwareOrderItems, posHardwareReturnOffered, posHardwareReturnReasonReady, posHardwareReturnTitle } from "../../model/pos-hardware-shop.js";
|
|
29
30
|
import { EntitlementUpsell, useCommerceEntitlement } from "./entitlement-gate.component.js";
|
|
30
31
|
import { newAttemptKey } from "./pos/pos-api.js";
|
|
31
32
|
import { openPosHardwareCheckout, posHardwareCatalog, posHardwareCheckout, posHardwareOrders, posHardwareRequestReturn, PosHardwareRequestError } from "./pos/pos-hardware-api.js";
|
|
@@ -39,11 +40,6 @@ export const POS_HARDWARE_STATUS_COLOR = {
|
|
|
39
40
|
canceled: 'default',
|
|
40
41
|
refunded: 'default'
|
|
41
42
|
};
|
|
42
|
-
/** What the buyer reads of their return request. */ const RETURN_LABELS = {
|
|
43
|
-
requested: 'Return requested',
|
|
44
|
-
declined: 'Return declined',
|
|
45
|
-
refunded: 'Returned'
|
|
46
|
-
};
|
|
47
43
|
const QUANTITIES = Array.from({
|
|
48
44
|
length: POS_HARDWARE_MAX_PER_LINE + 1
|
|
49
45
|
}, (_, index)=>index);
|
|
@@ -52,8 +48,6 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
52
48
|
day: 'numeric',
|
|
53
49
|
year: 'numeric'
|
|
54
50
|
}) : '—';
|
|
55
|
-
/** Why Check out is not offered to someone who works the register. */ const BUY_KEY_REASON = 'Only a member with the "Buy point of sale hardware" permission can place an order. Ask an organization admin.';
|
|
56
|
-
/** Why Check out waits on the two boxes below the summary (AGL-4038). */ const TERMS_REASON = 'Accept the hardware terms of sale and confirm the hardware is for your business first.';
|
|
57
51
|
/**
|
|
58
52
|
* The Hardware card (AGL-4038): Stripe card readers and accessories sold by
|
|
59
53
|
* the platform and shipped by Stripe straight to the store, with the store's
|
|
@@ -69,7 +63,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
69
63
|
* payments at the register: above the shop, and once an order has arrived,
|
|
70
64
|
* naming it. The prompt never switches Check out off.
|
|
71
65
|
*/ export function PosHardwareCard({ hostId, canManagePos = false, canBuyHardware = canManagePos }) {
|
|
72
|
-
var _ref,
|
|
66
|
+
var _ref, _checkoutState_blockedReason;
|
|
73
67
|
const { data: user } = useUser();
|
|
74
68
|
const { enqueueSnackbar } = useSnackbar();
|
|
75
69
|
const [catalog, setCatalog] = useState(null);
|
|
@@ -135,7 +129,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
135
129
|
setBusy(true);
|
|
136
130
|
try {
|
|
137
131
|
await posHardwareRequestReturn(user, hostId, returning.id, returnReason.trim());
|
|
138
|
-
enqueueSnackbar(
|
|
132
|
+
enqueueSnackbar(TEXT.returnSent, {
|
|
139
133
|
variant: 'success',
|
|
140
134
|
persist: false
|
|
141
135
|
});
|
|
@@ -143,7 +137,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
143
137
|
setReturnReason('');
|
|
144
138
|
await loadOrders();
|
|
145
139
|
} catch (error) {
|
|
146
|
-
enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message :
|
|
140
|
+
enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message : TEXT.returnFailed, {
|
|
147
141
|
variant: 'warning',
|
|
148
142
|
persist: false
|
|
149
143
|
});
|
|
@@ -182,18 +176,30 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
182
176
|
}, [
|
|
183
177
|
available
|
|
184
178
|
]);
|
|
185
|
-
const lines = useMemo(()=>Object.entries(quantities).filter(([, quantity])=>quantity > 0).map(([sku, quantity])=>({
|
|
186
|
-
sku,
|
|
187
|
-
quantity
|
|
188
|
-
})), [
|
|
189
|
-
quantities
|
|
190
|
-
]);
|
|
191
179
|
const shipping = (catalog == null ? void 0 : catalog.available) ? catalog.shipping.find((option)=>option.method === shippingMethod) : undefined;
|
|
192
|
-
|
|
180
|
+
// The basket and its summary, as the apps work them out (pos-hardware-shop.ts).
|
|
181
|
+
const basket = useMemo(()=>{
|
|
193
182
|
var _ref;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
183
|
+
return posHardwareBasket({
|
|
184
|
+
offers: (catalog == null ? void 0 : catalog.available) ? catalog.offers : [],
|
|
185
|
+
quantities,
|
|
186
|
+
shippingCents: (_ref = shipping == null ? void 0 : shipping.cents) != null ? _ref : null,
|
|
187
|
+
automaticTax: (catalog == null ? void 0 : catalog.available) ? catalog.automaticTax : false
|
|
188
|
+
});
|
|
189
|
+
}, [
|
|
190
|
+
catalog,
|
|
191
|
+
quantities,
|
|
192
|
+
shipping
|
|
193
|
+
]);
|
|
194
|
+
const lines = basket.lines;
|
|
195
|
+
const subtotalCents = basket.itemsCents;
|
|
196
|
+
const checkoutState = posHardwareCheckoutState({
|
|
197
|
+
canBuy: canBuyHardware,
|
|
198
|
+
termsAccepted,
|
|
199
|
+
businessUse,
|
|
200
|
+
hasLines: lines.length > 0,
|
|
201
|
+
hasShipping: Boolean(shipping)
|
|
202
|
+
});
|
|
197
203
|
// One attempt per basket: a second press of the same basket reaches the
|
|
198
204
|
// same Checkout Session, and a changed basket is a new one.
|
|
199
205
|
const basketKey = JSON.stringify([
|
|
@@ -219,7 +225,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
219
225
|
});
|
|
220
226
|
openPosHardwareCheckout(url);
|
|
221
227
|
} catch (error) {
|
|
222
|
-
enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message :
|
|
228
|
+
enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message : TEXT.checkoutFailed, {
|
|
223
229
|
variant: 'warning',
|
|
224
230
|
persist: false
|
|
225
231
|
});
|
|
@@ -229,12 +235,12 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
229
235
|
const columns = useMemo(()=>[
|
|
230
236
|
{
|
|
231
237
|
field: 'number',
|
|
232
|
-
headerName:
|
|
238
|
+
headerName: TEXT.columnOrder,
|
|
233
239
|
minWidth: 110
|
|
234
240
|
},
|
|
235
241
|
{
|
|
236
242
|
field: 'createdAtMs',
|
|
237
|
-
headerName:
|
|
243
|
+
headerName: TEXT.columnPlaced,
|
|
238
244
|
type: 'number',
|
|
239
245
|
minWidth: 120,
|
|
240
246
|
align: 'left',
|
|
@@ -243,21 +249,21 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
243
249
|
},
|
|
244
250
|
{
|
|
245
251
|
field: 'items',
|
|
246
|
-
headerName:
|
|
252
|
+
headerName: TEXT.columnItems,
|
|
247
253
|
flex: 1,
|
|
248
254
|
minWidth: 200,
|
|
249
|
-
valueGetter: (_value, row)=>row.lines
|
|
255
|
+
valueGetter: (_value, row)=>posHardwareOrderItems(row.lines)
|
|
250
256
|
},
|
|
251
257
|
{
|
|
252
258
|
field: 'totalCents',
|
|
253
|
-
headerName:
|
|
259
|
+
headerName: TEXT.columnTotal,
|
|
254
260
|
type: 'number',
|
|
255
261
|
minWidth: 100,
|
|
256
262
|
valueFormatter: (value)=>formatPosHardwareCents(value)
|
|
257
263
|
},
|
|
258
264
|
{
|
|
259
265
|
field: 'status',
|
|
260
|
-
headerName:
|
|
266
|
+
headerName: TEXT.columnStatus,
|
|
261
267
|
minWidth: 130,
|
|
262
268
|
valueGetter: (_value, row)=>POS_HARDWARE_STATUS_LABELS[row.status],
|
|
263
269
|
renderCell: ({ row })=>/*#__PURE__*/ _jsx(Chip, {
|
|
@@ -270,25 +276,25 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
270
276
|
// A reader bought in person, or an order shipped to you once it has
|
|
271
277
|
// shipped (AGL-4038), can be asked back from here.
|
|
272
278
|
field: 'returnRequest',
|
|
273
|
-
headerName:
|
|
279
|
+
headerName: TEXT.columnReturn,
|
|
274
280
|
minWidth: 170,
|
|
275
281
|
valueGetter: (_value, row)=>{
|
|
276
282
|
var _RETURN_LABELS_, _ref;
|
|
277
283
|
var _row_returnRequest;
|
|
278
284
|
return (_RETURN_LABELS_ = RETURN_LABELS[(_ref = (_row_returnRequest = row.returnRequest) == null ? void 0 : _row_returnRequest.state) != null ? _ref : '']) != null ? _RETURN_LABELS_ : '';
|
|
279
285
|
},
|
|
280
|
-
renderCell: ({ row })=>row.returnRequest ? RETURN_LABELS[row.returnRequest.state] : row
|
|
286
|
+
renderCell: ({ row })=>row.returnRequest ? RETURN_LABELS[row.returnRequest.state] : posHardwareReturnOffered(row) ? /*#__PURE__*/ _jsx(Button, {
|
|
281
287
|
size: "small",
|
|
282
288
|
onClick: (event)=>{
|
|
283
289
|
event.stopPropagation();
|
|
284
290
|
setReturning(row);
|
|
285
291
|
},
|
|
286
|
-
children:
|
|
292
|
+
children: TEXT.returnAction
|
|
287
293
|
}) : '—'
|
|
288
294
|
},
|
|
289
295
|
{
|
|
290
296
|
field: 'tracking',
|
|
291
|
-
headerName:
|
|
297
|
+
headerName: TEXT.columnTracking,
|
|
292
298
|
minWidth: 160,
|
|
293
299
|
valueGetter: (_value, row)=>{
|
|
294
300
|
var _ref;
|
|
@@ -311,10 +317,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
311
317
|
* Orders shipped from this card that have arrived, for the prompt. A reader
|
|
312
318
|
* bought from the platform's own store, at an event or online, is prompted
|
|
313
319
|
* on the Card readers to set up card instead, so it is not named twice.
|
|
314
|
-
*/ const arrived = posPlan.locked ? (orders != null ? orders : [])
|
|
315
|
-
var _order_source;
|
|
316
|
-
return ((_order_source = order.source) != null ? _order_source : 'online') === 'online' && (order.status === 'delivered' || order.status === 'registered');
|
|
317
|
-
}).map((order)=>order.number) : [];
|
|
320
|
+
*/ const arrived = posPlan.locked ? posHardwareArrivedNumbers(orders != null ? orders : []) : [];
|
|
318
321
|
const planPrompt = (text)=>/*#__PURE__*/ _jsx(EntitlementUpsell, {
|
|
319
322
|
planLabel: posPlan.planLabel,
|
|
320
323
|
upgradeHref: posPlan.upgradeHref,
|
|
@@ -325,7 +328,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
325
328
|
children: [
|
|
326
329
|
/*#__PURE__*/ _jsx(Typography, {
|
|
327
330
|
variant: "subtitle2",
|
|
328
|
-
children:
|
|
331
|
+
children: TEXT.ordersTitle
|
|
329
332
|
}),
|
|
330
333
|
arrived.length ? planPrompt(posPlanPrompt({
|
|
331
334
|
arrived
|
|
@@ -333,7 +336,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
333
336
|
orders && orders.length === 0 ? /*#__PURE__*/ _jsx(Typography, {
|
|
334
337
|
variant: "body2",
|
|
335
338
|
color: "text.secondary",
|
|
336
|
-
children:
|
|
339
|
+
children: TEXT.noOrders
|
|
337
340
|
}) : /*#__PURE__*/ _jsx(ListTable, {
|
|
338
341
|
rows: (orders != null ? orders : []).map((order)=>_extends({}, order, {
|
|
339
342
|
$id: order.id
|
|
@@ -350,7 +353,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
350
353
|
fullWidth: true,
|
|
351
354
|
children: [
|
|
352
355
|
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
353
|
-
children: returning ?
|
|
356
|
+
children: returning ? posHardwareReturnTitle(returning.number) : ''
|
|
354
357
|
}),
|
|
355
358
|
/*#__PURE__*/ _jsxs(DialogContent, {
|
|
356
359
|
sx: {
|
|
@@ -362,10 +365,10 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
362
365
|
/*#__PURE__*/ _jsx(Typography, {
|
|
363
366
|
variant: "body2",
|
|
364
367
|
color: "text.secondary",
|
|
365
|
-
children:
|
|
368
|
+
children: TEXT.returnBody
|
|
366
369
|
}),
|
|
367
370
|
/*#__PURE__*/ _jsx(TextField, {
|
|
368
|
-
label:
|
|
371
|
+
label: TEXT.returnField,
|
|
369
372
|
value: returnReason,
|
|
370
373
|
onChange: (event)=>setReturnReason(event.target.value),
|
|
371
374
|
multiline: true,
|
|
@@ -378,13 +381,13 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
378
381
|
children: [
|
|
379
382
|
/*#__PURE__*/ _jsx(Button, {
|
|
380
383
|
onClick: ()=>setReturning(null),
|
|
381
|
-
children:
|
|
384
|
+
children: TEXT.returnCancel
|
|
382
385
|
}),
|
|
383
386
|
/*#__PURE__*/ _jsx(Button, {
|
|
384
387
|
variant: "contained",
|
|
385
|
-
disabled: busy || returnReason
|
|
388
|
+
disabled: busy || !posHardwareReturnReasonReady(returnReason),
|
|
386
389
|
onClick: ()=>void requestReturn(),
|
|
387
|
-
children:
|
|
390
|
+
children: TEXT.returnSend
|
|
388
391
|
})
|
|
389
392
|
]
|
|
390
393
|
})
|
|
@@ -398,8 +401,8 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
398
401
|
if (!(orders == null ? void 0 : orders.length)) return null;
|
|
399
402
|
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
400
403
|
id: POS_HARDWARE_ANCHOR,
|
|
401
|
-
header:
|
|
402
|
-
subheader:
|
|
404
|
+
header: TEXT.header,
|
|
405
|
+
subheader: TEXT.historySubheader,
|
|
403
406
|
help: pluginDocsHelp('posHardware', {
|
|
404
407
|
anchor: '#bought-from-us-in-person'
|
|
405
408
|
}),
|
|
@@ -410,21 +413,21 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
410
413
|
}
|
|
411
414
|
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
412
415
|
id: POS_HARDWARE_ANCHOR,
|
|
413
|
-
header:
|
|
414
|
-
subheader:
|
|
416
|
+
header: TEXT.header,
|
|
417
|
+
subheader: TEXT.subheader,
|
|
415
418
|
help: pluginDocsHelp('posHardware', {
|
|
416
419
|
anchor: '#buy-a-reader-from-aglyn'
|
|
417
420
|
}),
|
|
418
421
|
HeaderProps: {
|
|
419
422
|
action: /*#__PURE__*/ _jsx(BlockedControl, {
|
|
420
|
-
blocked:
|
|
421
|
-
reason:
|
|
423
|
+
blocked: checkoutState.blockedReason !== null,
|
|
424
|
+
reason: (_checkoutState_blockedReason = checkoutState.blockedReason) != null ? _checkoutState_blockedReason : '',
|
|
422
425
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
423
426
|
size: "small",
|
|
424
427
|
variant: "contained",
|
|
425
428
|
disabled: busy || !lines.length || !shipping,
|
|
426
429
|
onClick: ()=>void checkout(),
|
|
427
|
-
children:
|
|
430
|
+
children: TEXT.checkout
|
|
428
431
|
})
|
|
429
432
|
})
|
|
430
433
|
},
|
|
@@ -436,17 +439,17 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
436
439
|
returned === 'placed' ? /*#__PURE__*/ _jsx(Alert, {
|
|
437
440
|
severity: "success",
|
|
438
441
|
onClose: ()=>setReturned(null),
|
|
439
|
-
children:
|
|
442
|
+
children: TEXT.placed
|
|
440
443
|
}) : returned === 'canceled' ? /*#__PURE__*/ _jsx(Alert, {
|
|
441
444
|
severity: "info",
|
|
442
445
|
onClose: ()=>setReturned(null),
|
|
443
|
-
children:
|
|
446
|
+
children: TEXT.canceled
|
|
444
447
|
}) : null,
|
|
445
448
|
posPlan.locked && !arrived.length ? planPrompt(posPlanPrompt()) : null,
|
|
446
449
|
/*#__PURE__*/ _jsx(Typography, {
|
|
447
450
|
variant: "body2",
|
|
448
451
|
color: "text.secondary",
|
|
449
|
-
children:
|
|
452
|
+
children: TEXT.intro
|
|
450
453
|
}),
|
|
451
454
|
/*#__PURE__*/ _jsx(Box, {
|
|
452
455
|
sx: {
|
|
@@ -496,7 +499,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
496
499
|
/*#__PURE__*/ _jsx(TextField, {
|
|
497
500
|
select: true,
|
|
498
501
|
size: "small",
|
|
499
|
-
label:
|
|
502
|
+
label: TEXT.quantity,
|
|
500
503
|
value: (_quantities_offer_sku = quantities[offer.sku]) != null ? _quantities_offer_sku : 0,
|
|
501
504
|
onChange: (event)=>setQuantities((prev)=>_extends({}, prev, {
|
|
502
505
|
[offer.sku]: Number(event.target.value)
|
|
@@ -534,7 +537,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
534
537
|
/*#__PURE__*/ _jsx(TextField, {
|
|
535
538
|
select: true,
|
|
536
539
|
size: "small",
|
|
537
|
-
label:
|
|
540
|
+
label: TEXT.shipping,
|
|
538
541
|
value: shippingMethod,
|
|
539
542
|
onChange: (event)=>setShippingMethod(event.target.value),
|
|
540
543
|
sx: {
|
|
@@ -555,20 +558,20 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
555
558
|
"aria-label": "Order summary",
|
|
556
559
|
children: [
|
|
557
560
|
/*#__PURE__*/ _jsx(SummaryRow, {
|
|
558
|
-
label:
|
|
561
|
+
label: TEXT.items,
|
|
559
562
|
value: formatPosHardwareCents(subtotalCents)
|
|
560
563
|
}),
|
|
561
564
|
/*#__PURE__*/ _jsx(SummaryRow, {
|
|
562
|
-
label:
|
|
565
|
+
label: TEXT.shipping,
|
|
563
566
|
value: shipping ? formatPosHardwareCents(shipping.cents) : '—'
|
|
564
567
|
}),
|
|
565
568
|
catalog.automaticTax ? /*#__PURE__*/ _jsx(SummaryRow, {
|
|
566
|
-
label:
|
|
567
|
-
value:
|
|
569
|
+
label: TEXT.tax,
|
|
570
|
+
value: TEXT.taxAtCheckout
|
|
568
571
|
}) : null,
|
|
569
572
|
/*#__PURE__*/ _jsx(SummaryRow, {
|
|
570
|
-
label:
|
|
571
|
-
value: formatPosHardwareCents(
|
|
573
|
+
label: basket.totalLabel,
|
|
574
|
+
value: formatPosHardwareCents(basket.totalCents),
|
|
572
575
|
strong: true
|
|
573
576
|
})
|
|
574
577
|
]
|
|
@@ -578,7 +581,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
578
581
|
/*#__PURE__*/ _jsx(Typography, {
|
|
579
582
|
variant: "caption",
|
|
580
583
|
color: "text.secondary",
|
|
581
|
-
children:
|
|
584
|
+
children: TEXT.shipsTo
|
|
582
585
|
}),
|
|
583
586
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
584
587
|
children: [
|
|
@@ -590,14 +593,14 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
590
593
|
label: /*#__PURE__*/ _jsxs(Typography, {
|
|
591
594
|
variant: "body2",
|
|
592
595
|
children: [
|
|
593
|
-
|
|
596
|
+
TEXT.termsBefore,
|
|
594
597
|
/*#__PURE__*/ _jsx(Link, {
|
|
595
598
|
href: posHardwareTermsUrl(),
|
|
596
599
|
target: "_blank",
|
|
597
600
|
rel: "noopener noreferrer",
|
|
598
|
-
children:
|
|
601
|
+
children: TEXT.termsLink
|
|
599
602
|
}),
|
|
600
|
-
|
|
603
|
+
TEXT.termsAfter
|
|
601
604
|
]
|
|
602
605
|
})
|
|
603
606
|
}),
|
|
@@ -608,7 +611,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
608
611
|
}),
|
|
609
612
|
label: /*#__PURE__*/ _jsx(Typography, {
|
|
610
613
|
variant: "body2",
|
|
611
|
-
children:
|
|
614
|
+
children: TEXT.businessUse
|
|
612
615
|
})
|
|
613
616
|
})
|
|
614
617
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-hardware-card.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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Card,\n CardContent,\n Checkbox,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n Link,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n formatPosHardwareCents,\n POS_HARDWARE_ANCHOR,\n POS_HARDWARE_MAX_PER_LINE,\n POS_HARDWARE_STATUS_LABELS,\n posPlanPrompt,\n type PosHardwareOrderStatus,\n type PosHardwareShippingMethod,\n} from '../../model/pos-hardware'\nimport { POS_HARDWARE_TERMS_SECTIONS, posHardwareTermsUrl } from '../../model/pos-hardware-terms'\nimport { EntitlementUpsell, useCommerceEntitlement } from './entitlement-gate.component'\nimport { newAttemptKey } from './pos/pos-api'\nimport {\n openPosHardwareCheckout,\n posHardwareCatalog,\n posHardwareCheckout,\n posHardwareOrders,\n posHardwareRequestReturn,\n PosHardwareRequestError,\n type PosHardwareCatalog,\n type PosHardwareOrderRow,\n} from './pos/pos-hardware-api'\n\n\nexport const POS_HARDWARE_STATUS_COLOR: Record<\n PosHardwareOrderStatus,\n 'default' | 'info' | 'primary' | 'success'\n> = {\n paid: 'info',\n ordered: 'info',\n received: 'info',\n shipped: 'primary',\n delivered: 'success',\n registered: 'success',\n canceled: 'default',\n refunded: 'default',\n}\n\n/** What the buyer reads of their return request. */\nconst RETURN_LABELS: Record<string, string> = {\n requested: 'Return requested',\n declined: 'Return declined',\n refunded: 'Returned',\n}\n\nconst QUANTITIES = Array.from({ length: POS_HARDWARE_MAX_PER_LINE + 1 }, (_, index) => index)\n\nconst placedOn = (ms: number) =>\n ms ? new Date(ms).toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' }) : '—'\n\nexport interface PosHardwareCardProps {\n hostId: string\n /**\n * Whether the viewer may work this site's register (`managePos`). The shop\n * is the register's hardware, so whoever works it is shown the shop.\n */\n canManagePos?: boolean\n /**\n * Whether the viewer may start a checkout (AGL-4047): the \"Buy point of\n * sale hardware\" key the route asks of a checkout. It stands on its own,\n * so a member who holds it without the register is shown the shop and\n * their orders too. Someone who works the register without it sees the\n * shop with Check out disabled and the reason. Absent follows\n * `canManagePos`.\n */\n canBuyHardware?: boolean\n}\n\n/** Why Check out is not offered to someone who works the register. */\nconst BUY_KEY_REASON =\n 'Only a member with the \"Buy point of sale hardware\" permission can place an order. Ask an organization admin.'\n\n/** Why Check out waits on the two boxes below the summary (AGL-4038). */\nconst TERMS_REASON = 'Accept the hardware terms of sale and confirm the hardware is for your business first.'\n\n/**\n * The Hardware card (AGL-4038): Stripe card readers and accessories sold by\n * the platform and shipped by Stripe straight to the store, with the store's\n * orders and their tracking underneath.\n *\n * HIDDEN, NOT DISABLED, while the deployment has not opened the shop: it is a\n * gate only the platform can lift, so naming it would point at a step nobody\n * on the workspace can take. The route answers `available: false` until\n * every price, the markup and the shipping figures are configured.\n *\n * ANYONE CAN BUY (AGL-4038): the shop is open on every plan. A workspace\n * without the point of sale is prompted to add it, because a reader takes\n * payments at the register: above the shop, and once an order has arrived,\n * naming it. The prompt never switches Check out off.\n */\nexport function PosHardwareCard({\n hostId,\n canManagePos = false,\n canBuyHardware = canManagePos,\n}: PosHardwareCardProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [catalog, setCatalog] = useState<PosHardwareCatalog | null>(null)\n const [orders, setOrders] = useState<PosHardwareOrderRow[] | null>(null)\n const [quantities, setQuantities] = useState<Record<string, number>>({})\n const [shippingMethod, setShippingMethod] = useState<PosHardwareShippingMethod | ''>('')\n const [busy, setBusy] = useState(false)\n const [returned, setReturned] = useState<'placed' | 'canceled' | null>(null)\n // The terms of sale and business use, ticked before checkout (AGL-4038).\n const [termsAccepted, setTermsAccepted] = useState(false)\n const [businessUse, setBusinessUse] = useState(false)\n const uid = user?.uid ?? ''\n // The route's own door (AGL-4047): the register, or the key to buy.\n const mayVisit = canManagePos || canBuyHardware\n // The point of sale, which a reader takes payments with (AGL-4038). Only\n // `locked` prompts: a plan still loading prompts nobody.\n const posPlan = useCommerceEntitlement(hostId, 'pos')\n\n useEffect(() => {\n if (!user || !mayVisit) return\n let active = true\n void posHardwareCatalog(user, hostId)\n .then((answer) => {\n if (active) setCatalog(answer)\n })\n .catch(() => {\n if (active) setCatalog({ available: false })\n })\n return () => {\n active = false\n }\n // Keyed on the person, not the session object.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId, mayVisit])\n\n const available = catalog?.available === true\n\n const loadOrders = useCallback(async () => {\n if (!user) return\n try {\n setOrders((await posHardwareOrders(user, hostId)).orders)\n } catch {\n setOrders([])\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId])\n\n // The orders load whether or not the shop is open: a reader bought in\n // person (AGL-4038) is the workspace's purchase history too.\n useEffect(() => {\n if (mayVisit) void loadOrders()\n }, [mayVisit, loadOrders])\n\n /** The order whose return is being asked for, and why (AGL-4038). */\n const [returning, setReturning] = useState<PosHardwareOrderRow | null>(null)\n const [returnReason, setReturnReason] = useState('')\n const requestReturn = async () => {\n if (!user || !returning) return\n setBusy(true)\n try {\n await posHardwareRequestReturn(user, hostId, returning.id, returnReason.trim())\n enqueueSnackbar('Return requested. Our team arranges it with you.', { variant: 'success', persist: false })\n setReturning(null)\n setReturnReason('')\n await loadOrders()\n } catch (error) {\n enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message : 'The request did not go through', {\n variant: 'warning',\n persist: false,\n })\n } finally {\n setBusy(false)\n }\n }\n\n // The first shipping speed is the default once the catalog answers.\n useEffect(() => {\n if (catalog?.available && !shippingMethod && catalog.shipping.length) {\n setShippingMethod(catalog.shipping[0].method)\n }\n }, [catalog, shippingMethod])\n\n // Back from Checkout: say what happened, then drop the marker from the URL.\n useEffect(() => {\n if (typeof window === 'undefined') return\n const url = new URL(window.location.href)\n const outcome = url.searchParams.get('hardwareOrder')\n if (outcome === 'placed' || outcome === 'canceled') {\n setReturned(outcome)\n url.searchParams.delete('hardwareOrder')\n window.history.replaceState(window.history.state, '', url.toString())\n }\n }, [])\n\n // Arrived by an email's link or Checkout's return: bring the card into view.\n useEffect(() => {\n if (!available || typeof window === 'undefined') return\n if (window.location.hash !== `#${POS_HARDWARE_ANCHOR}`) return\n document.getElementById(POS_HARDWARE_ANCHOR)?.scrollIntoView?.({ block: 'start' })\n }, [available])\n\n const lines = useMemo(\n () =>\n Object.entries(quantities)\n .filter(([, quantity]) => quantity > 0)\n .map(([sku, quantity]) => ({ sku, quantity })),\n [quantities],\n )\n const shipping = catalog?.available ? catalog.shipping.find((option) => option.method === shippingMethod) : undefined\n const subtotalCents = catalog?.available\n ? lines.reduce(\n (sum, line) => sum + (catalog.offers.find((offer) => offer.sku === line.sku)?.unitCents ?? 0) * line.quantity,\n 0,\n )\n : 0\n\n // One attempt per basket: a second press of the same basket reaches the\n // same Checkout Session, and a changed basket is a new one.\n const basketKey = JSON.stringify([lines, shippingMethod])\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const attemptKey = useMemo(() => newAttemptKey(), [basketKey])\n\n const checkout = async () => {\n if (!user || !shippingMethod || !lines.length || !termsAccepted || !businessUse) return\n setBusy(true)\n try {\n const { url } = await posHardwareCheckout(user, attemptKey, {\n hostId,\n lines,\n shippingMethod,\n hardwareTerms: { accepted: termsAccepted, businessUse },\n })\n openPosHardwareCheckout(url)\n } catch (error) {\n enqueueSnackbar(\n error instanceof PosHardwareRequestError ? error.message : 'Checkout could not be started',\n { variant: 'warning', persist: false },\n )\n setBusy(false)\n }\n }\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'number', headerName: 'Order', minWidth: 110 },\n {\n field: 'createdAtMs',\n headerName: 'Placed',\n type: 'number',\n minWidth: 120,\n align: 'left',\n headerAlign: 'left',\n valueFormatter: (value: number) => placedOn(value),\n },\n {\n field: 'items',\n headerName: 'Items',\n flex: 1,\n minWidth: 200,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) =>\n row.lines.map((line) => `${line.name} × ${line.quantity}`).join(', '),\n },\n {\n field: 'totalCents',\n headerName: 'Total',\n type: 'number',\n minWidth: 100,\n valueFormatter: (value: number) => formatPosHardwareCents(value),\n },\n {\n field: 'status',\n headerName: 'Status',\n minWidth: 130,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => POS_HARDWARE_STATUS_LABELS[row.status],\n renderCell: ({ row }: { row: PosHardwareOrderRow }) => (\n <Chip size=\"small\" color={POS_HARDWARE_STATUS_COLOR[row.status]} label={POS_HARDWARE_STATUS_LABELS[row.status]} />\n ),\n },\n {\n // A reader bought in person, or an order shipped to you once it has\n // shipped (AGL-4038), can be asked back from here.\n field: 'returnRequest',\n headerName: 'Return',\n minWidth: 170,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => RETURN_LABELS[row.returnRequest?.state ?? ''] ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.returnRequest ? (\n RETURN_LABELS[row.returnRequest.state]\n ) : (row.status === 'delivered' || row.status === 'registered' || (row.source !== 'in_person' && row.status === 'shipped')) ? (\n <Button\n size=\"small\"\n onClick={(event) => {\n event.stopPropagation()\n setReturning(row)\n }}\n >\n {'Request a return'}\n </Button>\n ) : (\n '—'\n ),\n },\n {\n field: 'tracking',\n headerName: 'Tracking',\n minWidth: 160,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => row.tracking?.number ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.tracking?.url ? (\n <Link href={row.tracking.url} target=\"_blank\" rel=\"noopener noreferrer\">\n {row.tracking.number}\n </Link>\n ) : (\n row.tracking?.number ?? '—'\n ),\n },\n ],\n [],\n )\n\n /*\n * Orders shipped from this card that have arrived, for the prompt. A reader\n * bought from the platform's own store, at an event or online, is prompted\n * on the Card readers to set up card instead, so it is not named twice.\n */\n const arrived = posPlan.locked\n ? (orders ?? [])\n .filter((order) => (order.source ?? 'online') === 'online' && (order.status === 'delivered' || order.status === 'registered'))\n .map((order) => order.number)\n : []\n const planPrompt = (text: string) => (\n <EntitlementUpsell planLabel={posPlan.planLabel} upgradeHref={posPlan.upgradeHref}>\n {text}\n </EntitlementUpsell>\n )\n\n const ordersSection = (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Your orders'}</Typography>\n {arrived.length ? planPrompt(posPlanPrompt({ arrived })) : null}\n {orders && orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No hardware orders yet.'}\n </Typography>\n ) : (\n <ListTable\n rows={(orders ?? []).map((order) => ({ ...order, $id: order.id }))}\n columns={columns}\n loading={orders === null}\n hideFooter\n quickFilter={false}\n />\n )}\n <Dialog open={Boolean(returning)} onClose={() => setReturning(null)} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{returning ? `Return ${returning.number}?` : ''}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Tell us why. Our team gets your request and arranges the return with you. Returns follow the hardware terms of sale: the return shipping is yours to pay, the original shipping is not refunded, and any restocking fee charged for the return comes off the refund.'}\n </Typography>\n <TextField\n label=\"Why are you returning it?\"\n value={returnReason}\n onChange={(event) => setReturnReason(event.target.value)}\n multiline\n minRows={2}\n fullWidth\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setReturning(null)}>{'Cancel'}</Button>\n <Button variant=\"contained\" disabled={busy || returnReason.trim().length < 3} onClick={() => void requestReturn()}>\n {'Request return'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n\n // With the shop closed, the card is the purchase history alone, and only\n // when there is one (AGL-4038): a reader bought in person.\n if (!available || !catalog?.available) {\n if (!orders?.length) return null\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={'Hardware'}\n subheader={'Your card reader orders'}\n help={pluginDocsHelp('posHardware', { anchor: '#bought-from-us-in-person' })}\n contentGutterX\n contentGutterY\n >\n {ordersSection}\n </CardDisplay>\n )\n }\n\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={'Hardware'}\n subheader={'Card readers and accessories, set up and shipped to you'}\n help={pluginDocsHelp('posHardware', { anchor: '#buy-a-reader-from-aglyn' })}\n HeaderProps={{\n action: (\n <BlockedControl\n blocked={!canBuyHardware || !termsAccepted || !businessUse}\n reason={!canBuyHardware ? BUY_KEY_REASON : TERMS_REASON}\n >\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={busy || !lines.length || !shipping}\n onClick={() => void checkout()}\n >\n {'Check out'}\n </Button>\n </BlockedControl>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={3}>\n {returned === 'placed' ? (\n <Alert severity=\"success\" onClose={() => setReturned(null)}>\n {'Thanks, your order is in. It shows under Your orders within a minute, and we email you as it ships.'}\n </Alert>\n ) : returned === 'canceled' ? (\n <Alert severity=\"info\" onClose={() => setReturned(null)}>\n {'Checkout was canceled. Nothing was charged.'}\n </Alert>\n ) : null}\n {posPlan.locked && !arrived.length ? planPrompt(posPlanPrompt()) : null}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Choose the readers and accessories you need. We set each reader up and ship your order to the address you enter at checkout. The delivery email says how to start taking payments with it.'}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gap: 2,\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, 1fr)', md: 'repeat(3, 1fr)' },\n }}\n >\n {catalog.offers.map((offer) => (\n <Card key={offer.sku} variant=\"outlined\">\n <CardContent>\n <Stack spacing={1} sx={{ height: '100%' }}>\n <Typography variant=\"subtitle2\">{offer.name}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ flex: 1 }}>\n {offer.use}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', justifyContent: 'space-between' }}>\n <Typography variant=\"body1\">{formatPosHardwareCents(offer.unitCents)}</Typography>\n <TextField\n select\n size=\"small\"\n label=\"Quantity\"\n value={quantities[offer.sku] ?? 0}\n onChange={(event) =>\n setQuantities((prev) => ({ ...prev, [offer.sku]: Number(event.target.value) }))\n }\n slotProps={{ htmlInput: { 'aria-label': `Quantity of ${offer.name}` } }}\n >\n {QUANTITIES.map((quantity) => (\n <MenuItem key={quantity} value={quantity}>\n {quantity}\n </MenuItem>\n ))}\n </TextField>\n </Stack>\n </Stack>\n </CardContent>\n </Card>\n ))}\n </Box>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'flex-start' } }}>\n <TextField\n select\n size=\"small\"\n label=\"Shipping\"\n value={shippingMethod}\n onChange={(event) => setShippingMethod(event.target.value as PosHardwareShippingMethod)}\n sx={{ minWidth: { sm: '40%' } }}\n >\n {catalog.shipping.map((option) => (\n <MenuItem key={option.method} value={option.method}>\n {`${option.label} · ${formatPosHardwareCents(option.cents)}`}\n </MenuItem>\n ))}\n </TextField>\n <Stack spacing={0.5} sx={{ flex: 1 }} aria-label=\"Order summary\">\n <SummaryRow label=\"Items\" value={formatPosHardwareCents(subtotalCents)} />\n <SummaryRow label=\"Shipping\" value={shipping ? formatPosHardwareCents(shipping.cents) : '—'} />\n {catalog.automaticTax ? <SummaryRow label=\"Tax\" value=\"Calculated at checkout\" /> : null}\n <SummaryRow\n label={catalog.automaticTax ? 'Total before tax' : 'Total'}\n value={formatPosHardwareCents(subtotalCents + (shipping?.cents ?? 0))}\n strong\n />\n </Stack>\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Ships to street addresses in the United States. P.O. boxes and military addresses are not accepted.'}\n </Typography>\n <Stack>\n <FormControlLabel\n control={<Checkbox checked={termsAccepted} onChange={(event) => setTermsAccepted(event.target.checked)} />}\n label={\n <Typography variant=\"body2\">\n {'I accept the '}\n <Link href={posHardwareTermsUrl()} target=\"_blank\" rel=\"noopener noreferrer\">\n {`hardware terms of sale (Terms, Sections ${POS_HARDWARE_TERMS_SECTIONS})`}\n </Link>\n {'.'}\n </Typography>\n }\n />\n <FormControlLabel\n control={<Checkbox checked={businessUse} onChange={(event) => setBusinessUse(event.target.checked)} />}\n label={<Typography variant=\"body2\">{'I am buying this hardware for use in my business.'}</Typography>}\n />\n </Stack>\n {ordersSection}\n </Stack>\n </CardDisplay>\n )\n}\nPosHardwareCard.displayName = 'PosHardwareCard'\n\nfunction SummaryRow(props: { label: string; value: string; strong?: boolean }) {\n return (\n <Stack direction=\"row\" sx={{ justifyContent: 'space-between' }}>\n <Typography variant=\"body2\" color={props.strong ? 'text.primary' : 'text.secondary'}>\n {props.label}\n </Typography>\n <Typography variant=\"body2\" sx={props.strong ? { fontWeight: 'fontWeightMedium' } : undefined}>\n {props.value}\n </Typography>\n </Stack>\n )\n}\n\nexport default PosHardwareCard\n"],"names":["pluginDocsHelp","CardDisplay","BlockedControl","ListTable","useSnackbar","useUser","Alert","Box","Button","Card","CardContent","Checkbox","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","Link","MenuItem","Stack","TextField","Typography","useCallback","useEffect","useMemo","useState","formatPosHardwareCents","POS_HARDWARE_ANCHOR","POS_HARDWARE_MAX_PER_LINE","POS_HARDWARE_STATUS_LABELS","posPlanPrompt","POS_HARDWARE_TERMS_SECTIONS","posHardwareTermsUrl","EntitlementUpsell","useCommerceEntitlement","newAttemptKey","openPosHardwareCheckout","posHardwareCatalog","posHardwareCheckout","posHardwareOrders","posHardwareRequestReturn","PosHardwareRequestError","POS_HARDWARE_STATUS_COLOR","paid","ordered","received","shipped","delivered","registered","canceled","refunded","RETURN_LABELS","requested","declined","QUANTITIES","Array","from","length","_","index","placedOn","ms","Date","toLocaleDateString","month","day","year","BUY_KEY_REASON","TERMS_REASON","PosHardwareCard","hostId","canManagePos","canBuyHardware","data","user","enqueueSnackbar","catalog","setCatalog","orders","setOrders","quantities","setQuantities","shippingMethod","setShippingMethod","busy","setBusy","returned","setReturned","termsAccepted","setTermsAccepted","businessUse","setBusinessUse","uid","mayVisit","posPlan","active","then","answer","catch","available","loadOrders","returning","setReturning","returnReason","setReturnReason","requestReturn","id","trim","variant","persist","error","message","shipping","method","window","url","URL","location","href","outcome","searchParams","get","delete","history","replaceState","state","toString","document","hash","getElementById","scrollIntoView","block","lines","Object","entries","filter","quantity","map","sku","find","option","undefined","subtotalCents","reduce","sum","line","offers","offer","unitCents","basketKey","JSON","stringify","attemptKey","checkout","hardwareTerms","accepted","columns","field","headerName","minWidth","type","align","headerAlign","valueFormatter","value","flex","valueGetter","_value","row","name","join","status","renderCell","size","color","label","returnRequest","source","onClick","event","stopPropagation","tracking","number","target","rel","arrived","locked","order","planPrompt","text","planLabel","upgradeHref","ordersSection","spacing","rows","$id","loading","hideFooter","quickFilter","open","Boolean","onClose","maxWidth","fullWidth","sx","display","flexDirection","gap","onChange","multiline","minRows","disabled","header","subheader","help","anchor","contentGutterX","contentGutterY","HeaderProps","action","blocked","reason","severity","gridTemplateColumns","xs","sm","md","height","use","direction","alignItems","justifyContent","select","prev","Number","slotProps","htmlInput","cents","aria-label","SummaryRow","automaticTax","strong","control","checked","displayName","props","fontWeight"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AAEtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,yBAAyB,EACzBC,0BAA0B,EAC1BC,aAAa,QAGR,8BAA0B;AACjC,SAASC,2BAA2B,EAAEC,mBAAmB,QAAQ,oCAAgC;AACjG,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,kCAA8B;AACxF,SAASC,aAAa,QAAQ,mBAAe;AAC7C,SACEC,uBAAuB,EACvBC,kBAAkB,EAClBC,mBAAmB,EACnBC,iBAAiB,EACjBC,wBAAwB,EACxBC,uBAAuB,QAGlB,4BAAwB;AAG/B,OAAO,MAAMC,4BAGT;IACFC,MAAM;IACNC,SAAS;IACTC,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G;oBAAEK,YAAY;gBAAmB,IAAIzG;0BACjFwG,MAAMjF,KAAK;;;;AAIpB;AAEA,eAAe/F,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-hardware-card.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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Card,\n CardContent,\n Checkbox,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n Link,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n formatPosHardwareCents,\n POS_HARDWARE_ANCHOR,\n POS_HARDWARE_MAX_PER_LINE,\n POS_HARDWARE_STATUS_LABELS,\n posPlanPrompt,\n type PosHardwareOrderStatus,\n type PosHardwareShippingMethod,\n} from '../../model/pos-hardware'\nimport { posHardwareTermsUrl } from '../../model/pos-hardware-terms'\nimport {\n POS_HARDWARE_RETURN_LABELS as RETURN_LABELS,\n POS_HARDWARE_SHOP_TEXT as TEXT,\n posHardwareArrivedNumbers,\n posHardwareBasket,\n posHardwareCheckoutState,\n posHardwareOrderItems,\n posHardwareReturnOffered,\n posHardwareReturnReasonReady,\n posHardwareReturnTitle,\n} from '../../model/pos-hardware-shop'\nimport { EntitlementUpsell, useCommerceEntitlement } from './entitlement-gate.component'\nimport { newAttemptKey } from './pos/pos-api'\nimport {\n openPosHardwareCheckout,\n posHardwareCatalog,\n posHardwareCheckout,\n posHardwareOrders,\n posHardwareRequestReturn,\n PosHardwareRequestError,\n type PosHardwareCatalog,\n type PosHardwareOrderRow,\n} from './pos/pos-hardware-api'\n\n\nexport const POS_HARDWARE_STATUS_COLOR: Record<\n PosHardwareOrderStatus,\n 'default' | 'info' | 'primary' | 'success'\n> = {\n paid: 'info',\n ordered: 'info',\n received: 'info',\n shipped: 'primary',\n delivered: 'success',\n registered: 'success',\n canceled: 'default',\n refunded: 'default',\n}\n\nconst QUANTITIES = Array.from({ length: POS_HARDWARE_MAX_PER_LINE + 1 }, (_, index) => index)\n\nconst placedOn = (ms: number) =>\n ms ? new Date(ms).toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' }) : '—'\n\nexport interface PosHardwareCardProps {\n hostId: string\n /**\n * Whether the viewer may work this site's register (`managePos`). The shop\n * is the register's hardware, so whoever works it is shown the shop.\n */\n canManagePos?: boolean\n /**\n * Whether the viewer may start a checkout (AGL-4047): the \"Buy point of\n * sale hardware\" key the route asks of a checkout. It stands on its own,\n * so a member who holds it without the register is shown the shop and\n * their orders too. Someone who works the register without it sees the\n * shop with Check out disabled and the reason. Absent follows\n * `canManagePos`.\n */\n canBuyHardware?: boolean\n}\n\n/**\n * The Hardware card (AGL-4038): Stripe card readers and accessories sold by\n * the platform and shipped by Stripe straight to the store, with the store's\n * orders and their tracking underneath.\n *\n * HIDDEN, NOT DISABLED, while the deployment has not opened the shop: it is a\n * gate only the platform can lift, so naming it would point at a step nobody\n * on the workspace can take. The route answers `available: false` until\n * every price, the markup and the shipping figures are configured.\n *\n * ANYONE CAN BUY (AGL-4038): the shop is open on every plan. A workspace\n * without the point of sale is prompted to add it, because a reader takes\n * payments at the register: above the shop, and once an order has arrived,\n * naming it. The prompt never switches Check out off.\n */\nexport function PosHardwareCard({\n hostId,\n canManagePos = false,\n canBuyHardware = canManagePos,\n}: PosHardwareCardProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [catalog, setCatalog] = useState<PosHardwareCatalog | null>(null)\n const [orders, setOrders] = useState<PosHardwareOrderRow[] | null>(null)\n const [quantities, setQuantities] = useState<Record<string, number>>({})\n const [shippingMethod, setShippingMethod] = useState<PosHardwareShippingMethod | ''>('')\n const [busy, setBusy] = useState(false)\n const [returned, setReturned] = useState<'placed' | 'canceled' | null>(null)\n // The terms of sale and business use, ticked before checkout (AGL-4038).\n const [termsAccepted, setTermsAccepted] = useState(false)\n const [businessUse, setBusinessUse] = useState(false)\n const uid = user?.uid ?? ''\n // The route's own door (AGL-4047): the register, or the key to buy.\n const mayVisit = canManagePos || canBuyHardware\n // The point of sale, which a reader takes payments with (AGL-4038). Only\n // `locked` prompts: a plan still loading prompts nobody.\n const posPlan = useCommerceEntitlement(hostId, 'pos')\n\n useEffect(() => {\n if (!user || !mayVisit) return\n let active = true\n void posHardwareCatalog(user, hostId)\n .then((answer) => {\n if (active) setCatalog(answer)\n })\n .catch(() => {\n if (active) setCatalog({ available: false })\n })\n return () => {\n active = false\n }\n // Keyed on the person, not the session object.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId, mayVisit])\n\n const available = catalog?.available === true\n\n const loadOrders = useCallback(async () => {\n if (!user) return\n try {\n setOrders((await posHardwareOrders(user, hostId)).orders)\n } catch {\n setOrders([])\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId])\n\n // The orders load whether or not the shop is open: a reader bought in\n // person (AGL-4038) is the workspace's purchase history too.\n useEffect(() => {\n if (mayVisit) void loadOrders()\n }, [mayVisit, loadOrders])\n\n /** The order whose return is being asked for, and why (AGL-4038). */\n const [returning, setReturning] = useState<PosHardwareOrderRow | null>(null)\n const [returnReason, setReturnReason] = useState('')\n const requestReturn = async () => {\n if (!user || !returning) return\n setBusy(true)\n try {\n await posHardwareRequestReturn(user, hostId, returning.id, returnReason.trim())\n enqueueSnackbar(TEXT.returnSent, { variant: 'success', persist: false })\n setReturning(null)\n setReturnReason('')\n await loadOrders()\n } catch (error) {\n enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message : TEXT.returnFailed, {\n variant: 'warning',\n persist: false,\n })\n } finally {\n setBusy(false)\n }\n }\n\n // The first shipping speed is the default once the catalog answers.\n useEffect(() => {\n if (catalog?.available && !shippingMethod && catalog.shipping.length) {\n setShippingMethod(catalog.shipping[0].method)\n }\n }, [catalog, shippingMethod])\n\n // Back from Checkout: say what happened, then drop the marker from the URL.\n useEffect(() => {\n if (typeof window === 'undefined') return\n const url = new URL(window.location.href)\n const outcome = url.searchParams.get('hardwareOrder')\n if (outcome === 'placed' || outcome === 'canceled') {\n setReturned(outcome)\n url.searchParams.delete('hardwareOrder')\n window.history.replaceState(window.history.state, '', url.toString())\n }\n }, [])\n\n // Arrived by an email's link or Checkout's return: bring the card into view.\n useEffect(() => {\n if (!available || typeof window === 'undefined') return\n if (window.location.hash !== `#${POS_HARDWARE_ANCHOR}`) return\n document.getElementById(POS_HARDWARE_ANCHOR)?.scrollIntoView?.({ block: 'start' })\n }, [available])\n\n const shipping = catalog?.available ? catalog.shipping.find((option) => option.method === shippingMethod) : undefined\n // The basket and its summary, as the apps work them out (pos-hardware-shop.ts).\n const basket = useMemo(\n () =>\n posHardwareBasket({\n offers: catalog?.available ? catalog.offers : [],\n quantities,\n shippingCents: shipping?.cents ?? null,\n automaticTax: catalog?.available ? catalog.automaticTax : false,\n }),\n [catalog, quantities, shipping],\n )\n const lines = basket.lines\n const subtotalCents = basket.itemsCents\n const checkoutState = posHardwareCheckoutState({\n canBuy: canBuyHardware,\n termsAccepted,\n businessUse,\n hasLines: lines.length > 0,\n hasShipping: Boolean(shipping),\n })\n\n // One attempt per basket: a second press of the same basket reaches the\n // same Checkout Session, and a changed basket is a new one.\n const basketKey = JSON.stringify([lines, shippingMethod])\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const attemptKey = useMemo(() => newAttemptKey(), [basketKey])\n\n const checkout = async () => {\n if (!user || !shippingMethod || !lines.length || !termsAccepted || !businessUse) return\n setBusy(true)\n try {\n const { url } = await posHardwareCheckout(user, attemptKey, {\n hostId,\n lines,\n shippingMethod,\n hardwareTerms: { accepted: termsAccepted, businessUse },\n })\n openPosHardwareCheckout(url)\n } catch (error) {\n enqueueSnackbar(\n error instanceof PosHardwareRequestError ? error.message : TEXT.checkoutFailed,\n { variant: 'warning', persist: false },\n )\n setBusy(false)\n }\n }\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'number', headerName: TEXT.columnOrder, minWidth: 110 },\n {\n field: 'createdAtMs',\n headerName: TEXT.columnPlaced,\n type: 'number',\n minWidth: 120,\n align: 'left',\n headerAlign: 'left',\n valueFormatter: (value: number) => placedOn(value),\n },\n {\n field: 'items',\n headerName: TEXT.columnItems,\n flex: 1,\n minWidth: 200,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) =>\n posHardwareOrderItems(row.lines),\n },\n {\n field: 'totalCents',\n headerName: TEXT.columnTotal,\n type: 'number',\n minWidth: 100,\n valueFormatter: (value: number) => formatPosHardwareCents(value),\n },\n {\n field: 'status',\n headerName: TEXT.columnStatus,\n minWidth: 130,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => POS_HARDWARE_STATUS_LABELS[row.status],\n renderCell: ({ row }: { row: PosHardwareOrderRow }) => (\n <Chip size=\"small\" color={POS_HARDWARE_STATUS_COLOR[row.status]} label={POS_HARDWARE_STATUS_LABELS[row.status]} />\n ),\n },\n {\n // A reader bought in person, or an order shipped to you once it has\n // shipped (AGL-4038), can be asked back from here.\n field: 'returnRequest',\n headerName: TEXT.columnReturn,\n minWidth: 170,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => RETURN_LABELS[row.returnRequest?.state ?? ''] ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.returnRequest ? (\n RETURN_LABELS[row.returnRequest.state]\n ) : posHardwareReturnOffered(row) ? (\n <Button\n size=\"small\"\n onClick={(event) => {\n event.stopPropagation()\n setReturning(row)\n }}\n >\n {TEXT.returnAction}\n </Button>\n ) : (\n '—'\n ),\n },\n {\n field: 'tracking',\n headerName: TEXT.columnTracking,\n minWidth: 160,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => row.tracking?.number ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.tracking?.url ? (\n <Link href={row.tracking.url} target=\"_blank\" rel=\"noopener noreferrer\">\n {row.tracking.number}\n </Link>\n ) : (\n row.tracking?.number ?? '—'\n ),\n },\n ],\n [],\n )\n\n /*\n * Orders shipped from this card that have arrived, for the prompt. A reader\n * bought from the platform's own store, at an event or online, is prompted\n * on the Card readers to set up card instead, so it is not named twice.\n */\n const arrived = posPlan.locked\n ? posHardwareArrivedNumbers(orders ?? [])\n : []\n const planPrompt = (text: string) => (\n <EntitlementUpsell planLabel={posPlan.planLabel} upgradeHref={posPlan.upgradeHref}>\n {text}\n </EntitlementUpsell>\n )\n\n const ordersSection = (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{TEXT.ordersTitle}</Typography>\n {arrived.length ? planPrompt(posPlanPrompt({ arrived })) : null}\n {orders && orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {TEXT.noOrders}\n </Typography>\n ) : (\n <ListTable\n rows={(orders ?? []).map((order) => ({ ...order, $id: order.id }))}\n columns={columns}\n loading={orders === null}\n hideFooter\n quickFilter={false}\n />\n )}\n <Dialog open={Boolean(returning)} onClose={() => setReturning(null)} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{returning ? posHardwareReturnTitle(returning.number) : ''}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {TEXT.returnBody}\n </Typography>\n <TextField\n label={TEXT.returnField}\n value={returnReason}\n onChange={(event) => setReturnReason(event.target.value)}\n multiline\n minRows={2}\n fullWidth\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setReturning(null)}>{TEXT.returnCancel}</Button>\n <Button variant=\"contained\" disabled={busy || !posHardwareReturnReasonReady(returnReason)} onClick={() => void requestReturn()}>\n {TEXT.returnSend}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n\n // With the shop closed, the card is the purchase history alone, and only\n // when there is one (AGL-4038): a reader bought in person.\n if (!available || !catalog?.available) {\n if (!orders?.length) return null\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={TEXT.header}\n subheader={TEXT.historySubheader}\n help={pluginDocsHelp('posHardware', { anchor: '#bought-from-us-in-person' })}\n contentGutterX\n contentGutterY\n >\n {ordersSection}\n </CardDisplay>\n )\n }\n\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={TEXT.header}\n subheader={TEXT.subheader}\n help={pluginDocsHelp('posHardware', { anchor: '#buy-a-reader-from-aglyn' })}\n HeaderProps={{\n action: (\n <BlockedControl\n blocked={checkoutState.blockedReason !== null}\n reason={checkoutState.blockedReason ?? ''}\n >\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={busy || !lines.length || !shipping}\n onClick={() => void checkout()}\n >\n {TEXT.checkout}\n </Button>\n </BlockedControl>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={3}>\n {returned === 'placed' ? (\n <Alert severity=\"success\" onClose={() => setReturned(null)}>\n {TEXT.placed}\n </Alert>\n ) : returned === 'canceled' ? (\n <Alert severity=\"info\" onClose={() => setReturned(null)}>\n {TEXT.canceled}\n </Alert>\n ) : null}\n {posPlan.locked && !arrived.length ? planPrompt(posPlanPrompt()) : null}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {TEXT.intro}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gap: 2,\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, 1fr)', md: 'repeat(3, 1fr)' },\n }}\n >\n {catalog.offers.map((offer) => (\n <Card key={offer.sku} variant=\"outlined\">\n <CardContent>\n <Stack spacing={1} sx={{ height: '100%' }}>\n <Typography variant=\"subtitle2\">{offer.name}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ flex: 1 }}>\n {offer.use}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', justifyContent: 'space-between' }}>\n <Typography variant=\"body1\">{formatPosHardwareCents(offer.unitCents)}</Typography>\n <TextField\n select\n size=\"small\"\n label={TEXT.quantity}\n value={quantities[offer.sku] ?? 0}\n onChange={(event) =>\n setQuantities((prev) => ({ ...prev, [offer.sku]: Number(event.target.value) }))\n }\n slotProps={{ htmlInput: { 'aria-label': `Quantity of ${offer.name}` } }}\n >\n {QUANTITIES.map((quantity) => (\n <MenuItem key={quantity} value={quantity}>\n {quantity}\n </MenuItem>\n ))}\n </TextField>\n </Stack>\n </Stack>\n </CardContent>\n </Card>\n ))}\n </Box>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'flex-start' } }}>\n <TextField\n select\n size=\"small\"\n label={TEXT.shipping}\n value={shippingMethod}\n onChange={(event) => setShippingMethod(event.target.value as PosHardwareShippingMethod)}\n sx={{ minWidth: { sm: '40%' } }}\n >\n {catalog.shipping.map((option) => (\n <MenuItem key={option.method} value={option.method}>\n {`${option.label} · ${formatPosHardwareCents(option.cents)}`}\n </MenuItem>\n ))}\n </TextField>\n <Stack spacing={0.5} sx={{ flex: 1 }} aria-label=\"Order summary\">\n <SummaryRow label={TEXT.items} value={formatPosHardwareCents(subtotalCents)} />\n <SummaryRow label={TEXT.shipping} value={shipping ? formatPosHardwareCents(shipping.cents) : '—'} />\n {catalog.automaticTax ? <SummaryRow label={TEXT.tax} value={TEXT.taxAtCheckout} /> : null}\n <SummaryRow\n label={basket.totalLabel}\n value={formatPosHardwareCents(basket.totalCents)}\n strong\n />\n </Stack>\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {TEXT.shipsTo}\n </Typography>\n <Stack>\n <FormControlLabel\n control={<Checkbox checked={termsAccepted} onChange={(event) => setTermsAccepted(event.target.checked)} />}\n label={\n <Typography variant=\"body2\">\n {TEXT.termsBefore}\n <Link href={posHardwareTermsUrl()} target=\"_blank\" rel=\"noopener noreferrer\">\n {TEXT.termsLink}\n </Link>\n {TEXT.termsAfter}\n </Typography>\n }\n />\n <FormControlLabel\n control={<Checkbox checked={businessUse} onChange={(event) => setBusinessUse(event.target.checked)} />}\n label={<Typography variant=\"body2\">{TEXT.businessUse}</Typography>}\n />\n </Stack>\n {ordersSection}\n </Stack>\n </CardDisplay>\n )\n}\nPosHardwareCard.displayName = 'PosHardwareCard'\n\nfunction SummaryRow(props: { label: string; value: string; strong?: boolean }) {\n return (\n <Stack direction=\"row\" sx={{ justifyContent: 'space-between' }}>\n <Typography variant=\"body2\" color={props.strong ? 'text.primary' : 'text.secondary'}>\n {props.label}\n </Typography>\n <Typography variant=\"body2\" sx={props.strong ? { fontWeight: 'fontWeightMedium' } : undefined}>\n {props.value}\n </Typography>\n </Stack>\n )\n}\n\nexport default PosHardwareCard\n"],"names":["pluginDocsHelp","CardDisplay","BlockedControl","ListTable","useSnackbar","useUser","Alert","Box","Button","Card","CardContent","Checkbox","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","Link","MenuItem","Stack","TextField","Typography","useCallback","useEffect","useMemo","useState","formatPosHardwareCents","POS_HARDWARE_ANCHOR","POS_HARDWARE_MAX_PER_LINE","POS_HARDWARE_STATUS_LABELS","posPlanPrompt","posHardwareTermsUrl","POS_HARDWARE_RETURN_LABELS","RETURN_LABELS","POS_HARDWARE_SHOP_TEXT","TEXT","posHardwareArrivedNumbers","posHardwareBasket","posHardwareCheckoutState","posHardwareOrderItems","posHardwareReturnOffered","posHardwareReturnReasonReady","posHardwareReturnTitle","EntitlementUpsell","useCommerceEntitlement","newAttemptKey","openPosHardwareCheckout","posHardwareCatalog","posHardwareCheckout","posHardwareOrders","posHardwareRequestReturn","PosHardwareRequestError","POS_HARDWARE_STATUS_COLOR","paid","ordered","received","shipped","delivered","registered","canceled","refunded","QUANTITIES","Array","from","length","_","index","placedOn","ms","Date","toLocaleDateString","month","day","year","PosHardwareCard","hostId","canManagePos","canBuyHardware","checkoutState","data","user","enqueueSnackbar","catalog","setCatalog","orders","setOrders","quantities","setQuantities","shippingMethod","setShippingMethod","busy","setBusy","returned","setReturned","termsAccepted","setTermsAccepted","businessUse","setBusinessUse","uid","mayVisit","posPlan","active","then","answer","catch","available","loadOrders","returning","setReturning","returnReason","setReturnReason","requestReturn","id","trim","returnSent","variant","persist","error","message","returnFailed","shipping","method","window","url","URL","location","href","outcome","searchParams","get","delete","history","replaceState","state","toString","document","hash","getElementById","scrollIntoView","block","find","option","undefined","basket","offers","shippingCents","cents","automaticTax","lines","subtotalCents","itemsCents","canBuy","hasLines","hasShipping","Boolean","basketKey","JSON","stringify","attemptKey","checkout","hardwareTerms","accepted","checkoutFailed","columns","field","headerName","columnOrder","minWidth","columnPlaced","type","align","headerAlign","valueFormatter","value","columnItems","flex","valueGetter","_value","row","columnTotal","columnStatus","status","renderCell","size","color","label","columnReturn","returnRequest","onClick","event","stopPropagation","returnAction","columnTracking","tracking","number","target","rel","arrived","locked","planPrompt","text","planLabel","upgradeHref","ordersSection","spacing","ordersTitle","noOrders","rows","map","order","$id","loading","hideFooter","quickFilter","open","onClose","maxWidth","fullWidth","sx","display","flexDirection","gap","returnBody","returnField","onChange","multiline","minRows","returnCancel","disabled","returnSend","header","subheader","historySubheader","help","anchor","contentGutterX","contentGutterY","HeaderProps","action","blocked","blockedReason","reason","severity","placed","intro","gridTemplateColumns","xs","sm","md","offer","height","name","use","direction","alignItems","justifyContent","unitCents","select","quantity","sku","prev","Number","slotProps","htmlInput","aria-label","SummaryRow","items","tax","taxAtCheckout","totalLabel","totalCents","strong","shipsTo","control","checked","termsBefore","termsLink","termsAfter","displayName","props","fontWeight"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AAEtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,yBAAyB,EACzBC,0BAA0B,EAC1BC,aAAa,QAGR,8BAA0B;AACjC,SAASC,mBAAmB,QAAQ,oCAAgC;AACpE,SACEC,8BAA8BC,aAAa,EAC3CC,0BAA0BC,IAAI,EAC9BC,yBAAyB,EACzBC,iBAAiB,EACjBC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,sBAAsB,QACjB,mCAA+B;AACtC,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,kCAA8B;AACxF,SAASC,aAAa,QAAQ,mBAAe;AAC7C,SACEC,uBAAuB,EACvBC,kBAAkB,EAClBC,mBAAmB,EACnBC,iBAAiB,EACjBC,wBAAwB,EACxBC,uBAAuB,QAGlB,4BAAwB;AAG/B,OAAO,MAAMC,4BAGT;IACFC,MAAM;IACNC,SAAS;IACTC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