@aglyn/plugins-commerce 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/src/lib/components/console/catalog-organization-card.component.js +1 -1
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/host-quotes-card.component.js +23 -13
- package/src/lib/components/console/host-quotes-card.component.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/pay-link-readiness-notice.component.d.ts +1 -1
- package/src/lib/components/console/pay-link-readiness-notice.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-kiosk/kiosk-menu.d.ts +10 -3
- package/src/lib/components/console/pos-kiosk/kiosk-menu.js +29 -8
- package/src/lib/components/console/pos-kiosk/kiosk-menu.js.map +1 -1
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.d.ts +2 -0
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js +7 -0
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js.map +1 -1
- package/src/lib/components/console/pos-kiosk-page.component.d.ts +2 -0
- package/src/lib/components/console/pos-kiosk-page.component.js +54 -3
- package/src/lib/components/console/pos-kiosk-page.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +1 -1
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-day-totals-card.component.js +1 -1
- package/src/lib/components/console/pos-ops/pos-day-totals-card.component.js.map +1 -1
- package/src/lib/components/console/pos-reader-splash-setting.component.js +1 -1
- package/src/lib/components/console/pos-reader-splash-setting.component.js.map +1 -1
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +0 -2
- package/src/lib/components/console/product-add-ons-fields.component.js +1 -6
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/quote-editor-dialog.component.d.ts +7 -0
- package/src/lib/components/console/quote-editor-dialog.component.js +129 -32
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-pay-link.component.d.ts +4 -1
- package/src/lib/components/console/quote-pay-link.component.js +23 -12
- package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
- package/src/lib/components/console/quote-proofs.component.d.ts +3 -2
- package/src/lib/components/console/quote-proofs.component.js +73 -5
- package/src/lib/components/console/quote-proofs.component.js.map +1 -1
- package/src/lib/components/console/quote-send.component.js +9 -6
- package/src/lib/components/console/quote-send.component.js.map +1 -1
- package/src/lib/components/console/site-member-purchases.component.js +1 -1
- package/src/lib/components/console/site-member-purchases.component.js.map +1 -1
- package/src/lib/components/product-detail.js +1 -1
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.js +5 -3
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/product-reviews.js +17 -12
- package/src/lib/components/product-reviews.js.map +1 -1
- package/src/lib/components/quote-page-body.js +14 -8
- package/src/lib/components/quote-page-body.js.map +1 -1
- package/src/lib/components/related-products.js +2 -1
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/model/commerce-invoices.d.ts +1 -1
- package/src/lib/model/commerce-invoices.js +4 -1
- package/src/lib/model/commerce-invoices.js.map +1 -1
- package/src/lib/model/commerce-kiosk-search.d.ts +22 -0
- package/src/lib/model/commerce-kiosk-search.js +32 -0
- package/src/lib/model/commerce-kiosk-search.js.map +1 -0
- package/src/lib/model/commerce-pos-kiosk.d.ts +7 -1
- package/src/lib/model/commerce-pos-kiosk.js +1 -1
- package/src/lib/model/commerce-pos-kiosk.js.map +1 -1
- package/src/lib/model/commerce-quote-email.d.ts +7 -6
- package/src/lib/model/commerce-quote-email.js +11 -6
- package/src/lib/model/commerce-quote-email.js.map +1 -1
- package/src/lib/model/commerce-quote-pay.d.ts +6 -1
- package/src/lib/model/commerce-quote-pay.js +18 -8
- package/src/lib/model/commerce-quote-pay.js.map +1 -1
- package/src/lib/model/commerce-quote-proofs.d.ts +28 -1
- package/src/lib/model/commerce-quote-proofs.js +58 -2
- package/src/lib/model/commerce-quote-proofs.js.map +1 -1
- package/src/lib/model/commerce-quotes.d.ts +22 -1
- package/src/lib/model/commerce-quotes.js +25 -5
- package/src/lib/model/commerce-quotes.js.map +1 -1
- package/src/lib/model/plugin-permissions.d.ts +1 -1
- package/src/lib/model/plugin-permissions.js +10 -0
- package/src/lib/model/plugin-permissions.js.map +1 -1
- package/src/lib/model/product-modifiers.d.ts +4 -0
- package/src/lib/model/product-modifiers.js +5 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/server/commerce-pdf.d.ts +1 -1
- package/src/lib/server/commerce-pdf.js +1 -1
- package/src/lib/server/commerce-pdf.js.map +1 -1
- package/src/lib/server/paid-media-delivery.js +1 -1
- package/src/lib/server/paid-media-delivery.js.map +1 -1
- package/src/lib/server/pos-kiosk.js +70 -15
- package/src/lib/server/pos-kiosk.js.map +1 -1
- package/src/lib/server/quote-email.js +29 -25
- package/src/lib/server/quote-email.js.map +1 -1
- package/src/lib/server/quote-pay.js +6 -2
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote-proof-media.d.ts +63 -0
- package/src/lib/server/quote-proof-media.js +96 -0
- package/src/lib/server/quote-proof-media.js.map +1 -0
- package/src/lib/server/quote-proofs.js +17 -8
- package/src/lib/server/quote-proofs.js.map +1 -1
- package/src/lib/server/quote-uploads.d.ts +3 -1
- package/src/lib/server/quote-uploads.js +2 -1
- package/src/lib/server/quote-uploads.js.map +1 -1
- package/src/lib/server/quote.d.ts +3 -0
- package/src/lib/server/quote.js +127 -20
- package/src/lib/server/quote.js.map +1 -1
- package/src/lib/server/site-page-enricher.js +5 -1
- package/src/lib/server/site-page-enricher.js.map +1 -1
- package/src/lib/tenant-emails.js +16 -9
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-firestore.js +34 -5
- package/src/lib/testing/fake-firestore.js.map +1 -1
- package/src/lib/transfer/gift-cards.server.js +9 -11
- package/src/lib/transfer/gift-cards.server.js.map +1 -1
- package/src/lib/transfer/product-register-cells.d.ts +75 -0
- package/src/lib/transfer/product-register-cells.js +487 -0
- package/src/lib/transfer/product-register-cells.js.map +1 -0
- package/src/lib/transfer/product-transfer.d.ts +12 -0
- package/src/lib/transfer/product-transfer.js +174 -10
- package/src/lib/transfer/product-transfer.js.map +1 -1
- package/src/lib/transfer/products.server.js +24 -9
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/utils/commerce-document-pdf.js +12 -9
- package/src/lib/utils/commerce-document-pdf.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +2 -0
- package/src/lib/utils/quote-email-content.js +20 -10
- package/src/lib/utils/quote-email-content.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-ops/pos-day-totals-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\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useFirestoreCollection, useUser } from '@aglyn/tenant-feature-instance'\nimport { Alert, Button, Chip, Divider, Stack, Typography } from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'\nimport { DatePicker } from '@mui/x-date-pickers/DatePicker'\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'\nimport type { Dayjs } from 'dayjs'\nimport { collection, documentId, limit, orderBy, query } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react'\nimport {\n posDayRangeLabel,\n posDayReportIsEmpty,\n posDayReportSections,\n POS_DAY_REPORT_MAX_DAYS,\n POS_DAY_REPORT_ROUTE,\n type PosDayReport,\n} from '../../../model/commerce-pos-day-report'\nimport { formatReceiptMoney } from '../../../model/commerce-receipt'\nimport { escapeHtml } from '../../../utils/escape-html'\nimport CommerceStatTile from '../commerce-stat-tile.component'\nimport { EntitlementGatedCard } from '../entitlement-gate.component'\nimport { POS_RECEIPT_STYLES } from './pos-receipt'\nimport { printPosDocument } from './pos-shift-report.component'\n\n/*==========================================\n * DAY TOTALS (AGL-4037): one day's or one event's sales across every\n * register, shift and cashier, from `GET /api/commerce/pos-day-report`.\n *\n * The figures are the server's: the card formats them and never sums them.\n * Every table holds a whole, bounded answer (seven tenders at most, the\n * site's registers, its staff, the range's shifts), so the grid sorts each\n * by any column itself.\n *=========================================*/\n\nexport interface PosDayTotalsCardProps {\n hostId: string\n /** The viewer may work the register: what the route's gate asks. */\n canManagePos?: boolean\n}\n\nconst HEADER = 'Day totals'\nconst HELP = pluginDocsHelp('posOperations', { anchor: '#day-and-event-totals' })\nconst DAY_FORMAT = 'YYYY-MM-DD'\n\ntype Answer =\n | { state: 'idle' | 'loading' }\n | { state: 'ready'; report: PosDayReport }\n | { state: 'error'; error: string }\n\n/** A time as the shifts table lists it, in the viewer's locale. */\nconst when = (ms?: number | null) =>\n ms\n ? new Date(ms).toLocaleString([], { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' })\n : ''\n\n/** The day totals as a printable 80 mm document, like the Z report. */\nexport function posDayReportDocument(input: { report: PosDayReport }): string {\n const money = (cents: number) => formatReceiptMoney(cents, input.report.currency)\n const body = posDayReportSections(input.report, money)\n .map(\n (section) =>\n `<hr class=\"rule\"><div class=\"title\">${escapeHtml(section.section.toUpperCase())}</div>` +\n section.rows\n .map(\n (row) =>\n `<div class=\"row${row.strong ? ' total' : ''}\"><span>${escapeHtml(row.label)}</span><span>${escapeHtml(row.value)}</span></div>`,\n )\n .join(''),\n )\n .join('')\n return (\n '<!doctype html><html><head><meta charset=\"utf-8\">' +\n `<title>DAY TOTALS</title><style>${POS_RECEIPT_STYLES}</style></head><body>` +\n `<div class=\"receipt\"><div class=\"center\"><div class=\"store\">${escapeHtml(input.report.storeName || 'Register')}</div>` +\n `<div class=\"title\">DAY TOTALS</div><div class=\"muted\">${escapeHtml(posDayRangeLabel(input.report))}</div></div>` +\n `${body}</div></body></html>`\n )\n}\n\nfunction DrawerRows(props: { report: PosDayReport; money: (cents: number) => string }) {\n const drawers = posDayReportSections(props.report, props.money).find((section) => section.section === 'Cash drawers')\n return (\n <Stack spacing={0.5}>\n {drawers?.rows.map((row) => (\n <Stack key={row.label} direction=\"row\" sx={{ justifyContent: 'space-between', gap: 2 }}>\n <Typography variant=\"body2\" color={row.strong ? 'text.primary' : 'text.secondary'}>\n {row.label}\n </Typography>\n <Typography variant={row.strong ? 'subtitle2' : 'body2'} sx={{ fontVariantNumeric: 'tabular-nums' }}>\n {row.value}\n </Typography>\n </Stack>\n ))}\n </Stack>\n )\n}\n\nfunction Section(props: { title: string; children: ReactNode }) {\n return (\n <Stack spacing={1}>\n <Typography variant=\"overline\">{props.title}</Typography>\n {props.children}\n </Stack>\n )\n}\n\nfunction PosDayTotalsBody(props: PosDayTotalsCardProps) {\n const { hostId, canManagePos = false } = props\n const { data: user } = useUser()\n const [from, setFrom] = useState<Dayjs | null>(null)\n const [to, setTo] = useState<Dayjs | null>(null)\n const [answer, setAnswer] = useState<Answer>({ state: 'idle' })\n const [exporting, setExporting] = useState(false)\n\n const url = useCallback(\n (format?: 'csv') => {\n const params = new URLSearchParams({ hostId })\n if (from?.isValid()) params.set('from', from.format(DAY_FORMAT))\n if (to?.isValid()) params.set('to', to.format(DAY_FORMAT))\n if (format) params.set('format', format)\n return `${POS_DAY_REPORT_ROUTE}?${params.toString()}`\n },\n [hostId, from, to],\n )\n\n useEffect(() => {\n if (!user || !canManagePos) return\n let live = true\n setAnswer({ state: 'loading' })\n void (async () => {\n try {\n const response = await authorizedFetch(user as never, url(), { method: 'GET' })\n const body = (await response.json().catch(() => ({}))) as { report?: PosDayReport; error?: string }\n if (!live) return\n setAnswer(\n response.ok && body.report\n ? { state: 'ready', report: body.report }\n : { state: 'error', error: body.error || 'The day totals could not be read.' },\n )\n } catch {\n if (live) setAnswer({ state: 'error', error: 'The day totals could not be read. Check the connection.' })\n }\n })()\n return () => {\n live = false\n }\n }, [user, canManagePos, url])\n\n const report = answer.state === 'ready' ? answer.report : null\n const money = useCallback((cents: number) => formatReceiptMoney(cents, report?.currency ?? 'usd'), [report?.currency])\n const moneyColumn = useCallback(\n (field: string, headerName: string, minWidth = 110): GridColDef => ({\n field,\n headerName,\n type: 'number',\n minWidth,\n flex: 1,\n valueFormatter: (value: number | null | undefined) => (value == null ? '—' : money(value)),\n }),\n [money],\n )\n\n const tenderColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'label', headerName: 'Tender', flex: 1, minWidth: 140 },\n moneyColumn('salesCents', 'Sales'),\n moneyColumn('refundsCents', 'Refunds'),\n moneyColumn('netCents', 'Net'),\n ],\n [moneyColumn],\n )\n const salesColumns = useCallback(\n (nameHeader: string): GridColDef[] => [\n { field: 'name', headerName: nameHeader, flex: 1, minWidth: 140 },\n { field: 'orderCount', headerName: 'Orders', type: 'number', minWidth: 90 },\n moneyColumn('grossSalesCents', 'Gross sales'),\n moneyColumn('tipsCents', 'Tips', 90),\n moneyColumn('refundsCents', 'Refunds'),\n moneyColumn('netSalesCents', 'Net sales'),\n ],\n [moneyColumn],\n )\n const registerColumns = useMemo(() => salesColumns('Register'), [salesColumns])\n const cashierColumns = useMemo(() => salesColumns('Cashier'), [salesColumns])\n const shiftColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'registerName', headerName: 'Register', minWidth: 120, flex: 1 },\n {\n field: 'openedAtMs',\n headerName: 'Opened',\n minWidth: 140,\n valueFormatter: (value: number) => when(value),\n },\n {\n field: 'closedAtMs',\n headerName: 'Closed',\n minWidth: 140,\n // Open shifts sort after every closed one, by when they opened.\n valueGetter: (_value: unknown, row: Record<string, any>) =>\n row['closedAtMs'] ?? Number.MAX_SAFE_INTEGER - (row['openedAtMs'] ?? 0),\n renderCell: ({ row }: { row: Record<string, any> }) =>\n row['status'] === 'open' ? <Chip size=\"small\" color=\"success\" label=\"Open\" /> : when(row['closedAtMs']),\n },\n { field: 'openedByName', headerName: 'Opened by', minWidth: 130 },\n moneyColumn('openingFloatCents', 'Starting cash'),\n moneyColumn('netSalesCents', 'Net sales'),\n moneyColumn('expectedCashCents', 'Expected'),\n moneyColumn('countedCashCents', 'Counted'),\n {\n field: 'varianceCents',\n headerName: 'Variance',\n type: 'number',\n minWidth: 110,\n renderCell: ({ row }: { row: Record<string, any> }) =>\n row['varianceCents'] != null ? (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color={row['varianceCents'] === 0 ? 'success' : 'warning'}\n label={money(row['varianceCents'])}\n />\n ) : (\n '—'\n ),\n },\n ],\n [moneyColumn, money],\n )\n\n const rows = useMemo(\n () =>\n report\n ? {\n tenders: report.byTender.map((row) => ({ ...row, $id: row.method })),\n registers: report.byRegister.map((row) => ({ ...row, $id: row.registerId || 'none' })),\n cashiers: report.byCashier.map((row) => ({ ...row, $id: row.memberId || 'none' })),\n shifts: report.shifts.map((row) => ({ ...row, $id: `${row.registerId}/${row.shiftId}` })),\n }\n : null,\n [report],\n )\n\n const exportCsv = async () => {\n if (!user || !report) return\n setExporting(true)\n try {\n const response = await authorizedFetch(user as never, url('csv'), { method: 'GET' })\n if (!response.ok) {\n const body = (await response.json().catch(() => ({}))) as { error?: string }\n setAnswer({ state: 'error', error: body.error || 'The spreadsheet could not be made.' })\n return\n }\n const blob = new Blob([await response.text()], { type: 'text/csv;charset=utf-8' })\n const href = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = href\n link.download = `day-totals-${report.from}${report.to === report.from ? '' : `-to-${report.to}`}.csv`\n link.click()\n window.setTimeout(() => URL.revokeObjectURL(href), 1000)\n } finally {\n setExporting(false)\n }\n }\n\n const print = () => {\n if (!report) return\n printPosDocument(posDayReportDocument({ report }))\n }\n\n const lastDay = from?.isValid() ? from.add(POS_DAY_REPORT_MAX_DAYS - 1, 'day') : undefined\n\n return (\n <CardDisplay\n header={HEADER}\n help={HELP}\n HeaderProps={{\n action: (\n <Stack direction=\"row\" spacing={1}>\n <Button size=\"small\" onClick={() => void exportCsv()} disabled={!report || exporting}>\n {'Export CSV'}\n </Button>\n <Button size=\"small\" onClick={print} disabled={!report}>\n {'Print'}\n </Button>\n </Stack>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2.5}>\n {!canManagePos ? (\n <Alert severity=\"info\">\n {'Day totals are for members who can use the register: a site admin or editor with the \"Use the point of sale\" permission.'}\n </Alert>\n ) : null}\n <LocalizationProvider dateAdapter={AdapterDayjs}>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5} sx={{ alignItems: { sm: 'center' } }}>\n <DatePicker\n label=\"From\"\n value={from}\n onChange={(value) => {\n setFrom(value)\n if (value?.isValid() && to?.isValid() && (to.isBefore(value) || to.diff(value, 'day') >= POS_DAY_REPORT_MAX_DAYS)) {\n setTo(value)\n }\n }}\n disabled={!canManagePos}\n slotProps={{ textField: { size: 'small' } }}\n />\n <DatePicker\n label=\"To\"\n value={to}\n onChange={setTo}\n {...(from?.isValid() ? { minDate: from } : {})}\n {...(lastDay ? { maxDate: lastDay } : {})}\n disabled={!canManagePos}\n slotProps={{ textField: { size: 'small' } }}\n />\n <Button\n size=\"small\"\n disabled={!canManagePos || (!from && !to)}\n onClick={() => {\n setFrom(null)\n setTo(null)\n }}\n >\n {'Today'}\n </Button>\n </Stack>\n </LocalizationProvider>\n {answer.state === 'loading' ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Adding up every register…'}\n </Typography>\n ) : null}\n {answer.state === 'error' ? <Alert severity=\"warning\">{answer.error}</Alert> : null}\n {report && rows ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${posDayRangeLabel(report)} · ${report.timeZone} · every register and cashier`}\n </Typography>\n {report.truncated ? (\n <Alert severity=\"warning\">\n {'These days had more activity than one report reads; the figures are partial. Choose fewer days.'}\n </Alert>\n ) : null}\n {posDayReportIsEmpty(report) ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No register sales, returns or shifts on these days.'}\n </Typography>\n ) : (\n <>\n <Stack direction=\"row\" spacing={3} sx={{ flexWrap: 'wrap', rowGap: 1.5 }}>\n <CommerceStatTile label=\"Net sales\" value={money(report.totals.netSalesCents)} />\n <CommerceStatTile label=\"Gross sales\" value={money(report.totals.grossSalesCents)} />\n <CommerceStatTile label=\"Orders\" value={String(report.totals.orderCount)} />\n <CommerceStatTile label=\"Tips\" value={money(report.totals.tipsCents)} />\n <CommerceStatTile label=\"Tax\" value={money(report.totals.taxCents)} />\n <CommerceStatTile label=\"Discounts\" value={money(report.totals.discountsCents)} />\n <CommerceStatTile\n label={`Refunds (${report.totals.refundCount})`}\n value={money(report.totals.refundsCents)}\n />\n </Stack>\n <Section title=\"By tender\">\n <ListTable aria-label=\"Day totals by tender\" rows={rows.tenders} columns={tenderColumns} hideFooter noRowsLabel=\"No sales\" />\n </Section>\n <Section title=\"By register\">\n <ListTable aria-label=\"Day totals by register\" rows={rows.registers} columns={registerColumns} hideFooter noRowsLabel=\"No register sales\" />\n </Section>\n <Section title=\"By cashier\">\n <ListTable aria-label=\"Day totals by cashier\" rows={rows.cashiers} columns={cashierColumns} hideFooter noRowsLabel=\"No cashier sales\" />\n </Section>\n <Divider />\n <Section title=\"Cash drawers\">\n <DrawerRows report={report} money={money} />\n </Section>\n <Section title=\"Shifts\">\n {/* The one table that grows with the range: the grid pages it. */}\n <ListTable aria-label=\"Shifts on these days\" rows={rows.shifts} columns={shiftColumns} noRowsLabel=\"No shifts on these days\" />\n </Section>\n </>\n )}\n </>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n}\n\n/**\n * Day totals (AGL-4037): beside the shift history, for a store with a\n * register, on a plan with the point of sale.\n */\nexport function PosDayTotalsCard(props: PosDayTotalsCardProps) {\n const firestore = useFirestore()\n // Whether the store has a register at all: the first by id is enough to\n // answer, and an id order drops no register.\n const { data: registers, status } = useFirestoreCollection<any>(\n () =>\n query(collection(firestore, 'hosts', props.hostId, 'registers'), orderBy(documentId()), limit(1)),\n [firestore, props.hostId],\n { idField: '$id' },\n )\n if (status === 'success' && !registers?.length) return null\n return (\n <EntitlementGatedCard\n hostId={props.hostId}\n feature=\"pos\"\n header={HEADER}\n help={HELP}\n upsell={'Totals for a day or an event across every register, shift and cashier come with the point of sale.'}\n >\n <PosDayTotalsBody {...props} />\n </EntitlementGatedCard>\n )\n}\n\nPosDayTotalsCard.displayName = 'PosDayTotalsCard'\n\nexport default PosDayTotalsCard\n"],"names":["pluginDocsHelp","CardDisplay","ListTable","authorizedFetch","useFirestore","useFirestoreCollection","useUser","Alert","Button","Chip","Divider","Stack","Typography","AdapterDayjs","DatePicker","LocalizationProvider","collection","documentId","limit","orderBy","query","useCallback","useEffect","useMemo","useState","posDayRangeLabel","posDayReportIsEmpty","posDayReportSections","POS_DAY_REPORT_MAX_DAYS","POS_DAY_REPORT_ROUTE","formatReceiptMoney","escapeHtml","CommerceStatTile","EntitlementGatedCard","POS_RECEIPT_STYLES","printPosDocument","HEADER","HELP","anchor","DAY_FORMAT","when","ms","Date","toLocaleString","month","day","hour","minute","posDayReportDocument","input","money","cents","report","currency","body","map","section","toUpperCase","rows","row","strong","label","value","join","storeName","DrawerRows","props","drawers","find","spacing","direction","sx","justifyContent","gap","variant","color","fontVariantNumeric","Section","title","children","PosDayTotalsBody","hostId","canManagePos","data","user","from","setFrom","to","setTo","answer","setAnswer","state","exporting","setExporting","url","format","params","URLSearchParams","isValid","set","toString","live","response","method","json","catch","ok","error","moneyColumn","field","headerName","minWidth","type","flex","valueFormatter","tenderColumns","salesColumns","nameHeader","registerColumns","cashierColumns","shiftColumns","valueGetter","_value","Number","MAX_SAFE_INTEGER","renderCell","size","tenders","byTender","$id","registers","byRegister","registerId","cashiers","byCashier","memberId","shifts","shiftId","exportCsv","blob","Blob","text","href","URL","createObjectURL","link","document","createElement","download","click","window","setTimeout","revokeObjectURL","print","lastDay","add","undefined","header","help","HeaderProps","action","onClick","disabled","contentGutterX","contentGutterY","severity","dateAdapter","xs","sm","alignItems","onChange","isBefore","diff","slotProps","textField","minDate","maxDate","timeZone","truncated","flexWrap","rowGap","totals","netSalesCents","grossSalesCents","String","orderCount","tipsCents","taxCents","discountsCents","refundCount","refundsCents","aria-label","columns","hideFooter","noRowsLabel","PosDayTotalsCard","firestore","status","idField","length","feature","upsell","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,sBAAsB,EAAEC,OAAO,QAAQ,iCAAgC;AAC9F,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AAE/E,SAASC,YAAY,QAAQ,mCAAkC;AAC/D,SAASC,UAAU,QAAQ,iCAAgC;AAC3D,SAASC,oBAAoB,QAAQ,2CAA0C;AAE/E,SAASC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,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AMe,MAAM;QACpBuH,SAAQ;QACR3C,QAAQzH;QACR0H,MAAMzH;QACNoK,QAAQ;kBAER,cAAA,KAACzH,+BAAqBd;;AAG5B;AAEAiI,iBAAiBO,WAAW,GAAG;AAE/B,eAAeP,iBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-ops/pos-day-totals-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\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useFirestoreCollection, useUser } from '@aglyn/tenant-feature-instance'\nimport { Alert, Button, Chip, Divider, Stack, Typography } from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'\nimport { DatePicker } from '@mui/x-date-pickers/DatePicker'\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'\nimport type { Dayjs } from 'dayjs'\nimport { collection, documentId, limit, orderBy, query } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react'\nimport {\n posDayRangeLabel,\n posDayReportIsEmpty,\n posDayReportSections,\n POS_DAY_REPORT_MAX_DAYS,\n POS_DAY_REPORT_ROUTE,\n type PosDayReport,\n} from '../../../model/commerce-pos-day-report'\nimport { formatReceiptMoney } from '../../../model/commerce-receipt'\nimport { escapeHtml } from '../../../utils/escape-html'\nimport CommerceStatTile from '../commerce-stat-tile.component'\nimport { EntitlementGatedCard } from '../entitlement-gate.component'\nimport { POS_RECEIPT_STYLES } from './pos-receipt'\nimport { printPosDocument } from './pos-shift-report.component'\n\n/*==========================================\n * DAY TOTALS (AGL-4037): one day's or one event's sales across every\n * register, shift and cashier, from `GET /api/commerce/pos-day-report`.\n *\n * The figures are the server's: the card formats them and never sums them.\n * Every table holds a whole, bounded answer (seven tenders at most, the\n * site's registers, its staff, the range's shifts), so the grid sorts each\n * by any column itself.\n *=========================================*/\n\nexport interface PosDayTotalsCardProps {\n hostId: string\n /** The viewer may work the register: what the route's gate asks. */\n canManagePos?: boolean\n}\n\nconst HEADER = 'Day totals'\nconst HELP = pluginDocsHelp('posOperations', { anchor: '#day-and-event-totals' })\nconst DAY_FORMAT = 'YYYY-MM-DD'\n\ntype Answer =\n | { state: 'idle' | 'loading' }\n | { state: 'ready'; report: PosDayReport }\n | { state: 'error'; error: string }\n\n/** A time as the shifts table lists it, in the viewer's locale. */\nconst when = (ms?: number | null) =>\n ms\n ? new Date(ms).toLocaleString([], { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' })\n : ''\n\n/** The day totals as a printable 80 mm document, like the Z report. */\nexport function posDayReportDocument(input: { report: PosDayReport }): string {\n const money = (cents: number) => formatReceiptMoney(cents, input.report.currency)\n const body = posDayReportSections(input.report, money)\n .map(\n (section) =>\n `<hr class=\"rule\"><div class=\"title\">${escapeHtml(section.section.toUpperCase())}</div>` +\n section.rows\n .map(\n (row) =>\n `<div class=\"row${row.strong ? ' total' : ''}\"><span>${escapeHtml(row.label)}</span><span>${escapeHtml(row.value)}</span></div>`,\n )\n .join(''),\n )\n .join('')\n return (\n '<!doctype html><html><head><meta charset=\"utf-8\">' +\n `<title>DAY TOTALS</title><style>${POS_RECEIPT_STYLES}</style></head><body>` +\n `<div class=\"receipt\"><div class=\"center\"><div class=\"store\">${escapeHtml(input.report.storeName || 'Register')}</div>` +\n `<div class=\"title\">DAY TOTALS</div><div class=\"muted\">${escapeHtml(posDayRangeLabel(input.report))}</div></div>` +\n `${body}</div></body></html>`\n )\n}\n\nfunction DrawerRows(props: { report: PosDayReport; money: (cents: number) => string }) {\n const drawers = posDayReportSections(props.report, props.money).find((section) => section.section === 'Cash drawers')\n return (\n <Stack spacing={0.5}>\n {drawers?.rows.map((row) => (\n <Stack key={row.label} direction=\"row\" sx={{ justifyContent: 'space-between', gap: 2 }}>\n <Typography variant=\"body2\" color={row.strong ? 'text.primary' : 'text.secondary'}>\n {row.label}\n </Typography>\n <Typography variant={row.strong ? 'subtitle2' : 'body2'} sx={{ fontVariantNumeric: 'tabular-nums' }}>\n {row.value}\n </Typography>\n </Stack>\n ))}\n </Stack>\n )\n}\n\nfunction Section(props: { title: string; children: ReactNode }) {\n return (\n <Stack spacing={1}>\n <Typography variant=\"overline\">{props.title}</Typography>\n {props.children}\n </Stack>\n )\n}\n\nfunction PosDayTotalsBody(props: PosDayTotalsCardProps) {\n const { hostId, canManagePos = false } = props\n const { data: user } = useUser()\n const [from, setFrom] = useState<Dayjs | null>(null)\n const [to, setTo] = useState<Dayjs | null>(null)\n const [answer, setAnswer] = useState<Answer>({ state: 'idle' })\n const [exporting, setExporting] = useState(false)\n\n const url = useCallback(\n (format?: 'csv') => {\n const params = new URLSearchParams({ hostId })\n if (from?.isValid()) params.set('from', from.format(DAY_FORMAT))\n if (to?.isValid()) params.set('to', to.format(DAY_FORMAT))\n if (format) params.set('format', format)\n return `${POS_DAY_REPORT_ROUTE}?${params.toString()}`\n },\n [hostId, from, to],\n )\n\n useEffect(() => {\n if (!user || !canManagePos) return\n let live = true\n setAnswer({ state: 'loading' })\n void (async () => {\n try {\n const response = await authorizedFetch(user as never, url(), { method: 'GET' })\n const body = (await response.json().catch(() => ({}))) as { report?: PosDayReport; error?: string }\n if (!live) return\n setAnswer(\n response.ok && body.report\n ? { state: 'ready', report: body.report }\n : { state: 'error', error: body.error || 'The day totals could not be read.' },\n )\n } catch {\n if (live) setAnswer({ state: 'error', error: 'The day totals could not be read. Check the connection.' })\n }\n })()\n return () => {\n live = false\n }\n }, [user, canManagePos, url])\n\n const report = answer.state === 'ready' ? answer.report : null\n const money = useCallback((cents: number) => formatReceiptMoney(cents, report?.currency ?? 'usd'), [report?.currency])\n const moneyColumn = useCallback(\n (field: string, headerName: string, minWidth = 110): GridColDef => ({\n field,\n headerName,\n type: 'number',\n minWidth,\n flex: 1,\n valueFormatter: (value: number | null | undefined) => (value == null ? '—' : money(value)),\n }),\n [money],\n )\n\n const tenderColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'label', headerName: 'Tender', flex: 1, minWidth: 140 },\n moneyColumn('salesCents', 'Sales'),\n moneyColumn('refundsCents', 'Refunds'),\n moneyColumn('netCents', 'Net'),\n ],\n [moneyColumn],\n )\n const salesColumns = useCallback(\n (nameHeader: string): GridColDef[] => [\n { field: 'name', headerName: nameHeader, flex: 1, minWidth: 140 },\n { field: 'orderCount', headerName: 'Orders', type: 'number', minWidth: 90 },\n moneyColumn('grossSalesCents', 'Gross sales'),\n moneyColumn('tipsCents', 'Tips', 90),\n moneyColumn('refundsCents', 'Refunds'),\n moneyColumn('netSalesCents', 'Net sales'),\n ],\n [moneyColumn],\n )\n const registerColumns = useMemo(() => salesColumns('Register'), [salesColumns])\n const cashierColumns = useMemo(() => salesColumns('Cashier'), [salesColumns])\n const shiftColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'registerName', headerName: 'Register', minWidth: 120, flex: 1 },\n {\n field: 'openedAtMs',\n headerName: 'Opened',\n minWidth: 140,\n valueFormatter: (value: number) => when(value),\n },\n {\n field: 'closedAtMs',\n headerName: 'Closed',\n minWidth: 140,\n // Open shifts sort after every closed one, by when they opened.\n valueGetter: (_value: unknown, row: Record<string, any>) =>\n row['closedAtMs'] ?? Number.MAX_SAFE_INTEGER - (row['openedAtMs'] ?? 0),\n renderCell: ({ row }: { row: Record<string, any> }) =>\n row['status'] === 'open' ? <Chip size=\"small\" color=\"success\" label=\"Open\" /> : when(row['closedAtMs']),\n },\n { field: 'openedByName', headerName: 'Opened by', minWidth: 130 },\n moneyColumn('openingFloatCents', 'Starting cash'),\n moneyColumn('netSalesCents', 'Net sales'),\n moneyColumn('expectedCashCents', 'Expected'),\n moneyColumn('countedCashCents', 'Counted'),\n {\n field: 'varianceCents',\n headerName: 'Variance',\n type: 'number',\n minWidth: 110,\n renderCell: ({ row }: { row: Record<string, any> }) =>\n row['varianceCents'] != null ? (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color={row['varianceCents'] === 0 ? 'success' : 'warning'}\n label={money(row['varianceCents'])}\n />\n ) : (\n '—'\n ),\n },\n ],\n [moneyColumn, money],\n )\n\n const rows = useMemo(\n () =>\n report\n ? {\n tenders: report.byTender.map((row) => ({ ...row, $id: row.method })),\n registers: report.byRegister.map((row) => ({ ...row, $id: row.registerId || 'none' })),\n cashiers: report.byCashier.map((row) => ({ ...row, $id: row.memberId || 'none' })),\n shifts: report.shifts.map((row) => ({ ...row, $id: `${row.registerId}/${row.shiftId}` })),\n }\n : null,\n [report],\n )\n\n const exportCsv = async () => {\n if (!user || !report) return\n setExporting(true)\n try {\n const response = await authorizedFetch(user as never, url('csv'), { method: 'GET' })\n if (!response.ok) {\n const body = (await response.json().catch(() => ({}))) as { error?: string }\n setAnswer({ state: 'error', error: body.error || 'The spreadsheet could not be made.' })\n return\n }\n const blob = new Blob([await response.text()], { type: 'text/csv;charset=utf-8' })\n const href = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = href\n link.download = `day-totals-${report.from}${report.to === report.from ? '' : `-to-${report.to}`}.csv`\n link.click()\n window.setTimeout(() => URL.revokeObjectURL(href), 1000)\n } finally {\n setExporting(false)\n }\n }\n\n const print = () => {\n if (!report) return\n printPosDocument(posDayReportDocument({ report }))\n }\n\n const lastDay = from?.isValid() ? from.add(POS_DAY_REPORT_MAX_DAYS - 1, 'day') : undefined\n\n return (\n <CardDisplay\n header={HEADER}\n help={HELP}\n HeaderProps={{\n action: (\n <Stack direction=\"row\" spacing={1}>\n <Button size=\"small\" onClick={() => void exportCsv()} disabled={!report || exporting}>\n {'Export CSV'}\n </Button>\n <Button size=\"small\" onClick={print} disabled={!report}>\n {'Print'}\n </Button>\n </Stack>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2.5}>\n {!canManagePos ? (\n <Alert severity=\"info\">\n {'Day totals take the \"Use the point of sale\" permission, which site admins and editors hold by default.'}\n </Alert>\n ) : null}\n <LocalizationProvider dateAdapter={AdapterDayjs}>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5} sx={{ alignItems: { sm: 'center' } }}>\n <DatePicker\n label=\"From\"\n value={from}\n onChange={(value) => {\n setFrom(value)\n if (value?.isValid() && to?.isValid() && (to.isBefore(value) || to.diff(value, 'day') >= POS_DAY_REPORT_MAX_DAYS)) {\n setTo(value)\n }\n }}\n disabled={!canManagePos}\n slotProps={{ textField: { size: 'small' } }}\n />\n <DatePicker\n label=\"To\"\n value={to}\n onChange={setTo}\n {...(from?.isValid() ? { minDate: from } : {})}\n {...(lastDay ? { maxDate: lastDay } : {})}\n disabled={!canManagePos}\n slotProps={{ textField: { size: 'small' } }}\n />\n <Button\n size=\"small\"\n disabled={!canManagePos || (!from && !to)}\n onClick={() => {\n setFrom(null)\n setTo(null)\n }}\n >\n {'Today'}\n </Button>\n </Stack>\n </LocalizationProvider>\n {answer.state === 'loading' ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Adding up every register…'}\n </Typography>\n ) : null}\n {answer.state === 'error' ? <Alert severity=\"warning\">{answer.error}</Alert> : null}\n {report && rows ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${posDayRangeLabel(report)} · ${report.timeZone} · every register and cashier`}\n </Typography>\n {report.truncated ? (\n <Alert severity=\"warning\">\n {'These days had more activity than one report reads; the figures are partial. Choose fewer days.'}\n </Alert>\n ) : null}\n {posDayReportIsEmpty(report) ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No register sales, returns or shifts on these days.'}\n </Typography>\n ) : (\n <>\n <Stack direction=\"row\" spacing={3} sx={{ flexWrap: 'wrap', rowGap: 1.5 }}>\n <CommerceStatTile label=\"Net sales\" value={money(report.totals.netSalesCents)} />\n <CommerceStatTile label=\"Gross sales\" value={money(report.totals.grossSalesCents)} />\n <CommerceStatTile label=\"Orders\" value={String(report.totals.orderCount)} />\n <CommerceStatTile label=\"Tips\" value={money(report.totals.tipsCents)} />\n <CommerceStatTile label=\"Tax\" value={money(report.totals.taxCents)} />\n <CommerceStatTile label=\"Discounts\" value={money(report.totals.discountsCents)} />\n <CommerceStatTile\n label={`Refunds (${report.totals.refundCount})`}\n value={money(report.totals.refundsCents)}\n />\n </Stack>\n <Section title=\"By tender\">\n <ListTable aria-label=\"Day totals by tender\" rows={rows.tenders} columns={tenderColumns} hideFooter noRowsLabel=\"No sales\" />\n </Section>\n <Section title=\"By register\">\n <ListTable aria-label=\"Day totals by register\" rows={rows.registers} columns={registerColumns} hideFooter noRowsLabel=\"No register sales\" />\n </Section>\n <Section title=\"By cashier\">\n <ListTable aria-label=\"Day totals by cashier\" rows={rows.cashiers} columns={cashierColumns} hideFooter noRowsLabel=\"No cashier sales\" />\n </Section>\n <Divider />\n <Section title=\"Cash drawers\">\n <DrawerRows report={report} money={money} />\n </Section>\n <Section title=\"Shifts\">\n {/* The one table that grows with the range: the grid pages it. */}\n <ListTable aria-label=\"Shifts on these days\" rows={rows.shifts} columns={shiftColumns} noRowsLabel=\"No shifts on these days\" />\n </Section>\n </>\n )}\n </>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n}\n\n/**\n * Day totals (AGL-4037): beside the shift history, for a store with a\n * register, on a plan with the point of sale.\n */\nexport function PosDayTotalsCard(props: PosDayTotalsCardProps) {\n const firestore = useFirestore()\n // Whether the store has a register at all: the first by id is enough to\n // answer, and an id order drops no register.\n const { data: registers, status } = useFirestoreCollection<any>(\n () =>\n query(collection(firestore, 'hosts', props.hostId, 'registers'), orderBy(documentId()), limit(1)),\n [firestore, props.hostId],\n { idField: '$id' },\n )\n if (status === 'success' && !registers?.length) return null\n return (\n <EntitlementGatedCard\n hostId={props.hostId}\n feature=\"pos\"\n header={HEADER}\n help={HELP}\n upsell={'Totals for a day or an event across every register, shift and cashier come with the point of sale.'}\n >\n <PosDayTotalsBody {...props} />\n </EntitlementGatedCard>\n )\n}\n\nPosDayTotalsCard.displayName = 'PosDayTotalsCard'\n\nexport default PosDayTotalsCard\n"],"names":["pluginDocsHelp","CardDisplay","ListTable","authorizedFetch","useFirestore","useFirestoreCollection","useUser","Alert","Button","Chip","Divider","Stack","Typography","AdapterDayjs","DatePicker","LocalizationProvider","collection","documentId","limit","orderBy","query","useCallback","useEffect","useMemo","useState","posDayRangeLabel","posDayReportIsEmpty","posDayReportSections","POS_DAY_REPORT_MAX_DAYS","POS_DAY_REPORT_ROUTE","formatReceiptMoney","escapeHtml","CommerceStatTile","EntitlementGatedCard","POS_RECEIPT_STYLES","printPosDocument","HEADER","HELP","anchor","DAY_FORMAT","when","ms","Date","toLocaleString","month","day","hour","minute","posDayReportDocument","input","money","cents","report","currency","body","map","section","toUpperCase","rows","row","strong","label","value","join","storeName","DrawerRows","props","drawers","find","spacing","direction","sx","justifyContent","gap","variant","color","fontVariantNumeric","Section","title","children","PosDayTotalsBody","hostId","canManagePos","data","user","from","setFrom","to","setTo","answer","setAnswer","state","exporting","setExporting","url","format","params","URLSearchParams","isValid","set","toString","live","response","method","json","catch","ok","error","moneyColumn","field","headerName","minWidth","type","flex","valueFormatter","tenderColumns","salesColumns","nameHeader","registerColumns","cashierColumns","shiftColumns","valueGetter","_value","Number","MAX_SAFE_INTEGER","renderCell","size","tenders","byTender","$id","registers","byRegister","registerId","cashiers","byCashier","memberId","shifts","shiftId","exportCsv","blob","Blob","text","href","URL","createObjectURL","link","document","createElement","download","click","window","setTimeout","revokeObjectURL","print","lastDay","add","undefined","header","help","HeaderProps","action","onClick","disabled","contentGutterX","contentGutterY","severity","dateAdapter","xs","sm","alignItems","onChange","isBefore","diff","slotProps","textField","minDate","maxDate","timeZone","truncated","flexWrap","rowGap","totals","netSalesCents","grossSalesCents","String","orderCount","tipsCents","taxCents","discountsCents","refundCount","refundsCents","aria-label","columns","hideFooter","noRowsLabel","PosDayTotalsCard","firestore","status","idField","length","feature","upsell","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,sBAAsB,EAAEC,OAAO,QAAQ,iCAAgC;AAC9F,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AAE/E,SAASC,YAAY,QAAQ,mCAAkC;AAC/D,SAASC,UAAU,QAAQ,iCAAgC;AAC3D,SAASC,oBAAoB,QAAQ,2CAA0C;AAE/E,SAASC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,QAAQ,qBAAoB;AAClF,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAwB,QAAO;AACjF,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,oBAAoB,EACpBC,uBAAuB,EACvBC,oBAAoB,QAEf,4CAAwC;AAC/C,SAASC,kBAAkB,QAAQ,qCAAiC;AACpE,SAASC,UAAU,QAAQ,gCAA4B;AACvD,OAAOC,sBAAsB,qCAAiC;AAC9D,SAASC,oBAAoB,QAAQ,mCAA+B;AACpE,SAASC,kBAAkB,QAAQ,mBAAe;AAClD,SAASC,gBAAgB,QAAQ,kCAA8B;AAkB/D,MAAMC,SAAS;AACf,MAAMC,OAAOrC,eAAe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A,KAAC5E;wCAAU6L,cAAW;wCAAwBrI,MAAMA,KAAK2E,QAAQ;wCAAE2D,SAASzE;wCAAgB0E,UAAU;wCAACC,aAAY;;;8CAErH,KAACxL;8CACD,KAACmE;oCAAQC,OAAM;8CACb,cAAA,KAACb;wCAAWb,QAAQA;wCAAQF,OAAOA;;;8CAErC,KAAC2B;oCAAQC,OAAM;8CAEb,cAAA,KAAC5E;wCAAU6L,cAAW;wCAAuBrI,MAAMA,KAAK8E,MAAM;wCAAEwD,SAASxE;wCAAc0E,aAAY;;;;;;qBAKzG;;;;AAIZ;AAEA;;;CAGC,GACD,OAAO,SAASC,iBAAiBjI,KAA4B;IAC3D,MAAMkI,YAAYhM;IAClB,wEAAwE;IACxE,6CAA6C;IAC7C,MAAM,EAAE+E,MAAM+C,SAAS,EAAEmE,MAAM,EAAE,GAAGhM,uBAClC,IACEe,MAAMJ,WAAWoL,WAAW,SAASlI,MAAMe,MAAM,EAAE,cAAc9D,QAAQF,eAAeC,MAAM,KAChG;QAACkL;QAAWlI,MAAMe,MAAM;KAAC,EACzB;QAAEqH,SAAS;IAAM;IAEnB,IAAID,WAAW,aAAa,EAACnE,6BAAAA,UAAWqE,MAAM,GAAE,OAAO;IACvD,qBACE,KAACtK;QACCgD,QAAQf,MAAMe,MAAM;QACpBuH,SAAQ;QACR3C,QAAQzH;QACR0H,MAAMzH;QACNoK,QAAQ;kBAER,cAAA,KAACzH,+BAAqBd;;AAG5B;AAEAiI,iBAAiBO,WAAW,GAAG;AAE/B,eAAeP,iBAAgB"}
|
|
@@ -35,7 +35,7 @@ import { PosReaderSplashRequestError, readerSplashStatus, saveReaderSplash } fro
|
|
|
35
35
|
image.src = src;
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
const NOT_ALLOWED = '
|
|
38
|
+
const NOT_ALLOWED = 'Changing the readers takes the "Registers and devices" permission, which site admins and editors hold by default.';
|
|
39
39
|
/**
|
|
40
40
|
* "Reader start-up screen" on the POS devices card (AGL-4048): what the
|
|
41
41
|
* store's Stripe smart readers show while they wait for a payment. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-reader-splash-setting.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 { useMediaPicker, type PickedMedia } from '@aglyn/aglyn/app-utils/media-picker-context'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useConsoleHostRoute, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n FormControlLabel,\n Radio,\n RadioGroup,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useState } from 'react'\nimport {\n POS_READER_SPLASH_LARGEST,\n posReaderSplashArtworkProblem,\n type PosReaderSplashChoice,\n type PosReaderSplashStatus,\n} from '../../model/pos-reader-splash'\nimport {\n PosReaderSplashRequestError,\n readerSplashStatus,\n saveReaderSplash,\n} from './pos/pos-reader-splash-api'\n\nexport interface PosReaderSplashSettingProps {\n hostId: string\n /** Whether the viewer may change the site's readers (`managePos`, admin or editor). */\n canManagePos: boolean\n}\n\n/** An image's pixel size, read in the browser before anything is saved. */\nfunction imageSize(src: string): Promise<{ width: number; height: number } | null> {\n return new Promise((resolve) => {\n const image = new Image()\n image.onload = () => resolve({ width: image.naturalWidth, height: image.naturalHeight })\n image.onerror = () => resolve(null)\n image.src = src\n })\n}\n\nconst NOT_ALLOWED =\n 'Only an admin or editor with the \"Registers and devices\" point of sale permission can change the readers.'\n\n/**\n * \"Reader start-up screen\" on the POS devices card (AGL-4048): what the\n * store's Stripe smart readers show while they wait for a payment. The\n * platform's default screen, the workspace's logo on a white screen, or a\n * full-screen portrait image from the media library. A white-label\n * workspace is never offered the platform's screen and shows its own logo\n * unless it picks an image.\n *\n * The server applies the choice to the store's readers when it is saved\n * (and again when this opens and finds the logo changed since); readers\n * pick it up within about ten minutes.\n */\nexport function PosReaderSplashSetting({ hostId, canManagePos }: PosReaderSplashSettingProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { pickMedia } = useMediaPicker()\n const { orgSlug } = useConsoleHostRoute(hostId)\n const [status, setStatus] = useState<PosReaderSplashStatus | null>(null)\n const [busy, setBusy] = useState(false)\n const [picked, setPicked] = useState<PickedMedia | null>(null)\n const uid = user?.uid ?? ''\n\n useEffect(() => {\n if (!user) return\n let active = true\n readerSplashStatus(user, hostId)\n .then((answer) => {\n if (active) setStatus(answer)\n })\n .catch(() => {\n if (active) setStatus(null)\n })\n return () => {\n active = false\n }\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 save = useCallback(\n async (choice: PosReaderSplashChoice, image?: { mediaScope: string; mediaId: string }) => {\n if (!user) return\n setBusy(true)\n try {\n const answer = await saveReaderSplash(user, hostId, choice, image)\n setStatus(answer)\n if (!answer.problem) {\n enqueueSnackbar(\n answer.locationReady\n ? 'Saved. Your readers show it within about ten minutes.'\n : 'Saved. Your readers show it once you add one.',\n { variant: 'success', persist: false },\n )\n }\n } catch (error) {\n enqueueSnackbar(\n error instanceof PosReaderSplashRequestError ? error.message : 'The start-up screen could not be saved',\n { variant: 'warning', persist: false },\n )\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, enqueueSnackbar],\n )\n\n const chooseImage = async () => {\n const media = await pickMedia?.({ kind: 'image' })\n if (!media) return\n if (!media.mediaId || !media.mediaScope) {\n enqueueSnackbar('Choose an image from your media library.', { variant: 'warning', persist: false })\n return\n }\n const size = await imageSize(media.url)\n const problem = posReaderSplashArtworkProblem({\n contentType: media.contentType ?? null,\n width: size?.width ?? 0,\n height: size?.height ?? 0,\n })\n if (problem) {\n enqueueSnackbar(problem, { variant: 'warning', persist: false })\n return\n }\n setPicked(media)\n await save('image', { mediaScope: media.mediaScope, mediaId: media.mediaId })\n }\n\n if (!status?.available) return null\n\n const blockedReason = !canManagePos ? NOT_ALLOWED : busy ? 'Saving…' : null\n const hasLogo = Boolean(status.logoUrl)\n const profileHref = orgSlug ? `/${orgSlug}/settings/profile` : undefined\n const brand = status.productName\n const preview =\n status.effectiveChoice === 'logo' ? status.logoUrl : status.effectiveChoice === 'image' ? (picked?.url ?? status.image?.url ?? null) : null\n\n return (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Reader start-up screen'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'What your card readers show while they wait for a payment.'}\n </Typography>\n <RadioGroup\n value={status.effectiveChoice}\n onChange={(event) => {\n const choice = event.target.value as PosReaderSplashChoice\n if (choice === 'image') {\n if (status.image) void save('image', { mediaScope: status.image.mediaScope, mediaId: status.image.mediaId })\n else void chooseImage()\n return\n }\n void save(choice)\n }}\n >\n {status.whiteLabel ? null : (\n <FormControlLabel\n value=\"platform\"\n disabled={Boolean(blockedReason)}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{`The ${brand} start-up screen`}</Typography>\n {status.platformReady ? null : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Until it is ready, your readers show their standard screen.'}\n </Typography>\n )}\n </Stack>\n }\n />\n )}\n <FormControlLabel\n value=\"logo\"\n disabled={Boolean(blockedReason) || !hasLogo}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{'Your logo'}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Your organization profile’s logo, centered on a white screen.'}\n </Typography>\n </Stack>\n }\n />\n <FormControlLabel\n value=\"image\"\n disabled={Boolean(blockedReason)}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{'Your own image'}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`A full-screen portrait image from your media library, at least ${POS_READER_SPLASH_LARGEST.width} × ${POS_READER_SPLASH_LARGEST.height} pixels.`}\n </Typography>\n </Stack>\n }\n />\n </RadioGroup>\n {hasLogo ? null : (\n <PrerequisiteNotice\n href={profileHref}\n actionLabel=\"Organization profile\"\n severity={status.effectiveChoice === 'logo' ? 'warning' : 'info'}\n >\n {'Add a logo to your organization profile to show it on your card readers.'}\n </PrerequisiteNotice>\n )}\n {status.effectiveChoice === 'image' ? (\n <Box>\n <BlockedControl blocked={Boolean(blockedReason)} reason={blockedReason ?? ''}>\n <Button size=\"small\" onClick={() => void chooseImage()}>\n {status.image ? 'Choose another image' : 'Choose image'}\n </Button>\n </BlockedControl>\n </Box>\n ) : null}\n {preview ? (\n <Box\n component=\"img\"\n src={preview}\n alt=\"\"\n sx={(theme) => ({\n alignSelf: 'flex-start',\n maxWidth: theme.spacing(16),\n maxHeight: theme.spacing(16),\n objectFit: 'contain',\n borderRadius: 1,\n border: 1,\n borderColor: 'divider',\n })}\n />\n ) : null}\n {status.problem && !(status.effectiveChoice === 'logo' && !hasLogo) ? (\n <Alert severity=\"warning\">{status.problem}</Alert>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {!status.locationReady\n ? 'Your readers show it once you add your first one.'\n : status.appliedAtMs\n ? `Sent to your readers ${new Date(status.appliedAtMs).toLocaleString()}. Readers update within about ten minutes.`\n : 'Readers update within about ten minutes of a change.'}\n </Typography>\n )}\n </Stack>\n )\n}\nPosReaderSplashSetting.displayName = 'PosReaderSplashSetting'\n\nexport default PosReaderSplashSetting\n"],"names":["useMediaPicker","BlockedControl","PrerequisiteNotice","useSnackbar","useConsoleHostRoute","useUser","Alert","Box","Button","FormControlLabel","Radio","RadioGroup","Stack","Typography","useCallback","useEffect","useState","POS_READER_SPLASH_LARGEST","posReaderSplashArtworkProblem","PosReaderSplashRequestError","readerSplashStatus","saveReaderSplash","imageSize","src","Promise","resolve","image","Image","onload","width","naturalWidth","height","naturalHeight","onerror","NOT_ALLOWED","PosReaderSplashSetting","hostId","canManagePos","picked","status","data","user","enqueueSnackbar","pickMedia","orgSlug","setStatus","busy","setBusy","setPicked","uid","active","then","answer","catch","save","choice","problem","locationReady","variant","persist","error","message","chooseImage","media","kind","mediaId","mediaScope","size","url","contentType","available","blockedReason","hasLogo","Boolean","logoUrl","profileHref","undefined","brand","productName","preview","effectiveChoice","spacing","color","value","onChange","event","target","whiteLabel","disabled","control","label","platformReady","href","actionLabel","severity","blocked","reason","onClick","component","alt","sx","theme","alignSelf","maxWidth","maxHeight","objectFit","borderRadius","border","borderColor","appliedAtMs","Date","toLocaleString","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,cAAc,QAA0B,8CAA6C;AAC9F,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,mBAAmB,EAAEC,OAAO,QAAQ,iCAAgC;AAC7E,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,EACLC,UAAU,EACVC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxD,SACEC,yBAAyB,EACzBC,6BAA6B,QAGxB,mCAA+B;AACtC,SACEC,2BAA2B,EAC3BC,kBAAkB,EAClBC,gBAAgB,QACX,iCAA6B;AAQpC,yEAAyE,GACzE,SAASC,UAAUC,GAAW;IAC5B,OAAO,IAAIC,QAAQ,CAACC;QAClB,M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G,0CAA0C,CAAC,GACjH;;;;AAKhB;AACA5E,uBAAuB6E,WAAW,GAAG;AAErC,eAAe7E,uBAAsB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-reader-splash-setting.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 { useMediaPicker, type PickedMedia } from '@aglyn/aglyn/app-utils/media-picker-context'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useConsoleHostRoute, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n FormControlLabel,\n Radio,\n RadioGroup,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useState } from 'react'\nimport {\n POS_READER_SPLASH_LARGEST,\n posReaderSplashArtworkProblem,\n type PosReaderSplashChoice,\n type PosReaderSplashStatus,\n} from '../../model/pos-reader-splash'\nimport {\n PosReaderSplashRequestError,\n readerSplashStatus,\n saveReaderSplash,\n} from './pos/pos-reader-splash-api'\n\nexport interface PosReaderSplashSettingProps {\n hostId: string\n /** Whether the viewer may change the site's readers (`managePos`, admin or editor). */\n canManagePos: boolean\n}\n\n/** An image's pixel size, read in the browser before anything is saved. */\nfunction imageSize(src: string): Promise<{ width: number; height: number } | null> {\n return new Promise((resolve) => {\n const image = new Image()\n image.onload = () => resolve({ width: image.naturalWidth, height: image.naturalHeight })\n image.onerror = () => resolve(null)\n image.src = src\n })\n}\n\nconst NOT_ALLOWED =\n 'Changing the readers takes the \"Registers and devices\" permission, which site admins and editors hold by default.'\n\n/**\n * \"Reader start-up screen\" on the POS devices card (AGL-4048): what the\n * store's Stripe smart readers show while they wait for a payment. The\n * platform's default screen, the workspace's logo on a white screen, or a\n * full-screen portrait image from the media library. A white-label\n * workspace is never offered the platform's screen and shows its own logo\n * unless it picks an image.\n *\n * The server applies the choice to the store's readers when it is saved\n * (and again when this opens and finds the logo changed since); readers\n * pick it up within about ten minutes.\n */\nexport function PosReaderSplashSetting({ hostId, canManagePos }: PosReaderSplashSettingProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { pickMedia } = useMediaPicker()\n const { orgSlug } = useConsoleHostRoute(hostId)\n const [status, setStatus] = useState<PosReaderSplashStatus | null>(null)\n const [busy, setBusy] = useState(false)\n const [picked, setPicked] = useState<PickedMedia | null>(null)\n const uid = user?.uid ?? ''\n\n useEffect(() => {\n if (!user) return\n let active = true\n readerSplashStatus(user, hostId)\n .then((answer) => {\n if (active) setStatus(answer)\n })\n .catch(() => {\n if (active) setStatus(null)\n })\n return () => {\n active = false\n }\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 save = useCallback(\n async (choice: PosReaderSplashChoice, image?: { mediaScope: string; mediaId: string }) => {\n if (!user) return\n setBusy(true)\n try {\n const answer = await saveReaderSplash(user, hostId, choice, image)\n setStatus(answer)\n if (!answer.problem) {\n enqueueSnackbar(\n answer.locationReady\n ? 'Saved. Your readers show it within about ten minutes.'\n : 'Saved. Your readers show it once you add one.',\n { variant: 'success', persist: false },\n )\n }\n } catch (error) {\n enqueueSnackbar(\n error instanceof PosReaderSplashRequestError ? error.message : 'The start-up screen could not be saved',\n { variant: 'warning', persist: false },\n )\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, enqueueSnackbar],\n )\n\n const chooseImage = async () => {\n const media = await pickMedia?.({ kind: 'image' })\n if (!media) return\n if (!media.mediaId || !media.mediaScope) {\n enqueueSnackbar('Choose an image from your media library.', { variant: 'warning', persist: false })\n return\n }\n const size = await imageSize(media.url)\n const problem = posReaderSplashArtworkProblem({\n contentType: media.contentType ?? null,\n width: size?.width ?? 0,\n height: size?.height ?? 0,\n })\n if (problem) {\n enqueueSnackbar(problem, { variant: 'warning', persist: false })\n return\n }\n setPicked(media)\n await save('image', { mediaScope: media.mediaScope, mediaId: media.mediaId })\n }\n\n if (!status?.available) return null\n\n const blockedReason = !canManagePos ? NOT_ALLOWED : busy ? 'Saving…' : null\n const hasLogo = Boolean(status.logoUrl)\n const profileHref = orgSlug ? `/${orgSlug}/settings/profile` : undefined\n const brand = status.productName\n const preview =\n status.effectiveChoice === 'logo' ? status.logoUrl : status.effectiveChoice === 'image' ? (picked?.url ?? status.image?.url ?? null) : null\n\n return (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Reader start-up screen'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'What your card readers show while they wait for a payment.'}\n </Typography>\n <RadioGroup\n value={status.effectiveChoice}\n onChange={(event) => {\n const choice = event.target.value as PosReaderSplashChoice\n if (choice === 'image') {\n if (status.image) void save('image', { mediaScope: status.image.mediaScope, mediaId: status.image.mediaId })\n else void chooseImage()\n return\n }\n void save(choice)\n }}\n >\n {status.whiteLabel ? null : (\n <FormControlLabel\n value=\"platform\"\n disabled={Boolean(blockedReason)}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{`The ${brand} start-up screen`}</Typography>\n {status.platformReady ? null : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Until it is ready, your readers show their standard screen.'}\n </Typography>\n )}\n </Stack>\n }\n />\n )}\n <FormControlLabel\n value=\"logo\"\n disabled={Boolean(blockedReason) || !hasLogo}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{'Your logo'}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Your organization profile’s logo, centered on a white screen.'}\n </Typography>\n </Stack>\n }\n />\n <FormControlLabel\n value=\"image\"\n disabled={Boolean(blockedReason)}\n control={<Radio size=\"small\" />}\n label={\n <Stack>\n <Typography variant=\"body2\">{'Your own image'}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`A full-screen portrait image from your media library, at least ${POS_READER_SPLASH_LARGEST.width} × ${POS_READER_SPLASH_LARGEST.height} pixels.`}\n </Typography>\n </Stack>\n }\n />\n </RadioGroup>\n {hasLogo ? null : (\n <PrerequisiteNotice\n href={profileHref}\n actionLabel=\"Organization profile\"\n severity={status.effectiveChoice === 'logo' ? 'warning' : 'info'}\n >\n {'Add a logo to your organization profile to show it on your card readers.'}\n </PrerequisiteNotice>\n )}\n {status.effectiveChoice === 'image' ? (\n <Box>\n <BlockedControl blocked={Boolean(blockedReason)} reason={blockedReason ?? ''}>\n <Button size=\"small\" onClick={() => void chooseImage()}>\n {status.image ? 'Choose another image' : 'Choose image'}\n </Button>\n </BlockedControl>\n </Box>\n ) : null}\n {preview ? (\n <Box\n component=\"img\"\n src={preview}\n alt=\"\"\n sx={(theme) => ({\n alignSelf: 'flex-start',\n maxWidth: theme.spacing(16),\n maxHeight: theme.spacing(16),\n objectFit: 'contain',\n borderRadius: 1,\n border: 1,\n borderColor: 'divider',\n })}\n />\n ) : null}\n {status.problem && !(status.effectiveChoice === 'logo' && !hasLogo) ? (\n <Alert severity=\"warning\">{status.problem}</Alert>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {!status.locationReady\n ? 'Your readers show it once you add your first one.'\n : status.appliedAtMs\n ? `Sent to your readers ${new Date(status.appliedAtMs).toLocaleString()}. Readers update within about ten minutes.`\n : 'Readers update within about ten minutes of a change.'}\n </Typography>\n )}\n </Stack>\n )\n}\nPosReaderSplashSetting.displayName = 'PosReaderSplashSetting'\n\nexport default PosReaderSplashSetting\n"],"names":["useMediaPicker","BlockedControl","PrerequisiteNotice","useSnackbar","useConsoleHostRoute","useUser","Alert","Box","Button","FormControlLabel","Radio","RadioGroup","Stack","Typography","useCallback","useEffect","useState","POS_READER_SPLASH_LARGEST","posReaderSplashArtworkProblem","PosReaderSplashRequestError","readerSplashStatus","saveReaderSplash","imageSize","src","Promise","resolve","image","Image","onload","width","naturalWidth","height","naturalHeight","onerror","NOT_ALLOWED","PosReaderSplashSetting","hostId","canManagePos","picked","status","data","user","enqueueSnackbar","pickMedia","orgSlug","setStatus","busy","setBusy","setPicked","uid","active","then","answer","catch","save","choice","problem","locationReady","variant","persist","error","message","chooseImage","media","kind","mediaId","mediaScope","size","url","contentType","available","blockedReason","hasLogo","Boolean","logoUrl","profileHref","undefined","brand","productName","preview","effectiveChoice","spacing","color","value","onChange","event","target","whiteLabel","disabled","control","label","platformReady","href","actionLabel","severity","blocked","reason","onClick","component","alt","sx","theme","alignSelf","maxWidth","maxHeight","objectFit","borderRadius","border","borderColor","appliedAtMs","Date","toLocaleString","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,cAAc,QAA0B,8CAA6C;AAC9F,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,mBAAmB,EAAEC,OAAO,QAAQ,iCAAgC;AAC7E,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,EACLC,UAAU,EACVC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxD,SACEC,yBAAyB,EACzBC,6BAA6B,QAGxB,mCAA+B;AACtC,SACEC,2BAA2B,EAC3BC,kBAAkB,EAClBC,gBAAgB,QACX,iCAA6B;AAQpC,yEAAyE,GACzE,SAASC,UAAUC,GAAW;IAC5B,OAAO,I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sE,WAAW,EAAEE,cAAc,GAAG,0CAA0C,CAAC,GACjH;;;;AAKhB;AACA5E,uBAAuB6E,WAAW,GAAG;AAErC,eAAe7E,uBAAsB"}
|
|
@@ -13,8 +13,6 @@ export interface ProductAddOnsFieldsProps {
|
|
|
13
13
|
* option a product varies by ("Price by size"), else by variant.
|
|
14
14
|
*/
|
|
15
15
|
export declare function priceByLabel(options: readonly Pick<CommerceModel.ProductOption, 'name'>[]): string;
|
|
16
|
-
/** How a variant is named in a choice's price list. */
|
|
17
|
-
export declare function variantPriceLabel(variant: Pick<CommerceModel.ProductVariant, 'options'>): string;
|
|
18
16
|
/** A new group, as the console makes it from now on: shown on the website (AGL-4100). */
|
|
19
17
|
export declare function newAddOnGroup(): CommerceModel.ProductModifierGroup;
|
|
20
18
|
/**
|
|
@@ -40,11 +40,6 @@ function newId(prefix) {
|
|
|
40
40
|
});
|
|
41
41
|
return named.length === 1 ? `Price by ${named[0].name.trim().toLowerCase()}` : 'Price by variant';
|
|
42
42
|
}
|
|
43
|
-
/** How a variant is named in a choice's price list. */ export function variantPriceLabel(variant) {
|
|
44
|
-
var _variant_options;
|
|
45
|
-
const values = Object.values((_variant_options = variant.options) != null ? _variant_options : {}).filter(Boolean);
|
|
46
|
-
return values.length ? values.join(' / ') : 'Default';
|
|
47
|
-
}
|
|
48
43
|
/** A new group, as the console makes it from now on: shown on the website (AGL-4100). */ export function newAddOnGroup() {
|
|
49
44
|
return {
|
|
50
45
|
id: newId('g'),
|
|
@@ -294,7 +289,7 @@ function newId(prefix) {
|
|
|
294
289
|
children: variants.map((variant)=>{
|
|
295
290
|
var _option_priceCentsByVariant;
|
|
296
291
|
return /*#__PURE__*/ _jsx(TextField, {
|
|
297
|
-
label: variantPriceLabel(variant),
|
|
292
|
+
label: CommerceModel.variantPriceLabel(variant),
|
|
298
293
|
size: "small",
|
|
299
294
|
defaultValue: dollarsFromCents((_option_priceCentsByVariant = option.priceCentsByVariant) == null ? void 0 : _option_priceCentsByVariant[variant.id]),
|
|
300
295
|
placeholder: dollarsFromCents(option.priceCents) || '0.00',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/product-add-ons-fields.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 Box,\n Button,\n Collapse,\n FormControlLabel,\n IconButton,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { memo, useCallback, useId, useState } from 'react'\nimport * as CommerceModel from '../../model'\n\ntype Patch = Partial<CommerceModel.HostProduct>\n\nexport interface ProductAddOnsFieldsProps {\n modifierGroups: readonly CommerceModel.ProductModifierGroup[]\n /** The product's options, to name what a choice is priced by. */\n options: readonly CommerceModel.ProductOption[]\n /** The product's variants, each of which a choice may be priced on. */\n variants: readonly Pick<CommerceModel.ProductVariant, 'id' | 'options'>[]\n update: (patch: Patch) => void\n}\n\nfunction newId(prefix: string): string {\n return `${prefix}${Math.random().toString(36).slice(2, 10)}`\n}\n\n/** Dollars as typed, to whole cents; blank is free. */\nfunction centsFromDollars(value: string): number {\n const number = Math.round(Number(String(value).replace(/[^0-9.]/g, '')) * 100)\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/** Cents as the price field shows them; blank for free. */\nfunction dollarsFromCents(cents: number | undefined): string {\n return cents ? (cents / 100).toFixed(2) : ''\n}\n\n/**\n * What a choice's per-variant prices are called (AGL-4100): by the one\n * option a product varies by (\"Price by size\"), else by variant.\n */\nexport function priceByLabel(options: readonly Pick<CommerceModel.ProductOption, 'name'>[]): string {\n const named = options.filter((option) => option.name?.trim())\n return named.length === 1 ? `Price by ${named[0].name.trim().toLowerCase()}` : 'Price by variant'\n}\n\n/** How a variant is named in a choice's price list. */\nexport function variantPriceLabel(variant: Pick<CommerceModel.ProductVariant, 'options'>): string {\n const values = Object.values(variant.options ?? {}).filter(Boolean)\n return values.length ? values.join(' / ') : 'Default'\n}\n\n/** A new group, as the console makes it from now on: shown on the website (AGL-4100). */\nexport function newAddOnGroup(): CommerceModel.ProductModifierGroup {\n return {\n id: newId('g'),\n name: '',\n min: 0,\n max: 1,\n online: true,\n options: [{ id: newId('o'), name: '', priceCents: 0 }],\n }\n}\n\n/**\n * A choice's prices by variant with one variant's price set or cleared. A\n * cleared price follows the choice's own; with none left the field is\n * dropped, never stored as `undefined` (the save is a client-direct write,\n * which refuses one).\n */\nexport function withVariantPrice(\n option: CommerceModel.ProductModifierOption,\n variantId: string,\n raw: string,\n): CommerceModel.ProductModifierOption {\n const { priceCentsByVariant, ...rest } = option\n const next = { ...(priceCentsByVariant ?? {}) }\n if (raw.trim() === '') delete next[variantId]\n else next[variantId] = centsFromDollars(raw)\n return Object.keys(next).length ? { ...rest, priceCentsByVariant: next } : rest\n}\n\n/**\n * The product's add-ons (AGL-4100, from the register's modifiers of\n * AGL-3607): choices added to the item that are not stocked variants — walls\n * and printing on a canopy, a milk in a latte — each free or adding to the\n * price, and able to cost more on one variant than another. A group with a\n * minimum of 1 or more must be answered before the item is added. Each group\n * says whether the website's product page offers it; the register always\n * does.\n *\n * Offered on every store, with or without the point of sale, and saved with\n * the product, so editing it takes exactly what editing the product takes.\n * Memoized on its own props like every section of this editor (AGL-3423).\n */\nexport const ProductAddOnsFields = memo(function ProductAddOnsFields(\n props: ProductAddOnsFieldsProps,\n) {\n const { modifierGroups, options, variants, update } = props\n const helpId = useId()\n const [pricedByVariant, setPricedByVariant] = useState<Record<string, boolean>>({})\n const setGroups = useCallback(\n (groups: CommerceModel.ProductModifierGroup[]) => update({ modifierGroups: groups }),\n [update],\n )\n const editGroup = (index: number, patch: Partial<CommerceModel.ProductModifierGroup>) =>\n setGroups(modifierGroups.map((group, at) => (at === index ? { ...group, ...patch } : group)))\n const replaceOption = (\n groupIndex: number,\n optionIndex: number,\n next: CommerceModel.ProductModifierOption,\n ) => {\n const group = modifierGroups[groupIndex]\n editGroup(groupIndex, {\n options: group.options.map((option, at) => (at === optionIndex ? next : option)),\n })\n }\n const editOption = (\n groupIndex: number,\n optionIndex: number,\n patch: Partial<CommerceModel.ProductModifierOption>,\n ) => replaceOption(groupIndex, optionIndex, { ...modifierGroups[groupIndex].options[optionIndex], ...patch })\n const problem = CommerceModel.modifierGroupsProblem(modifierGroups)\n const variesByVariant = variants.length > 1\n const byLabel = priceByLabel(options)\n\n return (\n <Stack spacing={2}>\n <Typography id={helpId} variant=\"body2\" color=\"text.secondary\">\n {'Add-ons are choices added to the item that don’t need their own stock, such as walls or ' +\n 'printing on a canopy, or a milk in a latte. Each can be free or add to the price, and can ' +\n 'cost more on a larger size. Show a group on the website to offer it on the product’s page; ' +\n 'the register offers every group.'}\n </Typography>\n {modifierGroups.map((group, groupIndex) => (\n <Box\n key={group.id}\n role=\"group\"\n aria-label={group.name || 'Add-on group'}\n sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 2 }}\n >\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Group name\"\n size=\"small\"\n value={group.name}\n onChange={(event) => editGroup(groupIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"At least\"\n size=\"small\"\n value={group.min}\n onChange={(event) =>\n editGroup(groupIndex, { min: Math.max(0, Math.round(Number(event.target.value) || 0)) })\n }\n helperText={group.min > 0 ? 'Required' : 'Optional'}\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <TextField\n label=\"At most\"\n size=\"small\"\n value={group.max}\n onChange={(event) =>\n editGroup(groupIndex, { max: Math.max(1, Math.round(Number(event.target.value) || 1)) })\n }\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n color=\"error\"\n onClick={() => setGroups(modifierGroups.filter((_group, at) => at !== groupIndex))}\n >\n {'Remove group'}\n </Button>\n </Stack>\n <FormControlLabel\n control={\n <Switch\n checked={group.online === true}\n onChange={(event) => editGroup(groupIndex, { online: event.target.checked })}\n />\n }\n label=\"Show on the website\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {group.online === true\n ? 'Offered on the product’s page and at the register.'\n : 'Offered at the register only.'}\n </Typography>\n {group.options.map((option, optionIndex) => {\n const optionKey = `${group.id}:${option.id}`\n const byVariantOpen =\n pricedByVariant[optionKey] ?? Object.keys(option.priceCentsByVariant ?? {}).length > 0\n return (\n <Box key={option.id}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Choice\"\n size=\"small\"\n value={option.name}\n onChange={(event) => editOption(groupIndex, optionIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"Adds ($)\"\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCents)}\n placeholder=\"0.00\"\n onBlur={(event) =>\n editOption(groupIndex, optionIndex, { priceCents: centsFromDollars(event.target.value) })\n }\n sx={{ width: (theme) => theme.spacing(15) }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n {variesByVariant ? (\n <Button\n size=\"small\"\n aria-expanded={byVariantOpen}\n onClick={() =>\n setPricedByVariant((open) => ({ ...open, [optionKey]: !byVariantOpen }))\n }\n >\n {byLabel}\n </Button>\n ) : null}\n <IconButton\n aria-label={`Remove ${option.name || 'choice'}`}\n onClick={() =>\n editGroup(groupIndex, {\n options: group.options.filter((_option, at) => at !== optionIndex),\n max: Math.max(1, Math.min(group.max, group.options.length - 1)),\n })\n }\n >\n {'✕'}\n </IconButton>\n </Stack>\n {variesByVariant ? (\n <Collapse in={byVariantOpen} unmountOnExit>\n <Stack spacing={1} sx={{ pl: 2, pt: 1.5 }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`What “${option.name || 'this choice'}” adds on each. Leave one blank to use ` +\n 'the price above.'}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, minmax(0, 1fr))' },\n gap: 1,\n }}\n >\n {variants.map((variant) => (\n <TextField\n key={variant.id}\n label={variantPriceLabel(variant)}\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCentsByVariant?.[variant.id])}\n placeholder={dollarsFromCents(option.priceCents) || '0.00'}\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withVariantPrice(\n modifierGroups[groupIndex].options[optionIndex],\n variant.id,\n event.target.value,\n ),\n )\n }\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n ))}\n </Box>\n </Stack>\n </Collapse>\n ) : null}\n </Box>\n )\n })}\n <Box>\n <Button\n onClick={() =>\n editGroup(groupIndex, {\n options: [...group.options, { id: newId('o'), name: '', priceCents: 0 }],\n })\n }\n disabled={group.options.length >= CommerceModel.POS_MAX_MODIFIER_OPTIONS}\n >\n {'Add choice'}\n </Button>\n </Box>\n </Stack>\n </Box>\n ))}\n <Box>\n <Button\n variant=\"outlined\"\n aria-describedby={helpId}\n onClick={() => setGroups([...modifierGroups, newAddOnGroup()])}\n disabled={modifierGroups.length >= CommerceModel.POS_MAX_MODIFIER_GROUPS}\n >\n {'New add-on group'}\n </Button>\n </Box>\n {problem && modifierGroups.length ? (\n <Typography variant=\"body2\" color=\"warning.main\">\n {problem}\n </Typography>\n ) : null}\n </Stack>\n )\n})\n"],"names":["Box","Button","Collapse","FormControlLabel","IconButton","Stack","Switch","TextField","Typography","memo","useCallback","useId","useState","CommerceModel","newId","prefix","Math","random","toString","slice","centsFromDollars","value","number","round","Number","String","replace","isFinite","dollarsFromCents","cents","toFixed","priceByLabel","options","named","filter","option","name","trim","length","toLowerCase","variantPriceLabel","variant","values","Object","Boolean","join","newAddOnGroup","id","min","max","online","priceCents","withVariantPrice","variantId","raw","priceCentsByVariant","rest","next","keys","ProductAddOnsFields","props","modifierGroups","variants","update","helpId","pricedByVariant","setPricedByVariant","setGroups","groups","editGroup","index","patch","map","group","at","replaceOption","groupIndex","optionIndex","editOption","problem","modifierGroupsProblem","variesByVariant","byLabel","spacing","color","role","aria-label","sx","border","borderColor","borderRadius","p","direction","alignItems","flexWrap","rowGap","label","size","onChange","event","target","flex","minWidth","theme","helperText","width","slotProps","htmlInput","inputMode","onClick","_group","control","checked","optionKey","byVariantOpen","defaultValue","placeholder","onBlur","aria-expanded","open","_option","in","unmountOnExit","pl","pt","display","gridTemplateColumns","xs","sm","gap","disabled","POS_MAX_MODIFIER_OPTIONS","aria-describedby","POS_MAX_MODIFIER_GROUPS"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;;AAEA,SACEA,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,IAAI,EAAEC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,QAAO;AAC1D,YAAYC,mBAAmB,uBAAa;AAa5C,SAASC,MAAMC,MAAc;IAC3B,OAAO,GAAGA,SAASC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG,KAAK;AAC9D;AAEA,qDAAqD,GACrD,SAASC,iBAAiBC,KAAa;IACrC,MAAMC,SAASN,KAAKO,KAAK,CAACC,OAAOC,OAAOJ,OAAOK,OAAO,CAAC,YAAY,OAAO;IAC1E,OAAOF,OAAOG,QAAQ,CAACL,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AcvF,kBAAiBO,8BAAAA,OAAOoB,mBAAmB,qBAA1BpB,2BAA4B,CAACM,QAAQM,EAAE,CAAC;gEACvEqE,aAAaxF,iBAAiBO,OAAOgB,UAAU,KAAK;gEACpDkE,QAAQ,CAAClB,QACPxB,cACEC,YACAC,aACAzB,iBACES,cAAc,CAACe,WAAW,CAAC5C,OAAO,CAAC6C,YAAY,EAC/CpC,QAAQM,EAAE,EACVoD,MAAMC,MAAM,CAAC/E,KAAK;gEAIxBqF,WAAW;oEAAEC,WAAW;wEAAEC,WAAW;oEAAU;gEAAE;+DAhB5CnE,QAAQM,EAAE;;;;;6CAsBvB;;mCAjFIZ,OAAOY,EAAE;4BAoFvB;0CACA,KAAC/C;0CACC,cAAA,KAACC;oCACC4G,SAAS,IACPxC,UAAUO,YAAY;4CACpB5C,SAAS;mDAAIyC,MAAMzC,OAAO;gDAAE;oDAAEe,IAAIjC,MAAM;oDAAMsB,MAAM;oDAAIe,YAAY;gDAAE;6CAAE;wCAC1E;oCAEF+E,UAAUzD,MAAMzC,OAAO,CAACM,MAAM,IAAIzB,cAAcsH,wBAAwB;8CAEvE;;;;;mBA3JF1D,MAAM1B,EAAE;0BAiKjB,KAAC/C;0BACC,cAAA,KAACC;oBACCwC,SAAQ;oBACR2F,oBAAkBpE;oBAClB6C,SAAS,IAAM1C,UAAU;+BAAIN;4BAAgBf;yBAAgB;oBAC7DoF,UAAUrE,eAAevB,MAAM,IAAIzB,cAAcwH,uBAAuB;8BAEvE;;;YAGJtD,WAAWlB,eAAevB,MAAM,iBAC/B,KAAC9B;gBAAWiC,SAAQ;gBAAQ2C,OAAM;0BAC/BL;iBAED;;;AAGV,GAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/product-add-ons-fields.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 Box,\n Button,\n Collapse,\n FormControlLabel,\n IconButton,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { memo, useCallback, useId, useState } from 'react'\nimport * as CommerceModel from '../../model'\n\ntype Patch = Partial<CommerceModel.HostProduct>\n\nexport interface ProductAddOnsFieldsProps {\n modifierGroups: readonly CommerceModel.ProductModifierGroup[]\n /** The product's options, to name what a choice is priced by. */\n options: readonly CommerceModel.ProductOption[]\n /** The product's variants, each of which a choice may be priced on. */\n variants: readonly Pick<CommerceModel.ProductVariant, 'id' | 'options'>[]\n update: (patch: Patch) => void\n}\n\nfunction newId(prefix: string): string {\n return `${prefix}${Math.random().toString(36).slice(2, 10)}`\n}\n\n/** Dollars as typed, to whole cents; blank is free. */\nfunction centsFromDollars(value: string): number {\n const number = Math.round(Number(String(value).replace(/[^0-9.]/g, '')) * 100)\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/** Cents as the price field shows them; blank for free. */\nfunction dollarsFromCents(cents: number | undefined): string {\n return cents ? (cents / 100).toFixed(2) : ''\n}\n\n/**\n * What a choice's per-variant prices are called (AGL-4100): by the one\n * option a product varies by (\"Price by size\"), else by variant.\n */\nexport function priceByLabel(options: readonly Pick<CommerceModel.ProductOption, 'name'>[]): string {\n const named = options.filter((option) => option.name?.trim())\n return named.length === 1 ? `Price by ${named[0].name.trim().toLowerCase()}` : 'Price by variant'\n}\n\n/** A new group, as the console makes it from now on: shown on the website (AGL-4100). */\nexport function newAddOnGroup(): CommerceModel.ProductModifierGroup {\n return {\n id: newId('g'),\n name: '',\n min: 0,\n max: 1,\n online: true,\n options: [{ id: newId('o'), name: '', priceCents: 0 }],\n }\n}\n\n/**\n * A choice's prices by variant with one variant's price set or cleared. A\n * cleared price follows the choice's own; with none left the field is\n * dropped, never stored as `undefined` (the save is a client-direct write,\n * which refuses one).\n */\nexport function withVariantPrice(\n option: CommerceModel.ProductModifierOption,\n variantId: string,\n raw: string,\n): CommerceModel.ProductModifierOption {\n const { priceCentsByVariant, ...rest } = option\n const next = { ...(priceCentsByVariant ?? {}) }\n if (raw.trim() === '') delete next[variantId]\n else next[variantId] = centsFromDollars(raw)\n return Object.keys(next).length ? { ...rest, priceCentsByVariant: next } : rest\n}\n\n/**\n * The product's add-ons (AGL-4100, from the register's modifiers of\n * AGL-3607): choices added to the item that are not stocked variants — walls\n * and printing on a canopy, a milk in a latte — each free or adding to the\n * price, and able to cost more on one variant than another. A group with a\n * minimum of 1 or more must be answered before the item is added. Each group\n * says whether the website's product page offers it; the register always\n * does.\n *\n * Offered on every store, with or without the point of sale, and saved with\n * the product, so editing it takes exactly what editing the product takes.\n * Memoized on its own props like every section of this editor (AGL-3423).\n */\nexport const ProductAddOnsFields = memo(function ProductAddOnsFields(\n props: ProductAddOnsFieldsProps,\n) {\n const { modifierGroups, options, variants, update } = props\n const helpId = useId()\n const [pricedByVariant, setPricedByVariant] = useState<Record<string, boolean>>({})\n const setGroups = useCallback(\n (groups: CommerceModel.ProductModifierGroup[]) => update({ modifierGroups: groups }),\n [update],\n )\n const editGroup = (index: number, patch: Partial<CommerceModel.ProductModifierGroup>) =>\n setGroups(modifierGroups.map((group, at) => (at === index ? { ...group, ...patch } : group)))\n const replaceOption = (\n groupIndex: number,\n optionIndex: number,\n next: CommerceModel.ProductModifierOption,\n ) => {\n const group = modifierGroups[groupIndex]\n editGroup(groupIndex, {\n options: group.options.map((option, at) => (at === optionIndex ? next : option)),\n })\n }\n const editOption = (\n groupIndex: number,\n optionIndex: number,\n patch: Partial<CommerceModel.ProductModifierOption>,\n ) => replaceOption(groupIndex, optionIndex, { ...modifierGroups[groupIndex].options[optionIndex], ...patch })\n const problem = CommerceModel.modifierGroupsProblem(modifierGroups)\n const variesByVariant = variants.length > 1\n const byLabel = priceByLabel(options)\n\n return (\n <Stack spacing={2}>\n <Typography id={helpId} variant=\"body2\" color=\"text.secondary\">\n {'Add-ons are choices added to the item that don’t need their own stock, such as walls or ' +\n 'printing on a canopy, or a milk in a latte. Each can be free or add to the price, and can ' +\n 'cost more on a larger size. Show a group on the website to offer it on the product’s page; ' +\n 'the register offers every group.'}\n </Typography>\n {modifierGroups.map((group, groupIndex) => (\n <Box\n key={group.id}\n role=\"group\"\n aria-label={group.name || 'Add-on group'}\n sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 2 }}\n >\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Group name\"\n size=\"small\"\n value={group.name}\n onChange={(event) => editGroup(groupIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"At least\"\n size=\"small\"\n value={group.min}\n onChange={(event) =>\n editGroup(groupIndex, { min: Math.max(0, Math.round(Number(event.target.value) || 0)) })\n }\n helperText={group.min > 0 ? 'Required' : 'Optional'}\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <TextField\n label=\"At most\"\n size=\"small\"\n value={group.max}\n onChange={(event) =>\n editGroup(groupIndex, { max: Math.max(1, Math.round(Number(event.target.value) || 1)) })\n }\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n color=\"error\"\n onClick={() => setGroups(modifierGroups.filter((_group, at) => at !== groupIndex))}\n >\n {'Remove group'}\n </Button>\n </Stack>\n <FormControlLabel\n control={\n <Switch\n checked={group.online === true}\n onChange={(event) => editGroup(groupIndex, { online: event.target.checked })}\n />\n }\n label=\"Show on the website\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {group.online === true\n ? 'Offered on the product’s page and at the register.'\n : 'Offered at the register only.'}\n </Typography>\n {group.options.map((option, optionIndex) => {\n const optionKey = `${group.id}:${option.id}`\n const byVariantOpen =\n pricedByVariant[optionKey] ?? Object.keys(option.priceCentsByVariant ?? {}).length > 0\n return (\n <Box key={option.id}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Choice\"\n size=\"small\"\n value={option.name}\n onChange={(event) => editOption(groupIndex, optionIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"Adds ($)\"\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCents)}\n placeholder=\"0.00\"\n onBlur={(event) =>\n editOption(groupIndex, optionIndex, { priceCents: centsFromDollars(event.target.value) })\n }\n sx={{ width: (theme) => theme.spacing(15) }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n {variesByVariant ? (\n <Button\n size=\"small\"\n aria-expanded={byVariantOpen}\n onClick={() =>\n setPricedByVariant((open) => ({ ...open, [optionKey]: !byVariantOpen }))\n }\n >\n {byLabel}\n </Button>\n ) : null}\n <IconButton\n aria-label={`Remove ${option.name || 'choice'}`}\n onClick={() =>\n editGroup(groupIndex, {\n options: group.options.filter((_option, at) => at !== optionIndex),\n max: Math.max(1, Math.min(group.max, group.options.length - 1)),\n })\n }\n >\n {'✕'}\n </IconButton>\n </Stack>\n {variesByVariant ? (\n <Collapse in={byVariantOpen} unmountOnExit>\n <Stack spacing={1} sx={{ pl: 2, pt: 1.5 }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`What “${option.name || 'this choice'}” adds on each. Leave one blank to use ` +\n 'the price above.'}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, minmax(0, 1fr))' },\n gap: 1,\n }}\n >\n {variants.map((variant) => (\n <TextField\n key={variant.id}\n label={CommerceModel.variantPriceLabel(variant)}\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCentsByVariant?.[variant.id])}\n placeholder={dollarsFromCents(option.priceCents) || '0.00'}\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withVariantPrice(\n modifierGroups[groupIndex].options[optionIndex],\n variant.id,\n event.target.value,\n ),\n )\n }\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n ))}\n </Box>\n </Stack>\n </Collapse>\n ) : null}\n </Box>\n )\n })}\n <Box>\n <Button\n onClick={() =>\n editGroup(groupIndex, {\n options: [...group.options, { id: newId('o'), name: '', priceCents: 0 }],\n })\n }\n disabled={group.options.length >= CommerceModel.POS_MAX_MODIFIER_OPTIONS}\n >\n {'Add choice'}\n </Button>\n </Box>\n </Stack>\n </Box>\n ))}\n <Box>\n <Button\n variant=\"outlined\"\n aria-describedby={helpId}\n onClick={() => setGroups([...modifierGroups, newAddOnGroup()])}\n disabled={modifierGroups.length >= CommerceModel.POS_MAX_MODIFIER_GROUPS}\n >\n {'New add-on group'}\n </Button>\n </Box>\n {problem && modifierGroups.length ? (\n <Typography variant=\"body2\" color=\"warning.main\">\n {problem}\n </Typography>\n ) : null}\n </Stack>\n )\n})\n"],"names":["Box","Button","Collapse","FormControlLabel","IconButton","Stack","Switch","TextField","Typography","memo","useCallback","useId","useState","CommerceModel","newId","prefix","Math","random","toString","slice","centsFromDollars","value","number","round","Number","String","replace","isFinite","dollarsFromCents","cents","toFixed","priceByLabel","options","named","filter","option","name","trim","length","toLowerCase","newAddOnGroup","id","min","max","online","priceCents","withVariantPrice","variantId","raw","priceCentsByVariant","rest","next","Object","keys","ProductAddOnsFields","props","modifierGroups","variants","update","helpId","pricedByVariant","setPricedByVariant","setGroups","groups","editGroup","index","patch","map","group","at","replaceOption","groupIndex","optionIndex","editOption","problem","modifierGroupsProblem","variesByVariant","byLabel","spacing","variant","color","role","aria-label","sx","border","borderColor","borderRadius","p","direction","alignItems","flexWrap","rowGap","label","size","onChange","event","target","flex","minWidth","theme","helperText","width","slotProps","htmlInput","inputMode","onClick","_group","control","checked","optionKey","byVariantOpen","defaultValue","placeholder","onBlur","aria-expanded","open","_option","in","unmountOnExit","pl","pt","display","gridTemplateColumns","xs","sm","gap","variantPriceLabel","disabled","POS_MAX_MODIFIER_OPTIONS","aria-describedby","POS_MAX_MODIFIER_GROUPS"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;;AAEA,SACEA,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,IAAI,EAAEC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,QAAO;AAC1D,YAAYC,mBAAmB,uBAAa;AAa5C,SAASC,MAAMC,MAAc;IAC3B,OAAO,GAAGA,SAASC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG,KAAK;AAC9D;AAEA,qDAAqD,GACrD,SAASC,iBAAiBC,KAAa;IACrC,MAAMC,SAASN,KAAKO,KAAK,CAACC,OAAOC,OAAOJ,OAAOK,OAAO,CAAC,YAAY,OAAO;IAC1E,OAAOF,OAAOG,QAAQ,CAACL,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAEA,yDAAyD,GACzD,SAASM,iBAAiBC,KAAyB;IACjD,OAAOA,QAAQ,AAACA,CAAAA,QAAQ,GAAE,EAAGC,OAAO,CAAC,KAAK;AAC5C;AAEA;;;CAGC,GACD,OAAO,SAASC,aAAaC,OAA6D;IACxF,MAAMC,QAAQD,QAAQE,MAAM,CAAC,CAACC;YAAWA;gBAAAA,eAAAA,OAAOC,IAAI,qBAAXD,aAAaE,IAAI;;IAC1D,OAAOJ,MAAMK,MAAM,KAAK,IAAI,CAAC,SAAS,EAAEL,KAAK,CAAC,EAAE,CAACG,IAAI,CAACC,IAAI,GAA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AAIzB,cAAcmH,wBAAwB;8CAEvE;;;;;mBA3JF5D,MAAM3B,EAAE;0BAiKjB,KAACzC;0BACC,cAAA,KAACC;oBACC8E,SAAQ;oBACRkD,oBAAkBtE;oBAClB8C,SAAS,IAAM3C,UAAU;+BAAIN;4BAAgBhB;yBAAgB;oBAC7DuF,UAAUvE,eAAelB,MAAM,IAAIzB,cAAcqH,uBAAuB;8BAEvE;;;YAGJxD,WAAWlB,eAAelB,MAAM,iBAC/B,KAAC9B;gBAAWuE,SAAQ;gBAAQC,OAAM;0BAC/BN;iBAED;;;AAGV,GAAE"}
|
|
@@ -66,6 +66,13 @@ export interface QuoteEditorStart {
|
|
|
66
66
|
* shipping, notes and terms, with the totals worked out as it is edited. The
|
|
67
67
|
* server prices and saves it; the totals here are the same function's answer
|
|
68
68
|
* over the same inputs, and a connected tax service's figure arrives on save.
|
|
69
|
+
* A saved quote left as it is shows what its customer's page shows instead
|
|
70
|
+
* (AGL-4162): that is what the customer is charged until a save re-prices it.
|
|
71
|
+
*
|
|
72
|
+
* A quote may be saved with no items when it has a proof (AGL-4184), which is
|
|
73
|
+
* how a design goes out before it has a price: the editor then has no money to
|
|
74
|
+
* show, and an item added later makes it a normal quote. A new quote has
|
|
75
|
+
* nothing to upload a proof for yet, so it takes its first from the media library.
|
|
69
76
|
*/
|
|
70
77
|
export declare function QuoteEditorDialog(props: QuoteEditorDialogProps): import("react").JSX.Element;
|
|
71
78
|
export declare namespace QuoteEditorDialog {
|