@aglyn/plugins-commerce 1.13.0 → 1.15.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/account-subscriptions.d.ts +51 -0
- package/src/lib/components/account-subscriptions.js +168 -0
- package/src/lib/components/account-subscriptions.js.map +1 -0
- package/src/lib/components/account.js +12 -48
- package/src/lib/components/account.js.map +1 -1
- package/src/lib/components/cart.js +30 -6
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +6 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/commerce-console-sections.d.ts +1 -1
- package/src/lib/components/commerce-console-sections.js +5 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -1
- package/src/lib/components/console/paid-media.d.ts +1 -0
- package/src/lib/components/console/paid-media.js +15 -4
- package/src/lib/components/console/paid-media.js.map +1 -1
- package/src/lib/components/console/payments-settings-card.component.js +1 -1
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-api.d.ts +10 -1
- package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js +2 -2
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +2 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -1
- package/src/lib/components/console/pos-cellular-control.component.d.ts +1 -1
- package/src/lib/components/console/pos-cellular-control.component.js +5 -5
- package/src/lib/components/console/pos-cellular-control.component.js.map +1 -1
- package/src/lib/components/console/pos-devices-card.component.js +2 -2
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-card.component.d.ts +5 -0
- package/src/lib/components/console/pos-hardware-card.component.js +77 -8
- package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +137 -19
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
- package/src/lib/components/console/pos-page.component.js +19 -2
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +21 -2
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/subscription-detail-dialog.component.d.ts +58 -0
- package/src/lib/components/console/subscription-detail-dialog.component.js +201 -0
- package/src/lib/components/console/subscription-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/subscriptions-card.component.d.ts +60 -0
- package/src/lib/components/console/subscriptions-card.component.js +280 -0
- package/src/lib/components/console/subscriptions-card.component.js.map +1 -0
- package/src/lib/components/hardware-terms-consent.d.ts +22 -0
- package/src/lib/components/hardware-terms-consent.js +85 -0
- package/src/lib/components/hardware-terms-consent.js.map +1 -0
- package/src/lib/components/product-detail.js +25 -5
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/constants/operator-alerts.d.ts +1 -1
- package/src/lib/constants/operator-alerts.js +4 -4
- package/src/lib/constants/operator-alerts.js.map +1 -1
- package/src/lib/model/commerce-orders.d.ts +6 -2
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-payment-methods.d.ts +24 -0
- package/src/lib/model/commerce-payment-methods.js +35 -0
- package/src/lib/model/commerce-payment-methods.js.map +1 -1
- package/src/lib/model/commerce.d.ts +6 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/paid-media.d.ts +8 -0
- package/src/lib/model/paid-media.js +13 -0
- package/src/lib/model/paid-media.js.map +1 -1
- package/src/lib/model/pos-hardware-in-person.d.ts +23 -2
- package/src/lib/model/pos-hardware-in-person.js +52 -20
- package/src/lib/model/pos-hardware-in-person.js.map +1 -1
- package/src/lib/model/pos-hardware-tax-summary.d.ts +5 -1
- package/src/lib/model/pos-hardware-tax-summary.js +2 -1
- package/src/lib/model/pos-hardware-tax-summary.js.map +1 -1
- package/src/lib/model/pos-hardware-terms.d.ts +37 -2
- package/src/lib/model/pos-hardware-terms.js +68 -3
- package/src/lib/model/pos-hardware-terms.js.map +1 -1
- package/src/lib/model/pos-hardware.d.ts +101 -15
- package/src/lib/model/pos-hardware.js +128 -18
- package/src/lib/model/pos-hardware.js.map +1 -1
- package/src/lib/model/pos-reader-splash.js +2 -2
- package/src/lib/model/pos-reader-splash.js.map +1 -1
- package/src/lib/model/product-write.d.ts +3 -0
- package/src/lib/model/subscription-view.d.ts +90 -0
- package/src/lib/model/subscription-view.js +176 -0
- package/src/lib/model/subscription-view.js.map +1 -0
- package/src/lib/server/billing-webhook.d.ts +4 -6
- package/src/lib/server/billing-webhook.js +109 -51
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cart-checkout.js +45 -10
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/cart.js +15 -3
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/checkout.js +58 -16
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/draft-order.js +7 -3
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/membership-account.d.ts +22 -0
- package/src/lib/server/membership-account.js +52 -8
- package/src/lib/server/membership-account.js.map +1 -1
- package/src/lib/server/pos-auth.d.ts +3 -3
- package/src/lib/server/pos-auth.js +3 -3
- package/src/lib/server/pos-auth.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.js +1 -1
- package/src/lib/server/pos-cellular-billing.js.map +1 -1
- package/src/lib/server/pos-cellular-notify.js +1 -1
- package/src/lib/server/pos-cellular-notify.js.map +1 -1
- package/src/lib/server/pos-cellular.js +1 -1
- package/src/lib/server/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-hardware-admin.js +86 -13
- package/src/lib/server/pos-hardware-admin.js.map +1 -1
- package/src/lib/server/pos-hardware-attach.js +5 -5
- package/src/lib/server/pos-hardware-attach.js.map +1 -1
- package/src/lib/server/pos-hardware-cancel.js +65 -0
- package/src/lib/server/pos-hardware-cancel.js.map +1 -1
- package/src/lib/server/pos-hardware-closure-notices.js +2 -5
- package/src/lib/server/pos-hardware-closure-notices.js.map +1 -1
- package/src/lib/server/pos-hardware-closure.js +5 -8
- package/src/lib/server/pos-hardware-closure.js.map +1 -1
- package/src/lib/server/pos-hardware-in-person.d.ts +2 -1
- package/src/lib/server/pos-hardware-in-person.js +72 -17
- package/src/lib/server/pos-hardware-in-person.js.map +1 -1
- package/src/lib/server/pos-hardware-notify.d.ts +2 -0
- package/src/lib/server/pos-hardware-notify.js +30 -5
- package/src/lib/server/pos-hardware-notify.js.map +1 -1
- package/src/lib/server/pos-hardware-readers.d.ts +25 -0
- package/src/lib/server/pos-hardware-readers.js +206 -85
- package/src/lib/server/pos-hardware-readers.js.map +1 -1
- package/src/lib/server/pos-hardware-returns.d.ts +8 -3
- package/src/lib/server/pos-hardware-returns.js +39 -7
- package/src/lib/server/pos-hardware-returns.js.map +1 -1
- package/src/lib/server/pos-hardware-sale-fields.d.ts +76 -0
- package/src/lib/server/pos-hardware-sale-fields.js +114 -1
- package/src/lib/server/pos-hardware-sale-fields.js.map +1 -1
- package/src/lib/server/pos-hardware-sale.d.ts +2 -0
- package/src/lib/server/pos-hardware-sale.js +1 -0
- package/src/lib/server/pos-hardware-sale.js.map +1 -1
- package/src/lib/server/pos-hardware-tax-return-source.js +7 -4
- package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -1
- package/src/lib/server/pos-hardware-webhook.js +16 -3
- package/src/lib/server/pos-hardware-webhook.js.map +1 -1
- package/src/lib/server/pos-hardware.d.ts +14 -3
- package/src/lib/server/pos-hardware.js +83 -18
- package/src/lib/server/pos-hardware.js.map +1 -1
- package/src/lib/server/pos-ops-routes.js +2 -10
- package/src/lib/server/pos-ops-routes.js.map +1 -1
- package/src/lib/server/quote-pay.js +8 -4
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/stream.d.ts +2 -0
- package/src/lib/server/stream.js +22 -2
- package/src/lib/server/stream.js.map +1 -1
- package/src/lib/server/tax-return-source.js +5 -1
- package/src/lib/server/tax-return-source.js.map +1 -1
- package/src/lib/server.js +2 -2
- package/src/lib/server.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-hardware-buyer.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 {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n List,\n ListItem,\n ListItemText,\n Radio,\n RadioGroup,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState, type FormEvent } from 'react'\nimport { formatPosHardwareCents } from '../../../model/pos-hardware'\nimport { PosHardwareRequestError } from './pos-hardware-api'\nimport { PosHardwareSaleTerms } from './pos-hardware-sale-terms.component'\nimport {\n posHardwareAttach,\n posHardwareFindBuyer,\n posHardwareRegisterAtBooth,\n posHardwareSaleStatus,\n posHardwareSerials,\n posHardwareToAttach,\n type BoothStoreAddress,\n type BuyerChoice,\n type BuyerFindResult,\n type BuyerWorkspace,\n type ToAttachRow,\n} from './pos-hardware-sale-api'\n\ntype User = Parameters<typeof posHardwareSaleStatus>[0]\ntype Notify = (message: string, variant: 'success' | 'info' | 'warning' | 'error') => void\n\nexport interface PosHardwareBuyerProps {\n user: User\n hostId: string\n /** The sale open (or just paid) on this register, when it has a card reader. */\n saleOrderId: string | null\n notify: Notify\n}\n\n/** One choice of where the hardware goes, keyed for the radio group. */\ninterface Option {\n key: string\n label: string\n detail: string | null\n choice: BuyerChoice\n /** A store chosen with no card reader location yet: the booth asks for its address. */\n needsAddress?: boolean\n}\n\n/** Where the attached sale's readers go, as the register needs to know it. */\ninterface AttachedStore {\n /** A store was chosen, so a reader can be registered to it here. */\n chosen: boolean\n /** That store has no card reader location yet, so registering asks for its address. */\n needsAddress: boolean\n}\n\n/** No store chosen yet: nothing to register a reader to here. */\nconst NO_STORE: AttachedStore = { chosen: false, needsAddress: false }\n\n/** The address form's start, as the POS devices card starts it. */\nconst EMPTY_ADDRESS: BoothStoreAddress = { line1: '', city: '', state: '', postalCode: '', country: 'US' }\n\nfunction newKey(): string {\n return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`\n}\n\n/** The ways one workspace can take the hardware: each store, or the store chosen at setup. */\nfunction workspaceOptions(uid: string, workspace: BuyerWorkspace, who: string): Option[] {\n const plan = workspace.posPlan ? null : 'No point of sale plan yet: they add it when they set the reader up'\n return [\n ...workspace.stores.map((store) => ({\n key: `${uid}:${workspace.orgId}:${store.hostId}`,\n label: `${who} · ${workspace.name} · ${store.name}`,\n detail:\n [plan, store.hasLocation ? null : 'No card reader location on this store yet: you can enter its address here'].filter(Boolean).join('. ') ||\n null,\n choice: { uid, orgId: workspace.orgId, hostId: store.hostId },\n needsAddress: !store.hasLocation,\n })),\n {\n key: `${uid}:${workspace.orgId}:`,\n label: `${who} · ${workspace.name} · choose the store at setup`,\n detail: plan,\n choice: { uid, orgId: workspace.orgId },\n },\n ]\n}\n\n/** Every option an answer offers, people first. */\nfunction optionsOf(found: BuyerFindResult): Option[] {\n const options: Option[] = []\n for (const person of found.people) {\n const who = `${person.name || 'No name'} (${person.email})`\n if (!person.workspaces.length) {\n options.push({\n key: `${person.uid}::`,\n label: `${who} · no workspace yet`,\n detail: 'It joins the workspace they create.',\n choice: { uid: person.uid },\n })\n }\n for (const workspace of person.workspaces) options.push(...workspaceOptions(person.uid, workspace, who))\n }\n for (const workspace of found.workspaces) {\n if (!workspace.owner) continue\n const who = `${workspace.owner.name || 'Owner'} (${workspace.owner.email})`\n for (const option of workspaceOptions(workspace.owner.uid, workspace, who)) {\n if (!options.some((held) => held.key === option.key)) options.push(option)\n }\n }\n return options\n}\n\n/**\n * Finding the buyer and saying whose the card reader is (AGL-4038): by an\n * exact email, a person's name or a workspace's name. Shows the least that\n * picks the right person — a name, their whole email address, each workspace\n * and its stores, and what each still needs — and, for an address with no\n * account, offers to sell anyway and invite them.\n */\nfunction AttachDialog(props: {\n user: User\n hostId: string\n target: { registerOrderId: string } | { orderId: string; row: ToAttachRow }\n onClose: () => void\n onAttached: (message: string, store: AttachedStore) => void\n notify: Notify\n}) {\n const { user, hostId, target, onClose, onAttached, notify } = props\n const [query, setQuery] = useState('')\n const [found, setFound] = useState<BuyerFindResult | null>(null)\n const [searched, setSearched] = useState('')\n const [chosen, setChosen] = useState('')\n const [busy, setBusy] = useState(false)\n const [attemptKey] = useState(newKey)\n const options = found ? optionsOf(found) : []\n\n const search = async (event?: FormEvent) => {\n event?.preventDefault()\n const text = query.trim()\n if (text.length < 2) return\n setBusy(true)\n try {\n setFound(await posHardwareFindBuyer(user, hostId, text))\n setSearched(text)\n setChosen('')\n } catch (caught) {\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'The lookup did not answer', 'warning')\n } finally {\n setBusy(false)\n }\n }\n\n const attach = async (choice: BuyerChoice, needsAddress = false) => {\n setBusy(true)\n try {\n const answer = await posHardwareAttach(user, attemptKey, {\n hostId,\n buyer: choice,\n ...('registerOrderId' in target ? { registerOrderId: target.registerOrderId } : { orderId: target.orderId }),\n })\n onAttached(\n answer.outcome === 'waiting'\n ? 'Buyer attached. The card reader joins their workspace as soon as the sale is paid.'\n : answer.outcome === 'attached'\n ? 'Card reader attached to the buyer’s workspace.'\n : 'email' in choice\n ? 'Invitation sent. The card reader joins their workspace when they sign up.'\n : 'Attached to their account. It joins the workspace they create.',\n { chosen: 'hostId' in choice && Boolean(choice.hostId), needsAddress },\n )\n } catch (caught) {\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'The card reader could not be attached', 'warning')\n } finally {\n setBusy(false)\n }\n }\n\n const option = options.find((candidate) => candidate.key === chosen)\n return (\n <Dialog open onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Who is the card reader for?'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n {'row' in target ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${target.row.lines.map((line) => `${line.quantity} × ${line.name}`).join(', ')} · ${formatPosHardwareCents(target.row.totalCents)}`}\n </Typography>\n ) : null}\n <Stack component=\"form\" direction=\"row\" spacing={1} onSubmit={search} sx={{ mt: 1 }}>\n <TextField\n label=\"Email, name or workspace\"\n size=\"small\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n sx={{ flex: 1 }}\n autoFocus\n />\n <Button type=\"submit\" variant=\"outlined\" disabled={busy || query.trim().length < 2}>\n {'Search'}\n </Button>\n </Stack>\n {found?.noAccount ? (\n <Alert\n severity=\"info\"\n action={\n <Button disabled={busy} onClick={() => void attach({ email: searched })}>\n {'Invite them'}\n </Button>\n }\n >\n {`No account uses ${searched}. Sell anyway: we email them an invitation, and the card reader joins their workspace when they sign up.`}\n </Alert>\n ) : null}\n {found && !found.noAccount && !options.length ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Nobody matches. Try their exact email address.'}\n </Typography>\n ) : null}\n {options.length ? (\n <RadioGroup value={chosen} onChange={(event) => setChosen(event.target.value)} aria-label=\"Buyer\">\n {options.map((candidate) => (\n <FormControlLabel\n key={candidate.key}\n value={candidate.key}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{candidate.label}</Typography>\n {candidate.detail ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {candidate.detail}\n </Typography>\n ) : null}\n </Stack>\n }\n />\n ))}\n </RadioGroup>\n ) : null}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Every lookup is recorded. Ask the buyer before you search for them.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n disabled={busy || !option}\n onClick={() => option && void attach(option.choice, Boolean(option.needsAddress))}\n >\n {'Attach'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The To attach list (AGL-4038): card readers sold here that nobody has said\n * whose they are yet — at the kiosk, while the register was offline, or to a\n * buyer with no account or no workspace yet — newest first.\n */\nfunction ToAttachDialog(props: {\n user: User\n hostId: string\n onClose: () => void\n onPick: (row: ToAttachRow) => void\n notify: Notify\n}) {\n const { user, hostId, onClose, onPick, notify } = props\n const [rows, setRows] = useState<ToAttachRow[] | null>(null)\n useEffect(() => {\n let live = true\n posHardwareToAttach(user, hostId)\n .then((answer) => live && setRows(answer.orders))\n .catch((caught) => {\n if (!live) return\n setRows([])\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'The list could not be read', 'warning')\n })\n return () => {\n live = false\n }\n }, [user, hostId, notify])\n return (\n <Dialog open onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Card reader sales to attach'}</DialogTitle>\n <DialogContent>\n {rows && !rows.length ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Every card reader sold here is attached to its buyer.'}\n </Typography>\n ) : null}\n <List dense>\n {(rows ?? []).map((row) => (\n <ListItem\n key={row.id}\n secondaryAction={\n <Button size=\"small\" onClick={() => onPick(row)}>\n {'Attach'}\n </Button>\n }\n >\n <ListItemText\n primary={`${row.lines.map((line) => `${line.quantity} × ${line.name}`).join(', ')} · ${formatPosHardwareCents(row.totalCents)}`}\n secondary={[\n row.registerNumber ? `Sale #${row.registerNumber}` : row.number,\n new Date(row.createdAtMs).toLocaleString(),\n row.kiosk ? 'at the kiosk' : null,\n row.offline ? 'rung offline' : null,\n row.invited ? `invited ${row.contactEmail ?? ''}`.trim() : row.contactEmail,\n row.awaitingWorkspace ? 'has an account, no workspace yet' : null,\n ]\n .filter(Boolean)\n .join(' · ')}\n />\n </ListItem>\n ))}\n </List>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose}>{'Close'}</Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The sale's readers onto the buyer's store (AGL-4038): their serial numbers,\n * scanned or typed, so each sets itself up when the buyer adds it; and, with\n * the buyer there and their store chosen, registering it to that store now\n * by the code it shows.\n */\nfunction SaleReaders(props: {\n user: User\n hostId: string\n saleOrderId: string\n store: AttachedStore\n notify: Notify\n}) {\n const { user, hostId, saleOrderId, store, notify } = props\n const [serials, setSerials] = useState('')\n const [code, setCode] = useState('')\n const [busy, setBusy] = useState(false)\n const [attemptKey, setAttemptKey] = useState(newKey)\n // The buyer's store address (AGL-4038), asked for when their store has no\n // card reader location yet: from the lookup, or when the route says so.\n const [askAddress, setAskAddress] = useState(store.needsAddress)\n const [address, setAddress] = useState<BoothStoreAddress>(EMPTY_ADDRESS)\n useEffect(() => setAskAddress(store.needsAddress), [store.needsAddress])\n const addressComplete =\n Boolean(address.line1.trim() && address.city.trim() && address.postalCode.trim()) &&\n /^[A-Z]{2}$/.test(address.country)\n const run = async (work: () => Promise<string>) => {\n setBusy(true)\n try {\n notify(await work(), 'success')\n } catch (caught) {\n if (caught instanceof PosHardwareRequestError && caught.reason === 'needs-address') {\n setAskAddress(true)\n // A new attempt: the request with the address is a different one.\n setAttemptKey(newKey())\n }\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'That did not work. Try again.', 'warning')\n } finally {\n setBusy(false)\n }\n }\n const list = serials\n .split(/[\\s,;]+/)\n .map((serial) => serial.trim())\n .filter(Boolean)\n return (\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start' }}>\n <TextField\n size=\"small\"\n label=\"Reader serial numbers\"\n helperText=\"Scan or type each reader's serial. It sets itself up when the buyer adds it.\"\n value={serials}\n onChange={(event) => setSerials(event.target.value)}\n sx={{ flex: 1 }}\n />\n <Button\n disabled={busy || !list.length}\n onClick={() =>\n void run(async () => {\n await posHardwareSerials(user, { hostId, registerOrderId: saleOrderId, serials: list })\n return list.length === 1 ? 'Serial number saved' : 'Serial numbers saved'\n })\n }\n >\n {'Save'}\n </Button>\n </Stack>\n {store.chosen && askAddress ? (\n <Box sx={{ display: 'grid', gap: 1, gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' } }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ gridColumn: '1 / -1' }}>\n {'Their store has no address for card readers yet. Enter it with the buyer to register the reader now: ' +\n 'Stripe sets the reader up for this country. Or leave it, and they add it on their POS devices card.'}\n </Typography>\n <TextField\n size=\"small\"\n label=\"Street\"\n required\n value={address.line1}\n onChange={(event) => setAddress({ ...address, line1: event.target.value })}\n sx={{ gridColumn: '1 / -1' }}\n />\n <TextField\n size=\"small\"\n label=\"City\"\n required\n value={address.city}\n onChange={(event) => setAddress({ ...address, city: event.target.value })}\n />\n <TextField\n size=\"small\"\n label=\"State\"\n value={address.state}\n onChange={(event) => setAddress({ ...address, state: event.target.value })}\n />\n <TextField\n size=\"small\"\n label=\"Postal code\"\n required\n value={address.postalCode}\n onChange={(event) => setAddress({ ...address, postalCode: event.target.value })}\n />\n <TextField\n size=\"small\"\n label=\"Country\"\n required\n helperText=\"Two letters, like US\"\n value={address.country}\n onChange={(event) => setAddress({ ...address, country: event.target.value.toUpperCase().slice(0, 2) })}\n />\n </Box>\n ) : null}\n {store.chosen ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start' }}>\n <TextField\n size=\"small\"\n label=\"Code on the reader\"\n helperText=\"Register it to the buyer's store now, while they are here.\"\n value={code}\n onChange={(event) => setCode(event.target.value)}\n sx={{ flex: 1 }}\n />\n <Button\n disabled={busy || code.trim().length < 3 || (askAddress && !addressComplete)}\n onClick={() =>\n void run(async () => {\n const answer = await posHardwareRegisterAtBooth(user, attemptKey, {\n hostId,\n registerOrderId: saleOrderId,\n registrationCode: code.trim(),\n ...(askAddress ? { address } : {}),\n })\n setCode('')\n setAttemptKey(newKey())\n if (answer.storeAddressSaved) setAskAddress(false)\n return answer.storeAddressSaved\n ? 'Reader registered to their store, and the store’s address saved'\n : 'Reader registered to their store'\n })\n }\n >\n {'Register'}\n </Button>\n </Stack>\n ) : null}\n </Stack>\n )\n}\n\n/**\n * Selling a card reader at the platform's own store's register (AGL-4038):\n * on a sale that has one, the buyer is attached here, and every reader sold\n * without one waits on the To attach list. Draws nothing on any store but\n * the platform's own hardware seller. Loaded on its own, by the register.\n */\nfunction PosHardwareBuyer(props: PosHardwareBuyerProps) {\n const { user, hostId, saleOrderId, notify } = props\n const [seller, setSeller] = useState(false)\n const [dialog, setDialog] = useState<\n null | { kind: 'list' } | { kind: 'sale' } | { kind: 'entry'; row: ToAttachRow }\n >(null)\n const [attached, setAttached] = useState<{ orderId: string; message: string; store: AttachedStore } | null>(\n null,\n )\n\n useEffect(() => {\n let live = true\n posHardwareSaleStatus(user, hostId)\n .then((status) => live && setSeller(status.seller))\n .catch(() => undefined)\n return () => {\n live = false\n }\n }, [user, hostId])\n\n if (!seller) return null\n const attachedHere = attached && attached.orderId === saleOrderId ? attached : null\n return (\n <Stack spacing={1} sx={{ mt: 1 }}>\n {saleOrderId ? (\n <Alert\n severity={attachedHere ? 'success' : 'info'}\n action={\n <Button size=\"small\" onClick={() => setDialog({ kind: 'sale' })}>\n {attachedHere ? 'Change' : 'Attach buyer'}\n </Button>\n }\n >\n {attachedHere?.message ?? 'This sale has a card reader. Attach it to the buyer’s workspace.'}\n </Alert>\n ) : null}\n {saleOrderId ? (\n // The terms of sale, accepted before paying (AGL-4038, Terms 4.28).\n <PosHardwareSaleTerms user={user} hostId={hostId} saleOrderId={saleOrderId} notify={notify} />\n ) : null}\n {saleOrderId ? (\n <SaleReaders\n user={user}\n hostId={hostId}\n saleOrderId={saleOrderId}\n store={attachedHere?.store ?? NO_STORE}\n notify={notify}\n />\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Chip size=\"small\" variant=\"outlined\" label=\"Card reader sales\" />\n <Button size=\"small\" onClick={() => setDialog({ kind: 'list' })}>\n {'To attach'}\n </Button>\n </Stack>\n {dialog?.kind === 'list' ? (\n <ToAttachDialog\n user={user}\n hostId={hostId}\n notify={notify}\n onClose={() => setDialog(null)}\n onPick={(row) => setDialog({ kind: 'entry', row })}\n />\n ) : null}\n {dialog?.kind === 'sale' && saleOrderId ? (\n <AttachDialog\n user={user}\n hostId={hostId}\n target={{ registerOrderId: saleOrderId }}\n notify={notify}\n onClose={() => setDialog(null)}\n onAttached={(message, store) => {\n setAttached({ orderId: saleOrderId, message, store })\n setDialog(null)\n notify(message, 'success')\n }}\n />\n ) : null}\n {dialog?.kind === 'entry' ? (\n <AttachDialog\n user={user}\n hostId={hostId}\n target={{ orderId: dialog.row.id, row: dialog.row }}\n notify={notify}\n onClose={() => setDialog(null)}\n onAttached={(message) => {\n setDialog({ kind: 'list' })\n notify(message, 'success')\n }}\n />\n ) : null}\n </Stack>\n )\n}\n\nexport default PosHardwareBuyer\n"],"names":["Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","List","ListItem","ListItemText","Radio","RadioGroup","Stack","TextField","Typography","useEffect","useState","formatPosHardwareCents","PosHardwareRequestError","PosHardwareSaleTerms","posHardwareAttach","posHardwareFindBuyer","posHardwareRegisterAtBooth","posHardwareSaleStatus","posHardwareSerials","posHardwareToAttach","NO_STORE","chosen","needsAddress","EMPTY_ADDRESS","line1","city","state","postalCode","country","newKey","Date","now","toString","Math","random","slice","workspaceOptions","uid","workspace","who","plan","posPlan","stores","map","store","key","orgId","hostId","label","name","detail","hasLocation","filter","Boolean","join","choice","optionsOf","found","options","person","people","email","workspaces","length","push","owner","option","some","held","AttachDialog","props","user","target","onClose","onAttached","notify","query","setQuery","setFound","searched","setSearched","setChosen","busy","setBusy","attemptKey","search","event","preventDefault","text","trim","caught","message","attach","answer","buyer","registerOrderId","orderId","outcome","find","candidate","open","maxWidth","fullWidth","sx","display","flexDirection","gap","variant","color","row","lines","line","quantity","totalCents","component","direction","spacing","onSubmit","mt","size","value","onChange","flex","autoFocus","type","disabled","noAccount","severity","action","onClick","aria-label","control","ToAttachDialog","onPick","rows","setRows","live","then","orders","catch","dense","secondaryAction","primary","secondary","registerNumber","number","createdAtMs","toLocaleString","kiosk","offline","invited","contactEmail","awaitingWorkspace","id","SaleReaders","saleOrderId","serials","setSerials","code","setCode","setAttemptKey","askAddress","setAskAddress","address","setAddress","addressComplete","test","run","work","reason","list","split","serial","alignItems","helperText","gridTemplateColumns","xs","sm","gridColumn","required","toUpperCase","registrationCode","storeAddressSaved","PosHardwareBuyer","seller","setSeller","dialog","setDialog","attached","setAttached","status","undefined","attachedHere","kind"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,IAAI,EACJC,QAAQ,EACRC,YAAY,EACZC,KAAK,EACLC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,QAAQ,QAAwB,QAAO;AAC3D,SAASC,sBAAsB,QAAQ,iCAA6B;AACpE,SAASC,uBAAuB,QAAQ,wBAAoB;AAC5D,SAASC,oBAAoB,QAAQ,yCAAqC;AAC1E,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,qBAAqB,EACrBC,kBAAkB,EAClBC,mBAAmB,QAMd,6BAAyB;AA+BhC,+DAA+D,GAC/D,MAAMC,WAA0B;IAAEC,QAAQ;IAAOC,cAAc;AAAM;AAErE,iEAAiE,GACjE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S,IAAM0D,UAAU;gCAAEM,MAAM;4BAAO;kCAC1D;;;;YAGJP,CAAAA,0BAAAA,OAAQO,IAAI,MAAK,uBAChB,KAAC7D;gBACC7D,MAAMA;gBACNxB,QAAQA;gBACR4B,QAAQA;gBACRF,SAAS,IAAMkH,UAAU;gBACzBtD,QAAQ,CAACxB,MAAQ8E,UAAU;wBAAEM,MAAM;wBAASpF;oBAAI;iBAEhD;YACH6E,CAAAA,0BAAAA,OAAQO,IAAI,MAAK,UAAUtC,4BAC1B,KAACtF;gBACCE,MAAMA;gBACNxB,QAAQA;gBACRyB,QAAQ;oBAAEuB,iBAAiB4D;gBAAY;gBACvChF,QAAQA;gBACRF,SAAS,IAAMkH,UAAU;gBACzBjH,YAAY,CAACiB,SAAS/C;oBACpBiJ,YAAY;wBAAE7F,SAAS2D;wBAAahE;wBAAS/C;oBAAM;oBACnD+I,UAAU;oBACVhH,OAAOgB,SAAS;gBAClB;iBAEA;YACH+F,CAAAA,0BAAAA,OAAQO,IAAI,MAAK,wBAChB,KAAC5H;gBACCE,MAAMA;gBACNxB,QAAQA;gBACRyB,QAAQ;oBAAEwB,SAAS0F,OAAO7E,GAAG,CAAC4C,EAAE;oBAAE5C,KAAK6E,OAAO7E,GAAG;gBAAC;gBAClDlC,QAAQA;gBACRF,SAAS,IAAMkH,UAAU;gBACzBjH,YAAY,CAACiB;oBACXgG,UAAU;wBAAEM,MAAM;oBAAO;oBACzBtH,OAAOgB,SAAS;gBAClB;iBAEA;;;AAGV;AAEA,eAAe4F,iBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-hardware-buyer.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 {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n List,\n ListItem,\n ListItemText,\n Radio,\n RadioGroup,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState, type FormEvent } from 'react'\nimport { formatPosHardwareCents } from '../../../model/pos-hardware'\nimport { PosHardwareRequestError } from './pos-hardware-api'\nimport { PosHardwareSaleTerms } from './pos-hardware-sale-terms.component'\nimport {\n posHardwareAttach,\n posHardwareFindBuyer,\n posHardwareRegisterAtBooth,\n posHardwareSaleStatus,\n posHardwareSerials,\n posHardwareToAttach,\n type BoothStoreAddress,\n type BuyerChoice,\n type BuyerFindResult,\n type BuyerWorkspace,\n type ToAttachRow,\n} from './pos-hardware-sale-api'\n\ntype User = Parameters<typeof posHardwareSaleStatus>[0]\ntype Notify = (message: string, variant: 'success' | 'info' | 'warning' | 'error') => void\n\nexport interface PosHardwareBuyerProps {\n user: User\n hostId: string\n /** The sale open (or just paid) on this register, when it has a card reader. */\n saleOrderId: string | null\n notify: Notify\n}\n\n/** One choice of where the hardware goes, keyed for the radio group. */\ninterface Option {\n key: string\n label: string\n detail: string | null\n choice: BuyerChoice\n /** A store chosen with no card reader location yet: the booth asks for its address. */\n needsAddress?: boolean\n}\n\n/** Where the attached sale's readers go, as the register needs to know it. */\ninterface AttachedStore {\n /** A store was chosen, so a reader can be registered to it here. */\n chosen: boolean\n /** That store has no card reader location yet, so registering asks for its address. */\n needsAddress: boolean\n}\n\n/** No store chosen yet: nothing to register a reader to here. */\nconst NO_STORE: AttachedStore = { chosen: false, needsAddress: false }\n\n/** The address form's start, as the POS devices card starts it. */\nconst EMPTY_ADDRESS: BoothStoreAddress = { line1: '', city: '', state: '', postalCode: '', country: 'US' }\n\nfunction newKey(): string {\n return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`\n}\n\n/** The ways one workspace can take the hardware: each store, or the store chosen at setup. */\nfunction workspaceOptions(uid: string, workspace: BuyerWorkspace, who: string): Option[] {\n const plan = workspace.posPlan ? null : 'No point of sale plan yet: they add it when they set the reader up'\n return [\n ...workspace.stores.map((store) => ({\n key: `${uid}:${workspace.orgId}:${store.hostId}`,\n label: `${who} · ${workspace.name} · ${store.name}`,\n detail:\n [plan, store.hasLocation ? null : 'No card reader location on this store yet: you can enter its address here'].filter(Boolean).join('. ') ||\n null,\n choice: { uid, orgId: workspace.orgId, hostId: store.hostId },\n needsAddress: !store.hasLocation,\n })),\n {\n key: `${uid}:${workspace.orgId}:`,\n label: `${who} · ${workspace.name} · choose the store at setup`,\n detail: plan,\n choice: { uid, orgId: workspace.orgId },\n },\n ]\n}\n\n/** Every option an answer offers, people first. */\nfunction optionsOf(found: BuyerFindResult): Option[] {\n const options: Option[] = []\n for (const person of found.people) {\n const who = `${person.name || 'No name'} (${person.email})`\n if (!person.workspaces.length) {\n options.push({\n key: `${person.uid}::`,\n label: `${who} · no workspace yet`,\n detail: 'It joins the workspace they create.',\n choice: { uid: person.uid },\n })\n }\n for (const workspace of person.workspaces) options.push(...workspaceOptions(person.uid, workspace, who))\n }\n for (const workspace of found.workspaces) {\n if (!workspace.owner) continue\n const who = `${workspace.owner.name || 'Owner'} (${workspace.owner.email})`\n for (const option of workspaceOptions(workspace.owner.uid, workspace, who)) {\n if (!options.some((held) => held.key === option.key)) options.push(option)\n }\n }\n return options\n}\n\n/**\n * Finding the buyer and saying whose the card reader is (AGL-4038): by an\n * exact email, a person's name or a workspace's name. Shows the least that\n * picks the right person — a name, their whole email address, each workspace\n * and its stores, and what each still needs — and, for an address with no\n * account, offers to sell anyway and invite them.\n */\nfunction AttachDialog(props: {\n user: User\n hostId: string\n target: { registerOrderId: string } | { orderId: string; row: ToAttachRow }\n onClose: () => void\n onAttached: (message: string, store: AttachedStore) => void\n notify: Notify\n}) {\n const { user, hostId, target, onClose, onAttached, notify } = props\n const [query, setQuery] = useState('')\n const [found, setFound] = useState<BuyerFindResult | null>(null)\n const [searched, setSearched] = useState('')\n const [chosen, setChosen] = useState('')\n const [busy, setBusy] = useState(false)\n const [attemptKey] = useState(newKey)\n const options = found ? optionsOf(found) : []\n\n const search = async (event?: FormEvent) => {\n event?.preventDefault()\n const text = query.trim()\n if (text.length < 2) return\n setBusy(true)\n try {\n setFound(await posHardwareFindBuyer(user, hostId, text))\n setSearched(text)\n setChosen('')\n } catch (caught) {\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'The lookup did not answer', 'warning')\n } finally {\n setBusy(false)\n }\n }\n\n const attach = async (choice: BuyerChoice, needsAddress = false) => {\n setBusy(true)\n try {\n const answer = await posHardwareAttach(user, attemptKey, {\n hostId,\n buyer: choice,\n ...('registerOrderId' in target ? { registerOrderId: target.registerOrderId } : { orderId: target.orderId }),\n })\n onAttached(\n answer.outcome === 'waiting'\n ? 'Buyer attached. The card reader joins their workspace as soon as the sale is paid.'\n : answer.outcome === 'attached'\n ? 'Card reader attached to the buyer’s workspace.'\n : 'email' in choice\n ? 'Invitation sent. The card reader joins their workspace when they sign up.'\n : 'Attached to their account. It joins the workspace they create.',\n { chosen: 'hostId' in choice && Boolean(choice.hostId), needsAddress },\n )\n } catch (caught) {\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'The card reader could not be attached', 'warning')\n } finally {\n setBusy(false)\n }\n }\n\n const option = options.find((candidate) => candidate.key === chosen)\n return (\n <Dialog open onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Who is the card reader for?'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n {'row' in target ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${target.row.lines.map((line) => `${line.quantity} × ${line.name}`).join(', ')} · ${formatPosHardwareCents(target.row.totalCents)}`}\n </Typography>\n ) : null}\n <Stack component=\"form\" direction=\"row\" spacing={1} onSubmit={search} sx={{ mt: 1 }}>\n <TextField\n label=\"Email, name or workspace\"\n size=\"small\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n sx={{ flex: 1 }}\n autoFocus\n />\n <Button type=\"submit\" variant=\"outlined\" disabled={busy || query.trim().length < 2}>\n {'Search'}\n </Button>\n </Stack>\n {found?.noAccount ? (\n <Alert\n severity=\"info\"\n action={\n <Button disabled={busy} onClick={() => void attach({ email: searched })}>\n {'Invite them'}\n </Button>\n }\n >\n {`No account uses ${searched}. Sell anyway: we email them an invitation, and the card reader joins their workspace when they sign up.`}\n </Alert>\n ) : null}\n {found && !found.noAccount && !options.length ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Nobody matches. Try their exact email address.'}\n </Typography>\n ) : null}\n {options.length ? (\n <RadioGroup value={chosen} onChange={(event) => setChosen(event.target.value)} aria-label=\"Buyer\">\n {options.map((candidate) => (\n <FormControlLabel\n key={candidate.key}\n value={candidate.key}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{candidate.label}</Typography>\n {candidate.detail ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {candidate.detail}\n </Typography>\n ) : null}\n </Stack>\n }\n />\n ))}\n </RadioGroup>\n ) : null}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Every lookup is recorded. Ask the buyer before you search for them.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n disabled={busy || !option}\n onClick={() => option && void attach(option.choice, Boolean(option.needsAddress))}\n >\n {'Attach'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The To attach list (AGL-4038): card readers sold here that nobody has said\n * whose they are yet — at the kiosk, while the register was offline, or to a\n * buyer with no account or no workspace yet — newest first.\n */\nfunction ToAttachDialog(props: {\n user: User\n hostId: string\n onClose: () => void\n onPick: (row: ToAttachRow) => void\n notify: Notify\n}) {\n const { user, hostId, onClose, onPick, notify } = props\n const [rows, setRows] = useState<ToAttachRow[] | null>(null)\n useEffect(() => {\n let live = true\n posHardwareToAttach(user, hostId)\n .then((answer) => live && setRows(answer.orders))\n .catch((caught) => {\n if (!live) return\n setRows([])\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'The list could not be read', 'warning')\n })\n return () => {\n live = false\n }\n }, [user, hostId, notify])\n return (\n <Dialog open onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Card reader sales to attach'}</DialogTitle>\n <DialogContent>\n {rows && !rows.length ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Every card reader sold here is attached to its buyer.'}\n </Typography>\n ) : null}\n <List dense>\n {(rows ?? []).map((row) => (\n <ListItem\n key={row.id}\n secondaryAction={\n <Button size=\"small\" onClick={() => onPick(row)}>\n {'Attach'}\n </Button>\n }\n >\n <ListItemText\n primary={`${row.lines.map((line) => `${line.quantity} × ${line.name}`).join(', ')} · ${formatPosHardwareCents(row.totalCents)}`}\n secondary={[\n row.registerNumber ? `${row.online ? 'Online order' : 'Sale'} #${row.registerNumber}` : row.number,\n new Date(row.createdAtMs).toLocaleString(),\n row.kiosk ? 'at the kiosk' : null,\n row.offline ? 'rung offline' : null,\n row.invited ? `invited ${row.contactEmail ?? ''}`.trim() : row.contactEmail,\n row.awaitingWorkspace ? 'has an account, no workspace yet' : null,\n ]\n .filter(Boolean)\n .join(' · ')}\n />\n </ListItem>\n ))}\n </List>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose}>{'Close'}</Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The sale's readers onto the buyer's store (AGL-4038): their serial numbers,\n * scanned or typed, so each sets itself up when the buyer adds it; and, with\n * the buyer there and their store chosen, registering it to that store now\n * by the code it shows.\n */\nfunction SaleReaders(props: {\n user: User\n hostId: string\n saleOrderId: string\n store: AttachedStore\n notify: Notify\n}) {\n const { user, hostId, saleOrderId, store, notify } = props\n const [serials, setSerials] = useState('')\n const [code, setCode] = useState('')\n const [busy, setBusy] = useState(false)\n const [attemptKey, setAttemptKey] = useState(newKey)\n // The buyer's store address (AGL-4038), asked for when their store has no\n // card reader location yet: from the lookup, or when the route says so.\n const [askAddress, setAskAddress] = useState(store.needsAddress)\n const [address, setAddress] = useState<BoothStoreAddress>(EMPTY_ADDRESS)\n useEffect(() => setAskAddress(store.needsAddress), [store.needsAddress])\n const addressComplete =\n Boolean(address.line1.trim() && address.city.trim() && address.postalCode.trim()) &&\n /^[A-Z]{2}$/.test(address.country)\n const run = async (work: () => Promise<string>) => {\n setBusy(true)\n try {\n notify(await work(), 'success')\n } catch (caught) {\n if (caught instanceof PosHardwareRequestError && caught.reason === 'needs-address') {\n setAskAddress(true)\n // A new attempt: the request with the address is a different one.\n setAttemptKey(newKey())\n }\n notify(caught instanceof PosHardwareRequestError ? caught.message : 'That did not work. Try again.', 'warning')\n } finally {\n setBusy(false)\n }\n }\n const list = serials\n .split(/[\\s,;]+/)\n .map((serial) => serial.trim())\n .filter(Boolean)\n return (\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start' }}>\n <TextField\n size=\"small\"\n label=\"Reader serial numbers\"\n helperText=\"Scan or type each reader's serial. It sets itself up when the buyer adds it.\"\n value={serials}\n onChange={(event) => setSerials(event.target.value)}\n sx={{ flex: 1 }}\n />\n <Button\n disabled={busy || !list.length}\n onClick={() =>\n void run(async () => {\n await posHardwareSerials(user, { hostId, registerOrderId: saleOrderId, serials: list })\n return list.length === 1 ? 'Serial number saved' : 'Serial numbers saved'\n })\n }\n >\n {'Save'}\n </Button>\n </Stack>\n {store.chosen && askAddress ? (\n <Box sx={{ display: 'grid', gap: 1, gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' } }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ gridColumn: '1 / -1' }}>\n {'Their store has no address for card readers yet. Enter it with the buyer to register the reader now: ' +\n 'the reader is set up for this country. Or leave it, and they add it on their POS devices card.'}\n </Typography>\n <TextField\n size=\"small\"\n label=\"Street\"\n required\n value={address.line1}\n onChange={(event) => setAddress({ ...address, line1: event.target.value })}\n sx={{ gridColumn: '1 / -1' }}\n />\n <TextField\n size=\"small\"\n label=\"City\"\n required\n value={address.city}\n onChange={(event) => setAddress({ ...address, city: event.target.value })}\n />\n <TextField\n size=\"small\"\n label=\"State\"\n value={address.state}\n onChange={(event) => setAddress({ ...address, state: event.target.value })}\n />\n <TextField\n size=\"small\"\n label=\"Postal code\"\n required\n value={address.postalCode}\n onChange={(event) => setAddress({ ...address, postalCode: event.target.value })}\n />\n <TextField\n size=\"small\"\n label=\"Country\"\n required\n helperText=\"Two letters, like US\"\n value={address.country}\n onChange={(event) => setAddress({ ...address, country: event.target.value.toUpperCase().slice(0, 2) })}\n />\n </Box>\n ) : null}\n {store.chosen ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start' }}>\n <TextField\n size=\"small\"\n label=\"Code on the reader\"\n helperText=\"Register it to the buyer's store now, while they are here.\"\n value={code}\n onChange={(event) => setCode(event.target.value)}\n sx={{ flex: 1 }}\n />\n <Button\n disabled={busy || code.trim().length < 3 || (askAddress && !addressComplete)}\n onClick={() =>\n void run(async () => {\n const answer = await posHardwareRegisterAtBooth(user, attemptKey, {\n hostId,\n registerOrderId: saleOrderId,\n registrationCode: code.trim(),\n ...(askAddress ? { address } : {}),\n })\n setCode('')\n setAttemptKey(newKey())\n if (answer.storeAddressSaved) setAskAddress(false)\n return answer.storeAddressSaved\n ? 'Reader registered to their store, and the store’s address saved'\n : 'Reader registered to their store'\n })\n }\n >\n {'Register'}\n </Button>\n </Stack>\n ) : null}\n </Stack>\n )\n}\n\n/**\n * Selling a card reader at the platform's own store's register (AGL-4038):\n * on a sale that has one, the buyer is attached here, and every reader sold\n * without one waits on the To attach list. Draws nothing on any store but\n * the platform's own hardware seller. Loaded on its own, by the register.\n */\nfunction PosHardwareBuyer(props: PosHardwareBuyerProps) {\n const { user, hostId, saleOrderId, notify } = props\n const [seller, setSeller] = useState(false)\n const [dialog, setDialog] = useState<\n null | { kind: 'list' } | { kind: 'sale' } | { kind: 'entry'; row: ToAttachRow }\n >(null)\n const [attached, setAttached] = useState<{ orderId: string; message: string; store: AttachedStore } | null>(\n null,\n )\n\n useEffect(() => {\n let live = true\n posHardwareSaleStatus(user, hostId)\n .then((status) => live && setSeller(status.seller))\n .catch(() => undefined)\n return () => {\n live = false\n }\n }, [user, hostId])\n\n if (!seller) return null\n const attachedHere = attached && attached.orderId === saleOrderId ? attached : null\n return (\n <Stack spacing={1} sx={{ mt: 1 }}>\n {saleOrderId ? (\n <Alert\n severity={attachedHere ? 'success' : 'info'}\n action={\n <Button size=\"small\" onClick={() => setDialog({ kind: 'sale' })}>\n {attachedHere ? 'Change' : 'Attach buyer'}\n </Button>\n }\n >\n {attachedHere?.message ?? 'This sale has a card reader. Attach it to the buyer’s workspace.'}\n </Alert>\n ) : null}\n {saleOrderId ? (\n // The terms of sale, accepted before paying (AGL-4038, Terms 4.28).\n <PosHardwareSaleTerms user={user} hostId={hostId} saleOrderId={saleOrderId} notify={notify} />\n ) : null}\n {saleOrderId ? (\n <SaleReaders\n user={user}\n hostId={hostId}\n saleOrderId={saleOrderId}\n store={attachedHere?.store ?? NO_STORE}\n notify={notify}\n />\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Chip size=\"small\" variant=\"outlined\" label=\"Card reader sales\" />\n <Button size=\"small\" onClick={() => setDialog({ kind: 'list' })}>\n {'To attach'}\n </Button>\n </Stack>\n {dialog?.kind === 'list' ? (\n <ToAttachDialog\n user={user}\n hostId={hostId}\n notify={notify}\n onClose={() => setDialog(null)}\n onPick={(row) => setDialog({ kind: 'entry', row })}\n />\n ) : null}\n {dialog?.kind === 'sale' && saleOrderId ? (\n <AttachDialog\n user={user}\n hostId={hostId}\n target={{ registerOrderId: saleOrderId }}\n notify={notify}\n onClose={() => setDialog(null)}\n onAttached={(message, store) => {\n setAttached({ orderId: saleOrderId, message, store })\n setDialog(null)\n notify(message, 'success')\n }}\n />\n ) : null}\n {dialog?.kind === 'entry' ? (\n <AttachDialog\n user={user}\n hostId={hostId}\n target={{ orderId: dialog.row.id, row: dialog.row }}\n notify={notify}\n onClose={() => setDialog(null)}\n onAttached={(message) => {\n setDialog({ kind: 'list' })\n notify(message, 'success')\n }}\n />\n ) : null}\n </Stack>\n )\n}\n\nexport default PosHardwareBuyer\n"],"names":["Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","List","ListItem","ListItemText","Radio","RadioGroup","Stack","TextField","Typography","useEffect","useState","formatPosHardwareCents","PosHardwareRequestError","PosHardwareSaleTerms","posHardwareAttach","posHardwareFindBuyer","posHardwareRegisterAtBooth","posHardwareSaleStatus","posHardwareSerials","posHardwareToAttach","NO_STORE","chosen","needsAddress","EMPTY_ADDRESS","line1","city","state","postalCode","country","newKey","Date","now","toString","Math","random","slice","workspaceOptions","uid","workspace","who","plan","posPlan","stores","map","store","key","orgId","hostId","label","name","detail","hasLocation","filter","Boolean","join","choice","optionsOf","found","options","person","people","email","workspaces","length","push","owner","option","some","held","AttachDialog","props","user","target","onClose","onAttached","notify","query","setQuery","setFound","searched","setSearched","setChosen","busy","setBusy","attemptKey","search","event","preventDefault","text","trim","caught","message","attach","answer","buyer","registerOrderId","orderId","outcome","find","candidate","open","maxWidth","fullWidth","sx","display","flexDirection","gap","variant","color","row","lines","line","quantity","totalCents","component","direction","spacing","onSubmit","mt","size","value","onChange","flex","autoFocus","type","disabled","noAccount","severity","action","onClick","aria-label","control","ToAttachDialog","onPick","rows","setRows","live","then","orders","catch","dense","secondaryAction","primary","secondary","registerNumber","online","number","createdAtMs","toLocaleString","kiosk","offline","invited","contactEmail","awaitingWorkspace","id","SaleReaders","saleOrderId","serials","setSerials","code","setCode","setAttemptKey","askAddress","setAskAddress","address","setAddress","addressComplete","test","run","work","reason","list","split","serial","alignItems","helperText","gridTemplateColumns","xs","sm","gridColumn","required","toUpperCase","registrationCode","storeAddressSaved","PosHardwareBuyer","seller","setSeller","dialog","setDialog","attached","setAttached","status","undefined","attachedHere","kind"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,IAAI,EACJC,QAAQ,EACRC,YAAY,EACZC,KAAK,EACLC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,QAAQ,QAAwB,QAAO;AAC3D,SAASC,sBAAsB,QAAQ,iCAA6B;AACpE,SAASC,uBAAuB,QAAQ,wBAAoB;AAC5D,SAASC,oBAAoB,QAAQ,yCAAqC;AAC1E,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,qBAAqB,EACrBC,kBAAkB,EAClBC,mBAAmB,QAMd,6BAAyB;AA+BhC,+DAA+D,GAC/D,MAAMC,WAA0B;IAAEC,QAAQ;IAAOC,cAAc;AAAM;AAErE,iEAAiE,GACjE,MAAMC,gBAAmC;IAAEC,OAAO;IAAIC,MAAM;IAAIC,OAAO;IAAIC,YAAY;IAAIC,SAAS;AAAK;AAEzG,SAASC;IACP,OAAO,CAAC,OAAO,EAAEC,KAAKC,GAAG,GAAGC,QAAQ,CAAC,IAAI,CAAC,EAAEC,KAAKC,MAAM,GAAGF,QAAQ,CAAC,IAAIG,KAAK,CAAC,GAAG,KAAK;AACvF;AAEA,4FAA4F,GAC5F,SAASC,iBAAiBC,GAAW,EAAEC,SAAyB,EAAEC,GAAW;IAC3E,MAAMC,OAAOF,UAAUG,OAAO,GAAG,OAAO;IACxC,OAAO;WACFH,UAAUI,MAAM,CAACC,GAAG,CAAC,CAACC,QAAW,CAAA;gBAClCC,KAAK,GAAGR,IAA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SAAS,IAAMmH,UAAU;gBACzBlH,YAAY,CAACiB,SAAS/C;oBACpBkJ,YAAY;wBAAE9F,SAAS4D;wBAAajE;wBAAS/C;oBAAM;oBACnDgJ,UAAU;oBACVjH,OAAOgB,SAAS;gBAClB;iBAEA;YACHgG,CAAAA,0BAAAA,OAAQO,IAAI,MAAK,wBAChB,KAAC7H;gBACCE,MAAMA;gBACNxB,QAAQA;gBACRyB,QAAQ;oBAAEwB,SAAS2F,OAAO9E,GAAG,CAAC6C,EAAE;oBAAE7C,KAAK8E,OAAO9E,GAAG;gBAAC;gBAClDlC,QAAQA;gBACRF,SAAS,IAAMmH,UAAU;gBACzBlH,YAAY,CAACiB;oBACXiG,UAAU;wBAAEM,MAAM;oBAAO;oBACzBvH,OAAOgB,SAAS;gBAClB;iBAEA;;;AAGV;AAEA,eAAe6F,iBAAgB"}
|
|
@@ -35,6 +35,8 @@ export interface ToAttachRow {
|
|
|
35
35
|
registerOrderId: string | null;
|
|
36
36
|
registerNumber: number | null;
|
|
37
37
|
kiosk: boolean;
|
|
38
|
+
/** Bought from the store's own product pages or cart (AGL-4038), not at the register. */
|
|
39
|
+
online?: boolean;
|
|
38
40
|
offline: boolean;
|
|
39
41
|
lines: Array<{
|
|
40
42
|
sku: PosHardwareSkuId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-hardware-sale-api.ts"],"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 type { PosHardwareSku, PosHardwareSkuId } from '../../../model/pos-hardware'\nimport { sendPosHardwareRequest } from './pos-hardware-api'\n\n/*\n * Selling a card reader in person (AGL-4038), the client half of\n * `/api/commerce/pos-hardware-sale`, so no component builds a request by hand.\n */\n\ntype User = Parameters<typeof sendPosHardwareRequest>[0]\n\nconst SALE = '/api/commerce/pos-hardware-sale'\n\nexport type PosHardwareSaleStatus =\n | { seller: false }\n | { seller: true; items: Array<{ sku: PosHardwareSkuId; name: string; kind: PosHardwareSku['kind'] }> }\n\n/** Whether a store is the platform's own hardware seller, once per store per session. */\nconst statusByHost = new Map<string, Promise<PosHardwareSaleStatus>>()\n\nexport function posHardwareSaleStatus(user: User, hostId: string): Promise<PosHardwareSaleStatus> {\n const cached = statusByHost.get(hostId)\n if (cached) return cached\n const asked = sendPosHardwareRequest<PosHardwareSaleStatus>(user, SALE, {\n method: 'POST',\n body: { action: 'status', hostId },\n }).catch((error: unknown) => {\n // A refusal is not remembered: the next editor that opens asks again.\n statusByHost.delete(hostId)\n throw error\n })\n statusByHost.set(hostId, asked)\n return asked\n}\n\n/** A sale on the To attach list, as `pending` and `attach` answer it. */\nexport interface ToAttachRow {\n id: string\n number: string\n registerOrderId: string | null\n registerNumber: number | null\n kiosk: boolean\n offline: boolean\n lines: Array<{ sku: PosHardwareSkuId; name: string; quantity: number }>\n totalCents: number\n createdAtMs: number\n contactEmail: string | null\n attached: boolean\n storeChosen: boolean\n readers: number\n serialsTaken: number\n readersSetUp: number\n awaitingWorkspace: boolean\n invited: boolean\n}\n\nexport interface BuyerStore {\n hostId: string\n name: string\n hasLocation: boolean\n}\n\nexport interface BuyerWorkspace {\n orgId: string\n name: string\n posPlan: boolean\n stores: BuyerStore[]\n}\n\nexport interface BuyerPerson {\n uid: string\n name: string\n email: string\n workspaces: BuyerWorkspace[]\n}\n\nexport interface BuyerFindResult {\n kind: 'email' | 'name'\n people: BuyerPerson[]\n workspaces: Array<BuyerWorkspace & { owner: Omit<BuyerPerson, 'workspaces'> | null }>\n noAccount: boolean\n}\n\n/** Who the register says the buyer is. */\nexport type BuyerChoice = { uid: string; orgId?: string; hostId?: string } | { email: string }\n\nexport function posHardwareToAttach(user: User, hostId: string) {\n return sendPosHardwareRequest<{ orders: ToAttachRow[] }>(user, SALE, {\n method: 'POST',\n body: { action: 'pending', hostId },\n })\n}\n\nexport function posHardwareFindBuyer(user: User, hostId: string, query: string) {\n return sendPosHardwareRequest<BuyerFindResult>(user, SALE, {\n method: 'POST',\n body: { action: 'find', hostId, query },\n })\n}\n\nexport function posHardwareAttach(\n user: User,\n attemptKey: string,\n body: { hostId: string; buyer: BuyerChoice; registerOrderId?: string; orderId?: string },\n) {\n return sendPosHardwareRequest<{ outcome: 'waiting' } | { outcome: 'attached' | 'pending'; order: ToAttachRow }>(\n user,\n SALE,\n { method: 'POST', body: { ...body, action: 'attach' }, attemptKey },\n )\n}\n\n/** Saves the serial numbers of a sale's readers, taken at the sale. */\nexport function posHardwareSerials(\n user: User,\n body: { hostId: string; serials: string[]; registerOrderId?: string; orderId?: string },\n) {\n return sendPosHardwareRequest<{ ok: true; serials: string[]; recorded: boolean }>(user, SALE, {\n method: 'POST',\n body: { ...body, action: 'serials' },\n })\n}\n\n/** Registers a reader to the buyer's chosen store, by its code, at the booth. */\n/** The buyer's store address, typed at the booth for a store with no card reader location yet. */\nexport interface BoothStoreAddress {\n line1: string\n city: string\n state: string\n postalCode: string\n country: string\n}\n\nexport function posHardwareRegisterAtBooth(\n user: User,\n attemptKey: string,\n body: {\n hostId: string\n registrationCode: string\n registerOrderId?: string\n orderId?: string\n address?: BoothStoreAddress\n },\n) {\n return sendPosHardwareRequest<{ ok: true; readerId: string; storeAddressSaved: boolean; order: ToAttachRow }>(user, SALE, {\n method: 'POST',\n body: { ...body, action: 'register-at-booth' },\n attemptKey,\n })\n}\n\n/** The terms of sale the buyer accepts before paying (AGL-4038). */\nexport interface PosHardwareTermsView {\n version: string\n sections: string\n url: string\n summary: string[]\n}\n\n/** How and when the buyer accepted, as the route answers it. */\nexport interface PosHardwareTermsAcceptanceView {\n version: string\n sections: string\n method: 'tablet' | 'display' | 'notice'\n atMs: number\n}\n\nexport function posHardwareTerms(user: User, hostId: string) {\n return sendPosHardwareRequest<PosHardwareTermsView>(user, SALE, { method: 'POST', body: { action: 'terms', hostId } })\n}\n\nexport function posHardwareTermsStatus(user: User, hostId: string, registerOrderId: string) {\n return sendPosHardwareRequest<{ acceptance: PosHardwareTermsAcceptanceView | null }>(user, SALE, {\n method: 'POST',\n body: { action: 'terms-status', hostId, registerOrderId },\n })\n}\n\n/** Notes who is putting the terms on the display, before the register shows them there. */\nexport function posHardwareTermsOnDisplay(user: User, hostId: string, registerOrderId: string) {\n return sendPosHardwareRequest<{ ok: true }>(user, SALE, {\n method: 'POST',\n body: { action: 'terms-on-display', hostId, registerOrderId },\n })\n}\n\n/** The buyer accepted on the register tablet handed to them. */\nexport function posHardwareAcceptTerms(user: User, hostId: string, registerOrderId: string) {\n return sendPosHardwareRequest<{ ok: true; acceptance: PosHardwareTermsAcceptanceView }>(user, SALE, {\n method: 'POST',\n body: { action: 'accept-terms', hostId, registerOrderId },\n })\n}\n"],"names":["sendPosHardwareRequest","SALE","statusByHost","Map","posHardwareSaleStatus","user","hostId","cached","get","asked","method","body","action","catch","error","delete","set","posHardwareToAttach","posHardwareFindBuyer","query","posHardwareAttach","attemptKey","posHardwareSerials","posHardwareRegisterAtBooth","posHardwareTerms","posHardwareTermsStatus","registerOrderId","posHardwareTermsOnDisplay","posHardwareAcceptTerms"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,sBAAsB,QAAQ,wBAAoB;AAS3D,MAAMC,OAAO;AAMb,uFAAuF,GACvF,MAAMC,eAAe,IAAIC;AAEzB,OAAO,SAASC,sBAAsBC,IAAU,EAAEC,MAAc;IAC9D,MAAMC,SAASL,aAAaM,GAAG,CAACF;IAChC,IAAIC,QAAQ,OAAOA;IACnB,MAAME,QAAQT,uBAA8CK,MAAMJ,MAAM;QACtES,QAAQ;QACRC,MAAM;YAAEC,QAAQ;YAAUN;QAAO;IACnC,GAAGO,KAAK,CAAC,CAACC;QACR,sEAAsE;QACtEZ,aAAaa,MAAM,CAACT;QACpB,MAAMQ;IACR;IACAZ,aAAac,GAAG,CAACV,QAAQG;IACzB,OAAOA;AACT;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-hardware-sale-api.ts"],"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 type { PosHardwareSku, PosHardwareSkuId } from '../../../model/pos-hardware'\nimport { sendPosHardwareRequest } from './pos-hardware-api'\n\n/*\n * Selling a card reader in person (AGL-4038), the client half of\n * `/api/commerce/pos-hardware-sale`, so no component builds a request by hand.\n */\n\ntype User = Parameters<typeof sendPosHardwareRequest>[0]\n\nconst SALE = '/api/commerce/pos-hardware-sale'\n\nexport type PosHardwareSaleStatus =\n | { seller: false }\n | { seller: true; items: Array<{ sku: PosHardwareSkuId; name: string; kind: PosHardwareSku['kind'] }> }\n\n/** Whether a store is the platform's own hardware seller, once per store per session. */\nconst statusByHost = new Map<string, Promise<PosHardwareSaleStatus>>()\n\nexport function posHardwareSaleStatus(user: User, hostId: string): Promise<PosHardwareSaleStatus> {\n const cached = statusByHost.get(hostId)\n if (cached) return cached\n const asked = sendPosHardwareRequest<PosHardwareSaleStatus>(user, SALE, {\n method: 'POST',\n body: { action: 'status', hostId },\n }).catch((error: unknown) => {\n // A refusal is not remembered: the next editor that opens asks again.\n statusByHost.delete(hostId)\n throw error\n })\n statusByHost.set(hostId, asked)\n return asked\n}\n\n/** A sale on the To attach list, as `pending` and `attach` answer it. */\nexport interface ToAttachRow {\n id: string\n number: string\n registerOrderId: string | null\n registerNumber: number | null\n kiosk: boolean\n /** Bought from the store's own product pages or cart (AGL-4038), not at the register. */\n online?: boolean\n offline: boolean\n lines: Array<{ sku: PosHardwareSkuId; name: string; quantity: number }>\n totalCents: number\n createdAtMs: number\n contactEmail: string | null\n attached: boolean\n storeChosen: boolean\n readers: number\n serialsTaken: number\n readersSetUp: number\n awaitingWorkspace: boolean\n invited: boolean\n}\n\nexport interface BuyerStore {\n hostId: string\n name: string\n hasLocation: boolean\n}\n\nexport interface BuyerWorkspace {\n orgId: string\n name: string\n posPlan: boolean\n stores: BuyerStore[]\n}\n\nexport interface BuyerPerson {\n uid: string\n name: string\n email: string\n workspaces: BuyerWorkspace[]\n}\n\nexport interface BuyerFindResult {\n kind: 'email' | 'name'\n people: BuyerPerson[]\n workspaces: Array<BuyerWorkspace & { owner: Omit<BuyerPerson, 'workspaces'> | null }>\n noAccount: boolean\n}\n\n/** Who the register says the buyer is. */\nexport type BuyerChoice = { uid: string; orgId?: string; hostId?: string } | { email: string }\n\nexport function posHardwareToAttach(user: User, hostId: string) {\n return sendPosHardwareRequest<{ orders: ToAttachRow[] }>(user, SALE, {\n method: 'POST',\n body: { action: 'pending', hostId },\n })\n}\n\nexport function posHardwareFindBuyer(user: User, hostId: string, query: string) {\n return sendPosHardwareRequest<BuyerFindResult>(user, SALE, {\n method: 'POST',\n body: { action: 'find', hostId, query },\n })\n}\n\nexport function posHardwareAttach(\n user: User,\n attemptKey: string,\n body: { hostId: string; buyer: BuyerChoice; registerOrderId?: string; orderId?: string },\n) {\n return sendPosHardwareRequest<{ outcome: 'waiting' } | { outcome: 'attached' | 'pending'; order: ToAttachRow }>(\n user,\n SALE,\n { method: 'POST', body: { ...body, action: 'attach' }, attemptKey },\n )\n}\n\n/** Saves the serial numbers of a sale's readers, taken at the sale. */\nexport function posHardwareSerials(\n user: User,\n body: { hostId: string; serials: string[]; registerOrderId?: string; orderId?: string },\n) {\n return sendPosHardwareRequest<{ ok: true; serials: string[]; recorded: boolean }>(user, SALE, {\n method: 'POST',\n body: { ...body, action: 'serials' },\n })\n}\n\n/** Registers a reader to the buyer's chosen store, by its code, at the booth. */\n/** The buyer's store address, typed at the booth for a store with no card reader location yet. */\nexport interface BoothStoreAddress {\n line1: string\n city: string\n state: string\n postalCode: string\n country: string\n}\n\nexport function posHardwareRegisterAtBooth(\n user: User,\n attemptKey: string,\n body: {\n hostId: string\n registrationCode: string\n registerOrderId?: string\n orderId?: string\n address?: BoothStoreAddress\n },\n) {\n return sendPosHardwareRequest<{ ok: true; readerId: string; storeAddressSaved: boolean; order: ToAttachRow }>(user, SALE, {\n method: 'POST',\n body: { ...body, action: 'register-at-booth' },\n attemptKey,\n })\n}\n\n/** The terms of sale the buyer accepts before paying (AGL-4038). */\nexport interface PosHardwareTermsView {\n version: string\n sections: string\n url: string\n summary: string[]\n}\n\n/** How and when the buyer accepted, as the route answers it. */\nexport interface PosHardwareTermsAcceptanceView {\n version: string\n sections: string\n method: 'tablet' | 'display' | 'notice'\n atMs: number\n}\n\nexport function posHardwareTerms(user: User, hostId: string) {\n return sendPosHardwareRequest<PosHardwareTermsView>(user, SALE, { method: 'POST', body: { action: 'terms', hostId } })\n}\n\nexport function posHardwareTermsStatus(user: User, hostId: string, registerOrderId: string) {\n return sendPosHardwareRequest<{ acceptance: PosHardwareTermsAcceptanceView | null }>(user, SALE, {\n method: 'POST',\n body: { action: 'terms-status', hostId, registerOrderId },\n })\n}\n\n/** Notes who is putting the terms on the display, before the register shows them there. */\nexport function posHardwareTermsOnDisplay(user: User, hostId: string, registerOrderId: string) {\n return sendPosHardwareRequest<{ ok: true }>(user, SALE, {\n method: 'POST',\n body: { action: 'terms-on-display', hostId, registerOrderId },\n })\n}\n\n/** The buyer accepted on the register tablet handed to them. */\nexport function posHardwareAcceptTerms(user: User, hostId: string, registerOrderId: string) {\n return sendPosHardwareRequest<{ ok: true; acceptance: PosHardwareTermsAcceptanceView }>(user, SALE, {\n method: 'POST',\n body: { action: 'accept-terms', hostId, registerOrderId },\n })\n}\n"],"names":["sendPosHardwareRequest","SALE","statusByHost","Map","posHardwareSaleStatus","user","hostId","cached","get","asked","method","body","action","catch","error","delete","set","posHardwareToAttach","posHardwareFindBuyer","query","posHardwareAttach","attemptKey","posHardwareSerials","posHardwareRegisterAtBooth","posHardwareTerms","posHardwareTermsStatus","registerOrderId","posHardwareTermsOnDisplay","posHardwareAcceptTerms"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,sBAAsB,QAAQ,wBAAoB;AAS3D,MAAMC,OAAO;AAMb,uFAAuF,GACvF,MAAMC,eAAe,IAAIC;AAEzB,OAAO,SAASC,sBAAsBC,IAAU,EAAEC,MAAc;IAC9D,MAAMC,SAASL,aAAaM,GAAG,CAACF;IAChC,IAAIC,QAAQ,OAAOA;IACnB,MAAME,QAAQT,uBAA8CK,MAAMJ,MAAM;QACtES,QAAQ;QACRC,MAAM;YAAEC,QAAQ;YAAUN;QAAO;IACnC,GAAGO,KAAK,CAAC,CAACC;QACR,sEAAsE;QACtEZ,aAAaa,MAAM,CAACT;QACpB,MAAMQ;IACR;IACAZ,aAAac,GAAG,CAACV,QAAQG;IACzB,OAAOA;AACT;AAuDA,OAAO,SAASQ,oBAAoBZ,IAAU,EAAEC,MAAc;IAC5D,OAAON,uBAAkDK,MAAMJ,MAAM;QACnES,QAAQ;QACRC,MAAM;YAAEC,QAAQ;YAAWN;QAAO;IACpC;AACF;AAEA,OAAO,SAASY,qBAAqBb,IAAU,EAAEC,MAAc,EAAEa,KAAa;IAC5E,OAAOnB,uBAAwCK,MAAMJ,MAAM;QACzDS,QAAQ;QACRC,MAAM;YAAEC,QAAQ;YAAQN;YAAQa;QAAM;IACxC;AACF;AAEA,OAAO,SAASC,kBACdf,IAAU,EACVgB,UAAkB,EAClBV,IAAwF;IAExF,OAAOX,uBACLK,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/**
|
|
27
|
-
* 4G for a store's
|
|
27
|
+
* 4G for a store's S710 readers (AGL-4038), on the POS devices card.
|
|
28
28
|
* Stripe turns cellular service on for a store's reader Location, so this is
|
|
29
29
|
* one switch for the store: it says plainly that every S710 at the store
|
|
30
30
|
* gets 4G and that each one is charged, and turning it on takes an explicit
|
|
@@ -21,9 +21,9 @@ import { useUser } from "@aglyn/tenant-feature-instance";
|
|
|
21
21
|
import { Alert, Box, Button, Checkbox, Chip, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Stack, Typography } from "@mui/material";
|
|
22
22
|
import { useState } from "react";
|
|
23
23
|
import { posReadersCall, PosRequestError, usd } from "./pos/pos-api.js";
|
|
24
|
-
const readersText = (count)=>`${count}
|
|
24
|
+
const readersText = (count)=>`${count} S710 reader${count === 1 ? '' : 's'}`;
|
|
25
25
|
/**
|
|
26
|
-
* 4G for a store's
|
|
26
|
+
* 4G for a store's S710 readers (AGL-4038), on the POS devices card.
|
|
27
27
|
* Stripe turns cellular service on for a store's reader Location, so this is
|
|
28
28
|
* one switch for the store: it says plainly that every S710 at the store
|
|
29
29
|
* gets 4G and that each one is charged, and turning it on takes an explicit
|
|
@@ -95,7 +95,7 @@ const readersText = (count)=>`${count} Stripe Reader S710${count === 1 ? '' : 's
|
|
|
95
95
|
variant: "caption",
|
|
96
96
|
color: "text.secondary",
|
|
97
97
|
component: "p",
|
|
98
|
-
children: cellular.enabled ? `On for every
|
|
98
|
+
children: 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.`
|
|
99
99
|
})
|
|
100
100
|
]
|
|
101
101
|
}),
|
|
@@ -138,7 +138,7 @@ const readersText = (count)=>`${count} Stripe Reader S710${count === 1 ? '' : 's
|
|
|
138
138
|
children: [
|
|
139
139
|
/*#__PURE__*/ _jsx(Typography, {
|
|
140
140
|
variant: "body2",
|
|
141
|
-
children: `Every
|
|
141
|
+
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
142
|
}),
|
|
143
143
|
/*#__PURE__*/ _jsx(Typography, {
|
|
144
144
|
variant: "body2",
|
|
@@ -149,7 +149,7 @@ const readersText = (count)=>`${count} Stripe Reader S710${count === 1 ? '' : 's
|
|
|
149
149
|
checked: agreed,
|
|
150
150
|
onChange: (event)=>setAgreed(event.target.checked)
|
|
151
151
|
}),
|
|
152
|
-
label: `I agree to ${price} a month for each
|
|
152
|
+
label: `I agree to ${price} a month for each S710 reader at this store while 4G is on.`
|
|
153
153
|
})
|
|
154
154
|
]
|
|
155
155
|
}),
|
|
@@ -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} Stripe Reader S710${count === 1 ? '' : 's'}`\n\n/**\n * 4G for a store's Stripe Reader S710s (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 Stripe Reader S710 at this store (${readersText(cellular.readers)} now). Each is charged ${price} a month.`\n : `A Stripe Reader S710 can use Stripe's 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 Stripe Reader S710 at this store gets Stripe's 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 Stripe Reader S710 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,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AW6B,SAAQ;0CACjB,CAAC,qBAAqB,EAAER,MAAM,2SAA2S,CAAC;;0CAE7U,KAACvB;gCACC+D,uBAAS,KAACrE;oCAASsE,SAAS7C;oCAAQ8C,UAAU,CAACC,QAAU9C,UAAU8C,MAAMC,MAAM,CAACH,OAAO;;gCACvFhB,OAAO,CAAC,WAAW,EAAEzB,MAAM,kEAAkE,CAAC;;;;kCAGlG,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 */\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,EAAEA,UAAU,IAAI,KAAK,KAAK;AAEtF;;;;;;;;;;CAUC,GACD,OAAO,SAASC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,EAA2B;QAQ5CF;IAPtD,MAAM,EAAEG,MAAMC,IAAI,EAAE,GAAGzB;IACvB,MAAM,EAAE0B,eAAe,EAAE,GAAG3B;IAC5B,MAAM,CAAC4B,QAAQC,UAAU,GAAGf,SAA8B;IAC1D,MAAM,CAACgB,QAAQC,UAAU,GAAGjB,SAAS;IACrC,MAAM,CAACkB,MAAMC,QAAQ,GAAGnB,SAAS;IACjC,MAAMoB,QAAQjB,IAAIK,SAASa,kBAAkB;IAC7C,iFAAiF;IACjF,MAAMC,SAASb,kBAAAA,UAAYD,SAASe,OAAO,GAAG,QAAQf,0BAAAA,SAASgB,aAAa,YAAtBhB,0BAA0B;IAEhF,MAAMiB,SAAS,OAAOF;QACpB,IAAI,CAACX,MAAM;QACXO,QAAQ;QACR,IAAI;YACF,MAAMlB,eAAeW,MAAM;gBAAEc,QAAQ;gBAAYnB;gBAAQgB;eAAaA,UAAU;gBAAEI,SAASX;YAAO,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AAW,GAAG;AAEjC,eAAe5D,mBAAkB"}
|
|
@@ -238,7 +238,7 @@ const EMPTY_ADDRESS = {
|
|
|
238
238
|
readers.length === 0 ? /*#__PURE__*/ _jsx(Typography, {
|
|
239
239
|
variant: "body2",
|
|
240
240
|
color: "text.secondary",
|
|
241
|
-
children: (answer == null ? void 0 : answer.testMode) ? 'No card readers yet. In test mode, add one with the code "simulated-wpe" to try a simulated reader.' : 'No card readers yet. Add a
|
|
241
|
+
children: (answer == null ? void 0 : answer.testMode) ? 'No card readers yet. In test mode, add one with the code "simulated-wpe" to try a simulated reader.' : 'No card readers yet. Add a Touchscreen reader (S700) or Countertop reader (WisePOS E) with the code it shows on screen.'
|
|
242
242
|
}) : readers.map((reader)=>{
|
|
243
243
|
var _registerName, _reader_registerId;
|
|
244
244
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
@@ -548,7 +548,7 @@ const EMPTY_ADDRESS = {
|
|
|
548
548
|
(answer == null ? void 0 : (_answer_cellular = answer.cellular) == null ? void 0 : _answer_cellular.enabled) ? /*#__PURE__*/ _jsx(Typography, {
|
|
549
549
|
variant: "body2",
|
|
550
550
|
color: "text.secondary",
|
|
551
|
-
children: '4G is on at this store:
|
|
551
|
+
children: '4G is on at this store: an S710 reader you add gets it too, and is charged for it each month.'
|
|
552
552
|
}) : null,
|
|
553
553
|
/*#__PURE__*/ _jsx(TextField, {
|
|
554
554
|
label: "Registration code",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-devices-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 * as Aglyn from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useFirestore, useFirestoreCollection, useOrgPlan, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { collection, limit, query } from 'firebase/firestore'\nimport { lazy, Suspense, useCallback, useEffect, useState } from 'react'\nimport type { PosCellularView } from '../../model/pos-cellular'\nimport { posDisplayCall, posReadersCall, PosRequestError } from './pos/pos-api'\nimport { POS_DEVICES_ANCHOR } from './pos/pos-kiosk-readiness.component'\nimport { POS_REGISTERS_ANCHOR, usePosPairing } from './pos/pos-pairing.component'\nimport { PosReaderSplashSetting } from './pos-reader-splash-setting.component'\n\ninterface ReaderRow {\n id: string\n label: string\n registerId: string | null\n deviceType: string | null\n serialNumber: string | null\n status: string\n livemode: boolean\n}\n\ninterface ReadersAnswer {\n available: boolean\n testMode: boolean\n locationReady: boolean\n /** 4G for the store's S710s, where it is offered and the store has one (AGL-4038). */\n cellular?: PosCellularView\n readers: ReaderRow[]\n}\n\n/** Drawn only where 4G is offered, so it arrives with the first store that shows it. */\nconst PosCellularControl = lazy(() => import('./pos-cellular-control.component'))\n\ninterface DisplayRow {\n id: string\n label: string\n createdAtMs: number\n lastSeenAtMs: number\n}\n\nexport interface PosDevicesCardProps {\n hostId: string\n /**\n * Whether the viewer may work this site's register: `managePos`, as the\n * shell resolved it, on a site role that may run it (admin or editor).\n * Pairing a tablet is refused by the server otherwise, so the card says why\n * rather than offering a button that fails. Absent reads as not allowed.\n */\n canManagePos?: boolean\n /**\n * Whether the viewer may set the register's devices up (AGL-4047): the\n * \"Registers and devices\" key on top of `canManagePos`. Adding, renaming,\n * moving and removing a reader, pairing a display and signing one out are\n * refused by the server without it, so each control says why. Absent\n * follows `canManagePos`.\n */\n canSetUpDevices?: boolean\n}\n\n/** Why a device control is not offered to someone who works the register. */\nconst DEVICES_KEY_REASON =\n 'Only a member with the \"Registers and devices\" permission can set up card readers, displays and kiosks.'\n\nconst EMPTY_ADDRESS = { line1: '', line2: '', city: '', state: '', postalCode: '', country: 'US' }\n\n/**\n * The register's hardware (AGL-3607, AGL-3608): Stripe Terminal card readers\n * — registered with the code a reader shows, bound to a register, renamed,\n * removed — and the customer displays paired to each register, which can be\n * signed out. Readers appear only where card readers are offered at all.\n *\n * Each register pairs a new customer display or self-service kiosk here,\n * through the same flow as the register's own Pair display (AGL-3712); a site\n * with no register is sent to the card that makes one.\n */\nexport function PosDevicesCard({\n hostId,\n canManagePos = false,\n canSetUpDevices = canManagePos,\n}: PosDevicesCardProps) {\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n const { data: registerDocs } = useFirestoreCollection<any>(\n () => query(collection(firestore, 'hosts', hostId, 'registers'), limit(25)),\n [firestore, hostId],\n { idField: '$id' },\n )\n // Not \"no registers\" until the listen has answered.\n const noRegisters = registerDocs !== undefined && registerDocs.length === 0\n const registers = [...(registerDocs ?? [])].sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n const [answer, setAnswer] = useState<ReadersAnswer | null>(null)\n const [displays, setDisplays] = useState<Record<string, DisplayRow[]>>({})\n const [adding, setAdding] = useState(false)\n const [code, setCode] = useState('')\n const [label, setLabel] = useState('')\n const [registerId, setRegisterId] = useState('')\n const [address, setAddress] = useState(EMPTY_ADDRESS)\n const [busy, setBusy] = useState(false)\n const [renaming, setRenaming] = useState<{ id: string; label: string } | null>(null)\n const { org, ready: planReady } = useOrgPlan(hostId)\n const posEntitled = planReady && Aglyn.checkEntitlement(org as any, 'pos')\n\n const notify = useCallback(\n (error: unknown, fallback: string) =>\n enqueueSnackbar(error instanceof PosRequestError ? error.message : fallback, {\n variant: 'warning',\n persist: false,\n }),\n [enqueueSnackbar],\n )\n\n const onPairingError = useCallback(\n (message: string) => enqueueSnackbar(message, { variant: 'warning', persist: false }),\n [enqueueSnackbar],\n )\n const pairingFlow = usePosPairing({ user, hostId, onError: onPairingError })\n /** Why pairing is not offered to this viewer, or null when it is. */\n const pairBlocked = !planReady\n ? 'Checking your plan…'\n : !posEntitled\n ? 'Point of Sale is not on your plan. Upgrade in Billing to pair displays and kiosks.'\n : !canManagePos\n ? 'Pairing displays and kiosks takes the \"Use the point of sale\" permission, which site admins and editors hold by default.'\n : !canSetUpDevices\n ? DEVICES_KEY_REASON\n : null\n /** Why the reader controls are not offered, or null when they are. */\n const readersBlocked = !canManagePos\n ? 'Setting up card readers takes the \"Use the point of sale\" permission, which site admins and editors hold by default.'\n : !canSetUpDevices\n ? DEVICES_KEY_REASON\n : null\n\n const load = useCallback(\n async (refresh = false) => {\n if (!user) return\n try {\n setAnswer(await posReadersCall<ReadersAnswer>(user, { action: 'list', hostId, refresh }))\n } catch {\n setAnswer(null)\n }\n },\n [user, hostId],\n )\n const uid = user?.uid ?? ''\n useEffect(() => {\n void load(true)\n // Keyed on the person, not the session object (see the register page).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId])\n\n const registerIds = registers.map((register: any) => register.$id).join(',')\n useEffect(() => {\n if (!user || !registerIds) return\n let active = true\n void Promise.all(\n registerIds.split(',').map(async (id) => {\n const result = await posDisplayCall<{ displays: DisplayRow[] }>(user, {\n action: 'displays',\n hostId,\n registerId: id,\n }).catch(() => ({ displays: [] as DisplayRow[] }))\n return [id, result.displays] as const\n }),\n ).then((entries) => {\n if (active) setDisplays(Object.fromEntries(entries))\n })\n return () => {\n active = false\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId, registerIds])\n\n const registerName = (id: string | null) =>\n registers.find((register: any) => register.$id === id)?.name ?? null\n\n const addReader = async () => {\n if (!user) return\n setBusy(true)\n try {\n await posReadersCall(user, {\n action: 'register',\n hostId,\n registrationCode: code.trim(),\n label: label.trim(),\n ...(registerId ? { registerId } : {}),\n ...(answer?.locationReady ? {} : { address }),\n })\n setAdding(false)\n setCode('')\n setLabel('')\n setRegisterId('')\n await load()\n } catch (error) {\n notify(error, 'The reader could not be added')\n } finally {\n setBusy(false)\n }\n }\n\n const readers = answer?.readers ?? []\n const showReaders = Boolean(answer?.available)\n\n /*\n * Arrived by a kiosk's \"Open POS devices\" (AGL-3982): this card renders\n * after the page has already tried to scroll to the anchor, so it brings\n * itself into view.\n */\n useEffect(() => {\n if (typeof window === 'undefined' || window.location.hash !== `#${POS_DEVICES_ANCHOR}`) return\n document.getElementById(POS_DEVICES_ANCHOR)?.scrollIntoView?.({ block: 'start' })\n }, [])\n\n return (\n <CardDisplay\n id={POS_DEVICES_ANCHOR}\n header={'POS devices'}\n help={pluginDocsHelp('pos', { anchor: '#card-readers' })}\n HeaderProps={\n showReaders || noRegisters\n ? {\n action: (\n <Stack direction=\"row\" spacing={1}>\n {noRegisters ? (\n <Button size=\"small\" href={`#${POS_REGISTERS_ANCHOR}`}>\n {'Add a register'}\n </Button>\n ) : null}\n {showReaders ? (\n <BlockedControl blocked={Boolean(readersBlocked)} reason={readersBlocked ?? ''}>\n <Button size=\"small\" onClick={() => setAdding(true)}>\n {'Add card reader'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n ),\n }\n : undefined\n }\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n {showReaders ? (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Card readers'}</Typography>\n {readers.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {answer?.testMode\n ? 'No card readers yet. In test mode, add one with the code \"simulated-wpe\" to try a simulated reader.'\n : 'No card readers yet. Add a Stripe Reader S700 or BBPOS WisePOS E with the code it shows on screen.'}\n </Typography>\n ) : (\n readers.map((reader) => (\n <Stack\n key={reader.id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}\n >\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 160 }}>\n {reader.label}\n <Typography component=\"span\" variant=\"caption\" color=\"text.secondary\">\n {` · ${registerName(reader.registerId) ?? 'Any register'}` +\n (reader.livemode ? '' : ' · test')}\n </Typography>\n </Typography>\n <Chip\n size=\"small\"\n label={reader.status === 'online' ? 'Online' : 'Offline'}\n color={reader.status === 'online' ? 'success' : 'default'}\n />\n <TextField\n select\n size=\"small\"\n label=\"Register\"\n disabled={Boolean(readersBlocked)}\n value={reader.registerId ?? ''}\n onChange={async (event) => {\n if (!user) return\n try {\n await posReadersCall(user, {\n action: 'update',\n hostId,\n readerId: reader.id,\n registerId: event.target.value,\n })\n await load()\n } catch (error) {\n notify(error, 'The reader could not be updated')\n }\n }}\n sx={{ minWidth: 140 }}\n >\n <MenuItem value=\"\">{'Any register'}</MenuItem>\n {registers.map((register: any) => (\n <MenuItem key={register.$id} value={register.$id}>\n {register.name}\n </MenuItem>\n ))}\n </TextField>\n <BlockedControl blocked={Boolean(readersBlocked)} reason={readersBlocked ?? ''}>\n <Button\n size=\"small\"\n onClick={() => setRenaming({ id: reader.id, label: reader.label })}\n >\n {'Rename'}\n </Button>\n </BlockedControl>\n <Button\n size=\"small\"\n color=\"error\"\n disabled={Boolean(readersBlocked)}\n title={readersBlocked ?? undefined}\n onClick={async () => {\n const confirmed = await confirm({\n title: 'Remove this card reader?',\n description:\n `\"${reader.label}\" is removed from your account and stops taking payments. ` +\n 'To use it again, register it with a new code.',\n confirmationText: 'Remove',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed || !user) return\n try {\n await posReadersCall(user, { action: 'remove', hostId, readerId: reader.id })\n await load()\n } catch (error) {\n notify(error, 'The reader could not be removed')\n }\n }}\n >\n {'Remove'}\n </Button>\n </Stack>\n ))\n )}\n </Stack>\n ) : null}\n {showReaders && answer?.cellular ? (\n <Suspense fallback={null}>\n <PosCellularControl\n hostId={hostId}\n cellular={answer.cellular}\n blocked={readersBlocked}\n onChanged={() => load()}\n />\n </Suspense>\n ) : null}\n {/* What the readers show while idle (AGL-4048); renders nothing\n where card readers are not offered. */}\n {showReaders ? (\n <PosReaderSplashSetting hostId={hostId} canManagePos={canManagePos && canSetUpDevices} />\n ) : null}\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Customer displays and kiosks'}</Typography>\n {noRegisters ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'A display or kiosk pairs to a register. Add a register first.'}\n </Typography>\n ) : (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {pairBlocked ??\n 'Pair display gives you a code. Open the address it shows on the tablet and enter the code.'}\n </Typography>\n {registers.map((register: any) => (\n <Stack key={register.$id} spacing={0.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1, fontWeight: 'fontWeightMedium' }} noWrap>\n {register.name}\n </Typography>\n <Button\n size=\"small\"\n disabled={Boolean(pairBlocked)}\n onClick={() => void pairingFlow.open(register.$id, 'display', register.name)}\n aria-label={`Pair display to ${register.name}`}\n >\n {'Pair display'}\n </Button>\n </Stack>\n {(displays[register.$id] ?? []).map((display) => (\n <Stack key={`${register.$id}:${display.id}`} direction=\"row\" spacing={1} sx={{ alignItems: 'center', pl: 2 }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }}>\n {display.label}\n </Typography>\n <Chip\n size=\"small\"\n label={Date.now() - display.lastSeenAtMs < 120_000 ? 'Connected' : 'Not connected'}\n color={Date.now() - display.lastSeenAtMs < 120_000 ? 'success' : 'default'}\n />\n <Button\n size=\"small\"\n color=\"error\"\n disabled={Boolean(pairBlocked)}\n title={pairBlocked ?? undefined}\n onClick={async () => {\n if (!user) return\n try {\n await posDisplayCall(user, {\n action: 'revoke',\n hostId,\n registerId: register.$id,\n displayId: display.id,\n })\n setDisplays((prev) => ({\n ...prev,\n [register.$id]: (prev[register.$id] ?? []).filter((entry) => entry.id !== display.id),\n }))\n } catch (error) {\n notify(error, 'The display could not be signed out')\n }\n }}\n >\n {'Sign out'}\n </Button>\n </Stack>\n ))}\n </Stack>\n ))}\n </>\n )}\n </Stack>\n </Stack>\n\n <Dialog open={Boolean(renaming)} onClose={() => setRenaming(null)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{'Rename card reader'}</DialogTitle>\n <DialogContent>\n <TextField\n label=\"Name\"\n value={renaming?.label ?? ''}\n onChange={(event) => setRenaming((prev) => (prev ? { ...prev, label: event.target.value } : prev))}\n fullWidth\n autoFocus\n sx={{ mt: 1 }}\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setRenaming(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n disabled={!renaming?.label.trim()}\n onClick={async () => {\n if (!renaming || !user) return\n try {\n await posReadersCall(user, {\n action: 'update',\n hostId,\n readerId: renaming.id,\n label: renaming.label.trim(),\n })\n setRenaming(null)\n await load()\n } catch (error) {\n notify(error, 'The reader could not be renamed')\n }\n }}\n >\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog open={adding} onClose={() => setAdding(false)} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Add a card reader'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ mt: 1 }}>\n {'On the reader, open Settings and choose Generate pairing code, then enter the code it shows.'}\n </Typography>\n {answer?.cellular?.enabled ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'4G is on at this store: a Stripe Reader S710 you add gets it too, and is charged for it each month.'}\n </Typography>\n ) : null}\n <TextField\n label=\"Registration code\"\n value={code}\n onChange={(event) => setCode(event.target.value)}\n autoFocus\n slotProps={{ htmlInput: { autoComplete: 'off' } }}\n />\n <TextField label=\"Name\" placeholder=\"Front counter reader\" value={label} onChange={(event) => setLabel(event.target.value)} />\n <TextField select label=\"Register\" value={registerId} onChange={(event) => setRegisterId(event.target.value)}>\n <MenuItem value=\"\">{'Any register'}</MenuItem>\n {registers.map((register: any) => (\n <MenuItem key={register.$id} value={register.$id}>\n {register.name}\n </MenuItem>\n ))}\n </TextField>\n {answer && !answer.locationReady ? (\n <Box sx={{ display: 'grid', gap: 1.5, gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' } }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ gridColumn: '1 / -1' }}>\n {'Where the reader is used. Stripe sets the reader up for this country.'}\n </Typography>\n <TextField label=\"Street\" value={address.line1} onChange={(event) => setAddress({ ...address, line1: event.target.value })} sx={{ gridColumn: '1 / -1' }} />\n <TextField label=\"City\" value={address.city} onChange={(event) => setAddress({ ...address, city: event.target.value })} />\n <TextField label=\"State\" value={address.state} onChange={(event) => setAddress({ ...address, state: event.target.value })} />\n <TextField label=\"Postal code\" value={address.postalCode} onChange={(event) => setAddress({ ...address, postalCode: event.target.value })} />\n <TextField\n label=\"Country\"\n value={address.country}\n onChange={(event) => setAddress({ ...address, country: event.target.value.toUpperCase().slice(0, 2) })}\n />\n </Box>\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setAdding(false)}>{'Cancel'}</Button>\n <Button variant=\"contained\" disabled={busy || !code.trim()} onClick={() => void addReader()}>\n {'Add reader'}\n </Button>\n </DialogActions>\n </Dialog>\n {pairingFlow.dialog}\n </CardDisplay>\n )\n}\nPosDevicesCard.displayName = 'PosDevicesCard'\n\nexport default PosDevicesCard\n"],"names":["Aglyn","pluginDocsHelp","CardDisplay","useConfirmationContext","BlockedControl","useSnackbar","useFirestore","useFirestoreCollection","useOrgPlan","useUser","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","MenuItem","Stack","TextField","Typography","collection","limit","query","lazy","Suspense","useCallback","useEffect","useState","posDisplayCall","posReadersCall","PosRequestError","POS_DEVICES_ANCHOR","POS_REGISTERS_ANCHOR","usePosPairing","PosReaderSplashSetting","PosCellularControl","DEVICES_KEY_REASON","EMPTY_ADDRESS","line1","line2","city","state","postalCode","country","PosDevicesCard","hostId","canManagePos","canSetUpDevices","answer","firestore","data","user","enqueueSnackbar","confirm","registerDocs","idField","noRegisters","undefined","length","registers","sort","a","b","String","name","localeCompare","setAnswer","displays","setDisplays","adding","setAdding","code","setCode","label","setLabel","registerId","setRegisterId","address","setAddress","busy","setBusy","renaming","setRenaming","org","ready","planReady","posEntitled","checkEntitlement","notify","error","fallback","message","variant","persist","onPairingError","pairingFlow","onError","pairBlocked","readersBlocked","load","refresh","action","uid","registerIds","map","register","$id","join","active","Promise","all","split","id","result","catch","then","entries","Object","fromEntries","registerName","find","addReader","registrationCode","trim","locationReady","readers","showReaders","Boolean","available","document","window","location","hash","getElementById","scrollIntoView","block","header","help","anchor","HeaderProps","direction","spacing","size","href","blocked","reason","onClick","contentGutterX","contentGutterY","color","testMode","reader","sx","alignItems","flexWrap","rowGap","flex","minWidth","component","livemode","status","select","disabled","value","onChange","event","readerId","target","title","confirmed","description","confirmationText","confirmationButtonProps","cellular","onChanged","fontWeight","noWrap","open","aria-label","display","pl","Date","now","lastSeenAtMs","displayId","prev","filter","entry","onClose","maxWidth","fullWidth","autoFocus","mt","flexDirection","gap","enabled","slotProps","htmlInput","autoComplete","placeholder","gridTemplateColumns","xs","sm","gridColumn","toUpperCase","slice","dialog","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,SAASC,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,uBAAsB;AAC1E,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,YAAY,EAAEC,sBAA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ACJ,KAAK;;;kDACtI,KAACjJ;wCACCuD,OAAM;wCACN0F,OAAOtF,QAAQlC,OAAO;wCACtByH,UAAU,CAACC,QAAUvF,WAAW,aAAKD;gDAASlC,SAAS0H,MAAME,MAAM,CAACJ,KAAK,CAACyC,WAAW,GAAGC,KAAK,CAAC,GAAG;;;;iCAGnG;;;kCAEN,MAAChM;;0CACC,KAACH;gCAAOwI,SAAS,IAAM5E,UAAU;0CAAS;;0CAC1C,KAAC5D;gCAAOkF,SAAQ;gCAAYsE,UAAUnF,QAAQ,CAACR,KAAKoD,IAAI;gCAAIuB,SAAS,IAAM,KAAKzB;0CAC7E;;;;;;YAIN1B,YAAY+G,MAAM;;;AAGzB;AACAlK,eAAemK,WAAW,GAAG;AAE7B,eAAenK,eAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-devices-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 * as Aglyn from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useFirestore, useFirestoreCollection, useOrgPlan, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { collection, limit, query } from 'firebase/firestore'\nimport { lazy, Suspense, useCallback, useEffect, useState } from 'react'\nimport type { PosCellularView } from '../../model/pos-cellular'\nimport { posDisplayCall, posReadersCall, PosRequestError } from './pos/pos-api'\nimport { POS_DEVICES_ANCHOR } from './pos/pos-kiosk-readiness.component'\nimport { POS_REGISTERS_ANCHOR, usePosPairing } from './pos/pos-pairing.component'\nimport { PosReaderSplashSetting } from './pos-reader-splash-setting.component'\n\ninterface ReaderRow {\n id: string\n label: string\n registerId: string | null\n deviceType: string | null\n serialNumber: string | null\n status: string\n livemode: boolean\n}\n\ninterface ReadersAnswer {\n available: boolean\n testMode: boolean\n locationReady: boolean\n /** 4G for the store's S710s, where it is offered and the store has one (AGL-4038). */\n cellular?: PosCellularView\n readers: ReaderRow[]\n}\n\n/** Drawn only where 4G is offered, so it arrives with the first store that shows it. */\nconst PosCellularControl = lazy(() => import('./pos-cellular-control.component'))\n\ninterface DisplayRow {\n id: string\n label: string\n createdAtMs: number\n lastSeenAtMs: number\n}\n\nexport interface PosDevicesCardProps {\n hostId: string\n /**\n * Whether the viewer may work this site's register: `managePos`, as the\n * shell resolved it, on a site role that may run it (admin or editor).\n * Pairing a tablet is refused by the server otherwise, so the card says why\n * rather than offering a button that fails. Absent reads as not allowed.\n */\n canManagePos?: boolean\n /**\n * Whether the viewer may set the register's devices up (AGL-4047): the\n * \"Registers and devices\" key on top of `canManagePos`. Adding, renaming,\n * moving and removing a reader, pairing a display and signing one out are\n * refused by the server without it, so each control says why. Absent\n * follows `canManagePos`.\n */\n canSetUpDevices?: boolean\n}\n\n/** Why a device control is not offered to someone who works the register. */\nconst DEVICES_KEY_REASON =\n 'Only a member with the \"Registers and devices\" permission can set up card readers, displays and kiosks.'\n\nconst EMPTY_ADDRESS = { line1: '', line2: '', city: '', state: '', postalCode: '', country: 'US' }\n\n/**\n * The register's hardware (AGL-3607, AGL-3608): Stripe Terminal card readers\n * — registered with the code a reader shows, bound to a register, renamed,\n * removed — and the customer displays paired to each register, which can be\n * signed out. Readers appear only where card readers are offered at all.\n *\n * Each register pairs a new customer display or self-service kiosk here,\n * through the same flow as the register's own Pair display (AGL-3712); a site\n * with no register is sent to the card that makes one.\n */\nexport function PosDevicesCard({\n hostId,\n canManagePos = false,\n canSetUpDevices = canManagePos,\n}: PosDevicesCardProps) {\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n const { data: registerDocs } = useFirestoreCollection<any>(\n () => query(collection(firestore, 'hosts', hostId, 'registers'), limit(25)),\n [firestore, hostId],\n { idField: '$id' },\n )\n // Not \"no registers\" until the listen has answered.\n const noRegisters = registerDocs !== undefined && registerDocs.length === 0\n const registers = [...(registerDocs ?? [])].sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n const [answer, setAnswer] = useState<ReadersAnswer | null>(null)\n const [displays, setDisplays] = useState<Record<string, DisplayRow[]>>({})\n const [adding, setAdding] = useState(false)\n const [code, setCode] = useState('')\n const [label, setLabel] = useState('')\n const [registerId, setRegisterId] = useState('')\n const [address, setAddress] = useState(EMPTY_ADDRESS)\n const [busy, setBusy] = useState(false)\n const [renaming, setRenaming] = useState<{ id: string; label: string } | null>(null)\n const { org, ready: planReady } = useOrgPlan(hostId)\n const posEntitled = planReady && Aglyn.checkEntitlement(org as any, 'pos')\n\n const notify = useCallback(\n (error: unknown, fallback: string) =>\n enqueueSnackbar(error instanceof PosRequestError ? error.message : fallback, {\n variant: 'warning',\n persist: false,\n }),\n [enqueueSnackbar],\n )\n\n const onPairingError = useCallback(\n (message: string) => enqueueSnackbar(message, { variant: 'warning', persist: false }),\n [enqueueSnackbar],\n )\n const pairingFlow = usePosPairing({ user, hostId, onError: onPairingError })\n /** Why pairing is not offered to this viewer, or null when it is. */\n const pairBlocked = !planReady\n ? 'Checking your plan…'\n : !posEntitled\n ? 'Point of Sale is not on your plan. Upgrade in Billing to pair displays and kiosks.'\n : !canManagePos\n ? 'Pairing displays and kiosks takes the \"Use the point of sale\" permission, which site admins and editors hold by default.'\n : !canSetUpDevices\n ? DEVICES_KEY_REASON\n : null\n /** Why the reader controls are not offered, or null when they are. */\n const readersBlocked = !canManagePos\n ? 'Setting up card readers takes the \"Use the point of sale\" permission, which site admins and editors hold by default.'\n : !canSetUpDevices\n ? DEVICES_KEY_REASON\n : null\n\n const load = useCallback(\n async (refresh = false) => {\n if (!user) return\n try {\n setAnswer(await posReadersCall<ReadersAnswer>(user, { action: 'list', hostId, refresh }))\n } catch {\n setAnswer(null)\n }\n },\n [user, hostId],\n )\n const uid = user?.uid ?? ''\n useEffect(() => {\n void load(true)\n // Keyed on the person, not the session object (see the register page).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId])\n\n const registerIds = registers.map((register: any) => register.$id).join(',')\n useEffect(() => {\n if (!user || !registerIds) return\n let active = true\n void Promise.all(\n registerIds.split(',').map(async (id) => {\n const result = await posDisplayCall<{ displays: DisplayRow[] }>(user, {\n action: 'displays',\n hostId,\n registerId: id,\n }).catch(() => ({ displays: [] as DisplayRow[] }))\n return [id, result.displays] as const\n }),\n ).then((entries) => {\n if (active) setDisplays(Object.fromEntries(entries))\n })\n return () => {\n active = false\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId, registerIds])\n\n const registerName = (id: string | null) =>\n registers.find((register: any) => register.$id === id)?.name ?? null\n\n const addReader = async () => {\n if (!user) return\n setBusy(true)\n try {\n await posReadersCall(user, {\n action: 'register',\n hostId,\n registrationCode: code.trim(),\n label: label.trim(),\n ...(registerId ? { registerId } : {}),\n ...(answer?.locationReady ? {} : { address }),\n })\n setAdding(false)\n setCode('')\n setLabel('')\n setRegisterId('')\n await load()\n } catch (error) {\n notify(error, 'The reader could not be added')\n } finally {\n setBusy(false)\n }\n }\n\n const readers = answer?.readers ?? []\n const showReaders = Boolean(answer?.available)\n\n /*\n * Arrived by a kiosk's \"Open POS devices\" (AGL-3982): this card renders\n * after the page has already tried to scroll to the anchor, so it brings\n * itself into view.\n */\n useEffect(() => {\n if (typeof window === 'undefined' || window.location.hash !== `#${POS_DEVICES_ANCHOR}`) return\n document.getElementById(POS_DEVICES_ANCHOR)?.scrollIntoView?.({ block: 'start' })\n }, [])\n\n return (\n <CardDisplay\n id={POS_DEVICES_ANCHOR}\n header={'POS devices'}\n help={pluginDocsHelp('pos', { anchor: '#card-readers' })}\n HeaderProps={\n showReaders || noRegisters\n ? {\n action: (\n <Stack direction=\"row\" spacing={1}>\n {noRegisters ? (\n <Button size=\"small\" href={`#${POS_REGISTERS_ANCHOR}`}>\n {'Add a register'}\n </Button>\n ) : null}\n {showReaders ? (\n <BlockedControl blocked={Boolean(readersBlocked)} reason={readersBlocked ?? ''}>\n <Button size=\"small\" onClick={() => setAdding(true)}>\n {'Add card reader'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n ),\n }\n : undefined\n }\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n {showReaders ? (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Card readers'}</Typography>\n {readers.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {answer?.testMode\n ? 'No card readers yet. In test mode, add one with the code \"simulated-wpe\" to try a simulated reader.'\n : 'No card readers yet. Add a Touchscreen reader (S700) or Countertop reader (WisePOS E) with the code it shows on screen.'}\n </Typography>\n ) : (\n readers.map((reader) => (\n <Stack\n key={reader.id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}\n >\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 160 }}>\n {reader.label}\n <Typography component=\"span\" variant=\"caption\" color=\"text.secondary\">\n {` · ${registerName(reader.registerId) ?? 'Any register'}` +\n (reader.livemode ? '' : ' · test')}\n </Typography>\n </Typography>\n <Chip\n size=\"small\"\n label={reader.status === 'online' ? 'Online' : 'Offline'}\n color={reader.status === 'online' ? 'success' : 'default'}\n />\n <TextField\n select\n size=\"small\"\n label=\"Register\"\n disabled={Boolean(readersBlocked)}\n value={reader.registerId ?? ''}\n onChange={async (event) => {\n if (!user) return\n try {\n await posReadersCall(user, {\n action: 'update',\n hostId,\n readerId: reader.id,\n registerId: event.target.value,\n })\n await load()\n } catch (error) {\n notify(error, 'The reader could not be updated')\n }\n }}\n sx={{ minWidth: 140 }}\n >\n <MenuItem value=\"\">{'Any register'}</MenuItem>\n {registers.map((register: any) => (\n <MenuItem key={register.$id} value={register.$id}>\n {register.name}\n </MenuItem>\n ))}\n </TextField>\n <BlockedControl blocked={Boolean(readersBlocked)} reason={readersBlocked ?? ''}>\n <Button\n size=\"small\"\n onClick={() => setRenaming({ id: reader.id, label: reader.label })}\n >\n {'Rename'}\n </Button>\n </BlockedControl>\n <Button\n size=\"small\"\n color=\"error\"\n disabled={Boolean(readersBlocked)}\n title={readersBlocked ?? undefined}\n onClick={async () => {\n const confirmed = await confirm({\n title: 'Remove this card reader?',\n description:\n `\"${reader.label}\" is removed from your account and stops taking payments. ` +\n 'To use it again, register it with a new code.',\n confirmationText: 'Remove',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed || !user) return\n try {\n await posReadersCall(user, { action: 'remove', hostId, readerId: reader.id })\n await load()\n } catch (error) {\n notify(error, 'The reader could not be removed')\n }\n }}\n >\n {'Remove'}\n </Button>\n </Stack>\n ))\n )}\n </Stack>\n ) : null}\n {showReaders && answer?.cellular ? (\n <Suspense fallback={null}>\n <PosCellularControl\n hostId={hostId}\n cellular={answer.cellular}\n blocked={readersBlocked}\n onChanged={() => load()}\n />\n </Suspense>\n ) : null}\n {/* What the readers show while idle (AGL-4048); renders nothing\n where card readers are not offered. */}\n {showReaders ? (\n <PosReaderSplashSetting hostId={hostId} canManagePos={canManagePos && canSetUpDevices} />\n ) : null}\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Customer displays and kiosks'}</Typography>\n {noRegisters ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'A display or kiosk pairs to a register. Add a register first.'}\n </Typography>\n ) : (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {pairBlocked ??\n 'Pair display gives you a code. Open the address it shows on the tablet and enter the code.'}\n </Typography>\n {registers.map((register: any) => (\n <Stack key={register.$id} spacing={0.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1, fontWeight: 'fontWeightMedium' }} noWrap>\n {register.name}\n </Typography>\n <Button\n size=\"small\"\n disabled={Boolean(pairBlocked)}\n onClick={() => void pairingFlow.open(register.$id, 'display', register.name)}\n aria-label={`Pair display to ${register.name}`}\n >\n {'Pair display'}\n </Button>\n </Stack>\n {(displays[register.$id] ?? []).map((display) => (\n <Stack key={`${register.$id}:${display.id}`} direction=\"row\" spacing={1} sx={{ alignItems: 'center', pl: 2 }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }}>\n {display.label}\n </Typography>\n <Chip\n size=\"small\"\n label={Date.now() - display.lastSeenAtMs < 120_000 ? 'Connected' : 'Not connected'}\n color={Date.now() - display.lastSeenAtMs < 120_000 ? 'success' : 'default'}\n />\n <Button\n size=\"small\"\n color=\"error\"\n disabled={Boolean(pairBlocked)}\n title={pairBlocked ?? undefined}\n onClick={async () => {\n if (!user) return\n try {\n await posDisplayCall(user, {\n action: 'revoke',\n hostId,\n registerId: register.$id,\n displayId: display.id,\n })\n setDisplays((prev) => ({\n ...prev,\n [register.$id]: (prev[register.$id] ?? []).filter((entry) => entry.id !== display.id),\n }))\n } catch (error) {\n notify(error, 'The display could not be signed out')\n }\n }}\n >\n {'Sign out'}\n </Button>\n </Stack>\n ))}\n </Stack>\n ))}\n </>\n )}\n </Stack>\n </Stack>\n\n <Dialog open={Boolean(renaming)} onClose={() => setRenaming(null)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{'Rename card reader'}</DialogTitle>\n <DialogContent>\n <TextField\n label=\"Name\"\n value={renaming?.label ?? ''}\n onChange={(event) => setRenaming((prev) => (prev ? { ...prev, label: event.target.value } : prev))}\n fullWidth\n autoFocus\n sx={{ mt: 1 }}\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setRenaming(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n disabled={!renaming?.label.trim()}\n onClick={async () => {\n if (!renaming || !user) return\n try {\n await posReadersCall(user, {\n action: 'update',\n hostId,\n readerId: renaming.id,\n label: renaming.label.trim(),\n })\n setRenaming(null)\n await load()\n } catch (error) {\n notify(error, 'The reader could not be renamed')\n }\n }}\n >\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog open={adding} onClose={() => setAdding(false)} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{'Add a card reader'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ mt: 1 }}>\n {'On the reader, open Settings and choose Generate pairing code, then enter the code it shows.'}\n </Typography>\n {answer?.cellular?.enabled ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'4G is on at this store: an S710 reader you add gets it too, and is charged for it each month.'}\n </Typography>\n ) : null}\n <TextField\n label=\"Registration code\"\n value={code}\n onChange={(event) => setCode(event.target.value)}\n autoFocus\n slotProps={{ htmlInput: { autoComplete: 'off' } }}\n />\n <TextField label=\"Name\" placeholder=\"Front counter reader\" value={label} onChange={(event) => setLabel(event.target.value)} />\n <TextField select label=\"Register\" value={registerId} onChange={(event) => setRegisterId(event.target.value)}>\n <MenuItem value=\"\">{'Any register'}</MenuItem>\n {registers.map((register: any) => (\n <MenuItem key={register.$id} value={register.$id}>\n {register.name}\n </MenuItem>\n ))}\n </TextField>\n {answer && !answer.locationReady ? (\n <Box sx={{ display: 'grid', gap: 1.5, gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' } }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ gridColumn: '1 / -1' }}>\n {'Where the reader is used. Stripe sets the reader up for this country.'}\n </Typography>\n <TextField label=\"Street\" value={address.line1} onChange={(event) => setAddress({ ...address, line1: event.target.value })} sx={{ gridColumn: '1 / -1' }} />\n <TextField label=\"City\" value={address.city} onChange={(event) => setAddress({ ...address, city: event.target.value })} />\n <TextField label=\"State\" value={address.state} onChange={(event) => setAddress({ ...address, state: event.target.value })} />\n <TextField label=\"Postal code\" value={address.postalCode} onChange={(event) => setAddress({ ...address, postalCode: event.target.value })} />\n <TextField\n label=\"Country\"\n value={address.country}\n onChange={(event) => setAddress({ ...address, country: event.target.value.toUpperCase().slice(0, 2) })}\n />\n </Box>\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setAdding(false)}>{'Cancel'}</Button>\n <Button variant=\"contained\" disabled={busy || !code.trim()} onClick={() => void addReader()}>\n {'Add reader'}\n </Button>\n </DialogActions>\n </Dialog>\n {pairingFlow.dialog}\n </CardDisplay>\n )\n}\nPosDevicesCard.displayName = 'PosDevicesCard'\n\nexport default PosDevicesCard\n"],"names":["Aglyn","pluginDocsHelp","CardDisplay","useConfirmationContext","BlockedControl","useSnackbar","useFirestore","useFirestoreCollection","useOrgPlan","useUser","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","MenuItem","Stack","TextField","Typography","collection","limit","query","lazy","Suspense","useCallback","useEffect","useState","posDisplayCall","posReadersCall","PosRequestError","POS_DEVICES_ANCHOR","POS_REGISTERS_ANCHOR","usePosPairing","PosReaderSplashSetting","PosCellularControl","DEVICES_KEY_REASON","EMPTY_ADDRESS","line1","line2","city","state","postalCode","country","PosDevicesCard","hostId","canManagePos","canSetUpDevices","answer","firestore","data","user","enqueueSnackbar","confirm","registerDocs","idField","noRegisters","undefined","length","registers","sort","a","b","String","name","localeCompare","setAnswer","displays","setDisplays","adding","setAdding","code","setCode","label","setLabel","registerId","setRegisterId","address","setAddress","busy","setBusy","renaming","setRenaming","org","ready","planReady","posEntitled","checkEntitlement","notify","error","fallback","message","variant","persist","onPairingError","pairingFlow","onError","pairBlocked","readersBlocked","load","refresh","action","uid","registerIds","map","register","$id","join","active","Promise","all","split","id","result","catch","then","entries","Object","fromEntries","registerName","find","addReader","registrationCode","trim","locationReady","readers","showReaders","Boolean","available","document","window","location","hash","getElementById","scrollIntoView","block","header","help","anchor","HeaderProps","direction","spacing","size","href","blocked","reason","onClick","contentGutterX","contentGutterY","color","testMode","reader","sx","alignItems","flexWrap","rowGap","flex","minWidth","component","livemode","status","select","disabled","value","onChange","event","readerId","target","title","confirmed","description","confirmationText","confirmationButtonProps","cellular","onChanged","fontWeight","noWrap","open","aria-label","display","pl","Date","now","lastSeenAtMs","displayId","prev","filter","entry","onClose","maxWidth","fullWidth","autoFocus","mt","flexDirection","gap","enabled","slotProps","htmlInput","autoComplete","placeholder","gridTemplateColumns","xs","sm","gridColumn","toUpperCase","slice","dialog","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,SAASC,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,uBAAsB;AAC1E,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,YAAY,EAAEC,sBAAsB,EAAEC,UAAU,EAAEC,OAAO,QAAQ,iCAAgC;AAC1G,SACEC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,UAAU,EAAEC,KAAK,EAAEC,KAAK,QAAQ,qBAAoB;AAC7D,SAASC,IAAI,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAExE,SAASC,cAAc,EAAEC,cAAc,EAAEC,eAAe,QAAQ,mBAAe;AAC/E,SAASC,kB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