@aglyn/plugins-commerce 1.21.0 → 1.22.1
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 +16 -16
- package/src/lib/components/cart-fulfillment.js +19 -8
- package/src/lib/components/cart-fulfillment.js.map +1 -1
- package/src/lib/components/console/catalog-organization-card.component.js +28 -9
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/discounts-card.component.js +13 -4
- package/src/lib/components/console/discounts-card.component.js.map +1 -1
- package/src/lib/components/console/local-delivery-settings-card.component.js +13 -4
- package/src/lib/components/console/local-delivery-settings-card.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +13 -4
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +13 -4
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/quote-settings-card.component.js +13 -4
- package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
- package/src/lib/components/console/reservations-card.component.js +13 -4
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/return-settings-card.component.js +13 -4
- package/src/lib/components/console/return-settings-card.component.js.map +1 -1
- package/src/lib/components/console/shipping-settings-card.component.js +13 -4
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +13 -4
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/suppliers-card.component.js +13 -4
- package/src/lib/components/console/suppliers-card.component.js.map +1 -1
- package/src/lib/components/console/tax-settings-card.component.js +13 -4
- package/src/lib/components/console/tax-settings-card.component.js.map +1 -1
- package/src/lib/model/commerce-pos-offline.d.ts +21 -3
- package/src/lib/model/commerce-pos-offline.js +17 -5
- package/src/lib/model/commerce-pos-offline.js.map +1 -1
- package/src/lib/server/pos-offline-card-order.d.ts +2 -0
- package/src/lib/server/pos-offline-card-order.js +6 -2
- package/src/lib/server/pos-offline-card-order.js.map +1 -1
- package/src/lib/server/pos-offline-card-reconcile.d.ts +5 -1
- package/src/lib/server/pos-offline-card-reconcile.js +42 -10
- package/src/lib/server/pos-offline-card-reconcile.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +48 -6
- package/src/lib/server/pos-offline-sync.js +142 -31
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-stripe.d.ts +11 -0
- package/src/lib/server/pos-stripe.js +14 -0
- package/src/lib/server/pos-stripe.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +21 -1
- package/src/lib/server/pos-terminal.js +39 -5
- package/src/lib/server/pos-terminal.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.22.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,21 +25,21 @@
|
|
|
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.
|
|
40
|
-
"@stripe/react-stripe-js": "^
|
|
41
|
-
"@stripe/stripe-js": "^
|
|
42
|
-
"@swc/helpers": "0.5.
|
|
28
|
+
"@aglyn/aglyn": "1.22.1",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.22.1",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.22.1",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.22.1",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.22.1",
|
|
33
|
+
"@aglyn/shared-util-email": "1.22.1",
|
|
34
|
+
"@aglyn/shared-util-http": "1.22.1",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.22.1",
|
|
36
|
+
"@aglyn/shared-util-tools": "1.22.1",
|
|
37
|
+
"@aglyn/tenant-data-admin": "1.22.1",
|
|
38
|
+
"@aglyn/tenant-feature-instance": "1.22.1",
|
|
39
|
+
"@aglyn/tenant-runtime": "1.22.1",
|
|
40
|
+
"@stripe/react-stripe-js": "^7.0.1",
|
|
41
|
+
"@stripe/stripe-js": "^10.2.1",
|
|
42
|
+
"@swc/helpers": "0.5.24",
|
|
43
43
|
"dayjs": "^1.11.23",
|
|
44
44
|
"qrcode.react": "^4.2.0",
|
|
45
45
|
"sharp": "^0.35.5"
|
|
@@ -61,13 +61,25 @@ export function useCartFulfillment(hostId, cartSignature, /**
|
|
|
61
61
|
postalCode,
|
|
62
62
|
line1
|
|
63
63
|
]);
|
|
64
|
+
// What the request asks beyond the basket: a delivery quote, only for a
|
|
65
|
+
// postal code long enough to place. Keyed by its content, so the settle
|
|
66
|
+
// above handing back an equal object, or a switch between shipping and
|
|
67
|
+
// pickup, is not another request (AGL-4047: every cart load asked twice).
|
|
68
|
+
const wantsQuote = method === 'local_delivery' && asked.postalCode.length >= 3;
|
|
69
|
+
const quoteFor = wantsQuote ? JSON.stringify([
|
|
70
|
+
asked.postalCode,
|
|
71
|
+
asked.line1
|
|
72
|
+
]) : '';
|
|
64
73
|
useEffect(()=>{
|
|
65
74
|
if (!hostId || cartSignature === '[]' || buyNow === null) {
|
|
66
75
|
setOptions(EMPTY);
|
|
67
76
|
return;
|
|
68
77
|
}
|
|
69
78
|
let live = true;
|
|
70
|
-
const
|
|
79
|
+
const [quotePostal, quoteLine1] = quoteFor ? JSON.parse(quoteFor) : [
|
|
80
|
+
'',
|
|
81
|
+
''
|
|
82
|
+
];
|
|
71
83
|
fetch('/api/commerce/local-fulfillment-options', {
|
|
72
84
|
method: 'POST',
|
|
73
85
|
headers: {
|
|
@@ -75,12 +87,12 @@ export function useCartFulfillment(hostId, cartSignature, /**
|
|
|
75
87
|
},
|
|
76
88
|
body: JSON.stringify(_extends({
|
|
77
89
|
hostId
|
|
78
|
-
}, buyNow ? buyNow : {},
|
|
79
|
-
postalCode:
|
|
80
|
-
} : {},
|
|
90
|
+
}, buyNow ? buyNow : {}, quoteFor ? {
|
|
91
|
+
postalCode: quotePostal
|
|
92
|
+
} : {}, quoteFor && quoteLine1 ? {
|
|
81
93
|
address: {
|
|
82
|
-
line1:
|
|
83
|
-
postalCode:
|
|
94
|
+
line1: quoteLine1,
|
|
95
|
+
postalCode: quotePostal
|
|
84
96
|
}
|
|
85
97
|
} : {}))
|
|
86
98
|
}).then((response)=>response.ok ? response.json() : EMPTY).then((payload)=>{
|
|
@@ -113,8 +125,7 @@ export function useCartFulfillment(hostId, cartSignature, /**
|
|
|
113
125
|
hostId,
|
|
114
126
|
cartSignature,
|
|
115
127
|
round,
|
|
116
|
-
|
|
117
|
-
asked,
|
|
128
|
+
quoteFor,
|
|
118
129
|
buyNowKey
|
|
119
130
|
]);
|
|
120
131
|
const offered = options.pickup.length > 0 || Boolean(options.delivery);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/cart-fulfillment.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\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport FormControl from '@mui/material/FormControl'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport FormLabel from '@mui/material/FormLabel'\nimport MenuItem from '@mui/material/MenuItem'\nimport Radio from '@mui/material/Radio'\nimport RadioGroup from '@mui/material/RadioGroup'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { PickupLocationOption } from '../model/local-fulfillment-settings'\nimport type { ModifierSelection } from '../model/product-modifiers'\nimport { pickupReadyWithinLabel } from '../model/local-fulfillment-settings'\n\n/**\n * How the shopper receives the order (AGL-3624): shipped, picked up at one of\n * the store's locations, or brought by the store's own driver. Asked at the\n * cart because that is where the store still decides what the checkout\n * offers; `POST /api/commerce/local-fulfillment-options` answers what this\n * store and this basket can have, and the checkout decides the fee, the\n * minimum and the window again from the store's settings — nothing shown\n * here is trusted.\n *\n * A store with no pickup location and no local delivery gets an empty answer\n * and draws nothing: its cart is exactly what it was.\n */\n\nexport interface CartDeliveryWindow {\n id: string\n startMs: number\n endMs: number\n label: string\n}\n\nexport interface CartDeliveryQuote {\n zoneId?: string\n zoneName?: string\n feeCents?: number\n minimumCents?: number\n freeOverCents?: number\n shortfallCents?: number\n unavailable?: string\n}\n\nexport interface CartFulfillmentOptions {\n pickup: PickupLocationOption[]\n delivery: {\n country: string\n instructions?: string\n needsAddress: boolean\n windows: CartDeliveryWindow[]\n quote?: CartDeliveryQuote\n } | null\n /** Whether the store can text the buyer about the pickup or delivery. */\n texts?: boolean\n}\n\nexport type CartFulfillmentMethod = 'shipping' | 'pickup' | 'local_delivery'\n\nconst EMPTY: CartFulfillmentOptions = { pickup: [], delivery: null }\n\nexport function useCartFulfillment(\n hostId: string | undefined,\n cartSignature: string,\n /**\n * A product's Buy button asks for that product rather than the cart; `null`\n * asks nothing (a subscription, a download).\n */\n buyNow?: {\n productId: string\n variantId?: string\n quantity: number\n /** The add-ons chosen (AGL-4100): a delivery minimum counts them. */\n modifiers?: ModifierSelection[]\n } | null,\n) {\n const buyNowKey = buyNow === undefined ? '' : JSON.stringify(buyNow)\n const [options, setOptions] = useState<CartFulfillmentOptions>(EMPTY)\n const [method, setMethod] = useState<CartFulfillmentMethod>('shipping')\n const [locationId, setLocationId] = useState('')\n const [postalCode, setPostalCode] = useState('')\n const [line1, setLine1] = useState('')\n const [windowId, setWindowId] = useState('')\n const [textPhone, setTextPhone] = useState('')\n const [round, setRound] = useState(0)\n // The postal code and street the quote below was asked for, settled after\n // the shopper stops typing so a keystroke is not a request.\n const [asked, setAsked] = useState({ postalCode: '', line1: '' })\n useEffect(() => {\n const timer = setTimeout(() => setAsked({ postalCode: postalCode.trim(), line1: line1.trim() }), 400)\n return () => clearTimeout(timer)\n }, [postalCode, line1])\n\n useEffect(() => {\n if (!hostId || cartSignature === '[]' || buyNow === null) {\n setOptions(EMPTY)\n return\n }\n let live = true\n const wantsQuote = method === 'local_delivery' && asked.postalCode.length >= 3\n fetch('/api/commerce/local-fulfillment-options', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n ...(buyNow ? buyNow : {}),\n ...(wantsQuote ? { postalCode: asked.postalCode } : {}),\n ...(wantsQuote && asked.line1 ? { address: { line1: asked.line1, postalCode: asked.postalCode } } : {}),\n }),\n })\n .then((response) => (response.ok ? response.json() : EMPTY))\n .then((payload: CartFulfillmentOptions) => {\n if (!live) return\n const next: CartFulfillmentOptions = {\n pickup: Array.isArray(payload?.pickup) ? payload.pickup : [],\n delivery: payload?.delivery ?? null,\n texts: Boolean(payload?.texts),\n }\n setOptions(next)\n // A choice the store no longer offers falls back to shipping.\n setMethod((prior) =>\n (prior === 'pickup' && !next.pickup.length) || (prior === 'local_delivery' && !next.delivery)\n ? 'shipping'\n : prior,\n )\n setLocationId((prior) =>\n next.pickup.some((location) => location.id === prior) ? prior : (next.pickup[0]?.id ?? ''),\n )\n setWindowId((prior) =>\n next.delivery?.windows.some((window) => window.id === prior) ? prior : '',\n )\n })\n .catch(() => live && setOptions(EMPTY))\n return () => {\n live = false\n }\n // `buyNow` is read through its key.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hostId, cartSignature, round, method, asked, buyNowKey])\n\n const offered = options.pickup.length > 0 || Boolean(options.delivery)\n const quote = options.delivery?.quote\n const deliverable = Boolean(quote && !quote.unavailable && !(quote.shortfallCents && quote.shortfallCents > 0))\n /** What the checkout is sent; `null` for a shipped order. */\n const phone = options.texts && textPhone.trim() ? { textPhone: textPhone.trim() } : {}\n const request = useMemo(() => {\n if (method === 'pickup' && locationId) return { method: 'pickup' as const, locationId, ...phone }\n if (method === 'local_delivery') {\n return {\n method: 'local_delivery' as const,\n ...phone,\n postalCode: postalCode.trim(),\n ...(windowId ? { windowStartMs: Number(windowId) } : {}),\n ...(line1.trim() ? { address: { line1: line1.trim(), postalCode: postalCode.trim() } } : {}),\n }\n }\n return null\n // `phone` is derived from the two values listed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [method, locationId, postalCode, windowId, line1, textPhone, options.texts])\n /** Whether the choice is complete enough to check out with. */\n const ready =\n method === 'shipping' ||\n (method === 'pickup' && Boolean(locationId)) ||\n // The quote is the server's answer for what was typed: a zone that\n // reaches it and an order that meets its minimum.\n (method === 'local_delivery' && Boolean(postalCode.trim()) && Boolean(windowId) && deliverable)\n const signature = JSON.stringify(request)\n const reload = useCallback(() => setRound((value) => value + 1), [])\n return {\n options,\n offered,\n method,\n setMethod,\n locationId,\n setLocationId,\n postalCode,\n setPostalCode,\n line1,\n setLine1,\n windowId,\n setWindowId,\n textPhone,\n setTextPhone,\n request,\n ready,\n signature,\n reload,\n }\n}\n\nexport type CartFulfillmentState = ReturnType<typeof useCartFulfillment>\n\nexport function CartFulfillmentChoice(props: {\n state: CartFulfillmentState\n formatCents: (cents: number) => string\n}) {\n const { state, formatCents } = props\n const { options, method } = state\n if (!state.offered) return null\n const location = options.pickup.find((entry) => entry.id === state.locationId)\n const delivery = options.delivery\n const quote = delivery?.quote\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>\n <FormControl>\n <FormLabel id=\"cart-fulfillment-method\">\n <Typography variant=\"subtitle2\" component=\"span\">\n {'How do you want your order?'}\n </Typography>\n </FormLabel>\n <RadioGroup\n aria-labelledby=\"cart-fulfillment-method\"\n value={method}\n onChange={(event) => state.setMethod(event.target.value as CartFulfillmentMethod)}\n >\n <FormControlLabel value=\"shipping\" control={<Radio size=\"small\" />} label=\"Ship it\" />\n {options.pickup.length ? (\n <FormControlLabel\n value=\"pickup\"\n control={<Radio size=\"small\" />}\n label={options.pickup.length === 1 ? `Pick up at ${options.pickup[0].name}` : 'Pick up in store'}\n />\n ) : null}\n {delivery ? (\n <FormControlLabel value=\"local_delivery\" control={<Radio size=\"small\" />} label=\"Local delivery\" />\n ) : null}\n </RadioGroup>\n </FormControl>\n {method === 'pickup' ? (\n <>\n {options.pickup.length > 1 ? (\n <TextField\n select\n label=\"Pickup location\"\n value={state.locationId}\n onChange={(event) => state.setLocationId(event.target.value)}\n size=\"small\"\n >\n {options.pickup.map((entry) => (\n <MenuItem key={entry.id} value={entry.id}>\n {entry.name}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {location ? (\n <Box>\n {location.address ? (\n <Typography variant=\"body2\">{location.address}</Typography>\n ) : null}\n {location.hours ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" sx={{ whiteSpace: 'pre-line' }}>\n {location.hours}\n </Typography>\n ) : null}\n {location.readyWithinMinutes ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {`${pickupReadyWithinLabel(location.readyWithinMinutes)}. We’ll email you when it’s ready.`}\n </Typography>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {'We’ll email you when it’s ready.'}\n </Typography>\n )}\n {location.instructions ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {location.instructions}\n </Typography>\n ) : null}\n </Box>\n ) : null}\n </>\n ) : null}\n {method !== 'shipping' && options.texts ? (\n <TextField\n label=\"Mobile number (optional)\"\n value={state.textPhone}\n onChange={(event) => state.setTextPhone(event.target.value)}\n size=\"small\"\n helperText={\n method === 'pickup'\n ? 'We’ll text you when your order is ready'\n : 'We’ll text you when your order is on its way'\n }\n slotProps={{ htmlInput: { autoComplete: 'tel', inputMode: 'tel', maxLength: 24 } }}\n />\n ) : null}\n {method === 'local_delivery' && delivery ? (\n <>\n <TextField\n label=\"Postal code\"\n value={state.postalCode}\n onChange={(event) => state.setPostalCode(event.target.value)}\n size=\"small\"\n slotProps={{ htmlInput: { autoComplete: 'shipping postal-code', maxLength: 12 } }}\n />\n {delivery.needsAddress ? (\n <TextField\n label=\"Street address\"\n value={state.line1}\n onChange={(event) => state.setLine1(event.target.value)}\n size=\"small\"\n helperText=\"Delivery depends on the distance from the store\"\n slotProps={{ htmlInput: { autoComplete: 'shipping address-line1', maxLength: 120 } }}\n />\n ) : null}\n {quote?.unavailable ? <Alert severity=\"info\">{quote.unavailable}</Alert> : null}\n {quote && !quote.unavailable ? (\n quote.shortfallCents && quote.shortfallCents > 0 ? (\n <Alert severity=\"info\">\n {`Delivery needs an order of at least ${formatCents(quote.minimumCents ?? 0)}. ` +\n `Add ${formatCents(quote.shortfallCents)} more.`}\n </Alert>\n ) : (\n <Typography variant=\"body2\">\n {quote.feeCents\n ? `Delivery: ${formatCents(quote.feeCents)}`\n : 'Delivery: free'}\n {quote.freeOverCents && quote.feeCents\n ? ` (free over ${formatCents(quote.freeOverCents)})`\n : ''}\n </Typography>\n )\n ) : null}\n {delivery.windows.length ? (\n <TextField\n select\n label=\"Delivery time\"\n value={state.windowId}\n onChange={(event) => state.setWindowId(event.target.value)}\n size=\"small\"\n >\n {delivery.windows.map((window) => (\n <MenuItem key={window.id} value={window.id}>\n {window.label}\n </MenuItem>\n ))}\n </TextField>\n ) : (\n <Alert severity=\"info\">{'No delivery times are open right now.'}</Alert>\n )}\n {delivery.instructions ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {delivery.instructions}\n </Typography>\n ) : null}\n </>\n ) : null}\n </Box>\n )\n}\n"],"names":["Alert","Box","FormControl","FormControlLabel","FormLabel","MenuItem","Radio","RadioGroup","TextField","Typography","useCallback","useEffect","useMemo","useState","pickupReadyWithinLabel","EMPTY","pickup","delivery","useCartFulfillment","hostId","cartSignature","buyNow","options","buyNowKey","undefined","JSON","stringify","setOptions","method","setMethod","locationId","setLocationId","postalCode","setPostalCode","line1","setLine1","windowId","setWindowId","textPhone","setTextPhone","round","setRound","asked","setAsked","timer","setTimeout","trim","clearTimeout","live","wantsQuote","length","fetch","headers","body","address","then","response","ok","json","payload","next","Array","isArray","texts","Boolean","prior","some","location","id","windows","window","catch","offered","quote","deliverable","unavailable","shortfallCents","phone","request","windowStartMs","Number","ready","signature","reload","value","CartFulfillmentChoice","props","state","formatCents","find","entry","sx","display","flexDirection","gap","variant","component","aria-labelledby","onChange","event","target","control","size","label","name","select","map","hours","color","whiteSpace","readyWithinMinutes","instructions","helperText","slotProps","htmlInput","autoComplete","inputMode","maxLength","needsAddress","severity","minimumCents","feeCents","freeOverCents"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,OAAOA,WAAW,sBAAqB;AACvC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,gBAAgB,2BAA0B;AACjD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,WAAW,EAAEC,SAAS,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AMgD,QAAQ,GAClC,CAAC,YAAY,EAAEjC,YAAYf,MAAMiD,aAAa,EAAE,CAAC,CAAC,GAClD;;yBAGN;oBACHzG,SAASoD,OAAO,CAACnB,MAAM,iBACtB,KAAC1C;wBACCiG,MAAM;wBACNF,OAAM;wBACNnB,OAAOG,MAAMnD,QAAQ;wBACrB8D,UAAU,CAACC,QAAUZ,MAAMlD,WAAW,CAAC8D,MAAMC,MAAM,CAAChB,KAAK;wBACzDkB,MAAK;kCAEJrF,SAASoD,OAAO,CAACqC,GAAG,CAAC,CAACpC,uBACrB,KAACjE;gCAAyB+E,OAAOd,OAAOF,EAAE;0CACvCE,OAAOiC,KAAK;+BADAjC,OAAOF,EAAE;uCAM5B,KAACpE;wBAAMuH,UAAS;kCAAQ;;oBAEzBtG,SAAS8F,YAAY,iBACpB,KAACtG;wBAAWsF,SAAQ;wBAAUa,OAAM;kCACjC3F,SAAS8F,YAAY;yBAEtB;;iBAEJ;;;AAGV"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/cart-fulfillment.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\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport FormControl from '@mui/material/FormControl'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport FormLabel from '@mui/material/FormLabel'\nimport MenuItem from '@mui/material/MenuItem'\nimport Radio from '@mui/material/Radio'\nimport RadioGroup from '@mui/material/RadioGroup'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { PickupLocationOption } from '../model/local-fulfillment-settings'\nimport type { ModifierSelection } from '../model/product-modifiers'\nimport { pickupReadyWithinLabel } from '../model/local-fulfillment-settings'\n\n/**\n * How the shopper receives the order (AGL-3624): shipped, picked up at one of\n * the store's locations, or brought by the store's own driver. Asked at the\n * cart because that is where the store still decides what the checkout\n * offers; `POST /api/commerce/local-fulfillment-options` answers what this\n * store and this basket can have, and the checkout decides the fee, the\n * minimum and the window again from the store's settings — nothing shown\n * here is trusted.\n *\n * A store with no pickup location and no local delivery gets an empty answer\n * and draws nothing: its cart is exactly what it was.\n */\n\nexport interface CartDeliveryWindow {\n id: string\n startMs: number\n endMs: number\n label: string\n}\n\nexport interface CartDeliveryQuote {\n zoneId?: string\n zoneName?: string\n feeCents?: number\n minimumCents?: number\n freeOverCents?: number\n shortfallCents?: number\n unavailable?: string\n}\n\nexport interface CartFulfillmentOptions {\n pickup: PickupLocationOption[]\n delivery: {\n country: string\n instructions?: string\n needsAddress: boolean\n windows: CartDeliveryWindow[]\n quote?: CartDeliveryQuote\n } | null\n /** Whether the store can text the buyer about the pickup or delivery. */\n texts?: boolean\n}\n\nexport type CartFulfillmentMethod = 'shipping' | 'pickup' | 'local_delivery'\n\nconst EMPTY: CartFulfillmentOptions = { pickup: [], delivery: null }\n\nexport function useCartFulfillment(\n hostId: string | undefined,\n cartSignature: string,\n /**\n * A product's Buy button asks for that product rather than the cart; `null`\n * asks nothing (a subscription, a download).\n */\n buyNow?: {\n productId: string\n variantId?: string\n quantity: number\n /** The add-ons chosen (AGL-4100): a delivery minimum counts them. */\n modifiers?: ModifierSelection[]\n } | null,\n) {\n const buyNowKey = buyNow === undefined ? '' : JSON.stringify(buyNow)\n const [options, setOptions] = useState<CartFulfillmentOptions>(EMPTY)\n const [method, setMethod] = useState<CartFulfillmentMethod>('shipping')\n const [locationId, setLocationId] = useState('')\n const [postalCode, setPostalCode] = useState('')\n const [line1, setLine1] = useState('')\n const [windowId, setWindowId] = useState('')\n const [textPhone, setTextPhone] = useState('')\n const [round, setRound] = useState(0)\n // The postal code and street the quote below was asked for, settled after\n // the shopper stops typing so a keystroke is not a request.\n const [asked, setAsked] = useState({ postalCode: '', line1: '' })\n useEffect(() => {\n const timer = setTimeout(() => setAsked({ postalCode: postalCode.trim(), line1: line1.trim() }), 400)\n return () => clearTimeout(timer)\n }, [postalCode, line1])\n\n // What the request asks beyond the basket: a delivery quote, only for a\n // postal code long enough to place. Keyed by its content, so the settle\n // above handing back an equal object, or a switch between shipping and\n // pickup, is not another request (AGL-4047: every cart load asked twice).\n const wantsQuote = method === 'local_delivery' && asked.postalCode.length >= 3\n const quoteFor = wantsQuote ? JSON.stringify([asked.postalCode, asked.line1]) : ''\n\n useEffect(() => {\n if (!hostId || cartSignature === '[]' || buyNow === null) {\n setOptions(EMPTY)\n return\n }\n let live = true\n const [quotePostal, quoteLine1] = quoteFor ? (JSON.parse(quoteFor) as [string, string]) : ['', '']\n fetch('/api/commerce/local-fulfillment-options', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n ...(buyNow ? buyNow : {}),\n ...(quoteFor ? { postalCode: quotePostal } : {}),\n ...(quoteFor && quoteLine1 ? { address: { line1: quoteLine1, postalCode: quotePostal } } : {}),\n }),\n })\n .then((response) => (response.ok ? response.json() : EMPTY))\n .then((payload: CartFulfillmentOptions) => {\n if (!live) return\n const next: CartFulfillmentOptions = {\n pickup: Array.isArray(payload?.pickup) ? payload.pickup : [],\n delivery: payload?.delivery ?? null,\n texts: Boolean(payload?.texts),\n }\n setOptions(next)\n // A choice the store no longer offers falls back to shipping.\n setMethod((prior) =>\n (prior === 'pickup' && !next.pickup.length) || (prior === 'local_delivery' && !next.delivery)\n ? 'shipping'\n : prior,\n )\n setLocationId((prior) =>\n next.pickup.some((location) => location.id === prior) ? prior : (next.pickup[0]?.id ?? ''),\n )\n setWindowId((prior) =>\n next.delivery?.windows.some((window) => window.id === prior) ? prior : '',\n )\n })\n .catch(() => live && setOptions(EMPTY))\n return () => {\n live = false\n }\n // `buyNow` is read through its key.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hostId, cartSignature, round, quoteFor, buyNowKey])\n\n const offered = options.pickup.length > 0 || Boolean(options.delivery)\n const quote = options.delivery?.quote\n const deliverable = Boolean(quote && !quote.unavailable && !(quote.shortfallCents && quote.shortfallCents > 0))\n /** What the checkout is sent; `null` for a shipped order. */\n const phone = options.texts && textPhone.trim() ? { textPhone: textPhone.trim() } : {}\n const request = useMemo(() => {\n if (method === 'pickup' && locationId) return { method: 'pickup' as const, locationId, ...phone }\n if (method === 'local_delivery') {\n return {\n method: 'local_delivery' as const,\n ...phone,\n postalCode: postalCode.trim(),\n ...(windowId ? { windowStartMs: Number(windowId) } : {}),\n ...(line1.trim() ? { address: { line1: line1.trim(), postalCode: postalCode.trim() } } : {}),\n }\n }\n return null\n // `phone` is derived from the two values listed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [method, locationId, postalCode, windowId, line1, textPhone, options.texts])\n /** Whether the choice is complete enough to check out with. */\n const ready =\n method === 'shipping' ||\n (method === 'pickup' && Boolean(locationId)) ||\n // The quote is the server's answer for what was typed: a zone that\n // reaches it and an order that meets its minimum.\n (method === 'local_delivery' && Boolean(postalCode.trim()) && Boolean(windowId) && deliverable)\n const signature = JSON.stringify(request)\n const reload = useCallback(() => setRound((value) => value + 1), [])\n return {\n options,\n offered,\n method,\n setMethod,\n locationId,\n setLocationId,\n postalCode,\n setPostalCode,\n line1,\n setLine1,\n windowId,\n setWindowId,\n textPhone,\n setTextPhone,\n request,\n ready,\n signature,\n reload,\n }\n}\n\nexport type CartFulfillmentState = ReturnType<typeof useCartFulfillment>\n\nexport function CartFulfillmentChoice(props: {\n state: CartFulfillmentState\n formatCents: (cents: number) => string\n}) {\n const { state, formatCents } = props\n const { options, method } = state\n if (!state.offered) return null\n const location = options.pickup.find((entry) => entry.id === state.locationId)\n const delivery = options.delivery\n const quote = delivery?.quote\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>\n <FormControl>\n <FormLabel id=\"cart-fulfillment-method\">\n <Typography variant=\"subtitle2\" component=\"span\">\n {'How do you want your order?'}\n </Typography>\n </FormLabel>\n <RadioGroup\n aria-labelledby=\"cart-fulfillment-method\"\n value={method}\n onChange={(event) => state.setMethod(event.target.value as CartFulfillmentMethod)}\n >\n <FormControlLabel value=\"shipping\" control={<Radio size=\"small\" />} label=\"Ship it\" />\n {options.pickup.length ? (\n <FormControlLabel\n value=\"pickup\"\n control={<Radio size=\"small\" />}\n label={options.pickup.length === 1 ? `Pick up at ${options.pickup[0].name}` : 'Pick up in store'}\n />\n ) : null}\n {delivery ? (\n <FormControlLabel value=\"local_delivery\" control={<Radio size=\"small\" />} label=\"Local delivery\" />\n ) : null}\n </RadioGroup>\n </FormControl>\n {method === 'pickup' ? (\n <>\n {options.pickup.length > 1 ? (\n <TextField\n select\n label=\"Pickup location\"\n value={state.locationId}\n onChange={(event) => state.setLocationId(event.target.value)}\n size=\"small\"\n >\n {options.pickup.map((entry) => (\n <MenuItem key={entry.id} value={entry.id}>\n {entry.name}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {location ? (\n <Box>\n {location.address ? (\n <Typography variant=\"body2\">{location.address}</Typography>\n ) : null}\n {location.hours ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" sx={{ whiteSpace: 'pre-line' }}>\n {location.hours}\n </Typography>\n ) : null}\n {location.readyWithinMinutes ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {`${pickupReadyWithinLabel(location.readyWithinMinutes)}. We’ll email you when it’s ready.`}\n </Typography>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {'We’ll email you when it’s ready.'}\n </Typography>\n )}\n {location.instructions ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {location.instructions}\n </Typography>\n ) : null}\n </Box>\n ) : null}\n </>\n ) : null}\n {method !== 'shipping' && options.texts ? (\n <TextField\n label=\"Mobile number (optional)\"\n value={state.textPhone}\n onChange={(event) => state.setTextPhone(event.target.value)}\n size=\"small\"\n helperText={\n method === 'pickup'\n ? 'We’ll text you when your order is ready'\n : 'We’ll text you when your order is on its way'\n }\n slotProps={{ htmlInput: { autoComplete: 'tel', inputMode: 'tel', maxLength: 24 } }}\n />\n ) : null}\n {method === 'local_delivery' && delivery ? (\n <>\n <TextField\n label=\"Postal code\"\n value={state.postalCode}\n onChange={(event) => state.setPostalCode(event.target.value)}\n size=\"small\"\n slotProps={{ htmlInput: { autoComplete: 'shipping postal-code', maxLength: 12 } }}\n />\n {delivery.needsAddress ? (\n <TextField\n label=\"Street address\"\n value={state.line1}\n onChange={(event) => state.setLine1(event.target.value)}\n size=\"small\"\n helperText=\"Delivery depends on the distance from the store\"\n slotProps={{ htmlInput: { autoComplete: 'shipping address-line1', maxLength: 120 } }}\n />\n ) : null}\n {quote?.unavailable ? <Alert severity=\"info\">{quote.unavailable}</Alert> : null}\n {quote && !quote.unavailable ? (\n quote.shortfallCents && quote.shortfallCents > 0 ? (\n <Alert severity=\"info\">\n {`Delivery needs an order of at least ${formatCents(quote.minimumCents ?? 0)}. ` +\n `Add ${formatCents(quote.shortfallCents)} more.`}\n </Alert>\n ) : (\n <Typography variant=\"body2\">\n {quote.feeCents\n ? `Delivery: ${formatCents(quote.feeCents)}`\n : 'Delivery: free'}\n {quote.freeOverCents && quote.feeCents\n ? ` (free over ${formatCents(quote.freeOverCents)})`\n : ''}\n </Typography>\n )\n ) : null}\n {delivery.windows.length ? (\n <TextField\n select\n label=\"Delivery time\"\n value={state.windowId}\n onChange={(event) => state.setWindowId(event.target.value)}\n size=\"small\"\n >\n {delivery.windows.map((window) => (\n <MenuItem key={window.id} value={window.id}>\n {window.label}\n </MenuItem>\n ))}\n </TextField>\n ) : (\n <Alert severity=\"info\">{'No delivery times are open right now.'}</Alert>\n )}\n {delivery.instructions ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {delivery.instructions}\n </Typography>\n ) : null}\n </>\n ) : null}\n </Box>\n )\n}\n"],"names":["Alert","Box","FormControl","FormControlLabel","FormLabel","MenuItem","Radio","RadioGroup","TextField","Typography","useCallback","useEffect","useMemo","useState","pickupReadyWithinLabel","EMPTY","pickup","delivery","useCartFulfillment","hostId","cartSignature","buyNow","options","buyNowKey","undefined","JSON","stringify","setOptions","method","setMethod","locationId","setLocationId","postalCode","setPostalCode","line1","setLine1","windowId","setWindowId","textPhone","setTextPhone","round","setRound","asked","setAsked","timer","setTimeout","trim","clearTimeout","wantsQuote","length","quoteFor","live","quotePostal","quoteLine1","parse","fetch","headers","body","address","then","response","ok","json","payload","next","Array","isArray","texts","Boolean","prior","some","location","id","windows","window","catch","offered","quote","deliverable","unavailable","shortfallCents","phone","request","windowStartMs","Number","ready","signature","reload","value","CartFulfillmentChoice","props","state","formatCents","find","entry","sx","display","flexDirection","gap","variant","component","aria-labelledby","onChange","event","target","control","size","label","name","select","map","hours","color","whiteSpace","readyWithinMinutes","instructions","helperText","slotProps","htmlInput","autoComplete","inputMode","maxLength","needsAddress","severity","minimumCents","feeCents","freeOverCents"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,OAAOA,WAAW,sBAAqB;AACvC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,gBAAgB,2BAA0B;AACjD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAGjE,SAASC,sBAAsB,QAAQ,yCAAqC;AA+C5E,MAAMC,QAAgC;IAAEC,QAAQ,EAAE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AAYf,MAAMgD,QAAQ,GAAG,GAC1C;4BACHhD,MAAMiD,aAAa,IAAIjD,MAAMgD,QAAQ,GAClC,CAAC,YAAY,EAAEjC,YAAYf,MAAMiD,aAAa,EAAE,CAAC,CAAC,GAClD;;yBAGN;oBACH7G,SAASwD,OAAO,CAACxB,MAAM,iBACtB,KAACzC;wBACCqG,MAAM;wBACNF,OAAM;wBACNnB,OAAOG,MAAMvD,QAAQ;wBACrBkE,UAAU,CAACC,QAAUZ,MAAMtD,WAAW,CAACkE,MAAMC,MAAM,CAAChB,KAAK;wBACzDkB,MAAK;kCAEJzF,SAASwD,OAAO,CAACqC,GAAG,CAAC,CAACpC,uBACrB,KAACrE;gCAAyBmF,OAAOd,OAAOF,EAAE;0CACvCE,OAAOiC,KAAK;+BADAjC,OAAOF,EAAE;uCAM5B,KAACxE;wBAAM2H,UAAS;kCAAQ;;oBAEzB1G,SAASkG,YAAY,iBACpB,KAAC1G;wBAAW0F,SAAQ;wBAAUa,OAAM;kCACjC/F,SAASkG,YAAY;yBAEtB;;iBAEJ;;;AAGV"}
|
|
@@ -30,7 +30,7 @@ import { ceilingedWindow, collectionCeiling, useFirestoreCollection, writeGuarde
|
|
|
30
30
|
import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
|
|
31
31
|
import { TABLE_PAGE_SIZE_DEFAULT } from "@aglyn/shared-ui-jsx/const/table-pagination";
|
|
32
32
|
import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
33
|
-
import { isSeedChecking, seedCheckingText } from "@aglyn/tenant-feature-instance/hooks/use-seed-edits";
|
|
33
|
+
import { isSeedChecking, seedCheckingText, useHeldSave } from "@aglyn/tenant-feature-instance/hooks/use-seed-edits";
|
|
34
34
|
import { useSeedDraft } from "@aglyn/tenant-feature-instance/hooks/use-seed-draft";
|
|
35
35
|
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
36
36
|
import TransferHeaderActions from "../../transfer/transfer-header-actions.component.js";
|
|
@@ -449,9 +449,9 @@ const RULE_OP_MENU = RULE_OPS.map((op)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
|
449
449
|
/*#__PURE__*/ _jsx(Button, {
|
|
450
450
|
variant: "contained",
|
|
451
451
|
color: "primary",
|
|
452
|
-
disabled:
|
|
452
|
+
disabled: props.saving || !(draft == null ? void 0 : draft.name.trim()),
|
|
453
453
|
onClick: props.onSave,
|
|
454
|
-
children: 'Save'
|
|
454
|
+
children: props.saving ? 'Saving…' : 'Save'
|
|
455
455
|
})
|
|
456
456
|
]
|
|
457
457
|
})
|
|
@@ -698,9 +698,9 @@ const CollectionRuleRow = /*#__PURE__*/ memo(function CollectionRuleRow(props) {
|
|
|
698
698
|
/*#__PURE__*/ _jsx(Button, {
|
|
699
699
|
variant: "contained",
|
|
700
700
|
color: "primary",
|
|
701
|
-
disabled:
|
|
701
|
+
disabled: props.saving || !(draft == null ? void 0 : draft.name.trim()) || Boolean(error),
|
|
702
702
|
onClick: props.onSave,
|
|
703
|
-
children: 'Save'
|
|
703
|
+
children: props.saving ? 'Saving…' : 'Save'
|
|
704
704
|
})
|
|
705
705
|
]
|
|
706
706
|
})
|
|
@@ -1323,6 +1323,23 @@ const CollectionRuleRow = /*#__PURE__*/ memo(function CollectionRuleRow(props) {
|
|
|
1323
1323
|
rules
|
|
1324
1324
|
}));
|
|
1325
1325
|
}, []);
|
|
1326
|
+
// A press while Save is held is kept, and saves once confirmed (AGL-4047).
|
|
1327
|
+
const categoryHeld = useHeldSave(handleCategorySave, {
|
|
1328
|
+
checking: Boolean(categoryChecking),
|
|
1329
|
+
subject: 'category',
|
|
1330
|
+
onRefused: (message)=>enqueueSnackbar(message, {
|
|
1331
|
+
variant: 'warning',
|
|
1332
|
+
persist: false
|
|
1333
|
+
})
|
|
1334
|
+
});
|
|
1335
|
+
const collectionHeld = useHeldSave(handleCollectionSave, {
|
|
1336
|
+
checking: Boolean(collectionChecking),
|
|
1337
|
+
subject: 'collection',
|
|
1338
|
+
onRefused: (message)=>enqueueSnackbar(message, {
|
|
1339
|
+
variant: 'warning',
|
|
1340
|
+
persist: false
|
|
1341
|
+
})
|
|
1342
|
+
});
|
|
1326
1343
|
return /*#__PURE__*/ _jsxs(CardDisplay, {
|
|
1327
1344
|
header: 'Categories & collections',
|
|
1328
1345
|
HeaderProps: {
|
|
@@ -1377,8 +1394,9 @@ const CollectionRuleRow = /*#__PURE__*/ memo(function CollectionRuleRow(props) {
|
|
|
1377
1394
|
draft: categoryDraft,
|
|
1378
1395
|
categories: categories,
|
|
1379
1396
|
setDraft: setCategoryDraft,
|
|
1380
|
-
onSave:
|
|
1381
|
-
checkingText: categoryChecking
|
|
1397
|
+
onSave: categoryHeld.press,
|
|
1398
|
+
checkingText: categoryChecking,
|
|
1399
|
+
saving: categoryHeld.saving
|
|
1382
1400
|
}),
|
|
1383
1401
|
/*#__PURE__*/ _jsx(CollectionDialog, {
|
|
1384
1402
|
draft: collectionDraft,
|
|
@@ -1393,8 +1411,9 @@ const CollectionRuleRow = /*#__PURE__*/ memo(function CollectionRuleRow(props) {
|
|
|
1393
1411
|
setDraft: setCollectionDraft,
|
|
1394
1412
|
onProducts: setCollectionProducts,
|
|
1395
1413
|
onRule: updateRule,
|
|
1396
|
-
onSave:
|
|
1397
|
-
checkingText: collectionChecking
|
|
1414
|
+
onSave: collectionHeld.press,
|
|
1415
|
+
checkingText: collectionChecking,
|
|
1416
|
+
saving: collectionHeld.saving
|
|
1398
1417
|
})
|
|
1399
1418
|
]
|
|
1400
1419
|
});
|