@aglyn/plugins-commerce 1.16.0 → 1.17.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-cellular-control.component.d.ts +5 -0
- package/src/lib/components/console/pos-cellular-control.component.js +29 -15
- package/src/lib/components/console/pos-cellular-control.component.js.map +1 -1
- package/src/lib/components/product-grid.js +2 -1
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/product-name-lines.d.ts +37 -0
- package/src/lib/components/product-name-lines.js +36 -0
- package/src/lib/components/product-name-lines.js.map +1 -0
- package/src/lib/components/related-products.js +2 -1
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/model/pos-cellular.d.ts +31 -4
- package/src/lib/model/pos-cellular.js +39 -4
- package/src/lib/model/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.d.ts +4 -3
- package/src/lib/server/pos-cellular-billing.js +22 -11
- package/src/lib/server/pos-cellular-billing.js.map +1 -1
- package/src/lib/server/pos-cellular.js +43 -28
- package/src/lib/server/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-readers.js +8 -2
- package/src/lib/server/pos-readers.js.map +1 -1
- package/src/lib/server/quote.js +25 -2
- package/src/lib/server/quote.js.map +1 -1
- package/src/lib/server.d.ts +15 -0
- package/src/lib/server.js +28 -1
- package/src/lib/server.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.17.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.17.0",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.17.0",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.17.0",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.17.0",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.17.0",
|
|
33
|
+
"@aglyn/shared-util-email": "1.17.0",
|
|
34
|
+
"@aglyn/shared-util-http": "1.17.0",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.17.0",
|
|
36
|
+
"@aglyn/shared-util-tools": "1.17.0",
|
|
37
|
+
"@aglyn/tenant-data-admin": "1.17.0",
|
|
38
|
+
"@aglyn/tenant-feature-instance": "1.17.0",
|
|
39
|
+
"@aglyn/tenant-runtime": "1.17.0",
|
|
40
40
|
"@stripe/react-stripe-js": "^6.12.0",
|
|
41
41
|
"@stripe/stripe-js": "^9.17.0",
|
|
42
42
|
"@swc/helpers": "0.5.23",
|
|
@@ -33,6 +33,11 @@ export interface PosCellularControlProps {
|
|
|
33
33
|
* than hiding. A store whose 4G was turned off for an unpaid month says
|
|
34
34
|
* which, and how to turn it back on. Loaded only where 4G is offered and the
|
|
35
35
|
* store has an S710.
|
|
36
|
+
*
|
|
37
|
+
* A store on its own Stripe account is billed for 4G by Stripe, on that
|
|
38
|
+
* account, and never by the workspace: the row names no price (the only one
|
|
39
|
+
* known here is the platform's), turning it on asks for no agreement and no
|
|
40
|
+
* "Manage billing", and it says who bills it instead.
|
|
36
41
|
*/
|
|
37
42
|
export declare function PosCellularControl({ hostId, cellular, blocked, onChanged }: PosCellularControlProps): import("react").JSX.Element;
|
|
38
43
|
export declare namespace PosCellularControl {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2026 Aglyn LLC
|
|
@@ -32,6 +32,11 @@ const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
|
32
32
|
* than hiding. A store whose 4G was turned off for an unpaid month says
|
|
33
33
|
* which, and how to turn it back on. Loaded only where 4G is offered and the
|
|
34
34
|
* store has an S710.
|
|
35
|
+
*
|
|
36
|
+
* A store on its own Stripe account is billed for 4G by Stripe, on that
|
|
37
|
+
* account, and never by the workspace: the row names no price (the only one
|
|
38
|
+
* known here is the platform's), turning it on asks for no agreement and no
|
|
39
|
+
* "Manage billing", and it says who bills it instead.
|
|
35
40
|
*/ export function PosCellularControl({ hostId, cellular, blocked, onChanged }) {
|
|
36
41
|
var _cellular_turnOnBlocked;
|
|
37
42
|
const { data: user } = useUser();
|
|
@@ -39,9 +44,11 @@ const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
|
39
44
|
const [dialog, setDialog] = useState(null);
|
|
40
45
|
const [agreed, setAgreed] = useState(false);
|
|
41
46
|
const [busy, setBusy] = useState(false);
|
|
42
|
-
const
|
|
47
|
+
const ownAccount = cellular.ownAccount === true;
|
|
48
|
+
const price = cellular.readerMonthlyCents === null ? '' : usd(cellular.readerMonthlyCents);
|
|
43
49
|
// Off needs only the card's key; on is charged to the workspace, so billing too.
|
|
44
50
|
const reason = blocked != null ? blocked : cellular.enabled ? null : (_cellular_turnOnBlocked = cellular.turnOnBlocked) != null ? _cellular_turnOnBlocked : null;
|
|
51
|
+
const caption = ownAccount ? cellular.enabled ? `On for every S710 reader at this store (${readersText(cellular.readers)} now). Stripe bills its 4G price for each one to this store’s own Stripe account.` : 'An S710 reader can use 4G service when Wi-Fi drops. It turns on for every S710 at this store, and Stripe bills its 4G price for each one to this store’s own Stripe account.' : cellular.enabled ? `On for every S710 reader at this store (${readersText(cellular.readers)} now). Each is charged ${price} a month.` : `An S710 reader can use 4G service when Wi-Fi drops. It turns on for every S710 at this store, at ${price} a month each.`;
|
|
45
52
|
const change = async (enabled)=>{
|
|
46
53
|
if (!user) return;
|
|
47
54
|
setBusy(true);
|
|
@@ -50,7 +57,7 @@ const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
|
50
57
|
action: 'cellular',
|
|
51
58
|
hostId,
|
|
52
59
|
enabled
|
|
53
|
-
}, enabled ? {
|
|
60
|
+
}, enabled && !ownAccount ? {
|
|
54
61
|
consent: agreed
|
|
55
62
|
} : {}));
|
|
56
63
|
setDialog(null);
|
|
@@ -95,7 +102,7 @@ const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
|
95
102
|
variant: "caption",
|
|
96
103
|
color: "text.secondary",
|
|
97
104
|
component: "p",
|
|
98
|
-
children:
|
|
105
|
+
children: caption
|
|
99
106
|
})
|
|
100
107
|
]
|
|
101
108
|
}),
|
|
@@ -140,16 +147,23 @@ const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
|
140
147
|
variant: "body2",
|
|
141
148
|
children: `Every S710 reader at this store gets 4G service and uses it whenever Wi-Fi and Ethernet are not available. That is ${readersText(cellular.readers)} now, and any S710 you add here later.`
|
|
142
149
|
}),
|
|
143
|
-
/*#__PURE__*/ _jsx(Typography, {
|
|
150
|
+
ownAccount ? /*#__PURE__*/ _jsx(Typography, {
|
|
144
151
|
variant: "body2",
|
|
145
|
-
children:
|
|
146
|
-
}),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
children: 'Stripe bills its 4G price for each S710 to this store’s own Stripe account, under the store’s agreement with Stripe, for every calendar month it has 4G. This workspace is not charged for it. Turning 4G off stops it from the next month.'
|
|
153
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
156
|
+
variant: "body2",
|
|
157
|
+
children: `Each S710 is charged ${price} a month, plus any sales tax, for every calendar month it has 4G. The charge goes to this workspace's card at the start of the next month. Turning 4G off stops the charge from the next month. If a month's charge isn't paid, 4G is turned off after a grace period, until it's paid and turned on again.`
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
160
|
+
control: /*#__PURE__*/ _jsx(Checkbox, {
|
|
161
|
+
checked: agreed,
|
|
162
|
+
onChange: (event)=>setAgreed(event.target.checked)
|
|
163
|
+
}),
|
|
164
|
+
label: `I agree to ${price} a month for each S710 reader at this store while 4G is on.`
|
|
165
|
+
})
|
|
166
|
+
]
|
|
153
167
|
})
|
|
154
168
|
]
|
|
155
169
|
}),
|
|
@@ -162,7 +176,7 @@ const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
|
162
176
|
}),
|
|
163
177
|
/*#__PURE__*/ _jsx(Button, {
|
|
164
178
|
variant: "contained",
|
|
165
|
-
disabled: busy || !agreed,
|
|
179
|
+
disabled: busy || !ownAccount && !agreed,
|
|
166
180
|
onClick: ()=>void change(true),
|
|
167
181
|
children: 'Turn on 4G'
|
|
168
182
|
})
|
|
@@ -182,7 +196,7 @@ const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
|
182
196
|
/*#__PURE__*/ _jsx(DialogContent, {
|
|
183
197
|
children: /*#__PURE__*/ _jsx(Typography, {
|
|
184
198
|
variant: "body2",
|
|
185
|
-
children: 'The S710 readers at this store stop using 4G the next time they connect, and use Wi-Fi or Ethernet only. This month is still charged for each reader that had 4G in it.'
|
|
199
|
+
children: ownAccount ? 'The S710 readers at this store stop using 4G the next time they connect, and use Wi-Fi or Ethernet only. Stripe still bills this month for each reader that had 4G in it.' : 'The S710 readers at this store stop using 4G the next time they connect, and use Wi-Fi or Ethernet only. This month is still charged for each reader that had 4G in it.'
|
|
186
200
|
})
|
|
187
201
|
}),
|
|
188
202
|
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-cellular-control.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\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Checkbox,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useState } from 'react'\nimport type { PosCellularView } from '../../model/pos-cellular'\nimport { posReadersCall, PosRequestError, usd } from './pos/pos-api'\n\nexport interface PosCellularControlProps {\n hostId: string\n cellular: PosCellularView\n /** Why the viewer may not change it (\"Registers and devices\"), or null. */\n blocked: string | null\n /** Reload the card once it changed. */\n onChanged: () => void | Promise<void>\n}\n\nconst readersText = (count: number) => `${count} S710 reader${count === 1 ? '' : 's'}`\n\n/**\n * 4G for a store's S710 readers (AGL-4038), on the POS devices card.\n * Stripe turns cellular service on for a store's reader Location, so this is\n * one switch for the store: it says plainly that every S710 at the store\n * gets 4G and that each one is charged, and turning it on takes an explicit\n * agreement to the monthly price. Turning it ON is charged to the workspace,\n * so it also takes \"Manage billing\": without it the control says so rather\n * than hiding. A store whose 4G was turned off for an unpaid month says\n * which, and how to turn it back on. Loaded only where 4G is offered and the\n * store has an S710.\n */\nexport function PosCellularControl({ hostId, cellular, blocked, onChanged }: PosCellularControlProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [dialog, setDialog] = useState<'on' | 'off' | null>(null)\n const [agreed, setAgreed] = useState(false)\n const [busy, setBusy] = useState(false)\n const price = usd(cellular.readerMonthlyCents)\n // Off needs only the card's key; on is charged to the workspace, so billing too.\n const reason = blocked ?? (cellular.enabled ? null : (cellular.turnOnBlocked ?? null))\n\n const change = async (enabled: boolean) => {\n if (!user) return\n setBusy(true)\n try {\n await posReadersCall(user, { action: 'cellular', hostId, enabled, ...(enabled ? { consent: agreed } : {}) })\n setDialog(null)\n setAgreed(false)\n enqueueSnackbar(enabled ? '4G is on for this store’s S710 readers' : '4G is off for this store', {\n variant: 'success',\n persist: false,\n })\n await onChanged()\n } catch (error) {\n enqueueSnackbar(error instanceof PosRequestError ? error.message : '4G could not be changed. Try again.', {\n variant: 'warning',\n persist: false,\n })\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <Box sx={{ flex: 1, minWidth: 220 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 'fontWeightMedium' }}>\n {'4G (cellular)'}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {cellular.enabled\n ? `On for every S710 reader at this store (${readersText(cellular.readers)} now). Each is charged ${price} a month.`\n : `An S710 reader can use 4G service when Wi-Fi drops. It turns on for every S710 at this store, at ${price} a month each.`}\n </Typography>\n </Box>\n <Chip size=\"small\" label={cellular.enabled ? 'On' : 'Off'} color={cellular.enabled ? 'success' : 'default'} />\n <BlockedControl blocked={Boolean(reason)} reason={reason ?? ''}>\n <Button size=\"small\" onClick={() => setDialog(cellular.enabled ? 'off' : 'on')}>\n {cellular.enabled ? 'Turn off 4G' : 'Turn on 4G'}\n </Button>\n </BlockedControl>\n {cellular.suspended ? (\n <Alert severity=\"warning\" sx={{ flexBasis: '100%' }}>\n {`4G was turned off because the 4G charge for ${cellular.suspended.month} wasn't paid. Pay it on the Billing page, then turn 4G on again here.`}\n </Alert>\n ) : null}\n\n <Dialog open={dialog === 'on'} onClose={() => (busy ? undefined : setDialog(null))} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Turn on 4G for this store?'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 1.5 }}>\n <Typography variant=\"body2\">\n {`Every S710 reader at this store gets 4G service and uses it whenever Wi-Fi and Ethernet are not available. That is ${readersText(cellular.readers)} now, and any S710 you add here later.`}\n </Typography>\n <Typography variant=\"body2\">\n {`Each S710 is charged ${price} a month, plus any sales tax, for every calendar month it has 4G. The charge goes to this workspace's card at the start of the next month. Turning 4G off stops the charge from the next month. If a month's charge isn't paid, 4G is turned off after a grace period, until it's paid and turned on again.`}\n </Typography>\n <FormControlLabel\n control={<Checkbox checked={agreed} onChange={(event) => setAgreed(event.target.checked)} />}\n label={`I agree to ${price} a month for each S710 reader at this store while 4G is on.`}\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDialog(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !agreed} onClick={() => void change(true)}>\n {'Turn on 4G'}\n </Button>\n </DialogActions>\n </Dialog>\n\n <Dialog open={dialog === 'off'} onClose={() => (busy ? undefined : setDialog(null))} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{'Turn off 4G?'}</DialogTitle>\n <DialogContent>\n <Typography variant=\"body2\">\n {'The S710 readers at this store stop using 4G the next time they connect, and use Wi-Fi or Ethernet only. This month is still charged for each reader that had 4G in it.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDialog(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void change(false)}>\n {'Turn off 4G'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nPosCellularControl.displayName = 'PosCellularControl'\n\nexport default PosCellularControl\n"],"names":["BlockedControl","useSnackbar","useUser","Alert","Box","Button","Checkbox","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","Stack","Typography","useState","posReadersCall","PosRequestError","usd","readersText","count","PosCellularControl","hostId","cellular","blocked","onChanged","data","user","enqueueSnackbar","dialog","setDialog","agreed","setAgreed","busy","setBusy","price","readerMonthlyCents","reason","enabled","turnOnBlocked","change","action","consent","variant","persist","error","message","direction","spacing","sx","alignItems","flexWrap","rowGap","flex","minWidth","fontWeight","color","component","readers","size","label","Boolean","onClick","suspended","severity","flexBasis","month","open","onClose","undefined","maxWidth","fullWidth","display","flexDirection","gap","control","checked","onChange","event","target","disabled","displayName"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,QAAQ,QAAQ,QAAO;AAEhC,SAASC,cAAc,EAAEC,eAAe,EAAEC,GAAG,QAAQ,mBAAe;AAWpE,MAAMC,cAAc,CAACC,QAAkB,GAAGA,MAAM,YAAY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AAU9C,UAAU8C,MAAMC,MAAM,CAACH,OAAO;;gCACvFhB,OAAO,CAAC,WAAW,EAAEzB,MAAM,2DAA2D,CAAC;;;;kCAG3F,MAAC1B;;0CACC,KAACJ;gCAAOyD,SAAS,IAAMhC,UAAU;gCAAOkD,UAAU/C;0CAC/C;;0CAEH,KAAC5B;gCAAOsC,SAAQ;gCAAYqC,UAAU/C,QAAQ,CAACF;gCAAQ+B,SAAS,IAAM,KAAKtB,OAAO;0CAC/E;;;;;;0BAKP,MAAChC;gBAAO2D,MAAMtC,WAAW;gBAAOuC,SAAS,IAAOnC,OAAOoC,YAAYvC,UAAU;gBAAQwC,UAAS;gBAAKC,SAAS;;kCAC1G,KAAC5D;kCAAa;;kCACd,KAACD;kCACC,cAAA,KAACI;4BAAW6B,SAAQ;sCACjB;;;kCAGL,MAAClC;;0CACC,KAACJ;gCAAOyD,SAAS,IAAMhC,UAAU;gCAAOkD,UAAU/C;0CAC/C;;0CAEH,KAAC5B;gCAAOsC,SAAQ;gCAAYqC,UAAU/C;gCAAM6B,SAAS,IAAM,KAAKtB,OAAO;0CACpE;;;;;;;;AAMb;AACAnB,mBAAmB4D,WAAW,GAAG;AAEjC,eAAe5D,mBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-cellular-control.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\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Checkbox,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useState } from 'react'\nimport type { PosCellularView } from '../../model/pos-cellular'\nimport { posReadersCall, PosRequestError, usd } from './pos/pos-api'\n\nexport interface PosCellularControlProps {\n hostId: string\n cellular: PosCellularView\n /** Why the viewer may not change it (\"Registers and devices\"), or null. */\n blocked: string | null\n /** Reload the card once it changed. */\n onChanged: () => void | Promise<void>\n}\n\nconst readersText = (count: number) => `${count} S710 reader${count === 1 ? '' : 's'}`\n\n/**\n * 4G for a store's S710 readers (AGL-4038), on the POS devices card.\n * Stripe turns cellular service on for a store's reader Location, so this is\n * one switch for the store: it says plainly that every S710 at the store\n * gets 4G and that each one is charged, and turning it on takes an explicit\n * agreement to the monthly price. Turning it ON is charged to the workspace,\n * so it also takes \"Manage billing\": without it the control says so rather\n * than hiding. A store whose 4G was turned off for an unpaid month says\n * which, and how to turn it back on. Loaded only where 4G is offered and the\n * store has an S710.\n *\n * A store on its own Stripe account is billed for 4G by Stripe, on that\n * account, and never by the workspace: the row names no price (the only one\n * known here is the platform's), turning it on asks for no agreement and no\n * \"Manage billing\", and it says who bills it instead.\n */\nexport function PosCellularControl({ hostId, cellular, blocked, onChanged }: PosCellularControlProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [dialog, setDialog] = useState<'on' | 'off' | null>(null)\n const [agreed, setAgreed] = useState(false)\n const [busy, setBusy] = useState(false)\n const ownAccount = cellular.ownAccount === true\n const price = cellular.readerMonthlyCents === null ? '' : usd(cellular.readerMonthlyCents)\n // Off needs only the card's key; on is charged to the workspace, so billing too.\n const reason = blocked ?? (cellular.enabled ? null : (cellular.turnOnBlocked ?? null))\n const caption = ownAccount\n ? cellular.enabled\n ? `On for every S710 reader at this store (${readersText(cellular.readers)} now). Stripe bills its 4G price for each one to this store’s own Stripe account.`\n : 'An S710 reader can use 4G service when Wi-Fi drops. It turns on for every S710 at this store, and Stripe bills its 4G price for each one to this store’s own Stripe account.'\n : cellular.enabled\n ? `On for every S710 reader at this store (${readersText(cellular.readers)} now). Each is charged ${price} a month.`\n : `An S710 reader can use 4G service when Wi-Fi drops. It turns on for every S710 at this store, at ${price} a month each.`\n\n const change = async (enabled: boolean) => {\n if (!user) return\n setBusy(true)\n try {\n await posReadersCall(user, {\n action: 'cellular',\n hostId,\n enabled,\n ...(enabled && !ownAccount ? { consent: agreed } : {}),\n })\n setDialog(null)\n setAgreed(false)\n enqueueSnackbar(enabled ? '4G is on for this store’s S710 readers' : '4G is off for this store', {\n variant: 'success',\n persist: false,\n })\n await onChanged()\n } catch (error) {\n enqueueSnackbar(error instanceof PosRequestError ? error.message : '4G could not be changed. Try again.', {\n variant: 'warning',\n persist: false,\n })\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <Box sx={{ flex: 1, minWidth: 220 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 'fontWeightMedium' }}>\n {'4G (cellular)'}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {caption}\n </Typography>\n </Box>\n <Chip size=\"small\" label={cellular.enabled ? 'On' : 'Off'} color={cellular.enabled ? 'success' : 'default'} />\n <BlockedControl blocked={Boolean(reason)} reason={reason ?? ''}>\n <Button size=\"small\" onClick={() => setDialog(cellular.enabled ? 'off' : 'on')}>\n {cellular.enabled ? 'Turn off 4G' : 'Turn on 4G'}\n </Button>\n </BlockedControl>\n {cellular.suspended ? (\n <Alert severity=\"warning\" sx={{ flexBasis: '100%' }}>\n {`4G was turned off because the 4G charge for ${cellular.suspended.month} wasn't paid. Pay it on the Billing page, then turn 4G on again here.`}\n </Alert>\n ) : null}\n\n <Dialog open={dialog === 'on'} onClose={() => (busy ? undefined : setDialog(null))} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Turn on 4G for this store?'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 1.5 }}>\n <Typography variant=\"body2\">\n {`Every S710 reader at this store gets 4G service and uses it whenever Wi-Fi and Ethernet are not available. That is ${readersText(cellular.readers)} now, and any S710 you add here later.`}\n </Typography>\n {ownAccount ? (\n <Typography variant=\"body2\">\n {'Stripe bills its 4G price for each S710 to this store’s own Stripe account, under the store’s agreement with Stripe, for every calendar month it has 4G. This workspace is not charged for it. Turning 4G off stops it from the next month.'}\n </Typography>\n ) : (\n <>\n <Typography variant=\"body2\">\n {`Each S710 is charged ${price} a month, plus any sales tax, for every calendar month it has 4G. The charge goes to this workspace's card at the start of the next month. Turning 4G off stops the charge from the next month. If a month's charge isn't paid, 4G is turned off after a grace period, until it's paid and turned on again.`}\n </Typography>\n <FormControlLabel\n control={<Checkbox checked={agreed} onChange={(event) => setAgreed(event.target.checked)} />}\n label={`I agree to ${price} a month for each S710 reader at this store while 4G is on.`}\n />\n </>\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDialog(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || (!ownAccount && !agreed)} onClick={() => void change(true)}>\n {'Turn on 4G'}\n </Button>\n </DialogActions>\n </Dialog>\n\n <Dialog open={dialog === 'off'} onClose={() => (busy ? undefined : setDialog(null))} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{'Turn off 4G?'}</DialogTitle>\n <DialogContent>\n <Typography variant=\"body2\">\n {ownAccount\n ? 'The S710 readers at this store stop using 4G the next time they connect, and use Wi-Fi or Ethernet only. Stripe still bills this month for each reader that had 4G in it.'\n : 'The S710 readers at this store stop using 4G the next time they connect, and use Wi-Fi or Ethernet only. This month is still charged for each reader that had 4G in it.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDialog(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void change(false)}>\n {'Turn off 4G'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nPosCellularControl.displayName = 'PosCellularControl'\n\nexport default PosCellularControl\n"],"names":["BlockedControl","useSnackbar","useUser","Alert","Box","Button","Checkbox","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","Stack","Typography","useState","posReadersCall","PosRequestError","usd","readersText","count","PosCellularControl","hostId","cellular","blocked","onChanged","data","user","enqueueSnackbar","dialog","setDialog","agreed","setAgreed","busy","setBusy","ownAccount","price","readerMonthlyCents","reason","enabled","turnOnBlocked","caption","readers","change","action","consent","variant","persist","error","message","direction","spacing","sx","alignItems","flexWrap","rowGap","flex","minWidth","fontWeight","color","component","size","label","Boolean","onClick","suspended","severity","flexBasis","month","open","onClose","undefined","maxWidth","fullWidth","display","flexDirection","gap","control","checked","onChange","event","target","disabled","displayName"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,QAAQ,QAAQ,QAAO;AAEhC,SAASC,cAAc,EAAEC,eAAe,EAAEC,GAAG,QAAQ,mBAAe;AAWpE,MAAMC,cAAc,CAACC,QAAkB,GAAGA,MAAM,YAAY,EAAEA,UAAU,IAAI,KAAK,KAAK;AAEtF;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,EAA2B;QAS5CF;IARtD,MAAM,EAAEG,MAAMC,IAAI,EAAE,GAAGzB;IACvB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,KAACxB;wCACCiE,uBAAS,KAACvE;4CAASwE,SAAS/C;4CAAQgD,UAAU,CAACC,QAAUhD,UAAUgD,MAAMC,MAAM,CAACH,OAAO;;wCACvFhB,OAAO,CAAC,WAAW,EAAE1B,MAAM,2DAA2D,CAAC;;;;;;kCAK/F,MAAC3B;;0CACC,KAACJ;gCAAO2D,SAAS,IAAMlC,UAAU;gCAAOoD,UAAUjD;0CAC/C;;0CAEH,KAAC5B;gCAAOyC,SAAQ;gCAAYoC,UAAUjD,QAAS,CAACE,cAAc,CAACJ;gCAASiC,SAAS,IAAM,KAAKrB,OAAO;0CAChG;;;;;;0BAKP,MAACnC;gBAAO6D,MAAMxC,WAAW;gBAAOyC,SAAS,IAAOrC,OAAOsC,YAAYzC,UAAU;gBAAQ0C,UAAS;gBAAKC,SAAS;;kCAC1G,KAAC9D;kCAAa;;kCACd,KAACD;kCACC,cAAA,KAACI;4BAAWgC,SAAQ;sCACjBX,aACG,8KACA;;;kCAGR,MAAC1B;;0CACC,KAACJ;gCAAO2D,SAAS,IAAMlC,UAAU;gCAAOoD,UAAUjD;0CAC/C;;0CAEH,KAAC5B;gCAAOyC,SAAQ;gCAAYoC,UAAUjD;gCAAM+B,SAAS,IAAM,KAAKrB,OAAO;0CACpE;;;;;;;;AAMb;AACAtB,mBAAmB8D,WAAW,GAAG;AAEjC,eAAe9D,mBAAkB"}
|
|
@@ -41,6 +41,7 @@ import { addToCart } from "../utils/add-to-cart.js";
|
|
|
41
41
|
import { formatOrderMoney } from "../model/buyer-notifications.js";
|
|
42
42
|
import { ProductImagePlaceholder } from "./product-image-placeholder.js";
|
|
43
43
|
import { PRODUCT_PHOTO_FIT_ATTRIBUTE, productPhotoFit, productPhotoFitSx } from "./product-photo-fit.js";
|
|
44
|
+
import { PRODUCT_NAME_SX } from "./product-name-lines.js";
|
|
44
45
|
// Component ids are persisted in screen documents; never rename.
|
|
45
46
|
export const ID = 'product-grid';
|
|
46
47
|
/**
|
|
@@ -776,7 +777,7 @@ function priceLabel(item) {
|
|
|
776
777
|
children: [
|
|
777
778
|
/*#__PURE__*/ _jsx(Typography, {
|
|
778
779
|
variant: photoCards ? 'subtitle1' : 'subtitle2',
|
|
779
|
-
|
|
780
|
+
sx: PRODUCT_NAME_SX,
|
|
780
781
|
children: item.name
|
|
781
782
|
}),
|
|
782
783
|
/*#__PURE__*/ _jsxs(Box, {
|