@aglyn/plugins-commerce 1.10.0 → 1.12.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/host-quotes-card.component.js +20 -11
- package/src/lib/components/console/host-quotes-card.component.js.map +1 -1
- package/src/lib/components/console/invoice-send.component.d.ts +9 -2
- package/src/lib/components/console/invoice-send.component.js +58 -30
- package/src/lib/components/console/invoice-send.component.js.map +1 -1
- package/src/lib/components/console/pay-link-readiness-notice.component.d.ts +84 -0
- package/src/lib/components/console/pay-link-readiness-notice.component.js +164 -0
- package/src/lib/components/console/pay-link-readiness-notice.component.js.map +1 -0
- 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/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 +2 -0
- package/src/lib/components/console/quote-editor-dialog.component.js +35 -27
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-pay-link.component.d.ts +3 -0
- package/src/lib/components/console/quote-pay-link.component.js +9 -0
- package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
- package/src/lib/components/console/quote-send.component.d.ts +3 -0
- package/src/lib/components/console/quote-send.component.js +9 -0
- package/src/lib/components/console/quote-send.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 +5 -3
- 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 +45 -5
- package/src/lib/model/commerce-invoices.js +46 -9
- 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-pay.d.ts +110 -6
- package/src/lib/model/commerce-quote-pay.js +182 -23
- package/src/lib/model/commerce-quote-pay.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/billing-webhook.js +4 -1
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/commerce-pdf.js +2 -1
- package/src/lib/server/commerce-pdf.js.map +1 -1
- package/src/lib/server/invoice-email.js +2 -1
- package/src/lib/server/invoice-email.js.map +1 -1
- package/src/lib/server/order-invoice-send.js +1 -1
- package/src/lib/server/order-invoice-send.js.map +1 -1
- package/src/lib/server/order-status.d.ts +5 -1
- package/src/lib/server/order-status.js +19 -5
- package/src/lib/server/order-status.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 +2 -1
- package/src/lib/server/quote-email.js.map +1 -1
- package/src/lib/server/quote-pay.d.ts +39 -0
- package/src/lib/server/quote-pay.js +103 -43
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote-proofs.js +20 -11
- package/src/lib/server/quote-proofs.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/testing/fake-firestore.js +34 -5
- package/src/lib/testing/fake-firestore.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/invoice-email-content.d.ts +3 -1
- package/src/lib/utils/invoice-email-content.js +1 -1
- package/src/lib/utils/invoice-email-content.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +3 -1
- package/src/lib/utils/quote-email-content.js +3 -3
- package/src/lib/utils/quote-email-content.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-commerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
31
|
-
"@aglyn/shared-ui-next": "1.
|
|
32
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
33
|
-
"@aglyn/shared-util-email": "1.
|
|
34
|
-
"@aglyn/shared-util-http": "1.
|
|
35
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
36
|
-
"@aglyn/shared-util-tools": "1.
|
|
37
|
-
"@aglyn/tenant-data-admin": "1.
|
|
38
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
39
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.12.0",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.12.0",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.12.0",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.12.0",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.12.0",
|
|
33
|
+
"@aglyn/shared-util-email": "1.12.0",
|
|
34
|
+
"@aglyn/shared-util-http": "1.12.0",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.12.0",
|
|
36
|
+
"@aglyn/shared-util-tools": "1.12.0",
|
|
37
|
+
"@aglyn/tenant-data-admin": "1.12.0",
|
|
38
|
+
"@aglyn/tenant-feature-instance": "1.12.0",
|
|
39
|
+
"@aglyn/tenant-runtime": "1.12.0",
|
|
40
40
|
"@stripe/react-stripe-js": "^6.12.0",
|
|
41
41
|
"@stripe/stripe-js": "^9.17.0",
|
|
42
42
|
"@swc/helpers": "0.5.23",
|
|
@@ -23,9 +23,9 @@ import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
|
23
23
|
import { CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
24
24
|
import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
|
|
25
25
|
import { ListTable } from "@aglyn/shared-ui-jsx/components/list-table.component";
|
|
26
|
-
import { ceilingedWindow, collectionCeiling, useFirestore, useFirestoreCollection } from "@aglyn/tenant-feature-instance";
|
|
26
|
+
import { ceilingedWindow, collectionCeiling, useFirestore, useFirestoreCollection, useFirestoreDoc } from "@aglyn/tenant-feature-instance";
|
|
27
27
|
import { Button, Chip, Stack, Typography } from "@mui/material";
|
|
28
|
-
import { collection, limit, query, where } from "firebase/firestore";
|
|
28
|
+
import { collection, doc, limit, query, where } from "firebase/firestore";
|
|
29
29
|
import { useSearchParams } from "next/navigation";
|
|
30
30
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
31
31
|
import QuoteEditorDialog from "./quote-editor-dialog.component.js";
|
|
@@ -35,7 +35,7 @@ import QuoteEditorDialog from "./quote-editor-dialog.component.js";
|
|
|
35
35
|
*/ const QUOTE_CEILING = 500;
|
|
36
36
|
/** The products the editor's picker offers. */ const PRODUCT_WINDOW = 200;
|
|
37
37
|
const REFUSAL = commerceSitePermissionRefusal('commerce.quotes');
|
|
38
|
-
/** One quote as its row draws and sorts it. */ function quoteListRow(quote) {
|
|
38
|
+
/** One quote as its row draws and sorts it, under the store's sales tax choice. */ function quoteListRow(quote, store) {
|
|
39
39
|
var _quote_lineItems, _ref, _ref1, _ref2, _ref3;
|
|
40
40
|
var _quote_quote, _items_, _quote_totals, _quote_quote1, _CommerceModel_latestQuoteResponse;
|
|
41
41
|
const customer = (_quote_quote = quote.quote) == null ? void 0 : _quote_quote.customer;
|
|
@@ -47,6 +47,9 @@ const REFUSAL = commerceSitePermissionRefusal('commerce.quotes');
|
|
|
47
47
|
moreItems: Math.max(0, items.length - 1),
|
|
48
48
|
statusKey: status.key,
|
|
49
49
|
statusLabel: status.label,
|
|
50
|
+
// `quotePayTax`, as the pay page reads it (AGL-4162): a quote saved before
|
|
51
|
+
// the store chose its sales tax takes the choice as it stands now.
|
|
52
|
+
taxAtPayment: CommerceModel.isUnpaidQuote(quote) && CommerceModel.quotePayTax(quote.quote, store).basis.kind === 'at-payment',
|
|
50
53
|
totalCents: Number((_ref1 = (_quote_totals = quote.totals) == null ? void 0 : _quote_totals.totalCents) != null ? _ref1 : 0),
|
|
51
54
|
// The customer's latest answer counts as an update (AGL-4096), so a quote
|
|
52
55
|
// they just approved or asked changes to sorts to the top.
|
|
@@ -71,8 +74,17 @@ const REFUSAL = commerceSitePermissionRefusal('commerce.quotes');
|
|
|
71
74
|
const quotes = useMemo(()=>ceilingedWindow(quoteDocs != null ? quoteDocs : undefined, QUOTE_CEILING), [
|
|
72
75
|
quoteDocs
|
|
73
76
|
]);
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
// One read for the whole list. Until it answers, each quote's saved basis stands.
|
|
78
|
+
const { data: storeSettings } = useFirestoreDoc(()=>doc(firestore, 'hosts', hostId, 'settings', 'store'), [
|
|
79
|
+
firestore,
|
|
80
|
+
hostId
|
|
81
|
+
]);
|
|
82
|
+
const rows = useMemo(()=>{
|
|
83
|
+
const store = CommerceModel.payLinkStoreOf(storeSettings);
|
|
84
|
+
return quotes.rows.map((quote)=>quoteListRow(quote, store));
|
|
85
|
+
}, [
|
|
86
|
+
quotes,
|
|
87
|
+
storeSettings
|
|
76
88
|
]);
|
|
77
89
|
const { data: productDocs } = useFirestoreCollection(()=>collectionCeiling(collection(firestore, 'hosts', hostId, 'products'), PRODUCT_WINDOW), [
|
|
78
90
|
firestore,
|
|
@@ -143,9 +155,7 @@ const REFUSAL = commerceSitePermissionRefusal('commerce.quotes');
|
|
|
143
155
|
width: 140,
|
|
144
156
|
align: 'right',
|
|
145
157
|
headerAlign: 'right',
|
|
146
|
-
renderCell: ({ row })
|
|
147
|
-
var _row_quote_tax, _row_quote;
|
|
148
|
-
return /*#__PURE__*/ _jsxs(Stack, {
|
|
158
|
+
renderCell: ({ row })=>/*#__PURE__*/ _jsxs(Stack, {
|
|
149
159
|
sx: {
|
|
150
160
|
alignItems: 'flex-end',
|
|
151
161
|
minWidth: 0,
|
|
@@ -156,15 +166,14 @@ const REFUSAL = commerceSitePermissionRefusal('commerce.quotes');
|
|
|
156
166
|
variant: "body2",
|
|
157
167
|
children: posMoney(row.totalCents)
|
|
158
168
|
}),
|
|
159
|
-
|
|
169
|
+
row.taxAtPayment ? /*#__PURE__*/ _jsx(Typography, {
|
|
160
170
|
variant: "caption",
|
|
161
171
|
color: "text.secondary",
|
|
162
172
|
noWrap: true,
|
|
163
173
|
children: 'plus tax at payment'
|
|
164
174
|
}) : null
|
|
165
175
|
]
|
|
166
|
-
})
|
|
167
|
-
}
|
|
176
|
+
})
|
|
168
177
|
},
|
|
169
178
|
{
|
|
170
179
|
field: 'statusLabel',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/host-quotes-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 * as CommerceModel from '../../model'\nimport { posMoney } from '../../model/commerce-pos-ops'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n ceilingedWindow,\n collectionCeiling,\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { Button, Chip, Stack, Typography } from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { collection, limit, query, where } from 'firebase/firestore'\nimport { useSearchParams } from 'next/navigation'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport QuoteEditorDialog, { type QuoteRow } from './quote-editor-dialog.component'\n\nexport interface HostQuotesCardProps {\n hostId: string\n /** Holds \"Create and edit quotes\" (`commerce.quotes`). */\n canEdit: boolean\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n}\n\n/**\n * How many quotes the list reads. The whole set is read and the grid sorts\n * it by any column; a store past this many is told the list stops short.\n */\nconst QUOTE_CEILING = 500\n\n/** The products the editor's picker offers. */\nconst PRODUCT_WINDOW = 200\n\nconst REFUSAL = commerceSitePermissionRefusal('commerce.quotes')\n\ninterface QuoteListRow extends QuoteRow {\n customerLabel: string\n firstItem: string\n moreItems: number\n statusKey: ReturnType<typeof CommerceModel.quoteDisplayStatus>['key']\n statusLabel: string\n totalCents: number\n updatedAtMs: number\n}\n\n/** One quote as its row draws and sorts it. */\nfunction quoteListRow(quote: QuoteRow): QuoteListRow {\n const customer = quote.quote?.customer\n const status = CommerceModel.quoteDisplayStatus(quote)\n const items = quote.lineItems ?? []\n return {\n ...quote,\n customerLabel: customer?.name || customer?.company || customer?.email || '',\n firstItem: items[0]?.name ?? '',\n moreItems: Math.max(0, items.length - 1),\n statusKey: status.key,\n statusLabel: status.label,\n totalCents: Number(quote.totals?.totalCents ?? 0),\n // The customer's latest answer counts as an update (AGL-4096), so a quote\n // they just approved or asked changes to sorts to the top.\n updatedAtMs: Math.max(\n Number(quote.quote?.updatedAtMs ?? 0),\n Number(CommerceModel.latestQuoteResponse(quote.quote)?.atMs ?? 0),\n ),\n }\n}\n\n/**\n * Quotes (AGL-4093): prices put to a customer before they buy, beside the\n * orders they become. A quote is an unpaid order on the `quote` channel, so\n * this reads `hosts/{hostId}/orders` for that channel alone; the Orders list\n * above never shows one until it is paid.\n */\nexport function HostQuotesCard(props: HostQuotesCardProps) {\n const { hostId, canEdit, canSend } = props\n const firestore = useFirestore()\n const { data: quoteDocs, status } = useFirestoreCollection<QuoteRow>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'orders'),\n where('channel', '==', 'quote'),\n limit(QUOTE_CEILING + 1),\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const quotes = useMemo(() => ceilingedWindow<QuoteRow>(quoteDocs ?? undefined, QUOTE_CEILING), [quoteDocs])\n const rows = useMemo(() => Array.from(quotes.rows, quoteListRow), [quotes])\n\n const { data: productDocs } = useFirestoreCollection<Record<string, any>>(\n () => collectionCeiling(collection(firestore, 'hosts', hostId, 'products'), PRODUCT_WINDOW),\n [firestore, hostId],\n { idField: '$id' },\n )\n const products = useMemo(\n () => ceilingedWindow<Record<string, any>>(productDocs ?? undefined, PRODUCT_WINDOW).rows.filter((product) => !product['deletedAt']),\n [productDocs],\n )\n\n /** The quote open in the editor: its id, or `new`. */\n const [openId, setOpenId] = useState<string | null>(null)\n const openQuote = openId && openId !== 'new' ? (quotes.rows.find((row) => row.$id === openId) ?? null) : null\n\n // A manager notice opens its quote (AGL-4096): `?quote=<id>` on the Orders\n // page, once that quote has loaded. Read from the router, so a notice\n // followed while this page is already open opens its quote too; once per\n // id, so closing the dialog does not reopen it.\n const searchParams = useSearchParams()\n const linkedId = searchParams?.get('quote') ?? ''\n const opened = useRef('')\n useEffect(() => {\n if (!linkedId || opened.current === linkedId || !quotes.rows.some((row) => row.$id === linkedId)) return\n opened.current = linkedId\n setOpenId(linkedId)\n }, [linkedId, quotes.rows])\n\n const columns = useMemo<GridColDef[]>(\n () => [\n {\n field: 'number',\n headerName: 'Quote',\n flex: 1,\n minWidth: 160,\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Stack sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {CommerceModel.formatQuoteNumber(row, row.$id)}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {row.moreItems ? `${row.firstItem} and more` : row.firstItem}\n </Typography>\n </Stack>\n ),\n },\n {\n field: 'customerLabel',\n headerName: 'Customer',\n flex: 1,\n minWidth: 160,\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Typography variant=\"body2\" noWrap>\n {row.customerLabel || '—'}\n </Typography>\n ),\n },\n {\n field: 'totalCents',\n headerName: 'Total',\n type: 'number',\n width: 140,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Stack sx={{ alignItems: 'flex-end', minWidth: 0, width: 1 }}>\n <Typography variant=\"body2\">{posMoney(row.totalCents)}</Typography>\n {row.quote?.tax?.kind === 'at-payment' && CommerceModel.isUnpaidQuote(row) ? (\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {'plus tax at payment'}\n </Typography>\n ) : null}\n </Stack>\n ),\n },\n {\n field: 'statusLabel',\n headerName: 'Status',\n width: 180,\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={row.statusLabel}\n color={CommerceModel.QUOTE_STATUS_COLOR[row.statusKey]}\n />\n ),\n },\n {\n field: 'updatedAtMs',\n headerName: 'Updated',\n type: 'number',\n width: 140,\n align: 'left',\n headerAlign: 'left',\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Typography variant=\"body2\" noWrap>\n {row.updatedAtMs ? new Date(row.updatedAtMs).toLocaleDateString() : '—'}\n </Typography>\n ),\n },\n ],\n [],\n )\n\n const empty = status === 'success' && rows.length === 0\n\n return (\n <CardDisplay\n header={'Quotes'}\n subheader={'Prices for a customer’s order before they buy'}\n help={pluginDocsHelp('quotes', {\n anchor: '#make-a-quote',\n title: 'Quotes',\n excerpt:\n 'Put a price to a customer with your products, items typed for the job and anything ' +\n 'included. A quote becomes an order when it is paid.',\n })}\n HeaderProps={{\n action: (\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button size=\"small\" variant=\"contained\" onClick={() => setOpenId('new')}>\n {'New quote'}\n </Button>\n </BlockedControl>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n {empty ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No quotes yet. A quote prices a customer’s order before they buy: your products, ' +\n 'items typed for the job, and anything you include at no charge.'}\n </Typography>\n ) : (\n <Stack spacing={1}>\n {quotes.truncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'This store has more quotes than the list shows at once.'}\n </Typography>\n ) : null}\n <ListTable\n aria-label=\"Quotes\"\n rows={rows}\n columns={columns}\n loading={status === 'loading'}\n onOpen={(id) => setOpenId(id)}\n quickFilter\n initialState={{ sorting: { sortModel: [{ field: 'updatedAtMs', sort: 'desc' }] } }}\n noRowsLabel=\"No quotes match\"\n />\n </Stack>\n )}\n {/* A quote deleted while open closes its editor rather than turn it into a new one. */}\n {openId === 'new' || openQuote ? (\n <QuoteEditorDialog\n key={openId}\n hostId={hostId}\n quote={openQuote}\n products={products}\n canEdit={canEdit}\n canSend={canSend}\n onClose={() => setOpenId(null)}\n />\n ) : null}\n </CardDisplay>\n )\n}\nHostQuotesCard.displayName = 'HostQuotesCard'\n\nexport default HostQuotesCard\n"],"names":["CommerceModel","posMoney","commerceSitePermissionRefusal","pluginDocsHelp","CardDisplay","BlockedControl","ListTable","ceilingedWindow","collectionCeiling","useFirestore","useFirestoreCollection","Button","Chip","Stack","Typography","collection","limit","query","where","useSearchParams","useEffect","useMemo","useRef","useState","QuoteEditorDialog","QUOTE_CEILING","PRODUCT_WINDOW","REFUSAL","quoteListRow","quote","items","customer","status","quoteDisplayStatus","lineItems","customerLabel","name","company","email","firstItem","moreItems","Math","max","length","statusKey","key","statusLabel","label","totalCents","Number","totals","updatedAtMs","latestQuoteResponse","atMs","HostQuotesCard","props","quotes","hostId","canEdit","canSend","firestore","data","quoteDocs","idField","undefined","rows","Array","from","productDocs","products","filter","product","openId","setOpenId","openQuote","find","row","$id","searchParams","linkedId","get","opened","current","some","columns","field","headerName","flex","minWidth","renderCell","sx","variant","noWrap","formatQuoteNumber","color","type","width","align","headerAlign","alignItems","tax","kind","isUnpaidQuote","size","QUOTE_STATUS_COLOR","Date","toLocaleDateString","empty","header","subheader","help","anchor","title","excerpt","HeaderProps","action","blocked","reason","onClick","contentGutterX","contentGutterY","spacing","truncated","aria-label","loading","onOpen","id","quickFilter","initialState","sorting","sortModel","sort","noRowsLabel","onClose","displayName"],"mappings":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RC,OAAO;YACPC,SACE,wFACA;QACJ;QACAC,aAAa;YACXC,sBACE,KAAC9G;gBAAe+G,SAAS,CAAC1D;gBAAS2D,QAAQ1F;0BACzC,cAAA,KAAChB;oBAAO4F,MAAK;oBAAQZ,SAAQ;oBAAY2B,SAAS,IAAM7C,UAAU;8BAC/D;;;QAIT;QACA8C,cAAc;QACdC,cAAc;;YAEbb,sBACC,KAAC7F;gBAAW6E,SAAQ;gBAAQG,OAAM;0BAC/B,sFACC;+BAGJ,MAACjF;gBAAM4G,SAAS;;oBACbjE,OAAOkE,SAAS,iBACf,KAAC5G;wBAAW6E,SAAQ;wBAAUG,OAAM;kCACjC;yBAED;kCACJ,KAACxF;wBACCqH,cAAW;wBACX1D,MAAMA;wBACNmB,SAASA;wBACTwC,SAAS5F,WAAW;wBACpB6F,QAAQ,CAACC,KAAOrD,UAAUqD;wBAC1BC,WAAW;wBACXC,cAAc;4BAAEC,SAAS;gCAAEC,WAAW;oCAAC;wCAAE7C,OAAO;wCAAe8C,MAAM;oCAAO;iCAAE;4BAAC;wBAAE;wBACjFC,aAAY;;;;YAKjB5D,WAAW,SAASE,0BACnB,KAAClD;gBAECiC,QAAQA;gBACR5B,OAAO6C;gBACPL,UAAUA;gBACVX,SAASA;gBACTC,SAASA;gBACT0E,SAAS,IAAM5D,UAAU;eANpBD,UAQL;;;AAGV;AACAlB,eAAegF,WAAW,GAAG;AAE7B,eAAehF,eAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/host-quotes-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 * as CommerceModel from '../../model'\nimport { posMoney } from '../../model/commerce-pos-ops'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n ceilingedWindow,\n collectionCeiling,\n useFirestore,\n useFirestoreCollection,\n useFirestoreDoc,\n} from '@aglyn/tenant-feature-instance'\nimport { Button, Chip, Stack, Typography } from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { collection, doc, limit, query, where } from 'firebase/firestore'\nimport { useSearchParams } from 'next/navigation'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport QuoteEditorDialog, { type QuoteRow } from './quote-editor-dialog.component'\n\nexport interface HostQuotesCardProps {\n hostId: string\n /** Holds \"Create and edit quotes\" (`commerce.quotes`). */\n canEdit: boolean\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n}\n\n/**\n * How many quotes the list reads. The whole set is read and the grid sorts\n * it by any column; a store past this many is told the list stops short.\n */\nconst QUOTE_CEILING = 500\n\n/** The products the editor's picker offers. */\nconst PRODUCT_WINDOW = 200\n\nconst REFUSAL = commerceSitePermissionRefusal('commerce.quotes')\n\ninterface QuoteListRow extends QuoteRow {\n customerLabel: string\n firstItem: string\n moreItems: number\n statusKey: ReturnType<typeof CommerceModel.quoteDisplayStatus>['key']\n statusLabel: string\n /** Unpaid, with tax still to be added at payment: the pay page's own answer. */\n taxAtPayment: boolean\n totalCents: number\n updatedAtMs: number\n}\n\n/** One quote as its row draws and sorts it, under the store's sales tax choice. */\nfunction quoteListRow(quote: QuoteRow, store: CommerceModel.PayLinkStore): QuoteListRow {\n const customer = quote.quote?.customer\n const status = CommerceModel.quoteDisplayStatus(quote)\n const items = quote.lineItems ?? []\n return {\n ...quote,\n customerLabel: customer?.name || customer?.company || customer?.email || '',\n firstItem: items[0]?.name ?? '',\n moreItems: Math.max(0, items.length - 1),\n statusKey: status.key,\n statusLabel: status.label,\n // `quotePayTax`, as the pay page reads it (AGL-4162): a quote saved before\n // the store chose its sales tax takes the choice as it stands now.\n taxAtPayment: CommerceModel.isUnpaidQuote(quote) && CommerceModel.quotePayTax(quote.quote, store).basis.kind === 'at-payment',\n totalCents: Number(quote.totals?.totalCents ?? 0),\n // The customer's latest answer counts as an update (AGL-4096), so a quote\n // they just approved or asked changes to sorts to the top.\n updatedAtMs: Math.max(\n Number(quote.quote?.updatedAtMs ?? 0),\n Number(CommerceModel.latestQuoteResponse(quote.quote)?.atMs ?? 0),\n ),\n }\n}\n\n/**\n * Quotes (AGL-4093): prices put to a customer before they buy, beside the\n * orders they become. A quote is an unpaid order on the `quote` channel, so\n * this reads `hosts/{hostId}/orders` for that channel alone; the Orders list\n * above never shows one until it is paid.\n */\nexport function HostQuotesCard(props: HostQuotesCardProps) {\n const { hostId, canEdit, canSend } = props\n const firestore = useFirestore()\n const { data: quoteDocs, status } = useFirestoreCollection<QuoteRow>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'orders'),\n where('channel', '==', 'quote'),\n limit(QUOTE_CEILING + 1),\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const quotes = useMemo(() => ceilingedWindow<QuoteRow>(quoteDocs ?? undefined, QUOTE_CEILING), [quoteDocs])\n // One read for the whole list. Until it answers, each quote's saved basis stands.\n const { data: storeSettings } = useFirestoreDoc<{ tax?: unknown }>(\n () => doc(firestore, 'hosts', hostId, 'settings', 'store'),\n [firestore, hostId],\n )\n const rows = useMemo(() => {\n const store = CommerceModel.payLinkStoreOf(storeSettings)\n return quotes.rows.map((quote) => quoteListRow(quote, store))\n }, [quotes, storeSettings])\n\n const { data: productDocs } = useFirestoreCollection<Record<string, any>>(\n () => collectionCeiling(collection(firestore, 'hosts', hostId, 'products'), PRODUCT_WINDOW),\n [firestore, hostId],\n { idField: '$id' },\n )\n const products = useMemo(\n () => ceilingedWindow<Record<string, any>>(productDocs ?? undefined, PRODUCT_WINDOW).rows.filter((product) => !product['deletedAt']),\n [productDocs],\n )\n\n /** The quote open in the editor: its id, or `new`. */\n const [openId, setOpenId] = useState<string | null>(null)\n const openQuote = openId && openId !== 'new' ? (quotes.rows.find((row) => row.$id === openId) ?? null) : null\n\n // A manager notice opens its quote (AGL-4096): `?quote=<id>` on the Orders\n // page, once that quote has loaded. Read from the router, so a notice\n // followed while this page is already open opens its quote too; once per\n // id, so closing the dialog does not reopen it.\n const searchParams = useSearchParams()\n const linkedId = searchParams?.get('quote') ?? ''\n const opened = useRef('')\n useEffect(() => {\n if (!linkedId || opened.current === linkedId || !quotes.rows.some((row) => row.$id === linkedId)) return\n opened.current = linkedId\n setOpenId(linkedId)\n }, [linkedId, quotes.rows])\n\n const columns = useMemo<GridColDef[]>(\n () => [\n {\n field: 'number',\n headerName: 'Quote',\n flex: 1,\n minWidth: 160,\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Stack sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {CommerceModel.formatQuoteNumber(row, row.$id)}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {row.moreItems ? `${row.firstItem} and more` : row.firstItem}\n </Typography>\n </Stack>\n ),\n },\n {\n field: 'customerLabel',\n headerName: 'Customer',\n flex: 1,\n minWidth: 160,\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Typography variant=\"body2\" noWrap>\n {row.customerLabel || '—'}\n </Typography>\n ),\n },\n {\n field: 'totalCents',\n headerName: 'Total',\n type: 'number',\n width: 140,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Stack sx={{ alignItems: 'flex-end', minWidth: 0, width: 1 }}>\n <Typography variant=\"body2\">{posMoney(row.totalCents)}</Typography>\n {row.taxAtPayment ? (\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {'plus tax at payment'}\n </Typography>\n ) : null}\n </Stack>\n ),\n },\n {\n field: 'statusLabel',\n headerName: 'Status',\n width: 180,\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={row.statusLabel}\n color={CommerceModel.QUOTE_STATUS_COLOR[row.statusKey]}\n />\n ),\n },\n {\n field: 'updatedAtMs',\n headerName: 'Updated',\n type: 'number',\n width: 140,\n align: 'left',\n headerAlign: 'left',\n renderCell: ({ row }: { row: QuoteListRow }) => (\n <Typography variant=\"body2\" noWrap>\n {row.updatedAtMs ? new Date(row.updatedAtMs).toLocaleDateString() : '—'}\n </Typography>\n ),\n },\n ],\n [],\n )\n\n const empty = status === 'success' && rows.length === 0\n\n return (\n <CardDisplay\n header={'Quotes'}\n subheader={'Prices for a customer’s order before they buy'}\n help={pluginDocsHelp('quotes', {\n anchor: '#make-a-quote',\n title: 'Quotes',\n excerpt:\n 'Put a price to a customer with your products, items typed for the job and anything ' +\n 'included. A quote becomes an order when it is paid.',\n })}\n HeaderProps={{\n action: (\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button size=\"small\" variant=\"contained\" onClick={() => setOpenId('new')}>\n {'New quote'}\n </Button>\n </BlockedControl>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n {empty ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No quotes yet. A quote prices a customer’s order before they buy: your products, ' +\n 'items typed for the job, and anything you include at no charge.'}\n </Typography>\n ) : (\n <Stack spacing={1}>\n {quotes.truncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'This store has more quotes than the list shows at once.'}\n </Typography>\n ) : null}\n <ListTable\n aria-label=\"Quotes\"\n rows={rows}\n columns={columns}\n loading={status === 'loading'}\n onOpen={(id) => setOpenId(id)}\n quickFilter\n initialState={{ sorting: { sortModel: [{ field: 'updatedAtMs', sort: 'desc' }] } }}\n noRowsLabel=\"No quotes match\"\n />\n </Stack>\n )}\n {/* A quote deleted while open closes its editor rather than turn it into a new one. */}\n {openId === 'new' || openQuote ? (\n <QuoteEditorDialog\n key={openId}\n hostId={hostId}\n quote={openQuote}\n products={products}\n canEdit={canEdit}\n canSend={canSend}\n onClose={() => setOpenId(null)}\n />\n ) : null}\n </CardDisplay>\n )\n}\nHostQuotesCard.displayName = 'HostQuotesCard'\n\nexport default HostQuotesCard\n"],"names":["CommerceModel","posMoney","commerceSitePermissionRefusal","pluginDocsHelp","CardDisplay","BlockedControl","ListTable","ceilingedWindow","collectionCeiling","useFirestore","useFirestoreCollection","useFirestoreDoc","Button","Chip","Stack","Typography","collection","doc","limit","query","where","useSearchParams","useEffect","useMemo","useRef","useState","QuoteEditorDialog","QUOTE_CEILING","PRODUCT_WINDOW","REFUSAL","quoteListRow","quote","store","items","customer","status","quoteDisplayStatus","lineItems","customerLabel","name","company","email","firstItem","moreItems","Math","max","length","statusKey","key","statusLabel","label","taxAtPayment","isUnpaidQuote","quotePayTax","basis","kind","totalCents","Number","totals","updatedAtMs","latestQuoteResponse","atMs","HostQuotesCard","props","quotes","hostId","canEdit","canSend","firestore","data","quoteDocs","idField","undefined","storeSettings","rows","payLinkStoreOf","map","productDocs","products","filter","product","openId","setOpenId","openQuote","find","row","$id","searchParams","linkedId","get","opened","current","some","columns","field","headerName","flex","minWidth","renderCell","sx","variant","noWrap","formatQuoteNumber","color","type","width","align","headerAlign","alignItems","size","QUOTE_STATUS_COLOR","Date","toLocaleDateString","empty","header","subheader","help","anchor","title","excerpt","HeaderProps","action","blocked","reason","onClick","contentGutterX","contentGutterY","spacing","truncated","aria-label","loading","onOpen","id","quickFilter","initialState","sorting","sortModel","sort","noRowsLabel","onClose","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,QAAQ,QAAQ,kCAA8B;AACvD,SAASC,6BAA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MAAMC,QAAQ9E,WAAW,aAAauC,KAAK5B,MAAM,KAAK;IAEtD,qBACE,MAAC1C;QACC8G,QAAQ;QACRC,WAAW;QACXC,MAAMjH,eAAe,UAAU;YAC7BkH,QAAQ;YACRC,OAAO;YACPC,SACE,wFACA;QACJ;QACAC,aAAa;YACXC,sBACE,KAACpH;gBAAeqH,SAAS,CAACxD;gBAASyD,QAAQ9F;0BACzC,cAAA,KAACjB;oBAAOiG,MAAK;oBAAQT,SAAQ;oBAAYwB,SAAS,IAAM1C,UAAU;8BAC/D;;;QAIT;QACA2C,cAAc;QACdC,cAAc;;YAEbb,sBACC,KAAClG;gBAAWqF,SAAQ;gBAAQG,OAAM;0BAC/B,sFACC;+BAGJ,MAACzF;gBAAMiH,SAAS;;oBACb/D,OAAOgE,SAAS,iBACf,KAACjH;wBAAWqF,SAAQ;wBAAUG,OAAM;kCACjC;yBAED;kCACJ,KAACjG;wBACC2H,cAAW;wBACXvD,MAAMA;wBACNmB,SAASA;wBACTqC,SAAS/F,WAAW;wBACpBgG,QAAQ,CAACC,KAAOlD,UAAUkD;wBAC1BC,WAAW;wBACXC,cAAc;4BAAEC,SAAS;gCAAEC,WAAW;oCAAC;wCAAE1C,OAAO;wCAAe2C,MAAM;oCAAO;iCAAE;4BAAC;wBAAE;wBACjFC,aAAY;;;;YAKjBzD,WAAW,SAASE,0BACnB,KAACzD;gBAECuC,QAAQA;gBACRlC,OAAOoD;gBACPL,UAAUA;gBACVZ,SAASA;gBACTC,SAASA;gBACTwE,SAAS,IAAMzD,UAAU;eANpBD,UAQL;;;AAGV;AACAnB,eAAe8E,WAAW,GAAG;AAE7B,eAAe9E,eAAc"}
|
|
@@ -34,8 +34,15 @@ export interface InvoiceSendDialogProps {
|
|
|
34
34
|
* invoice PDF attached. Unpaid, the email carries a Pay button to the order's
|
|
35
35
|
* lasting pay link on the business's site; paid, it is the customer's record.
|
|
36
36
|
* A quote's invoice lands in the quote's conversation, and an order's in its
|
|
37
|
-
* own.
|
|
38
|
-
*
|
|
37
|
+
* own.
|
|
38
|
+
*
|
|
39
|
+
* The form's body mounts with the dialog's opening, so everything it reads
|
|
40
|
+
* (the site's name and contact email, once; the store's tax choice and its
|
|
41
|
+
* payments, live) is read only while it is open, and the dialog that offers
|
|
42
|
+
* it listens to nothing more. It says what the customer's Pay waits on, if
|
|
43
|
+
* anything (AGL-4162), and judges the send under the store's sales tax choice
|
|
44
|
+
* as the server does: a quote saved before the store chose is sent as the
|
|
45
|
+
* store's choice prices it.
|
|
39
46
|
*/
|
|
40
47
|
export declare function InvoiceSendDialog(props: InvoiceSendDialogProps): import("react").JSX.Element;
|
|
41
48
|
export declare namespace InvoiceSendDialog {
|
|
@@ -14,15 +14,18 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ 'use client';
|
|
17
|
-
import {
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
19
|
import * as CommerceModel from "../../model/index.js";
|
|
19
20
|
import { siteContactEmail, resolveHostToken } from "@aglyn/aglyn/app-utils/host-tokens";
|
|
21
|
+
import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
|
|
20
22
|
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
21
23
|
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
22
24
|
import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
|
|
23
25
|
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, TextField, Typography } from "@mui/material";
|
|
24
26
|
import { doc, getDoc } from "firebase/firestore";
|
|
25
27
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
28
|
+
import { PayLinkReadinessNotice, usePayLinkReadiness } from "./pay-link-readiness-notice.component.js";
|
|
26
29
|
/** `Oct 29, 2026, 3:04 PM`. */ const sentAt = (atMs)=>new Date(atMs).toLocaleString('en-US', {
|
|
27
30
|
dateStyle: 'medium',
|
|
28
31
|
timeStyle: 'short'
|
|
@@ -42,16 +45,38 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
42
45
|
* invoice PDF attached. Unpaid, the email carries a Pay button to the order's
|
|
43
46
|
* lasting pay link on the business's site; paid, it is the customer's record.
|
|
44
47
|
* A quote's invoice lands in the quote's conversation, and an order's in its
|
|
45
|
-
* own.
|
|
46
|
-
*
|
|
48
|
+
* own.
|
|
49
|
+
*
|
|
50
|
+
* The form's body mounts with the dialog's opening, so everything it reads
|
|
51
|
+
* (the site's name and contact email, once; the store's tax choice and its
|
|
52
|
+
* payments, live) is read only while it is open, and the dialog that offers
|
|
53
|
+
* it listens to nothing more. It says what the customer's Pay waits on, if
|
|
54
|
+
* anything (AGL-4162), and judges the send under the store's sales tax choice
|
|
55
|
+
* as the server does: a quote saved before the store chose is sent as the
|
|
56
|
+
* store's choice prices it.
|
|
47
57
|
*/ export function InvoiceSendDialog(props) {
|
|
48
|
-
const { open, onClose
|
|
58
|
+
const { open, onClose } = props;
|
|
59
|
+
const [busy, setBusy] = useState(false);
|
|
60
|
+
return /*#__PURE__*/ _jsx(Dialog, {
|
|
61
|
+
open: open,
|
|
62
|
+
onClose: busy ? undefined : onClose,
|
|
63
|
+
maxWidth: "sm",
|
|
64
|
+
fullWidth: true,
|
|
65
|
+
"aria-labelledby": "invoice-send-title",
|
|
66
|
+
children: /*#__PURE__*/ _jsx(InvoiceSendForm, _extends({}, props, {
|
|
67
|
+
busy: busy,
|
|
68
|
+
setBusy: setBusy
|
|
69
|
+
}))
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** The open form: filled once when it mounts; edits after that are the member's. */ function InvoiceSendForm(props) {
|
|
73
|
+
var _readiness_gaps, _readiness_gaps1;
|
|
74
|
+
const { onClose, hostId, orderId, order, busy, setBusy } = props;
|
|
49
75
|
const firestore = useFirestore();
|
|
50
76
|
const { data: user } = useUser();
|
|
51
77
|
const { enqueueSnackbar } = useSnackbar();
|
|
52
|
-
const [
|
|
53
|
-
const [
|
|
54
|
-
const [subject, setSubject] = useState('');
|
|
78
|
+
const [to, setTo] = useState(()=>CommerceModel.invoiceSendPrefill(order));
|
|
79
|
+
const [subject, setSubject] = useState(()=>CommerceModel.invoiceEmailDefaultSubject(order, '', orderId));
|
|
55
80
|
const [message, setMessage] = useState('');
|
|
56
81
|
const [contact, setContact] = useState(null);
|
|
57
82
|
/*
|
|
@@ -67,11 +92,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
67
92
|
message
|
|
68
93
|
]);
|
|
69
94
|
useEffect(()=>{
|
|
70
|
-
if (!open) return;
|
|
71
95
|
let live = true;
|
|
72
|
-
setTo(CommerceModel.invoiceSendPrefill(order));
|
|
73
|
-
setSubject(CommerceModel.invoiceEmailDefaultSubject(order, '', orderId));
|
|
74
|
-
setMessage('');
|
|
75
96
|
void getDoc(doc(firestore, 'hosts', hostId)).then((snapshot)=>{
|
|
76
97
|
var _snapshot_data, _resolveHostToken;
|
|
77
98
|
if (!live) return;
|
|
@@ -86,13 +107,16 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
86
107
|
};
|
|
87
108
|
// Filled once per opening; edits after that are the member's.
|
|
88
109
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
|
-
}, [
|
|
90
|
-
|
|
91
|
-
]);
|
|
110
|
+
}, []);
|
|
111
|
+
const readiness = usePayLinkReadiness(hostId, order);
|
|
92
112
|
const paid = CommerceModel.invoiceIsPaid(order);
|
|
93
|
-
const refused = CommerceModel.invoiceSendRefusal(order, orderId, to.trim());
|
|
94
|
-
// The address is the form's to fix; every other refusal is the order's,
|
|
113
|
+
const refused = CommerceModel.invoiceSendRefusal(order, orderId, to.trim(), readiness.store);
|
|
114
|
+
// The address is the form's to fix; every other refusal is the order's,
|
|
115
|
+
// said up front once the store's settings are read. One the notice already
|
|
116
|
+
// names, with its fix, is not said twice.
|
|
95
117
|
const blocker = refused && refused !== 'no-address' && refused !== 'bad-address' ? refused : null;
|
|
118
|
+
const toldByNotice = blocker === 'tax-undecided' && ((_readiness_gaps = readiness.gaps) == null ? void 0 : _readiness_gaps.includes('tax-undecided')) || blocker === 'tax-save' && ((_readiness_gaps1 = readiness.gaps) == null ? void 0 : _readiness_gaps1.includes('tax-save'));
|
|
119
|
+
const blockerLine = blocker && !readiness.storeLoading && !toldByNotice ? blocker : null;
|
|
96
120
|
const threaded = Boolean(CommerceModel.invoiceEmailThread(order));
|
|
97
121
|
const number = CommerceModel.formatInvoiceNumber(order, orderId);
|
|
98
122
|
const send = useCallback(async ()=>{
|
|
@@ -143,14 +167,10 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
143
167
|
message,
|
|
144
168
|
number,
|
|
145
169
|
enqueueSnackbar,
|
|
146
|
-
onClose
|
|
170
|
+
onClose,
|
|
171
|
+
setBusy
|
|
147
172
|
]);
|
|
148
|
-
return /*#__PURE__*/ _jsxs(
|
|
149
|
-
open: open,
|
|
150
|
-
onClose: busy ? undefined : onClose,
|
|
151
|
-
maxWidth: "sm",
|
|
152
|
-
fullWidth: true,
|
|
153
|
-
"aria-labelledby": "invoice-send-title",
|
|
173
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
154
174
|
children: [
|
|
155
175
|
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
156
176
|
id: "invoice-send-title",
|
|
@@ -163,10 +183,14 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
163
183
|
pt: 1
|
|
164
184
|
},
|
|
165
185
|
children: [
|
|
166
|
-
|
|
186
|
+
/*#__PURE__*/ _jsx(PayLinkReadinessNotice, {
|
|
187
|
+
readiness: readiness,
|
|
188
|
+
noun: "invoice"
|
|
189
|
+
}),
|
|
190
|
+
blockerLine ? /*#__PURE__*/ _jsx(Typography, {
|
|
167
191
|
variant: "body2",
|
|
168
192
|
color: "error",
|
|
169
|
-
children: CommerceModel.invoiceSendRefusalMessage(
|
|
193
|
+
children: CommerceModel.invoiceSendRefusalMessage(blockerLine)
|
|
170
194
|
}) : null,
|
|
171
195
|
/*#__PURE__*/ _jsx(TextField, {
|
|
172
196
|
label: "To",
|
|
@@ -220,11 +244,15 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
220
244
|
disabled: busy,
|
|
221
245
|
children: 'Cancel'
|
|
222
246
|
}),
|
|
223
|
-
/*#__PURE__*/ _jsx(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
247
|
+
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
248
|
+
blocked: Boolean(blocker) && !readiness.storeLoading,
|
|
249
|
+
reason: blocker ? CommerceModel.invoiceSendRefusalMessage(blocker) : '',
|
|
250
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
251
|
+
variant: "contained",
|
|
252
|
+
disabled: busy || !to.trim() || Boolean(blocker) || readiness.storeLoading,
|
|
253
|
+
onClick: ()=>void send(),
|
|
254
|
+
children: busy ? 'Sending…' : 'Send'
|
|
255
|
+
})
|
|
228
256
|
})
|
|
229
257
|
]
|
|
230
258
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/invoice-send.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 * as CommerceModel from '../../model'\nimport { siteContactEmail, resolveHostToken, type HostTokenSource } from '@aglyn/aglyn/app-utils/host-tokens'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { doc, getDoc } from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\n/** `Oct 29, 2026, 3:04 PM`. */\nconst sentAt = (atMs: number) =>\n new Date(atMs).toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short' })\n\n/**\n * The order's (or the quote's) last invoice email, as the console says it:\n * `Invoice sent Oct 29, 2026, 3:04 PM to jordan@example.com.` Null when none\n * was sent.\n */\nexport function invoiceSentLine(order: Pick<CommerceModel.HostOrder, 'invoiceSends'>): string | null {\n const last = CommerceModel.lastInvoiceSend(order)\n if (!last) return null\n return `${last.paid ? 'Paid invoice' : 'Invoice'} sent ${sentAt(Number(last.atMs))} to ${last.to || 'the customer'}.`\n}\n\nexport interface InvoiceSendDialogProps {\n open: boolean\n onClose: () => void\n hostId: string\n orderId: string\n order: CommerceModel.HostOrder\n}\n\n/**\n * Send invoice (AGL-4099), for an order or a quote: a short form (To,\n * Subject, Message) that emails the invoice in the site's look with the\n * invoice PDF attached. Unpaid, the email carries a Pay button to the order's\n * lasting pay link on the business's site; paid, it is the customer's record.\n * A quote's invoice lands in the quote's conversation, and an order's in its\n * own. The site's name and contact email are read once when the form opens,\n * so the dialog that offers it listens to nothing more.\n */\nexport function InvoiceSendDialog(props: InvoiceSendDialogProps) {\n const { open, onClose, hostId, orderId, order } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [busy, setBusy] = useState(false)\n const [to, setTo] = useState('')\n const [subject, setSubject] = useState('')\n const [message, setMessage] = useState('')\n const [contact, setContact] = useState<string | null>(null)\n\n /*\n * One attempt per form (AGL-1697's rule): a retried Send presents the same\n * key and is answered from the first, so the customer never gets two; a\n * changed form is a new attempt.\n */\n const attemptKey = useRef('')\n useEffect(() => {\n attemptKey.current = ''\n }, [to, subject, message])\n\n useEffect(() => {\n if (!open) return\n let live = true\n setTo(CommerceModel.invoiceSendPrefill(order))\n setSubject(CommerceModel.invoiceEmailDefaultSubject(order, '', orderId))\n setMessage('')\n void getDoc(doc(firestore, 'hosts', hostId))\n .then((snapshot) => {\n if (!live) return\n const host = (snapshot.data() ?? {}) as Record<string, unknown>\n const businessName = String(resolveHostToken('businessName', host as HostTokenSource) ?? '').trim()\n setSubject(CommerceModel.invoiceEmailDefaultSubject(order, businessName, orderId))\n const listed = siteContactEmail(host as never)\n setContact(listed && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(listed) ? listed : null)\n })\n .catch(() => undefined)\n return () => {\n live = false\n }\n // Filled once per opening; edits after that are the member's.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open])\n\n const paid = CommerceModel.invoiceIsPaid(order)\n const refused = CommerceModel.invoiceSendRefusal(order, orderId, to.trim())\n // The address is the form's to fix; every other refusal is the order's, said up front.\n const blocker = refused && refused !== 'no-address' && refused !== 'bad-address' ? refused : null\n const threaded = Boolean(CommerceModel.invoiceEmailThread(order))\n const number = CommerceModel.formatInvoiceNumber(order, orderId)\n\n const send = useCallback(async () => {\n setBusy(true)\n try {\n if (!attemptKey.current) {\n attemptKey.current = globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n }\n const response = await authorizedFetch(user, '/api/commerce/order-invoice-send', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey.current },\n body: JSON.stringify({ hostId, orderId, to, subject, message }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'The invoice could not be sent', { variant: 'error', allowDuplicate: true })\n }\n enqueueSnackbar(`${number} sent to ${String(payload.to ?? to)}`, { variant: 'success', persist: false })\n onClose()\n } finally {\n setBusy(false)\n }\n }, [user, hostId, orderId, to, subject, message, number, enqueueSnackbar, onClose])\n\n return (\n <Dialog open={open} onClose={busy ? undefined : onClose} maxWidth=\"sm\" fullWidth aria-labelledby=\"invoice-send-title\">\n <DialogTitle id=\"invoice-send-title\">{`Send invoice: ${number}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n {blocker ? (\n <Typography variant=\"body2\" color=\"error\">\n {CommerceModel.invoiceSendRefusalMessage(blocker)}\n </Typography>\n ) : null}\n <TextField\n label=\"To\"\n type=\"email\"\n value={to}\n onChange={(event) => setTo(event.target.value)}\n required\n fullWidth\n disabled={busy}\n />\n <TextField\n label=\"Subject\"\n value={subject}\n onChange={(event) => setSubject(event.target.value)}\n fullWidth\n disabled={busy}\n slotProps={{ htmlInput: { maxLength: CommerceModel.QUOTE_MAX_SEND_SUBJECT } }}\n helperText={\n threaded\n ? 'Keep the subject the same to keep these emails in one conversation in your customer’s inbox.'\n : undefined\n }\n />\n <TextField\n label=\"Message\"\n value={message}\n onChange={(event) => setMessage(event.target.value)}\n multiline\n minRows={4}\n fullWidth\n disabled={busy}\n slotProps={{ htmlInput: { maxLength: CommerceModel.QUOTE_MAX_SEND_MESSAGE } }}\n helperText=\"Shown at the top of the email, in your words.\"\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {(paid\n ? 'The email shows the invoice as paid, with the date it was paid, for your customer’s records. '\n : 'The email shows the invoice number, date, total and what is due, with a button to pay it by card on your site. The button keeps working until it is paid. ') +\n `The invoice is attached as a PDF. Replies go to ${contact || 'your email'}.`}\n </Typography>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !to.trim() || Boolean(blocker)} onClick={() => void send()}>\n {busy ? 'Sending…' : 'Send'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\nInvoiceSendDialog.displayName = 'InvoiceSendDialog'\n\nexport default InvoiceSendDialog\n"],"names":["CommerceModel","siteContactEmail","resolveHostToken","useSnackbar","authorizedFetch","useFirestore","useUser","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","TextField","Typography","doc","getDoc","useCallback","useEffect","useRef","useState","sentAt","atMs","Date","toLocaleString","dateStyle","timeStyle","invoiceSentLine","order","last","lastInvoiceSend","paid","Number","to","InvoiceSendDialog","props","open","onClose","hostId","orderId","firestore","data","user","enqueueSnackbar","busy","setBusy","setTo","subject","setSubject","message","setMessage","contact","setContact","attemptKey","current","live","invoiceSendPrefill","invoiceEmailDefaultSubject","then","snapshot","host","businessName","String","trim","listed","test","catch","undefined","invoiceIsPaid","refused","invoiceSendRefusal","blocker","threaded","Boolean","invoiceEmailThread","number","formatInvoiceNumber","send","payload","globalThis","crypto","randomUUID","now","Math","random","toString","slice","response","method","headers","body","JSON","stringify","json","ok","error","variant","allowDuplicate","persist","maxWidth","fullWidth","aria-labelledby","id","spacing","sx","pt","color","invoiceSendRefusalMessage","label","type","value","onChange","event","target","required","disabled","slotProps","htmlInput","maxLength","QUOTE_MAX_SEND_SUBJECT","helperText","multiline","minRows","QUOTE_MAX_SEND_MESSAGE","onClick","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,gBAAgB,EAAEC,gBAAgB,QAA8B,qCAAoC;AAC7G,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,OAAO,QAAQ,iCAAgC;AACtE,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,GAAG,EAAEC,MAAM,QAAQ,qBAAoB;AAChD,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAEhE,6BAA6B,GA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MAAM,CAACH,KAAK;4BAClDV,SAAS;4BACTe,UAAUvE;4BACVwE,WAAW;gCAAEC,WAAW;oCAAEC,WAAWtH,cAAcuH,sBAAsB;gCAAC;4BAAE;4BAC5EC,YACEhD,WACI,iGACAL;;sCAGR,KAACtD;4BACC+F,OAAM;4BACNE,OAAO7D;4BACP8D,UAAU,CAACC,QAAU9D,WAAW8D,MAAMC,MAAM,CAACH,KAAK;4BAClDW,SAAS;4BACTC,SAAS;4BACTtB,SAAS;4BACTe,UAAUvE;4BACVwE,WAAW;gCAAEC,WAAW;oCAAEC,WAAWtH,cAAc2H,sBAAsB;gCAAC;4BAAE;4BAC5EH,YAAW;;sCAEb,KAAC1G;4BAAWkF,SAAQ;4BAAQU,OAAM;sCAC/B,AAAC3E,CAAAA,OACE,kGACA,4JAA2J,IAC7J,CAAC,gDAAgD,EAAEoB,WAAW,aAAa,CAAC,CAAC;;;;;0BAIrF,MAAC1C;;kCACC,KAACF;wBAAOqH,SAASvF;wBAAS8E,UAAUvE;kCACjC;;kCAEH,KAACrC;wBAAOyF,SAAQ;wBAAYmB,UAAUvE,QAAQ,CAACX,GAAG8B,IAAI,MAAMU,QAAQF;wBAAUqD,SAAS,IAAM,KAAK/C;kCAC/FjC,OAAO,aAAa;;;;;;AAK/B;AACAV,kBAAkB2F,WAAW,GAAG;AAEhC,eAAe3F,kBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/invoice-send.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 * as CommerceModel from '../../model'\nimport { siteContactEmail, resolveHostToken, type HostTokenSource } from '@aglyn/aglyn/app-utils/host-tokens'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { doc, getDoc } from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { PayLinkReadinessNotice, usePayLinkReadiness } from './pay-link-readiness-notice.component'\n\n/** `Oct 29, 2026, 3:04 PM`. */\nconst sentAt = (atMs: number) =>\n new Date(atMs).toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short' })\n\n/**\n * The order's (or the quote's) last invoice email, as the console says it:\n * `Invoice sent Oct 29, 2026, 3:04 PM to jordan@example.com.` Null when none\n * was sent.\n */\nexport function invoiceSentLine(order: Pick<CommerceModel.HostOrder, 'invoiceSends'>): string | null {\n const last = CommerceModel.lastInvoiceSend(order)\n if (!last) return null\n return `${last.paid ? 'Paid invoice' : 'Invoice'} sent ${sentAt(Number(last.atMs))} to ${last.to || 'the customer'}.`\n}\n\nexport interface InvoiceSendDialogProps {\n open: boolean\n onClose: () => void\n hostId: string\n orderId: string\n order: CommerceModel.HostOrder\n}\n\n/**\n * Send invoice (AGL-4099), for an order or a quote: a short form (To,\n * Subject, Message) that emails the invoice in the site's look with the\n * invoice PDF attached. Unpaid, the email carries a Pay button to the order's\n * lasting pay link on the business's site; paid, it is the customer's record.\n * A quote's invoice lands in the quote's conversation, and an order's in its\n * own.\n *\n * The form's body mounts with the dialog's opening, so everything it reads\n * (the site's name and contact email, once; the store's tax choice and its\n * payments, live) is read only while it is open, and the dialog that offers\n * it listens to nothing more. It says what the customer's Pay waits on, if\n * anything (AGL-4162), and judges the send under the store's sales tax choice\n * as the server does: a quote saved before the store chose is sent as the\n * store's choice prices it.\n */\nexport function InvoiceSendDialog(props: InvoiceSendDialogProps) {\n const { open, onClose } = props\n const [busy, setBusy] = useState(false)\n return (\n <Dialog open={open} onClose={busy ? undefined : onClose} maxWidth=\"sm\" fullWidth aria-labelledby=\"invoice-send-title\">\n <InvoiceSendForm {...props} busy={busy} setBusy={setBusy} />\n </Dialog>\n )\n}\n\n/** The open form: filled once when it mounts; edits after that are the member's. */\nfunction InvoiceSendForm(\n props: InvoiceSendDialogProps & { busy: boolean; setBusy: (busy: boolean) => void },\n) {\n const { onClose, hostId, orderId, order, busy, setBusy } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [to, setTo] = useState(() => CommerceModel.invoiceSendPrefill(order))\n const [subject, setSubject] = useState(() => CommerceModel.invoiceEmailDefaultSubject(order, '', orderId))\n const [message, setMessage] = useState('')\n const [contact, setContact] = useState<string | null>(null)\n\n /*\n * One attempt per form (AGL-1697's rule): a retried Send presents the same\n * key and is answered from the first, so the customer never gets two; a\n * changed form is a new attempt.\n */\n const attemptKey = useRef('')\n useEffect(() => {\n attemptKey.current = ''\n }, [to, subject, message])\n\n useEffect(() => {\n let live = true\n void getDoc(doc(firestore, 'hosts', hostId))\n .then((snapshot) => {\n if (!live) return\n const host = (snapshot.data() ?? {}) as Record<string, unknown>\n const businessName = String(resolveHostToken('businessName', host as HostTokenSource) ?? '').trim()\n setSubject(CommerceModel.invoiceEmailDefaultSubject(order, businessName, orderId))\n const listed = siteContactEmail(host as never)\n setContact(listed && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(listed) ? listed : null)\n })\n .catch(() => undefined)\n return () => {\n live = false\n }\n // Filled once per opening; edits after that are the member's.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const readiness = usePayLinkReadiness(hostId, order)\n const paid = CommerceModel.invoiceIsPaid(order)\n const refused = CommerceModel.invoiceSendRefusal(order, orderId, to.trim(), readiness.store)\n // The address is the form's to fix; every other refusal is the order's,\n // said up front once the store's settings are read. One the notice already\n // names, with its fix, is not said twice.\n const blocker = refused && refused !== 'no-address' && refused !== 'bad-address' ? refused : null\n const toldByNotice =\n (blocker === 'tax-undecided' && readiness.gaps?.includes('tax-undecided')) ||\n (blocker === 'tax-save' && readiness.gaps?.includes('tax-save'))\n const blockerLine = blocker && !readiness.storeLoading && !toldByNotice ? blocker : null\n const threaded = Boolean(CommerceModel.invoiceEmailThread(order))\n const number = CommerceModel.formatInvoiceNumber(order, orderId)\n\n const send = useCallback(async () => {\n setBusy(true)\n try {\n if (!attemptKey.current) {\n attemptKey.current = globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n }\n const response = await authorizedFetch(user, '/api/commerce/order-invoice-send', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey.current },\n body: JSON.stringify({ hostId, orderId, to, subject, message }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'The invoice could not be sent', { variant: 'error', allowDuplicate: true })\n }\n enqueueSnackbar(`${number} sent to ${String(payload.to ?? to)}`, { variant: 'success', persist: false })\n onClose()\n } finally {\n setBusy(false)\n }\n }, [user, hostId, orderId, to, subject, message, number, enqueueSnackbar, onClose, setBusy])\n\n return (\n <>\n <DialogTitle id=\"invoice-send-title\">{`Send invoice: ${number}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <PayLinkReadinessNotice readiness={readiness} noun=\"invoice\" />\n {blockerLine ? (\n <Typography variant=\"body2\" color=\"error\">\n {CommerceModel.invoiceSendRefusalMessage(blockerLine)}\n </Typography>\n ) : null}\n <TextField\n label=\"To\"\n type=\"email\"\n value={to}\n onChange={(event) => setTo(event.target.value)}\n required\n fullWidth\n disabled={busy}\n />\n <TextField\n label=\"Subject\"\n value={subject}\n onChange={(event) => setSubject(event.target.value)}\n fullWidth\n disabled={busy}\n slotProps={{ htmlInput: { maxLength: CommerceModel.QUOTE_MAX_SEND_SUBJECT } }}\n helperText={\n threaded\n ? 'Keep the subject the same to keep these emails in one conversation in your customer’s inbox.'\n : undefined\n }\n />\n <TextField\n label=\"Message\"\n value={message}\n onChange={(event) => setMessage(event.target.value)}\n multiline\n minRows={4}\n fullWidth\n disabled={busy}\n slotProps={{ htmlInput: { maxLength: CommerceModel.QUOTE_MAX_SEND_MESSAGE } }}\n helperText=\"Shown at the top of the email, in your words.\"\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {(paid\n ? 'The email shows the invoice as paid, with the date it was paid, for your customer’s records. '\n : 'The email shows the invoice number, date, total and what is due, with a button to pay it by card on your site. The button keeps working until it is paid. ') +\n `The invoice is attached as a PDF. Replies go to ${contact || 'your email'}.`}\n </Typography>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={busy}>\n {'Cancel'}\n </Button>\n <BlockedControl\n blocked={Boolean(blocker) && !readiness.storeLoading}\n reason={blocker ? CommerceModel.invoiceSendRefusalMessage(blocker) : ''}\n >\n <Button\n variant=\"contained\"\n disabled={busy || !to.trim() || Boolean(blocker) || readiness.storeLoading}\n onClick={() => void send()}\n >\n {busy ? 'Sending…' : 'Send'}\n </Button>\n </BlockedControl>\n </DialogActions>\n </>\n )\n}\n\nInvoiceSendDialog.displayName = 'InvoiceSendDialog'\n\nexport default InvoiceSendDialog\n"],"names":["CommerceModel","siteContactEmail","resolveHostToken","BlockedControl","useSnackbar","authorizedFetch","useFirestore","useUser","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","TextField","Typography","doc","getDoc","useCallback","useEffect","useRef","useState","PayLinkReadinessNotice","usePayLinkReadiness","sentAt","atMs","Date","toLocaleString","dateStyle","timeStyle","invoiceSentLine","order","last","lastInvoiceSend","paid","Number","to","InvoiceSendDialog","props","open","onClose","busy","setBusy","undefined","maxWidth","fullWidth","aria-labelledby","InvoiceSendForm","readiness","hostId","orderId","firestore","data","user","enqueueSnackbar","setTo","invoiceSendPrefill","subject","setSubject","invoiceEmailDefaultSubject","message","setMessage","contact","setContact","attemptKey","current","live","then","snapshot","host","businessName","String","trim","listed","test","catch","invoiceIsPaid","refused","invoiceSendRefusal","store","blocker","toldByNotice","gaps","includes","blockerLine","storeLoading","threaded","Boolean","invoiceEmailThread","number","formatInvoiceNumber","send","payload","globalThis","crypto","randomUUID","now","Math","random","toString","slice","response","method","headers","body","JSON","stringify","json","ok","error","variant","allowDuplicate","persist","id","spacing","sx","pt","noun","color","invoiceSendRefusalMessage","label","type","value","onChange","event","target","required","disabled","slotProps","htmlInput","maxLength","QUOTE_MAX_SEND_SUBJECT","helperText","multiline","minRows","QUOTE_MAX_SEND_MESSAGE","onClick","blocked","reason","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,gBAAgB,EAAEC,gBAAgB,QAA8B,qCAAoC;AAC7G,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,OAAO,QAAQ,iCAAgC;AACtE,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,GAAG,EAAEC,MAAM,QAAQ,qBAAoB;AAChD,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,2CAAuC;AAEnG,6BAA6B,GAC7B,MAAMC,SAAS,CAACC,OACd,IAAIC,KAAKD,MAAME,cAAc,CAAC,SAAS;QAAEC,WAAW;QAAUC,WAAW;IAAQ;AAEnF;;;;CAIC,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CsG,SAAQ;4BACRiB,UAAUtF,QAAQ,CAACL,GAAGoC,IAAI,MAAMe,QAAQP,YAAYhC,UAAUqC,YAAY;4BAC1EmD,SAAS,IAAM,KAAK7C;sCAEnBlD,OAAO,aAAa;;;;;;;AAMjC;AAEAJ,kBAAkBsG,WAAW,GAAG;AAEhC,eAAetG,kBAAiB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import * as CommerceModel from '../../model';
|
|
18
|
+
import { type AlertProps } from '@mui/material';
|
|
19
|
+
/** An order the pay link may charge: a quote or a draft order; null for a quote not saved yet. */
|
|
20
|
+
export type PayLinkNoticeOrder = (Pick<CommerceModel.HostOrder, 'status' | 'channel'> & Partial<Pick<CommerceModel.HostOrder, 'quote'>>) | null;
|
|
21
|
+
/** Where a pay link stands with the business's setup, as the console reads it. */
|
|
22
|
+
export interface PayLinkReadiness {
|
|
23
|
+
/** What the notice names (`payLinkGaps`); null while anything is still being read. */
|
|
24
|
+
gaps: CommerceModel.PayLinkGap[] | null;
|
|
25
|
+
/** The store's sales tax choice; undefined while it is read, or when it can't be. */
|
|
26
|
+
store: CommerceModel.PayLinkStore | undefined;
|
|
27
|
+
/** The store's settings are still being read. */
|
|
28
|
+
storeLoading: boolean;
|
|
29
|
+
/** Why the workspace can't take card payments, in `useMerchantPayments`'s words. */
|
|
30
|
+
paymentsReason: string | null;
|
|
31
|
+
/** The site's Payments settings page. */
|
|
32
|
+
paymentsHref: string | null;
|
|
33
|
+
/** The site's Taxes settings page. */
|
|
34
|
+
taxesHref: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether customers can pay an order's pay link, for the console's notice
|
|
38
|
+
* (AGL-4162): the workspace owner's payment account (`useMerchantPayments`,
|
|
39
|
+
* the client's copy of the check the page and Pay make) and the store's
|
|
40
|
+
* sales tax choice, read live. Without a site nothing is read and nothing is
|
|
41
|
+
* answered, so a form can hold its reads until it opens.
|
|
42
|
+
*/
|
|
43
|
+
export declare function usePayLinkReadiness(hostId: string | undefined, order: PayLinkNoticeOrder): PayLinkReadiness;
|
|
44
|
+
/** The notice's first line: `Customers can’t pay this quote online yet.` */
|
|
45
|
+
export declare function payLinkNoticeTitle(noun: 'quote' | 'invoice'): string;
|
|
46
|
+
/** What the notice says about one gap, and the button that fixes it where a page does. */
|
|
47
|
+
export declare function payLinkGapLine(gap: CommerceModel.PayLinkGap, input: Pick<PayLinkReadiness, 'paymentsReason' | 'paymentsHref' | 'taxesHref'> & {
|
|
48
|
+
noun: 'quote' | 'invoice';
|
|
49
|
+
}): {
|
|
50
|
+
text: string;
|
|
51
|
+
action: string | null;
|
|
52
|
+
href: string | null;
|
|
53
|
+
};
|
|
54
|
+
export interface PayLinkReadinessNoticeProps {
|
|
55
|
+
readiness: PayLinkReadiness;
|
|
56
|
+
/** What the customer's page calls it: a quote, or an invoice in the Send invoice form. */
|
|
57
|
+
noun: 'quote' | 'invoice';
|
|
58
|
+
sx?: AlertProps['sx'];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* "Customers can't pay this quote online yet." (AGL-4162), naming each setup
|
|
62
|
+
* step a customer's Pay waits on, with a button to the page that fixes it.
|
|
63
|
+
* Drawn only once both answers are in, and only when something is missing.
|
|
64
|
+
* The notice holds nothing back itself: the quote can still be sent and its
|
|
65
|
+
* link copied, for a business that takes the payment another way.
|
|
66
|
+
*/
|
|
67
|
+
export declare function PayLinkReadinessNotice(props: PayLinkReadinessNoticeProps): import("react").JSX.Element;
|
|
68
|
+
export declare namespace PayLinkReadinessNotice {
|
|
69
|
+
var displayName: string;
|
|
70
|
+
}
|
|
71
|
+
export interface PayLinkReadinessNoticeForProps extends Omit<PayLinkReadinessNoticeProps, 'readiness'> {
|
|
72
|
+
hostId: string;
|
|
73
|
+
order: PayLinkNoticeOrder;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The notice with its own reads ({@link usePayLinkReadiness}), for a surface
|
|
77
|
+
* that mounts it only while it is on screen: a form's body, or a section
|
|
78
|
+
* drawn only for an unpaid quote.
|
|
79
|
+
*/
|
|
80
|
+
export declare function PayLinkReadinessNoticeFor(props: PayLinkReadinessNoticeForProps): import("react").JSX.Element;
|
|
81
|
+
export declare namespace PayLinkReadinessNoticeFor {
|
|
82
|
+
var displayName: string;
|
|
83
|
+
}
|
|
84
|
+
export default PayLinkReadinessNotice;
|