@aglyn/plugins-commerce 1.12.0 → 1.14.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.
Files changed (79) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/console/catalog-organization-card.component.js +1 -1
  3. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
  4. package/src/lib/components/console/host-quotes-card.component.js +3 -2
  5. package/src/lib/components/console/host-quotes-card.component.js.map +1 -1
  6. package/src/lib/components/console/order-detail-dialog.component.js +1 -1
  7. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  8. package/src/lib/components/console/pay-link-readiness-notice.component.d.ts +1 -1
  9. package/src/lib/components/console/pay-link-readiness-notice.component.js.map +1 -1
  10. package/src/lib/components/console/pos-devices-card.component.js +2 -2
  11. package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
  12. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +1 -1
  13. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
  14. package/src/lib/components/console/pos-ops/pos-day-totals-card.component.js +1 -1
  15. package/src/lib/components/console/pos-ops/pos-day-totals-card.component.js.map +1 -1
  16. package/src/lib/components/console/pos-reader-splash-setting.component.js +1 -1
  17. package/src/lib/components/console/pos-reader-splash-setting.component.js.map +1 -1
  18. package/src/lib/components/console/quote-editor-dialog.component.d.ts +5 -0
  19. package/src/lib/components/console/quote-editor-dialog.component.js +104 -16
  20. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  21. package/src/lib/components/console/quote-pay-link.component.d.ts +4 -1
  22. package/src/lib/components/console/quote-pay-link.component.js +23 -12
  23. package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
  24. package/src/lib/components/console/quote-proofs.component.d.ts +3 -2
  25. package/src/lib/components/console/quote-proofs.component.js +73 -5
  26. package/src/lib/components/console/quote-proofs.component.js.map +1 -1
  27. package/src/lib/components/console/quote-send.component.js +9 -6
  28. package/src/lib/components/console/quote-send.component.js.map +1 -1
  29. package/src/lib/components/console/site-member-purchases.component.js +1 -1
  30. package/src/lib/components/console/site-member-purchases.component.js.map +1 -1
  31. package/src/lib/components/quote-page-body.js +14 -8
  32. package/src/lib/components/quote-page-body.js.map +1 -1
  33. package/src/lib/model/commerce-invoices.d.ts +1 -1
  34. package/src/lib/model/commerce-invoices.js +4 -1
  35. package/src/lib/model/commerce-invoices.js.map +1 -1
  36. package/src/lib/model/commerce-quote-email.d.ts +7 -6
  37. package/src/lib/model/commerce-quote-email.js +11 -6
  38. package/src/lib/model/commerce-quote-email.js.map +1 -1
  39. package/src/lib/model/commerce-quote-pay.d.ts +6 -1
  40. package/src/lib/model/commerce-quote-pay.js +18 -8
  41. package/src/lib/model/commerce-quote-pay.js.map +1 -1
  42. package/src/lib/model/commerce-quote-proofs.d.ts +28 -1
  43. package/src/lib/model/commerce-quote-proofs.js +58 -2
  44. package/src/lib/model/commerce-quote-proofs.js.map +1 -1
  45. package/src/lib/model/commerce-quotes.d.ts +22 -1
  46. package/src/lib/model/commerce-quotes.js +25 -5
  47. package/src/lib/model/commerce-quotes.js.map +1 -1
  48. package/src/lib/model/plugin-permissions.d.ts +1 -1
  49. package/src/lib/model/plugin-permissions.js +10 -0
  50. package/src/lib/model/plugin-permissions.js.map +1 -1
  51. package/src/lib/server/commerce-pdf.d.ts +1 -1
  52. package/src/lib/server/commerce-pdf.js +1 -1
  53. package/src/lib/server/commerce-pdf.js.map +1 -1
  54. package/src/lib/server/paid-media-delivery.js +1 -1
  55. package/src/lib/server/paid-media-delivery.js.map +1 -1
  56. package/src/lib/server/quote-email.js +29 -25
  57. package/src/lib/server/quote-email.js.map +1 -1
  58. package/src/lib/server/quote-pay.js +6 -2
  59. package/src/lib/server/quote-pay.js.map +1 -1
  60. package/src/lib/server/quote-proof-media.d.ts +63 -0
  61. package/src/lib/server/quote-proof-media.js +96 -0
  62. package/src/lib/server/quote-proof-media.js.map +1 -0
  63. package/src/lib/server/quote-proofs.js +9 -5
  64. package/src/lib/server/quote-proofs.js.map +1 -1
  65. package/src/lib/server/quote-uploads.d.ts +3 -1
  66. package/src/lib/server/quote-uploads.js +2 -1
  67. package/src/lib/server/quote-uploads.js.map +1 -1
  68. package/src/lib/server/quote.d.ts +3 -0
  69. package/src/lib/server/quote.js +127 -20
  70. package/src/lib/server/quote.js.map +1 -1
  71. package/src/lib/tenant-emails.js +16 -9
  72. package/src/lib/tenant-emails.js.map +1 -1
  73. package/src/lib/transfer/gift-cards.server.js +9 -11
  74. package/src/lib/transfer/gift-cards.server.js.map +1 -1
  75. package/src/lib/utils/commerce-document-pdf.js +12 -9
  76. package/src/lib/utils/commerce-document-pdf.js.map +1 -1
  77. package/src/lib/utils/quote-email-content.d.ts +2 -0
  78. package/src/lib/utils/quote-email-content.js +20 -10
  79. package/src/lib/utils/quote-email-content.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-pay-link.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 { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\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 { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useState } from 'react'\nimport { PayLinkReadinessNoticeFor } from './pay-link-readiness-notice.component'\n\nconst SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send')\n\nexport interface QuotePayLinkSectionProps {\n hostId: string\n quoteId: string\n quote: Pick<CommerceModel.HostOrder, 'status' | 'channel' | 'number' | 'quote'>\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n /** The editor holds changes not saved yet, which the link does not show. */\n edited: boolean\n}\n\n/**\n * A quote's pay link (AGL-4094): the address the business sends the\n * customer, which opens the quote on the business's own site with a Pay\n * button. \"Copy pay link\" asks the server for it (it is signed there) and puts\n * it on the clipboard and on screen; \"Replace link\" makes a new one and the\n * one sent before stops opening the quote.\n *\n * The link shown is kept with the version it was made at, and drops as soon\n * as the quote's stored version (`quote.linkVersion`) moves past it: a\n * revision's first email and Replace link (here or anywhere else) both move\n * it, and the link from before then opens only \"This quote was updated\". A\n * link already on screen is fetched again at the new version; Copy pay link\n * never copies one older than the quote's.\n *\n * Above it, what the customer's Pay waits on, if anything (AGL-4162): the\n * link can still be copied and sent.\n */\nexport function QuotePayLinkSection(props: QuotePayLinkSectionProps) {\n const { hostId, quoteId, quote, canSend, edited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [signed, setSigned] = useState<{ url: string; version: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingReplace, setConfirmingReplace] = useState(false)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const version = CommerceModel.quoteLinkVersion(quote.quote)\n // A link the server made at a version the stored quote has not caught up to yet is the newest one.\n const url = signed && signed.version >= version ? signed.url : ''\n\n const ask = useCallback(\n async (action: 'pay-link' | 'replace-link'): Promise<string | null> => {\n setBusy(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action, hostId, quoteId }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok || !payload?.url) {\n enqueueSnackbar(payload?.error ?? 'The pay link could not be made', { variant: 'error', allowDuplicate: true })\n return null\n }\n const made = Math.floor(Number(payload.linkVersion))\n setSigned({ url: String(payload.url), version: Number.isFinite(made) && made >= 1 ? made : version })\n return String(payload.url)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, version, enqueueSnackbar],\n )\n\n // The quote's link moved on (a revision was emailed, or the link replaced):\n // the one on screen opens nothing now, so fetch the current one in its place.\n const stale = signed !== null && signed.version < version\n useEffect(() => {\n if (stale) void ask('pay-link')\n // Once per version the quote moves to; `ask` changing does not ask again.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stale, version])\n\n const copy = useCallback(\n async (link: string, done: string) => {\n try {\n await navigator.clipboard.writeText(link)\n enqueueSnackbar(done, { variant: 'success', persist: false })\n } catch {\n // The link is on screen to copy by hand when the clipboard is refused.\n enqueueSnackbar('Copy the link below to send it', { variant: 'info', persist: false })\n }\n },\n [enqueueSnackbar],\n )\n\n const copyLink = useCallback(async () => {\n const link = url || (await ask('pay-link'))\n if (link) await copy(link, 'Pay link copied')\n }, [url, ask, copy])\n\n const replaceLink = useCallback(async () => {\n const link = await ask('replace-link')\n setConfirmingReplace(false)\n if (link) await copy(link, 'New pay link copied. The earlier link no longer opens the quote.')\n }, [ask, copy])\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{'Pay link'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {unpaid\n ? 'Send this link to the customer. It opens the quote on your site, where they can pay it.'\n : 'The link opens the paid quote and the customer’s order.'}\n </Typography>\n {edited && unpaid ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Save your changes first: the link opens the quote as it was last saved.'}\n </Typography>\n ) : null}\n </Stack>\n {unpaid ? <PayLinkReadinessNoticeFor hostId={hostId} order={quote} noun=\"quote\" /> : null}\n {url ? (\n <TextField\n label=\"Pay link\"\n value={url}\n size=\"small\"\n fullWidth\n slotProps={{ htmlInput: { readOnly: true }, inputLabel: { shrink: true } }}\n onFocus={(event) => event.target.select()}\n />\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button variant=\"outlined\" size=\"small\" disabled={busy} onClick={() => void copyLink()}>\n {'Copy pay link'}\n </Button>\n </BlockedControl>\n {unpaid ? (\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button size=\"small\" disabled={busy} onClick={() => setConfirmingReplace(true)}>\n {'Replace link'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n <Dialog open={confirmingReplace} onClose={() => setConfirmingReplace(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{'Replace the pay link?'}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {'The link you sent before will stop working: it will tell the customer the quote was updated, ' +\n 'and show nothing of it. Send them the new link.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingReplace(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void replaceLink()}>\n {'Replace link'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuotePayLinkSection.displayName = 'QuotePayLinkSection'\n\nexport default QuotePayLinkSection\n"],"names":["CommerceModel","commerceSitePermissionRefusal","BlockedControl","useSnackbar","authorizedFetch","useUser","Button","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Stack","TextField","Typography","useCallback","useEffect","useState","PayLinkReadinessNoticeFor","SEND_REFUSAL","QuotePayLinkSection","props","hostId","quoteId","quote","canSend","edited","data","user","enqueueSnackbar","signed","setSigned","busy","setBusy","confirmingReplace","setConfirmingReplace","unpaid","isUnpaidQuote","version","quoteLinkVersion","url","ask","action","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","variant","allowDuplicate","made","Math","floor","Number","linkVersion","String","isFinite","stale","copy","link","done","navigator","clipboard","writeText","persist","copyLink","replaceLink","spacing","color","order","noun","label","value","size","fullWidth","slotProps","htmlInput","readOnly","inputLabel","shrink","onFocus","event","target","select","direction","sx","flexWrap","rowGap","blocked","reason","disabled","onClick","open","onClose","maxWidth","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxD,SAASC,yBAAyB,QAAQ,2CAAuC;AAEjF,MAAMC,eAAelB,8BAA8B;AAYnD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASmB,oBAAoBC,KAA+B;IACjE,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IACpD,MAAM,EAAEM,MAAMC,IAAI,EAAE,GAAGvB;IACvB,MAAM,EAAEwB,eAAe,EAAE,GAAG1B;IAC5B,MAAM,CAAC2B,QAAQC,UAAU,GAAGd,SAAkD;IAC9E,MAAM,CAACe,MAAMC,QAAQ,GAAGhB,SAAS;IACjC,MAAM,CAACiB,mBAAmBC,qBAAqB,GAAGlB,SAAS;IAC3D,MAAMmB,SAASpC,cAAcqC,aAAa,CAACb;IAC3C,MAAMc,UAAUtC,cAAcuC,gBAAgB,CAACf,MAAMA,KAAK;IAC1D,mGAA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,MAAK;4BAAQiB,UAAUhE;4BAAMiE,SAAS,IAAM,KAAK1B;sCACzE;;;oBAGJnC,uBACC,KAAClC;wBAAe4F,SAAS,CAACrE;wBAASsE,QAAQ5E;kCACzC,cAAA,KAACb;4BAAOyE,MAAK;4BAAQiB,UAAUhE;4BAAMiE,SAAS,IAAM9D,qBAAqB;sCACtE;;yBAGH;;;0BAEN,MAAC5B;gBAAO2F,MAAMhE;gBAAmBiE,SAAS,IAAMhE,qBAAqB;gBAAQiE,UAAS;gBAAKpB,SAAS;;kCAClG,KAACrE;kCAAa;;kCACd,KAACF;kCACC,cAAA,KAACC;sCACE,kGACC;;;kCAGN,MAACF;;0CACC,KAACF;gCAAO2F,SAAS,IAAM9D,qBAAqB;gCAAQ6D,UAAUhE;0CAC3D;;0CAEH,KAAC1B;gCAAOgD,SAAQ;gCAAY0C,UAAUhE;gCAAMiE,SAAS,IAAM,KAAKzB;0CAC7D;;;;;;;;AAMb;AACApD,oBAAoBiF,WAAW,GAAG;AAElC,eAAejF,oBAAmB"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-pay-link.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 { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\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 { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useState } from 'react'\nimport { PayLinkReadinessNoticeFor } from './pay-link-readiness-notice.component'\n\nconst SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send')\n\nexport interface QuotePayLinkSectionProps {\n hostId: string\n quoteId: string\n quote: Pick<CommerceModel.HostOrder, 'status' | 'channel' | 'number' | 'quote' | 'lineItems'>\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n /** The editor holds changes not saved yet, which the link does not show. */\n edited: boolean\n}\n\n/**\n * A quote's pay link (AGL-4094): the address the business sends the\n * customer, which opens the quote on the business's own site with a Pay\n * button. \"Copy pay link\" asks the server for it (it is signed there) and puts\n * it on the clipboard and on screen; \"Replace link\" makes a new one and the\n * one sent before stops opening the quote.\n *\n * The link shown is kept with the version it was made at, and drops as soon\n * as the quote's stored version (`quote.linkVersion`) moves past it: a\n * revision's first email and Replace link (here or anywhere else) both move\n * it, and the link from before then opens only \"This quote was updated\". A\n * link already on screen is fetched again at the new version; Copy pay link\n * never copies one older than the quote's.\n *\n * Above it, what the customer's Pay waits on, if anything (AGL-4162): the\n * link can still be copied and sent.\n *\n * It is the same link on a proof only quote (AGL-4184), called what it opens\n * there: the proof, for whoever holds the link, with nothing to pay.\n */\nexport function QuotePayLinkSection(props: QuotePayLinkSectionProps) {\n const { hostId, quoteId, quote, canSend, edited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [signed, setSigned] = useState<{ url: string; version: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingReplace, setConfirmingReplace] = useState(false)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const version = CommerceModel.quoteLinkVersion(quote.quote)\n const proofOnly = CommerceModel.quoteIsProofOnly(quote)\n const linkName = proofOnly ? 'proof link' : 'pay link'\n const LinkName = proofOnly ? 'Proof link' : 'Pay link'\n const opens = proofOnly ? 'proof' : 'quote'\n // A link the server made at a version the stored quote has not caught up to yet is the newest one.\n const url = signed && signed.version >= version ? signed.url : ''\n\n const ask = useCallback(\n async (action: 'pay-link' | 'replace-link'): Promise<string | null> => {\n setBusy(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action, hostId, quoteId }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok || !payload?.url) {\n enqueueSnackbar(payload?.error ?? `The ${linkName} could not be made`, { variant: 'error', allowDuplicate: true })\n return null\n }\n const made = Math.floor(Number(payload.linkVersion))\n setSigned({ url: String(payload.url), version: Number.isFinite(made) && made >= 1 ? made : version })\n return String(payload.url)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, version, linkName, enqueueSnackbar],\n )\n\n // The quote's link moved on (a revision was emailed, or the link replaced):\n // the one on screen opens nothing now, so fetch the current one in its place.\n const stale = signed !== null && signed.version < version\n useEffect(() => {\n if (stale) void ask('pay-link')\n // Once per version the quote moves to; `ask` changing does not ask again.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stale, version])\n\n const copy = useCallback(\n async (link: string, done: string) => {\n try {\n await navigator.clipboard.writeText(link)\n enqueueSnackbar(done, { variant: 'success', persist: false })\n } catch {\n // The link is on screen to copy by hand when the clipboard is refused.\n enqueueSnackbar('Copy the link below to send it', { variant: 'info', persist: false })\n }\n },\n [enqueueSnackbar],\n )\n\n const copyLink = useCallback(async () => {\n const link = url || (await ask('pay-link'))\n if (link) await copy(link, `${LinkName} copied`)\n }, [url, ask, copy, LinkName])\n\n const replaceLink = useCallback(async () => {\n const link = await ask('replace-link')\n setConfirmingReplace(false)\n if (link) await copy(link, `New ${linkName} copied. The earlier link no longer opens the ${opens}.`)\n }, [ask, copy, linkName, opens])\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{LinkName}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'Send this link to the customer. It opens the proof on your site, with no prices, where they can approve it or ask for changes. Only someone with the link can open it.'\n : unpaid\n ? 'Send this link to the customer. It opens the quote on your site, where they can pay it.'\n : 'The link opens the paid quote and the customer’s order.'}\n </Typography>\n {edited && unpaid ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Save your changes first: the link opens the ${opens} as it was last saved.`}\n </Typography>\n ) : null}\n </Stack>\n {unpaid ? <PayLinkReadinessNoticeFor hostId={hostId} order={quote} noun=\"quote\" /> : null}\n {url ? (\n <TextField\n label={LinkName}\n value={url}\n size=\"small\"\n fullWidth\n slotProps={{ htmlInput: { readOnly: true }, inputLabel: { shrink: true } }}\n onFocus={(event) => event.target.select()}\n />\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button variant=\"outlined\" size=\"small\" disabled={busy} onClick={() => void copyLink()}>\n {`Copy ${linkName}`}\n </Button>\n </BlockedControl>\n {unpaid ? (\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button size=\"small\" disabled={busy} onClick={() => setConfirmingReplace(true)}>\n {'Replace link'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n <Dialog open={confirmingReplace} onClose={() => setConfirmingReplace(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Replace the ${linkName}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {`The link you sent before will stop working: it will tell the customer the ${opens} was updated, ` +\n 'and show nothing of it. Send them the new link.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingReplace(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void replaceLink()}>\n {'Replace link'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuotePayLinkSection.displayName = 'QuotePayLinkSection'\n\nexport default QuotePayLinkSection\n"],"names":["CommerceModel","commerceSitePermissionRefusal","BlockedControl","useSnackbar","authorizedFetch","useUser","Button","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Stack","TextField","Typography","useCallback","useEffect","useState","PayLinkReadinessNoticeFor","SEND_REFUSAL","QuotePayLinkSection","props","hostId","quoteId","quote","canSend","edited","data","user","enqueueSnackbar","signed","setSigned","busy","setBusy","confirmingReplace","setConfirmingReplace","unpaid","isUnpaidQuote","version","quoteLinkVersion","proofOnly","quoteIsProofOnly","linkName","LinkName","opens","url","ask","action","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","variant","allowDuplicate","made","Math","floor","Number","linkVersion","String","isFinite","stale","copy","link","done","navigator","clipboard","writeText","persist","copyLink","replaceLink","spacing","color","order","noun","label","value","size","fullWidth","slotProps","htmlInput","readOnly","inputLabel","shrink","onFocus","event","target","select","direction","sx","flexWrap","rowGap","blocked","reason","disabled","onClick","open","onClose","maxWidth","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxD,SAASC,yBAAyB,QAAQ,2CAAuC;AAEjF,MAAMC,eAAelB,8BAA8B;AAYnD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASmB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S,CAAC,CAAC;;kCACxC,KAACjC;kCACC,cAAA,KAACC;sCACE,CAAC,0EAA0E,EAAEkC,MAAM,cAAc,CAAC,GACjG;;;kCAGN,MAACpC;;0CACC,KAACF;gCAAOgG,SAAS,IAAMnE,qBAAqB;gCAAQkE,UAAUrE;0CAC3D;;0CAEH,KAAC1B;gCAAOqD,SAAQ;gCAAY0C,UAAUrE;gCAAMsE,SAAS,IAAM,KAAKzB;0CAC7D;;;;;;;;AAMb;AACAzD,oBAAoBsF,WAAW,GAAG;AAElC,eAAetF,oBAAmB"}
@@ -27,8 +27,9 @@ export interface QuoteProofsSectionProps {
27
27
  /**
28
28
  * A quote's proofs and revisions (AGL-4096), in its editor: the current
29
29
  * revision's proofs (a picture for an image, a chip for a PDF or a design
30
- * file), Add proof, what the customer last said with any files they sent,
31
- * "Start revision N+1", and every earlier revision as it was kept.
30
+ * file), Add proof and From media library (AGL-4184), what the customer last
31
+ * said with any files they sent, "Start revision N+1", and every earlier
32
+ * revision as it was kept.
32
33
  */
33
34
  export declare function QuoteProofsSection(props: QuoteProofsSectionProps): import("react").JSX.Element;
34
35
  export declare namespace QuoteProofsSection {
@@ -18,6 +18,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
18
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  import * as CommerceModel from "../../model/index.js";
20
20
  import { commerceSitePermissionRefusal } from "../../model/plugin-permissions.js";
21
+ import { useMediaPicker } from "@aglyn/aglyn/app-utils/media-picker-context";
21
22
  import { checkVisitorUploadSelection, formatVisitorUploadBytes, visitorUploadIsInline, VISITOR_UPLOAD_ACCEPT, VISITOR_UPLOAD_MAX_BYTES } from "@aglyn/aglyn/app-utils/visitor-upload";
22
23
  import { sendVisitorUpload } from "@aglyn/aglyn/app-utils/visitor-upload-client";
23
24
  import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
@@ -212,20 +213,24 @@ function dateTime(atMs) {
212
213
  /**
213
214
  * A quote's proofs and revisions (AGL-4096), in its editor: the current
214
215
  * revision's proofs (a picture for an image, a chip for a PDF or a design
215
- * file), Add proof, what the customer last said with any files they sent,
216
- * "Start revision N+1", and every earlier revision as it was kept.
216
+ * file), Add proof and From media library (AGL-4184), what the customer last
217
+ * said with any files they sent, "Start revision N+1", and every earlier
218
+ * revision as it was kept.
217
219
  */ export function QuoteProofsSection(props) {
218
220
  var _ref;
219
221
  const { hostId, quoteId, quote, canEdit, onEdited } = props;
220
222
  const { data: user } = useUser();
221
223
  const { enqueueSnackbar } = useSnackbar();
224
+ const { pickMedia } = useMediaPicker();
222
225
  const section = quote.quote;
223
226
  const revision = Math.max(1, Number((_ref = section == null ? void 0 : section.revision) != null ? _ref : 1) || 1);
224
227
  const proofs = CommerceModel.currentQuoteProofs(section);
228
+ const proofOnly = CommerceModel.quoteIsProofOnly(quote);
225
229
  const latest = CommerceModel.latestQuoteResponse(section);
226
230
  const unpaid = CommerceModel.isUnpaidQuote(quote);
227
231
  const addRefusal = CommerceModel.quoteProofChangeRefusal(quote, 'add');
228
- const removable = CommerceModel.quoteProofChangeRefusal(quote, 'remove') === null;
232
+ // A quote with no lines keeps its last proof (`needs-proof`), so it offers no way to remove it.
233
+ const removable = CommerceModel.quoteProofChangeRefusal(quote, 'remove') === null && !(proofOnly && proofs.length === 1);
229
234
  const [sending, setSending] = useState(null);
230
235
  const [busy, setBusy] = useState(false);
231
236
  const [confirmingRevision, setConfirmingRevision] = useState(false);
@@ -350,6 +355,58 @@ function dateTime(atMs) {
350
355
  onEdited,
351
356
  enqueueSnackbar
352
357
  ]);
358
+ /**
359
+ * A file from the media library: the shared picker offers what this member
360
+ * can read, a private file included, and the server copies the bytes into the
361
+ * quote's private proofs. Only the file's library and id are sent.
362
+ */ const addFromLibrary = useCallback(async ()=>{
363
+ const picked = await (pickMedia == null ? void 0 : pickMedia({
364
+ allowPrivate: true
365
+ }));
366
+ if (!picked) return;
367
+ const problem = CommerceModel.quoteLibraryProofProblem(picked);
368
+ if (problem) return void enqueueSnackbar(problem, {
369
+ variant: 'error',
370
+ allowDuplicate: true
371
+ });
372
+ setSending({
373
+ done: 0,
374
+ total: 1
375
+ });
376
+ try {
377
+ const answer = await postQuote(user, {
378
+ action: 'proof-from-media',
379
+ hostId,
380
+ quoteId,
381
+ media: {
382
+ mediaScope: picked.mediaScope,
383
+ mediaId: picked.mediaId
384
+ }
385
+ });
386
+ if (!answer.ok) {
387
+ var _answer_payload_error;
388
+ return void enqueueSnackbar(String((_answer_payload_error = answer.payload['error']) != null ? _answer_payload_error : 'The proof could not be added'), {
389
+ variant: 'error',
390
+ allowDuplicate: true
391
+ });
392
+ }
393
+ onEdited(Number(answer.payload['updatedAtMs']) || 0);
394
+ } catch (unused) {
395
+ enqueueSnackbar('The proof could not be added', {
396
+ variant: 'error',
397
+ allowDuplicate: true
398
+ });
399
+ } finally{
400
+ setSending(null);
401
+ }
402
+ }, [
403
+ pickMedia,
404
+ user,
405
+ hostId,
406
+ quoteId,
407
+ onEdited,
408
+ enqueueSnackbar
409
+ ]);
353
410
  const removeProof = useCallback(async (proofId)=>{
354
411
  setBusy(true);
355
412
  try {
@@ -433,7 +490,7 @@ function dateTime(atMs) {
433
490
  /*#__PURE__*/ _jsx(Typography, {
434
491
  variant: "body2",
435
492
  color: "text.secondary",
436
- children: (section == null ? void 0 : section.requireProofApproval) ? 'The customer sees these on the quote page and approves them before they can pay.' : 'The customer sees these on the quote page, and can approve them or ask for changes. Paying doesn’t wait on it.'
493
+ children: proofOnly ? 'The customer sees these on the proof page, with no prices, and can approve them or ask for changes.' : (section == null ? void 0 : section.requireProofApproval) ? 'The customer sees these on the quote page and approves them before they can pay.' : 'The customer sees these on the quote page, and can approve them or ask for changes. Paying doesn’t wait on it.'
437
494
  })
438
495
  ]
439
496
  }),
@@ -452,7 +509,7 @@ function dateTime(atMs) {
452
509
  }) : /*#__PURE__*/ _jsx(Typography, {
453
510
  variant: "body2",
454
511
  color: "text.secondary",
455
- children: 'No proofs on this revision yet. Add an image, a PDF or a design file for the customer to approve.'
512
+ children: proofOnly ? 'No proof on this revision yet, so there is nothing to send. Add one for the customer to approve, or add items to the quote.' : 'No proofs on this revision yet. Add an image, a PDF or a design file for the customer to approve.'
456
513
  }),
457
514
  unpaid ? /*#__PURE__*/ _jsxs(Stack, {
458
515
  direction: "row",
@@ -491,6 +548,17 @@ function dateTime(atMs) {
491
548
  children: sending ? `Sending ${sending.done + 1} of ${sending.total}…` : 'Add proof'
492
549
  })
493
550
  }),
551
+ pickMedia ? /*#__PURE__*/ _jsx(BlockedControl, {
552
+ blocked: !canEdit || Boolean(addRefusal),
553
+ reason: !canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : '',
554
+ children: /*#__PURE__*/ _jsx(Button, {
555
+ variant: "outlined",
556
+ size: "small",
557
+ disabled: busy || Boolean(sending),
558
+ onClick: ()=>void addFromLibrary(),
559
+ children: 'From media library'
560
+ })
561
+ }) : null,
494
562
  /*#__PURE__*/ _jsx(BlockedControl, {
495
563
  blocked: !canEdit,
496
564
  reason: REFUSAL,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-proofs.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 { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport {\n checkVisitorUploadSelection,\n formatVisitorUploadBytes,\n visitorUploadIsInline,\n VISITOR_UPLOAD_ACCEPT,\n VISITOR_UPLOAD_MAX_BYTES,\n} from '@aglyn/aglyn/app-utils/visitor-upload'\nimport { sendVisitorUpload } from '@aglyn/aglyn/app-utils/visitor-upload-client'\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 { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n CircularProgress,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Divider,\n Paper,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'\n\nconst REFUSAL = commerceSitePermissionRefusal('commerce.quotes')\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\n/** A file the console lists: a proof, or one the customer sent. Never its storage path. */\ninterface ListedFile {\n id: string\n name: string\n contentType: string\n size: number\n}\n\n/** An earlier revision as the route lists it. */\ntype RevisionView = Omit<CommerceModel.QuoteRevisionSnapshot, 'proofs' | 'responses'> & {\n proofs: ListedFile[]\n responses: Array<Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }>\n}\n\nexport interface QuoteProofsSectionProps {\n hostId: string\n quoteId: string\n quote: CommerceModel.HostOrder\n /** Holds \"Create and edit quotes\" (`commerce.quotes`). */\n canEdit: boolean\n /** A change here moved the quote's edit stamp; the editor saves against the new one. */\n onEdited: (updatedAtMs: number) => void\n}\n\nasync function postQuote(user: User, body: Record<string, unknown>): Promise<{ ok: boolean; payload: Record<string, any> }> {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n return { ok: response.ok, payload: await response.json().catch(() => ({})) }\n}\n\n/** One of the quote's files as a blob, fetched with the member's token; null when refused. */\nasync function fetchQuoteFile(\n user: User,\n body: { hostId: string; quoteId: string; fileId: string; revision?: number },\n): Promise<Blob | null> {\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action: 'file', ...body }),\n })\n return response.ok ? await response.blob() : null\n } catch {\n return null\n }\n}\n\nfunction dateTime(atMs: number | undefined): string {\n return atMs ? new Date(atMs).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' }) : ''\n}\n\n/** A picture of an image proof, loaded with the member's token. */\nfunction ProofThumbnail(props: { user: User; hostId: string; quoteId: string; file: ListedFile; revision?: number }) {\n const { user, hostId, quoteId, file, revision } = props\n const [src, setSrc] = useState<string | null>(null)\n useEffect(() => {\n let live = true\n let url = ''\n void fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(revision ? { revision } : {}) }).then((blob) => {\n if (!live || !blob) return\n url = URL.createObjectURL(blob)\n setSrc(url)\n })\n return () => {\n live = false\n if (url) URL.revokeObjectURL(url)\n }\n }, [user, hostId, quoteId, file.id, revision])\n return (\n <Box\n sx={(theme) => ({\n width: theme.spacing(16),\n height: theme.spacing(12),\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n bgcolor: 'action.hover',\n borderRadius: 1,\n overflow: 'hidden',\n })}\n >\n {src ? (\n <Box component=\"img\" src={src} alt={file.name} sx={{ maxWidth: 1, maxHeight: 1, objectFit: 'contain' }} />\n ) : (\n <CircularProgress size={20} aria-label={`Loading ${file.name}`} />\n )}\n </Box>\n )\n}\n\n/** A file: a picture for an image, a chip naming it for anything else; both download it. */\nfunction QuoteFileTile(props: {\n user: User\n hostId: string\n quoteId: string\n file: ListedFile\n revision?: number\n onDownload: (file: ListedFile, revision?: number) => void\n onRemove?: () => void\n removeBlocked?: boolean\n}) {\n const { file, revision, onDownload, onRemove, removeBlocked } = props\n const image = visitorUploadIsInline(file.contentType)\n return (\n <Paper variant=\"outlined\" sx={{ p: 1 }}>\n <Stack spacing={1} sx={(theme) => ({ width: image ? theme.spacing(16) : 'auto', maxWidth: theme.spacing(32) })}>\n {image ? <ProofThumbnail {...props} /> : null}\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={`${file.name} · ${formatVisitorUploadBytes(file.size)}`}\n onClick={() => onDownload(file, revision)}\n title={`Download ${file.name}`}\n />\n {onRemove ? (\n <BlockedControl blocked={Boolean(removeBlocked)} reason={REFUSAL}>\n <Button size=\"small\" color=\"inherit\" onClick={onRemove} aria-label={`Remove ${file.name}`}>\n {'Remove'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n </Paper>\n )\n}\n\n/** What the customer said, with any files they sent. */\nfunction QuoteResponseNote(props: {\n response: Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }\n tile: (file: ListedFile) => ReactNode\n}) {\n const { response, tile } = props\n if (response.action === 'approve') {\n return (\n <Alert severity=\"success\">\n <Stack spacing={0.5}>\n <Typography variant=\"body2\">{`Approved by ${response.name || 'the customer'} on ${dateTime(response.atMs)}.`}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {[response.ip ? `From ${response.ip}` : '', response.userAgent ?? ''].filter(Boolean).join(' · ')}\n </Typography>\n </Stack>\n </Alert>\n )\n }\n return (\n <Alert severity=\"warning\">\n <Stack spacing={1}>\n <Typography variant=\"body2\">{`Changes requested on ${dateTime(response.atMs)}:`}</Typography>\n <Typography variant=\"body2\" sx={{ whiteSpace: 'pre-line' }}>\n {response.comment}\n </Typography>\n {response.files?.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {response.files.map((file) => tile(file))}\n </Stack>\n ) : null}\n </Stack>\n </Alert>\n )\n}\n\n/**\n * A quote's proofs and revisions (AGL-4096), in its editor: the current\n * revision's proofs (a picture for an image, a chip for a PDF or a design\n * file), Add proof, what the customer last said with any files they sent,\n * \"Start revision N+1\", and every earlier revision as it was kept.\n */\nexport function QuoteProofsSection(props: QuoteProofsSectionProps) {\n const { hostId, quoteId, quote, canEdit, onEdited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const section = quote.quote\n const revision = Math.max(1, Number(section?.revision ?? 1) || 1)\n const proofs = CommerceModel.currentQuoteProofs(section)\n const latest = CommerceModel.latestQuoteResponse(section)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const addRefusal = CommerceModel.quoteProofChangeRefusal(quote, 'add')\n const removable = CommerceModel.quoteProofChangeRefusal(quote, 'remove') === null\n const [sending, setSending] = useState<{ done: number; total: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingRevision, setConfirmingRevision] = useState(false)\n const [history, setHistory] = useState<RevisionView[] | null>(null)\n const [historyError, setHistoryError] = useState('')\n const picker = useRef<HTMLInputElement>(null)\n\n const loadHistory = useCallback(async () => {\n setHistoryError('')\n const answer = await postQuote(user, { action: 'revisions', hostId, quoteId }).catch(() => null)\n if (!answer?.ok) {\n setHistoryError(String(answer?.payload?.error ?? 'Earlier revisions could not be loaded.'))\n return\n }\n setHistory(Array.isArray(answer.payload['revisions']) ? (answer.payload['revisions'] as RevisionView[]) : [])\n }, [user, hostId, quoteId])\n\n // Earlier revisions are read when there are some, and again after one is added.\n useEffect(() => {\n if (revision > 1) void loadHistory()\n }, [revision, loadHistory])\n\n const download = useCallback(\n async (file: ListedFile, fromRevision?: number) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(fromRevision ? { revision: fromRevision } : {}) })\n if (!blob) return void enqueueSnackbar('The file could not be downloaded', { variant: 'error', allowDuplicate: true })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n\n const addProofs = useCallback(\n async (files: File[]) => {\n const problem = checkVisitorUploadSelection(files, proofs.length, CommerceModel.QUOTE_MAX_PROOFS)\n if (problem) return void enqueueSnackbar(problem, { variant: 'error', allowDuplicate: true })\n setSending({ done: 0, total: files.length })\n try {\n for (const [index, file] of files.entries()) {\n let stamp = 0\n const sent = await sendVisitorUpload({\n file,\n requestTicket: async (request) => {\n const answer = await postQuote(user, { action: 'proof-ticket', hostId, quoteId, file: request })\n return answer.ok\n ? (answer.payload as { ticket: string; upload: { url: string; fields: Record<string, string> } })\n : { error: String(answer.payload['error'] ?? 'The proof could not be sent') }\n },\n finalize: async (ticket) => {\n const answer = await postQuote(user, { action: 'proof-finalize', hostId, quoteId, ticket })\n if (!answer.ok) return { error: String(answer.payload['error'] ?? 'The proof could not be kept') }\n stamp = Number(answer.payload['updatedAtMs']) || 0\n return { file: answer.payload['proof'] }\n },\n })\n if ('error' in sent) {\n enqueueSnackbar(sent.error, { variant: 'error', allowDuplicate: true })\n break\n }\n if (stamp) onEdited(stamp)\n setSending({ done: index + 1, total: files.length })\n }\n } finally {\n setSending(null)\n }\n },\n [user, hostId, quoteId, proofs.length, onEdited, enqueueSnackbar],\n )\n\n const removeProof = useCallback(\n async (proofId: string) => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'proof-remove', hostId, quoteId, proofId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The proof could not be removed'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, onEdited, enqueueSnackbar],\n )\n\n const startRevision = useCallback(async () => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'start-revision', hostId, quoteId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The revision could not be started'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n enqueueSnackbar(`Revision ${Number(answer.payload['revision']) || revision + 1} started`, { variant: 'success', persist: false })\n setConfirmingRevision(false)\n } finally {\n setBusy(false)\n }\n }, [user, hostId, quoteId, revision, onEdited, enqueueSnackbar])\n\n const tile = (file: ListedFile, fromRevision?: number, onRemove?: () => void) => (\n <QuoteFileTile\n key={`${fromRevision ?? 'current'}-${file.id}`}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n revision={fromRevision}\n onDownload={(picked, at) => void download(picked, at)}\n onRemove={onRemove}\n removeBlocked={!canEdit}\n />\n )\n\n const earlier = (history ?? []).filter((entry) => Number(entry.revision) < revision).reverse()\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{`Proofs · Revision ${revision}`}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {section?.requireProofApproval\n ? 'The customer sees these on the quote page and approves them before they can pay.'\n : 'The customer sees these on the quote page, and can approve them or ask for changes. Paying doesn’t wait on it.'}\n </Typography>\n </Stack>\n\n {latest ? <QuoteResponseNote response={latest} tile={(file) => tile(file)} /> : null}\n\n {proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {proofs.map((proof) =>\n tile(proof, undefined, removable ? () => void removeProof(proof.id) : undefined),\n )}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No proofs on this revision yet. Add an image, a PDF or a design file for the customer to approve.'}\n </Typography>\n )}\n\n {unpaid ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap', alignItems: 'center' }}>\n <input\n ref={picker}\n type=\"file\"\n multiple\n hidden\n accept={VISITOR_UPLOAD_ACCEPT}\n data-testid=\"quote-proof-picker\"\n onChange={(event) => {\n const files = Array.from(event.target.files ?? [])\n event.target.value = ''\n if (files.length) void addProofs(files)\n }}\n />\n <BlockedControl\n blocked={!canEdit || Boolean(addRefusal)}\n reason={!canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : ''}\n >\n <Button variant=\"outlined\" size=\"small\" disabled={busy || Boolean(sending)} onClick={() => picker.current?.click()}>\n {sending ? `Sending ${sending.done + 1} of ${sending.total}…` : 'Add proof'}\n </Button>\n </BlockedControl>\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button size=\"small\" disabled={busy || Boolean(sending)} onClick={() => setConfirmingRevision(true)}>\n {`Start revision ${revision + 1}`}\n </Button>\n </BlockedControl>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Up to ${CommerceModel.QUOTE_MAX_PROOFS} files, ${formatVisitorUploadBytes(VISITOR_UPLOAD_MAX_BYTES)} each.`}\n </Typography>\n </Stack>\n ) : null}\n\n {revision > 1 ? (\n <Stack spacing={1.5}>\n <Divider />\n <Typography variant=\"subtitle2\">{'Earlier revisions'}</Typography>\n {historyError ? <Alert severity=\"error\">{historyError}</Alert> : null}\n {history === null && !historyError ? <CircularProgress size={20} aria-label=\"Loading earlier revisions\" /> : null}\n {earlier.map((entry) => (\n <Paper key={entry.revision} variant=\"outlined\" sx={{ p: 2 }}>\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 0.5 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 'fontWeightMedium' }}>{`Revision ${entry.revision}`}</Typography>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={CommerceModel.QUOTE_STAGE_LABELS[entry.stage] ?? entry.stage}\n color={CommerceModel.QUOTE_STATUS_COLOR[entry.stage] ?? 'default'}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Replaced ${dateTime(entry.closedAtMs)}`}\n </Typography>\n </Stack>\n {entry.proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {entry.proofs.map((proof) => tile(proof, entry.revision))}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No proofs.'}\n </Typography>\n )}\n {entry.responses.map((response, index) => (\n <QuoteResponseNote key={index} response={response} tile={(file) => tile(file, entry.revision)} />\n ))}\n </Stack>\n </Paper>\n ))}\n </Stack>\n ) : null}\n\n <Dialog open={confirmingRevision} onClose={() => setConfirmingRevision(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Start revision ${revision + 1}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {`Revision ${revision} is kept as it is now, with its proofs and the customer’s answers. ` +\n `Revision ${revision + 1} starts with no proofs, ready for new ones and any changes to the quote.`}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingRevision(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void startRevision()}>\n {`Start revision ${revision + 1}`}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuoteProofsSection.displayName = 'QuoteProofsSection'\n\nexport default QuoteProofsSection\n\n/**\n * The files a quote's request came with (AGL-4098), as the customer's files:\n * a picture for an image, a chip naming anything else, each downloaded\n * through the quote's own route. They stay where the request keeps them, so a\n * request deleted from the Inbox takes them with it.\n */\nexport function QuoteRequestFilesSection(props: { hostId: string; quoteId: string; quote: CommerceModel.HostOrder }) {\n const { hostId, quoteId, quote } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const request = quote.quote?.request\n const files = CommerceModel.quoteRequestFileViews(quote.quote?.requestFiles)\n const download = useCallback(\n async (file: ListedFile) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id })\n if (!blob) {\n return void enqueueSnackbar('The file could not be downloaded. The request may have been deleted from the Inbox.', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n if (!request || !user) return null\n const when = request.receivedAtMs ? ` on ${dateTime(request.receivedAtMs)}` : ''\n return (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'From the request'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Sent through “${request.formName}”${when}.` + (files.length ? ' The files they sent:' : ' They sent no files.')}\n </Typography>\n {files.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {files.map((file) => (\n <QuoteFileTile\n key={file.id}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n onDownload={(picked) => void download(picked)}\n />\n ))}\n </Stack>\n ) : null}\n </Stack>\n )\n}\n"],"names":["CommerceModel","commerceSitePermissionRefusal","checkVisitorUploadSelection","formatVisitorUploadBytes","visitorUploadIsInline","VISITOR_UPLOAD_ACCEPT","VISITOR_UPLOAD_MAX_BYTES","sendVisitorUpload","BlockedControl","useSnackbar","authorizedFetch","useUser","Alert","Box","Button","Chip","CircularProgress","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Divider","Paper","Stack","Typography","useCallback","useEffect","useRef","useState","REFUSAL","postQuote","user","body","response","method","headers","JSON","stringify","ok","payload","json","catch","fetchQuoteFile","action","blob","dateTime","atMs","Date","toLocaleString","undefined","dateStyle","timeStyle","ProofThumbnail","props","hostId","quoteId","file","revision","src","setSrc","live","url","fileId","id","then","URL","createObjectURL","revokeObjectURL","sx","theme","width","spacing","height","display","alignItems","justifyContent","bgcolor","borderRadius","overflow","component","alt","name","maxWidth","maxHeight","objectFit","size","aria-label","QuoteFileTile","onDownload","onRemove","removeBlocked","image","contentType","variant","p","label","onClick","title","blocked","Boolean","reason","color","QuoteResponseNote","tile","severity","ip","userAgent","filter","join","whiteSpace","comment","files","length","direction","useFlexGap","flexWrap","map","QuoteProofsSection","quote","canEdit","onEdited","data","enqueueSnackbar","section","Math","max","Number","proofs","currentQuoteProofs","latest","latestQuoteResponse","unpaid","isUnpaidQuote","addRefusal","quoteProofChangeRefusal","removable","sending","setSending","busy","setBusy","confirmingRevision","setConfirmingRevision","history","setHistory","historyError","setHistoryError","picker","loadHistory","answer","String","error","Array","isArray","download","fromRevision","allowDuplicate","link","document","createElement","href","click","setTimeout","addProofs","problem","QUOTE_MAX_PROOFS","done","total","index","entries","stamp","sent","requestTicket","request","finalize","ticket","removeProof","proofId","startRevision","persist","picked","at","earlier","entry","reverse","requireProofApproval","proof","input","ref","type","multiple","hidden","accept","data-testid","onChange","event","from","target","value","quoteProofRefusalMessage","disabled","current","rowGap","fontWeight","QUOTE_STAGE_LABELS","stage","QUOTE_STATUS_COLOR","closedAtMs","responses","open","onClose","fullWidth","displayName","QuoteRequestFilesSection","quoteRequestFileViews","requestFiles","when","receivedAtMs","formName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SACEC,2BAA2B,EAC3BC,wBAAwB,EACxBC,qBAAqB,EACrBC,qBAAqB,EACrBC,wBAAwB,QACnB,wCAAuC;AAC9C,SAASC,iBAAiB,QAAQ,+CAA8C;AAChF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,OAAO,EACPC,KAAK,EACLC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAwB,QAAO;AAEhF,MAAMC,UAAU7B,8BAA8B;AA4B9C,eAAe8B,UAAUC,IAAU,EAAEC,IAA6B;IAChE,MAAMC,WAAW,MAAMxB,gBAAgBsB,MAAM,uBAAuB;QAClEG,QAAQ;QACRC,SAAS;YAAE,gBAAgB;QAAmB;QAC9CH,MAAMI,KAAKC,SAAS,CAACL;IACvB;IACA,OAAO;QAAEM,IAAIL,SAASK,EAA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,GAAG,CAAC,IAAI,EAAE3K,SAAS+H,QAAQ4C,YAAY,GAAG,GAAG;IAC9E,qBACE,MAACjM;QAAMgD,SAAS;;0BACd,KAAC/C;gBAAWqE,SAAQ;0BAAa;;0BACjC,KAACrE;gBAAWqE,SAAQ;gBAAQQ,OAAM;0BAC/B,CAAC,cAAc,EAAEuE,QAAQ6C,QAAQ,CAAC,CAAC,EAAEF,KAAK,CAAC,CAAC,GAAIxG,CAAAA,MAAMC,MAAM,GAAG,0BAA0B,sBAAqB;;YAEhHD,MAAMC,MAAM,iBACX,KAACzF;gBAAM0F,WAAU;gBAAM1C,SAAS;gBAAG2C,UAAU;gBAAC9C,IAAI;oBAAE+C,UAAU;gBAAO;0BAClEJ,MAAMK,GAAG,CAAC,CAAC5D,qBACV,KAAC+B;wBAECxD,MAAMA;wBACNuB,QAAQA;wBACRC,SAASA;wBACTC,MAAMA;wBACNgC,YAAY,CAAC2F,SAAW,KAAK1B,SAAS0B;uBALjC3H,KAAKO,EAAE;iBAShB;;;AAGV"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-proofs.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 { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { useMediaPicker } from '@aglyn/aglyn/app-utils/media-picker-context'\nimport {\n checkVisitorUploadSelection,\n formatVisitorUploadBytes,\n visitorUploadIsInline,\n VISITOR_UPLOAD_ACCEPT,\n VISITOR_UPLOAD_MAX_BYTES,\n} from '@aglyn/aglyn/app-utils/visitor-upload'\nimport { sendVisitorUpload } from '@aglyn/aglyn/app-utils/visitor-upload-client'\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 { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n CircularProgress,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Divider,\n Paper,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'\n\nconst REFUSAL = commerceSitePermissionRefusal('commerce.quotes')\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\n/** A file the console lists: a proof, or one the customer sent. Never its storage path. */\ninterface ListedFile {\n id: string\n name: string\n contentType: string\n size: number\n}\n\n/** An earlier revision as the route lists it. */\ntype RevisionView = Omit<CommerceModel.QuoteRevisionSnapshot, 'proofs' | 'responses'> & {\n proofs: ListedFile[]\n responses: Array<Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }>\n}\n\nexport interface QuoteProofsSectionProps {\n hostId: string\n quoteId: string\n quote: CommerceModel.HostOrder\n /** Holds \"Create and edit quotes\" (`commerce.quotes`). */\n canEdit: boolean\n /** A change here moved the quote's edit stamp; the editor saves against the new one. */\n onEdited: (updatedAtMs: number) => void\n}\n\nasync function postQuote(user: User, body: Record<string, unknown>): Promise<{ ok: boolean; payload: Record<string, any> }> {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n return { ok: response.ok, payload: await response.json().catch(() => ({})) }\n}\n\n/** One of the quote's files as a blob, fetched with the member's token; null when refused. */\nasync function fetchQuoteFile(\n user: User,\n body: { hostId: string; quoteId: string; fileId: string; revision?: number },\n): Promise<Blob | null> {\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action: 'file', ...body }),\n })\n return response.ok ? await response.blob() : null\n } catch {\n return null\n }\n}\n\nfunction dateTime(atMs: number | undefined): string {\n return atMs ? new Date(atMs).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' }) : ''\n}\n\n/** A picture of an image proof, loaded with the member's token. */\nfunction ProofThumbnail(props: { user: User; hostId: string; quoteId: string; file: ListedFile; revision?: number }) {\n const { user, hostId, quoteId, file, revision } = props\n const [src, setSrc] = useState<string | null>(null)\n useEffect(() => {\n let live = true\n let url = ''\n void fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(revision ? { revision } : {}) }).then((blob) => {\n if (!live || !blob) return\n url = URL.createObjectURL(blob)\n setSrc(url)\n })\n return () => {\n live = false\n if (url) URL.revokeObjectURL(url)\n }\n }, [user, hostId, quoteId, file.id, revision])\n return (\n <Box\n sx={(theme) => ({\n width: theme.spacing(16),\n height: theme.spacing(12),\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n bgcolor: 'action.hover',\n borderRadius: 1,\n overflow: 'hidden',\n })}\n >\n {src ? (\n <Box component=\"img\" src={src} alt={file.name} sx={{ maxWidth: 1, maxHeight: 1, objectFit: 'contain' }} />\n ) : (\n <CircularProgress size={20} aria-label={`Loading ${file.name}`} />\n )}\n </Box>\n )\n}\n\n/** A file: a picture for an image, a chip naming it for anything else; both download it. */\nfunction QuoteFileTile(props: {\n user: User\n hostId: string\n quoteId: string\n file: ListedFile\n revision?: number\n onDownload: (file: ListedFile, revision?: number) => void\n onRemove?: () => void\n removeBlocked?: boolean\n}) {\n const { file, revision, onDownload, onRemove, removeBlocked } = props\n const image = visitorUploadIsInline(file.contentType)\n return (\n <Paper variant=\"outlined\" sx={{ p: 1 }}>\n <Stack spacing={1} sx={(theme) => ({ width: image ? theme.spacing(16) : 'auto', maxWidth: theme.spacing(32) })}>\n {image ? <ProofThumbnail {...props} /> : null}\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={`${file.name} · ${formatVisitorUploadBytes(file.size)}`}\n onClick={() => onDownload(file, revision)}\n title={`Download ${file.name}`}\n />\n {onRemove ? (\n <BlockedControl blocked={Boolean(removeBlocked)} reason={REFUSAL}>\n <Button size=\"small\" color=\"inherit\" onClick={onRemove} aria-label={`Remove ${file.name}`}>\n {'Remove'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n </Paper>\n )\n}\n\n/** What the customer said, with any files they sent. */\nfunction QuoteResponseNote(props: {\n response: Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }\n tile: (file: ListedFile) => ReactNode\n}) {\n const { response, tile } = props\n if (response.action === 'approve') {\n return (\n <Alert severity=\"success\">\n <Stack spacing={0.5}>\n <Typography variant=\"body2\">{`Approved by ${response.name || 'the customer'} on ${dateTime(response.atMs)}.`}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {[response.ip ? `From ${response.ip}` : '', response.userAgent ?? ''].filter(Boolean).join(' · ')}\n </Typography>\n </Stack>\n </Alert>\n )\n }\n return (\n <Alert severity=\"warning\">\n <Stack spacing={1}>\n <Typography variant=\"body2\">{`Changes requested on ${dateTime(response.atMs)}:`}</Typography>\n <Typography variant=\"body2\" sx={{ whiteSpace: 'pre-line' }}>\n {response.comment}\n </Typography>\n {response.files?.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {response.files.map((file) => tile(file))}\n </Stack>\n ) : null}\n </Stack>\n </Alert>\n )\n}\n\n/**\n * A quote's proofs and revisions (AGL-4096), in its editor: the current\n * revision's proofs (a picture for an image, a chip for a PDF or a design\n * file), Add proof and From media library (AGL-4184), what the customer last\n * said with any files they sent, \"Start revision N+1\", and every earlier\n * revision as it was kept.\n */\nexport function QuoteProofsSection(props: QuoteProofsSectionProps) {\n const { hostId, quoteId, quote, canEdit, onEdited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { pickMedia } = useMediaPicker()\n const section = quote.quote\n const revision = Math.max(1, Number(section?.revision ?? 1) || 1)\n const proofs = CommerceModel.currentQuoteProofs(section)\n const proofOnly = CommerceModel.quoteIsProofOnly(quote)\n const latest = CommerceModel.latestQuoteResponse(section)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const addRefusal = CommerceModel.quoteProofChangeRefusal(quote, 'add')\n // A quote with no lines keeps its last proof (`needs-proof`), so it offers no way to remove it.\n const removable = CommerceModel.quoteProofChangeRefusal(quote, 'remove') === null && !(proofOnly && proofs.length === 1)\n const [sending, setSending] = useState<{ done: number; total: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingRevision, setConfirmingRevision] = useState(false)\n const [history, setHistory] = useState<RevisionView[] | null>(null)\n const [historyError, setHistoryError] = useState('')\n const picker = useRef<HTMLInputElement>(null)\n\n const loadHistory = useCallback(async () => {\n setHistoryError('')\n const answer = await postQuote(user, { action: 'revisions', hostId, quoteId }).catch(() => null)\n if (!answer?.ok) {\n setHistoryError(String(answer?.payload?.error ?? 'Earlier revisions could not be loaded.'))\n return\n }\n setHistory(Array.isArray(answer.payload['revisions']) ? (answer.payload['revisions'] as RevisionView[]) : [])\n }, [user, hostId, quoteId])\n\n // Earlier revisions are read when there are some, and again after one is added.\n useEffect(() => {\n if (revision > 1) void loadHistory()\n }, [revision, loadHistory])\n\n const download = useCallback(\n async (file: ListedFile, fromRevision?: number) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(fromRevision ? { revision: fromRevision } : {}) })\n if (!blob) return void enqueueSnackbar('The file could not be downloaded', { variant: 'error', allowDuplicate: true })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n\n const addProofs = useCallback(\n async (files: File[]) => {\n const problem = checkVisitorUploadSelection(files, proofs.length, CommerceModel.QUOTE_MAX_PROOFS)\n if (problem) return void enqueueSnackbar(problem, { variant: 'error', allowDuplicate: true })\n setSending({ done: 0, total: files.length })\n try {\n for (const [index, file] of files.entries()) {\n let stamp = 0\n const sent = await sendVisitorUpload({\n file,\n requestTicket: async (request) => {\n const answer = await postQuote(user, { action: 'proof-ticket', hostId, quoteId, file: request })\n return answer.ok\n ? (answer.payload as { ticket: string; upload: { url: string; fields: Record<string, string> } })\n : { error: String(answer.payload['error'] ?? 'The proof could not be sent') }\n },\n finalize: async (ticket) => {\n const answer = await postQuote(user, { action: 'proof-finalize', hostId, quoteId, ticket })\n if (!answer.ok) return { error: String(answer.payload['error'] ?? 'The proof could not be kept') }\n stamp = Number(answer.payload['updatedAtMs']) || 0\n return { file: answer.payload['proof'] }\n },\n })\n if ('error' in sent) {\n enqueueSnackbar(sent.error, { variant: 'error', allowDuplicate: true })\n break\n }\n if (stamp) onEdited(stamp)\n setSending({ done: index + 1, total: files.length })\n }\n } finally {\n setSending(null)\n }\n },\n [user, hostId, quoteId, proofs.length, onEdited, enqueueSnackbar],\n )\n\n /**\n * A file from the media library: the shared picker offers what this member\n * can read, a private file included, and the server copies the bytes into the\n * quote's private proofs. Only the file's library and id are sent.\n */\n const addFromLibrary = useCallback(async () => {\n const picked = await pickMedia?.({ allowPrivate: true })\n if (!picked) return\n const problem = CommerceModel.quoteLibraryProofProblem(picked)\n if (problem) return void enqueueSnackbar(problem, { variant: 'error', allowDuplicate: true })\n setSending({ done: 0, total: 1 })\n try {\n const answer = await postQuote(user, {\n action: 'proof-from-media',\n hostId,\n quoteId,\n media: { mediaScope: picked.mediaScope, mediaId: picked.mediaId },\n })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The proof could not be added'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n } catch {\n enqueueSnackbar('The proof could not be added', { variant: 'error', allowDuplicate: true })\n } finally {\n setSending(null)\n }\n }, [pickMedia, user, hostId, quoteId, onEdited, enqueueSnackbar])\n\n const removeProof = useCallback(\n async (proofId: string) => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'proof-remove', hostId, quoteId, proofId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The proof could not be removed'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, onEdited, enqueueSnackbar],\n )\n\n const startRevision = useCallback(async () => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'start-revision', hostId, quoteId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The revision could not be started'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n enqueueSnackbar(`Revision ${Number(answer.payload['revision']) || revision + 1} started`, { variant: 'success', persist: false })\n setConfirmingRevision(false)\n } finally {\n setBusy(false)\n }\n }, [user, hostId, quoteId, revision, onEdited, enqueueSnackbar])\n\n const tile = (file: ListedFile, fromRevision?: number, onRemove?: () => void) => (\n <QuoteFileTile\n key={`${fromRevision ?? 'current'}-${file.id}`}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n revision={fromRevision}\n onDownload={(picked, at) => void download(picked, at)}\n onRemove={onRemove}\n removeBlocked={!canEdit}\n />\n )\n\n const earlier = (history ?? []).filter((entry) => Number(entry.revision) < revision).reverse()\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{`Proofs · Revision ${revision}`}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'The customer sees these on the proof page, with no prices, and can approve them or ask for changes.'\n : section?.requireProofApproval\n ? 'The customer sees these on the quote page and approves them before they can pay.'\n : 'The customer sees these on the quote page, and can approve them or ask for changes. Paying doesn’t wait on it.'}\n </Typography>\n </Stack>\n\n {latest ? <QuoteResponseNote response={latest} tile={(file) => tile(file)} /> : null}\n\n {proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {proofs.map((proof) =>\n tile(proof, undefined, removable ? () => void removeProof(proof.id) : undefined),\n )}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'No proof on this revision yet, so there is nothing to send. Add one for the customer to approve, or add items to the quote.'\n : 'No proofs on this revision yet. Add an image, a PDF or a design file for the customer to approve.'}\n </Typography>\n )}\n\n {unpaid ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap', alignItems: 'center' }}>\n <input\n ref={picker}\n type=\"file\"\n multiple\n hidden\n accept={VISITOR_UPLOAD_ACCEPT}\n data-testid=\"quote-proof-picker\"\n onChange={(event) => {\n const files = Array.from(event.target.files ?? [])\n event.target.value = ''\n if (files.length) void addProofs(files)\n }}\n />\n <BlockedControl\n blocked={!canEdit || Boolean(addRefusal)}\n reason={!canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : ''}\n >\n <Button variant=\"outlined\" size=\"small\" disabled={busy || Boolean(sending)} onClick={() => picker.current?.click()}>\n {sending ? `Sending ${sending.done + 1} of ${sending.total}…` : 'Add proof'}\n </Button>\n </BlockedControl>\n {pickMedia ? (\n <BlockedControl\n blocked={!canEdit || Boolean(addRefusal)}\n reason={!canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : ''}\n >\n <Button variant=\"outlined\" size=\"small\" disabled={busy || Boolean(sending)} onClick={() => void addFromLibrary()}>\n {'From media library'}\n </Button>\n </BlockedControl>\n ) : null}\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button size=\"small\" disabled={busy || Boolean(sending)} onClick={() => setConfirmingRevision(true)}>\n {`Start revision ${revision + 1}`}\n </Button>\n </BlockedControl>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Up to ${CommerceModel.QUOTE_MAX_PROOFS} files, ${formatVisitorUploadBytes(VISITOR_UPLOAD_MAX_BYTES)} each.`}\n </Typography>\n </Stack>\n ) : null}\n\n {revision > 1 ? (\n <Stack spacing={1.5}>\n <Divider />\n <Typography variant=\"subtitle2\">{'Earlier revisions'}</Typography>\n {historyError ? <Alert severity=\"error\">{historyError}</Alert> : null}\n {history === null && !historyError ? <CircularProgress size={20} aria-label=\"Loading earlier revisions\" /> : null}\n {earlier.map((entry) => (\n <Paper key={entry.revision} variant=\"outlined\" sx={{ p: 2 }}>\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 0.5 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 'fontWeightMedium' }}>{`Revision ${entry.revision}`}</Typography>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={CommerceModel.QUOTE_STAGE_LABELS[entry.stage] ?? entry.stage}\n color={CommerceModel.QUOTE_STATUS_COLOR[entry.stage] ?? 'default'}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Replaced ${dateTime(entry.closedAtMs)}`}\n </Typography>\n </Stack>\n {entry.proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {entry.proofs.map((proof) => tile(proof, entry.revision))}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No proofs.'}\n </Typography>\n )}\n {entry.responses.map((response, index) => (\n <QuoteResponseNote key={index} response={response} tile={(file) => tile(file, entry.revision)} />\n ))}\n </Stack>\n </Paper>\n ))}\n </Stack>\n ) : null}\n\n <Dialog open={confirmingRevision} onClose={() => setConfirmingRevision(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Start revision ${revision + 1}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {`Revision ${revision} is kept as it is now, with its proofs and the customer’s answers. ` +\n `Revision ${revision + 1} starts with no proofs, ready for new ones and any changes to the quote.`}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingRevision(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void startRevision()}>\n {`Start revision ${revision + 1}`}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuoteProofsSection.displayName = 'QuoteProofsSection'\n\nexport default QuoteProofsSection\n\n/**\n * The files a quote's request came with (AGL-4098), as the customer's files:\n * a picture for an image, a chip naming anything else, each downloaded\n * through the quote's own route. They stay where the request keeps them, so a\n * request deleted from the Inbox takes them with it.\n */\nexport function QuoteRequestFilesSection(props: { hostId: string; quoteId: string; quote: CommerceModel.HostOrder }) {\n const { hostId, quoteId, quote } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const request = quote.quote?.request\n const files = CommerceModel.quoteRequestFileViews(quote.quote?.requestFiles)\n const download = useCallback(\n async (file: ListedFile) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id })\n if (!blob) {\n return void enqueueSnackbar('The file could not be downloaded. The request may have been deleted from the Inbox.', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n if (!request || !user) return null\n const when = request.receivedAtMs ? ` on ${dateTime(request.receivedAtMs)}` : ''\n return (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'From the request'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Sent through “${request.formName}”${when}.` + (files.length ? ' The files they sent:' : ' They sent no files.')}\n </Typography>\n {files.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {files.map((file) => (\n <QuoteFileTile\n key={file.id}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n onDownload={(picked) => void download(picked)}\n />\n ))}\n </Stack>\n ) : null}\n </Stack>\n )\n}\n"],"names":["CommerceModel","commerceSitePermissionRefusal","useMediaPicker","checkVisitorUploadSelection","formatVisitorUploadBytes","visitorUploadIsInline","VISITOR_UPLOAD_ACCEPT","VISITOR_UPLOAD_MAX_BYTES","sendVisitorUpload","BlockedControl","useSnackbar","authorizedFetch","useUser","Alert","Box","Button","Chip","CircularProgress","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Divider","Paper","Stack","Typography","useCallback","useEffect","useRef","useState","REFUSAL","postQuote","user","body","response","method","headers","JSON","stringify","ok","payload","json","catch","fetchQuoteFile","action","blob","dateTime","atMs","Date","toLocaleString","undefined","dateStyle","timeStyle","ProofThumbnail","props","hostId","quoteId","file","revision","src","setSrc","live","url","fileId","id","then","URL","createObjectURL","revokeObjectURL","sx","theme","width","spacing","height","display","alignItems","justifyContent","bgcolor","borderRadius","overflow","component","alt","name","maxWidth","maxHeight","objectFit","size","aria-label","QuoteFileTile","onDownload","onRemove","removeBlocked","image","contentType","variant","p","label","onClick","title","blocked","Boolean","reason","color","QuoteResponseNote","tile","severity","ip","userAgent","filter","join","whiteSpace","comment","files","length","direction","useFlexGap","flexWrap","map","QuoteProofsSection","quote","canEdit","onEdited","data","enqueueSnackbar","pickMedia","section","Math","max","Number","proofs","currentQuoteProofs","proofOnly","quoteIsProofOnly","latest","latestQuoteResponse","unpaid","isUnpaidQuote","addRefusal","quoteProofChangeRefusal","removable","sending","setSending","busy","setBusy","confirmingRevision","setConfirmingRevision","history","setHistory","historyError","setHistoryError","picker","loadHistory","answer","String","error","Array","isArray","download","fromRevision","allowDuplicate","link","document","createElement","href","click","setTimeout","addProofs","problem","QUOTE_MAX_PROOFS","done","total","index","entries","stamp","sent","requestTicket","request","finalize","ticket","addFromLibrary","picked","allowPrivate","quoteLibraryProofProblem","media","mediaScope","mediaId","removeProof","proofId","startRevision","persist","at","earlier","entry","reverse","requireProofApproval","proof","input","ref","type","multiple","hidden","accept","data-testid","onChange","event","from","target","value","quoteProofRefusalMessage","disabled","current","rowGap","fontWeight","QUOTE_STAGE_LABELS","stage","QUOTE_STATUS_COLOR","closedAtMs","responses","open","onClose","fullWidth","displayName","QuoteRequestFilesSection","quoteRequestFileViews","requestFiles","when","receivedAtMs","formName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SACEC,2BAA2B,EAC3BC,wBAAwB,EACxBC,qBAAqB,EACrBC,qBAAqB,EACrBC,wBAAwB,QACnB,wCAAuC;AAC9C,SAASC,iBAAiB,QAAQ,+CAA8C;AAChF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,OAAO,EACPC,KAAK,EACLC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAwB,QAAO;AAEhF,MAAMC,UAAU9B,8BAA8B;AA4B9C,eAAe+B,UAAUC,IAAU,EAAEC,IAA6B;IAChE,MAAMC,WAAW,MAAMxB,gBAAgBsB,MAAM,uBAAuB;QAClEG,QAAQ;QACRC,SAAS;YAAE,gBAAgB;QAAmB;QAC9CH,MAAMI,KAAKC,SAAS,CAACL;IACvB;IACA,OAAO;QAAEM,IAAIL,SAASK,EAAE;QAAEC,SAAS,MAAMN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ACA;QAAC9B;QAAMuB;QAAQC;QAASmE;KAAgB;IAE1C,IAAI,CAACqD,WAAW,CAAChJ,MAAM,OAAO;IAC9B,MAAMiM,OAAOjD,QAAQkD,YAAY,GAAG,CAAC,IAAI,EAAEpL,SAASkI,QAAQkD,YAAY,GAAG,GAAG;IAC9E,qBACE,MAAC1M;QAAMgD,SAAS;;0BACd,KAAC/C;gBAAWqE,SAAQ;0BAAa;;0BACjC,KAACrE;gBAAWqE,SAAQ;gBAAQQ,OAAM;0BAC/B,CAAC,cAAc,EAAE0E,QAAQmD,QAAQ,CAAC,CAAC,EAAEF,KAAK,CAAC,CAAC,GAAIjH,CAAAA,MAAMC,MAAM,GAAG,0BAA0B,sBAAqB;;YAEhHD,MAAMC,MAAM,iBACX,KAACzF;gBAAM0F,WAAU;gBAAM1C,SAAS;gBAAG2C,UAAU;gBAAC9C,IAAI;oBAAE+C,UAAU;gBAAO;0BAClEJ,MAAMK,GAAG,CAAC,CAAC5D,qBACV,KAAC+B;wBAECxD,MAAMA;wBACNuB,QAAQA;wBACRC,SAASA;wBACTC,MAAMA;wBACNgC,YAAY,CAAC2F,SAAW,KAAKvB,SAASuB;uBALjC3H,KAAKO,EAAE;iBAShB;;;AAGV"}
@@ -60,10 +60,13 @@ const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
60
60
  const unpaid = CommerceModel.isUnpaidQuote(quote);
61
61
  const last = CommerceModel.lastQuoteSend(section);
62
62
  const revision = Number((_ref = section == null ? void 0 : section.revision) != null ? _ref : 1);
63
- const label = CommerceModel.quoteSendLabel(section);
63
+ // A proof with no price yet (AGL-4184) goes out as a proof, and only with one on it.
64
+ const proofOnly = CommerceModel.quoteIsProofOnly(quote);
65
+ const label = CommerceModel.quoteSendLabel(section, proofOnly);
64
66
  const replacesLink = CommerceModel.quoteSendReplacesLink(section);
65
67
  const approvalFirst = CommerceModel.quotePaymentBlockedByApproval(section);
66
68
  const proofCount = CommerceModel.currentQuoteProofs(section).length;
69
+ const nothingToSend = proofOnly && proofCount === 0;
67
70
  const listed = siteContactEmail(host);
68
71
  const contact = listed && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(listed) ? listed : null;
69
72
  const [open, setOpen] = useState(false);
@@ -146,7 +149,7 @@ const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
146
149
  quote,
147
150
  enqueueSnackbar
148
151
  ]);
149
- const status = last ? `Sent ${sentAt(Number(last.atMs))} to ${last.to || 'the customer'}` + (Number(last.revision) < revision ? ` (revision ${last.revision})` : '') + '.' : 'Not sent yet. Email it with your message, the proof and the PDF, or copy the pay link below and send it yourself.';
152
+ const status = last ? `Sent ${sentAt(Number(last.atMs))} to ${last.to || 'the customer'}` + (Number(last.revision) < revision ? ` (revision ${last.revision})` : '') + '.' : proofOnly ? 'Not sent yet. Email it with your message and the proof, or copy the proof link below and send it yourself.' : 'Not sent yet. Email it with your message, the proof and the PDF, or copy the pay link below and send it yourself.';
150
153
  return /*#__PURE__*/ _jsxs(Stack, {
151
154
  spacing: 1.5,
152
155
  children: [
@@ -184,8 +187,8 @@ const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
184
187
  spacing: 1,
185
188
  children: [
186
189
  unpaid ? /*#__PURE__*/ _jsx(BlockedControl, {
187
- blocked: !canSend,
188
- reason: SEND_REFUSAL,
190
+ blocked: !canSend || nothingToSend,
191
+ reason: !canSend ? SEND_REFUSAL : CommerceModel.quoteSendRefusalMessage('nothing-to-send'),
189
192
  children: /*#__PURE__*/ _jsx(Button, {
190
193
  variant: "contained",
191
194
  size: "small",
@@ -194,7 +197,7 @@ const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
194
197
  children: label
195
198
  })
196
199
  }) : null,
197
- /*#__PURE__*/ _jsx(BlockedControl, {
200
+ proofOnly ? null : /*#__PURE__*/ _jsx(BlockedControl, {
198
201
  blocked: !canSend,
199
202
  reason: SEND_REFUSAL,
200
203
  children: /*#__PURE__*/ _jsx(Button, {
@@ -277,7 +280,7 @@ const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
277
280
  /*#__PURE__*/ _jsx(Typography, {
278
281
  variant: "body2",
279
282
  color: "text.secondary",
280
- children: `The email shows the quote number, revision ${revision} and total` + (proofCount ? ', the proof' : '') + `, with the quote attached as a PDF and a button to ${approvalFirst ? 'approve the proof' : 'pay'} on your site. ` + `Replies go to ${contact || 'your email'}.`
283
+ children: (proofOnly ? `The email shows the proof and revision ${revision}, with no price, and a button to review it on your site. ` : `The email shows the quote number, revision ${revision} and total` + (proofCount ? ', the proof' : '') + `, with the quote attached as a PDF and a button to ${approvalFirst ? 'approve the proof' : 'pay'} on your site. `) + `Replies go to ${contact || 'your email'}.`
281
284
  }),
282
285
  replacesLink ? /*#__PURE__*/ _jsx(Typography, {
283
286
  variant: "body2",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-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 { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\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, useFirestoreDoc, 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 } from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { InvoiceSendDialog, invoiceSentLine } from './invoice-send.component'\nimport { PayLinkReadinessNoticeFor } from './pay-link-readiness-notice.component'\n\nconst SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send')\n\nexport interface QuoteSendSectionProps {\n hostId: string\n quoteId: string\n quote: CommerceModel.HostOrder\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n /** The editor holds changes not saved yet, which the email would not show. */\n edited: boolean\n}\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 * Emailing the quote to the customer (AGL-4097): when it was last sent and to\n * whom, and Send quote, Send again or Send revision N, which opens a short\n * form (To, Subject, Message). The server writes the email in the site's\n * look with the proof, the PDF and the pay button, in the customer's\n * conversation with the business.\n *\n * Send invoice (AGL-4099) sits beside it: for an unpaid quote, an invoice for\n * a customer who needs one to pay (with the same pay link); for a paid one,\n * the invoice as their record. Both reply into the quote's conversation.\n *\n * The form says what the customer's Pay waits on, if anything (AGL-4162),\n * and sends all the same.\n */\nexport function QuoteSendSection(props: QuoteSendSectionProps) {\n const { hostId, quoteId, quote, canSend, edited } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { data: host } = useFirestoreDoc<Record<string, unknown>>(\n () => doc(firestore, 'hosts', hostId),\n [firestore, hostId],\n )\n const businessName = String(resolveHostToken('businessName', (host ?? {}) as HostTokenSource) ?? '').trim()\n const section = quote.quote\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const last = CommerceModel.lastQuoteSend(section)\n const revision = Number(section?.revision ?? 1)\n const label = CommerceModel.quoteSendLabel(section)\n const replacesLink = CommerceModel.quoteSendReplacesLink(section)\n const approvalFirst = CommerceModel.quotePaymentBlockedByApproval(section)\n const proofCount = CommerceModel.currentQuoteProofs(section).length\n const listed = siteContactEmail(host as never)\n const contact = listed && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(listed) ? listed : null\n\n const [open, setOpen] = useState(false)\n const [invoicing, setInvoicing] = useState(false)\n const invoiceLine = invoiceSentLine(quote)\n const closed = quote.status === 'cancelled' || quote.status === 'refunded'\n const [busy, setBusy] = useState(false)\n const [to, setTo] = useState('')\n const [subject, setSubject] = useState('')\n const [message, setMessage] = useState('')\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 const openForm = useCallback(() => {\n setTo(CommerceModel.quoteSendPrefill(quote))\n setSubject(CommerceModel.quoteEmailDefaultSubject(quote, businessName, quoteId))\n setMessage('')\n setOpen(true)\n }, [quote, businessName, quoteId])\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/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey.current },\n body: JSON.stringify({ action: 'send', hostId, quoteId, to, subject, message }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'The quote could not be sent', { variant: 'error', allowDuplicate: true })\n }\n enqueueSnackbar(\n `${CommerceModel.formatQuoteNumber(quote, quoteId)} sent to ${String(payload.to ?? to)}` +\n (payload.linkReplaced ? '. The link in your earlier email no longer opens the quote.' : ''),\n { variant: 'success', persist: false },\n )\n setOpen(false)\n } finally {\n setBusy(false)\n }\n }, [user, hostId, quoteId, to, subject, message, quote, enqueueSnackbar])\n\n const status = last\n ? `Sent ${sentAt(Number(last.atMs))} to ${last.to || 'the customer'}` +\n (Number(last.revision) < revision ? ` (revision ${last.revision})` : '') +\n '.'\n : 'Not sent yet. Email it with your message, the proof and the PDF, or copy the pay link below and send it yourself.'\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{'Email to customer'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {unpaid ? status : last ? status : 'This quote was paid without being emailed.'}\n </Typography>\n {unpaid && replacesLink ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Sending revision ${revision} gives your customer a new pay link. The link in your earlier email will say the quote was updated.`}\n </Typography>\n ) : null}\n {unpaid && edited ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Save your changes first: the email shows the quote as it was last saved.'}\n </Typography>\n ) : null}\n {invoiceLine ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {invoiceLine}\n </Typography>\n ) : null}\n </Stack>\n {!closed ? (\n <Stack direction=\"row\" spacing={1}>\n {unpaid ? (\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button variant=\"contained\" size=\"small\" disabled={busy || edited} onClick={openForm}>\n {label}\n </Button>\n </BlockedControl>\n ) : null}\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button\n variant={unpaid ? 'outlined' : 'contained'}\n size=\"small\"\n disabled={busy || (unpaid && edited)}\n onClick={() => setInvoicing(true)}\n >\n {'Send invoice'}\n </Button>\n </BlockedControl>\n </Stack>\n ) : null}\n <InvoiceSendDialog\n open={invoicing}\n onClose={() => setInvoicing(false)}\n hostId={hostId}\n orderId={quoteId}\n order={quote}\n />\n <Dialog open={open} onClose={busy ? undefined : () => setOpen(false)} maxWidth=\"sm\" fullWidth aria-labelledby=\"quote-send-title\">\n <DialogTitle id=\"quote-send-title\">{`${label}: ${CommerceModel.formatQuoteNumber(quote, quoteId)}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <PayLinkReadinessNoticeFor hostId={hostId} order={quote} noun=\"quote\" />\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 section?.emailThread\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 {`The email shows the quote number, revision ${revision} and total` +\n (proofCount ? ', the proof' : '') +\n `, with the quote attached as a PDF and a button to ${approvalFirst ? 'approve the proof' : 'pay'} on your site. ` +\n `Replies go to ${contact || 'your email'}.`}\n </Typography>\n {replacesLink ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'This sends a new pay link. The link in your earlier email will say the quote was updated.'}\n </Typography>\n ) : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setOpen(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !to.trim()} onClick={() => void send()}>\n {busy ? 'Sending…' : 'Send'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuoteSendSection.displayName = 'QuoteSendSection'\n\nexport default QuoteSendSection\n"],"names":["CommerceModel","commerceSitePermissionRefusal","siteContactEmail","resolveHostToken","BlockedControl","useSnackbar","authorizedFetch","useFirestore","useFirestoreDoc","useUser","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","TextField","Typography","doc","useCallback","useEffect","useRef","useState","InvoiceSendDialog","invoiceSentLine","PayLinkReadinessNoticeFor","SEND_REFUSAL","sentAt","atMs","Date","toLocaleString","dateStyle","timeStyle","QuoteSendSection","props","hostId","quoteId","quote","canSend","edited","firestore","data","user","enqueueSnackbar","host","businessName","String","trim","section","unpaid","isUnpaidQuote","last","lastQuoteSend","revision","Number","label","quoteSendLabel","replacesLink","quoteSendReplacesLink","approvalFirst","quotePaymentBlockedByApproval","proofCount","currentQuoteProofs","length","listed","contact","test","open","setOpen","invoicing","setInvoicing","invoiceLine","closed","status","busy","setBusy","to","setTo","subject","setSubject","message","setMessage","attemptKey","current","openForm","quoteSendPrefill","quoteEmailDefaultSubject","send","payload","globalThis","crypto","randomUUID","now","Math","random","toString","slice","response","method","headers","body","JSON","stringify","action","json","catch","ok","error","variant","allowDuplicate","formatQuoteNumber","linkReplaced","persist","spacing","color","direction","blocked","reason","size","disabled","onClick","onClose","orderId","order","undefined","maxWidth","fullWidth","aria-labelledby","id","sx","pt","noun","type","value","onChange","event","target","required","slotProps","htmlInput","maxLength","QUOTE_MAX_SEND_SUBJECT","helperText","emailThread","multiline","minRows","QUOTE_MAX_SEND_MESSAGE","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,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,eAAe,EAAEC,OAAO,QAAQ,iCAAgC;AACvF,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,GAAG,QAAQ,qBAAo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x"],"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 { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\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, useFirestoreDoc, 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 } from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { InvoiceSendDialog, invoiceSentLine } from './invoice-send.component'\nimport { PayLinkReadinessNoticeFor } from './pay-link-readiness-notice.component'\n\nconst SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send')\n\nexport interface QuoteSendSectionProps {\n hostId: string\n quoteId: string\n quote: CommerceModel.HostOrder\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n /** The editor holds changes not saved yet, which the email would not show. */\n edited: boolean\n}\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 * Emailing the quote to the customer (AGL-4097): when it was last sent and to\n * whom, and Send quote, Send again or Send revision N, which opens a short\n * form (To, Subject, Message). The server writes the email in the site's\n * look with the proof, the PDF and the pay button, in the customer's\n * conversation with the business.\n *\n * Send invoice (AGL-4099) sits beside it: for an unpaid quote, an invoice for\n * a customer who needs one to pay (with the same pay link); for a paid one,\n * the invoice as their record. Both reply into the quote's conversation.\n *\n * The form says what the customer's Pay waits on, if anything (AGL-4162),\n * and sends all the same.\n */\nexport function QuoteSendSection(props: QuoteSendSectionProps) {\n const { hostId, quoteId, quote, canSend, edited } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { data: host } = useFirestoreDoc<Record<string, unknown>>(\n () => doc(firestore, 'hosts', hostId),\n [firestore, hostId],\n )\n const businessName = String(resolveHostToken('businessName', (host ?? {}) as HostTokenSource) ?? '').trim()\n const section = quote.quote\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const last = CommerceModel.lastQuoteSend(section)\n const revision = Number(section?.revision ?? 1)\n // A proof with no price yet (AGL-4184) goes out as a proof, and only with one on it.\n const proofOnly = CommerceModel.quoteIsProofOnly(quote)\n const label = CommerceModel.quoteSendLabel(section, proofOnly)\n const replacesLink = CommerceModel.quoteSendReplacesLink(section)\n const approvalFirst = CommerceModel.quotePaymentBlockedByApproval(section)\n const proofCount = CommerceModel.currentQuoteProofs(section).length\n const nothingToSend = proofOnly && proofCount === 0\n const listed = siteContactEmail(host as never)\n const contact = listed && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(listed) ? listed : null\n\n const [open, setOpen] = useState(false)\n const [invoicing, setInvoicing] = useState(false)\n const invoiceLine = invoiceSentLine(quote)\n const closed = quote.status === 'cancelled' || quote.status === 'refunded'\n const [busy, setBusy] = useState(false)\n const [to, setTo] = useState('')\n const [subject, setSubject] = useState('')\n const [message, setMessage] = useState('')\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 const openForm = useCallback(() => {\n setTo(CommerceModel.quoteSendPrefill(quote))\n setSubject(CommerceModel.quoteEmailDefaultSubject(quote, businessName, quoteId))\n setMessage('')\n setOpen(true)\n }, [quote, businessName, quoteId])\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/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey.current },\n body: JSON.stringify({ action: 'send', hostId, quoteId, to, subject, message }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'The quote could not be sent', { variant: 'error', allowDuplicate: true })\n }\n enqueueSnackbar(\n `${CommerceModel.formatQuoteNumber(quote, quoteId)} sent to ${String(payload.to ?? to)}` +\n (payload.linkReplaced ? '. The link in your earlier email no longer opens the quote.' : ''),\n { variant: 'success', persist: false },\n )\n setOpen(false)\n } finally {\n setBusy(false)\n }\n }, [user, hostId, quoteId, to, subject, message, quote, enqueueSnackbar])\n\n const status = last\n ? `Sent ${sentAt(Number(last.atMs))} to ${last.to || 'the customer'}` +\n (Number(last.revision) < revision ? ` (revision ${last.revision})` : '') +\n '.'\n : proofOnly\n ? 'Not sent yet. Email it with your message and the proof, or copy the proof link below and send it yourself.'\n : 'Not sent yet. Email it with your message, the proof and the PDF, or copy the pay link below and send it yourself.'\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{'Email to customer'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {unpaid ? status : last ? status : 'This quote was paid without being emailed.'}\n </Typography>\n {unpaid && replacesLink ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Sending revision ${revision} gives your customer a new pay link. The link in your earlier email will say the quote was updated.`}\n </Typography>\n ) : null}\n {unpaid && edited ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Save your changes first: the email shows the quote as it was last saved.'}\n </Typography>\n ) : null}\n {invoiceLine ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {invoiceLine}\n </Typography>\n ) : null}\n </Stack>\n {!closed ? (\n <Stack direction=\"row\" spacing={1}>\n {unpaid ? (\n <BlockedControl\n blocked={!canSend || nothingToSend}\n reason={!canSend ? SEND_REFUSAL : CommerceModel.quoteSendRefusalMessage('nothing-to-send')}\n >\n <Button variant=\"contained\" size=\"small\" disabled={busy || edited} onClick={openForm}>\n {label}\n </Button>\n </BlockedControl>\n ) : null}\n {proofOnly ? null : (\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button\n variant={unpaid ? 'outlined' : 'contained'}\n size=\"small\"\n disabled={busy || (unpaid && edited)}\n onClick={() => setInvoicing(true)}\n >\n {'Send invoice'}\n </Button>\n </BlockedControl>\n )}\n </Stack>\n ) : null}\n <InvoiceSendDialog\n open={invoicing}\n onClose={() => setInvoicing(false)}\n hostId={hostId}\n orderId={quoteId}\n order={quote}\n />\n <Dialog open={open} onClose={busy ? undefined : () => setOpen(false)} maxWidth=\"sm\" fullWidth aria-labelledby=\"quote-send-title\">\n <DialogTitle id=\"quote-send-title\">{`${label}: ${CommerceModel.formatQuoteNumber(quote, quoteId)}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <PayLinkReadinessNoticeFor hostId={hostId} order={quote} noun=\"quote\" />\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 section?.emailThread\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 {(proofOnly\n ? `The email shows the proof and revision ${revision}, with no price, and a button to review it on your site. `\n : `The email shows the quote number, revision ${revision} and total` +\n (proofCount ? ', the proof' : '') +\n `, with the quote attached as a PDF and a button to ${approvalFirst ? 'approve the proof' : 'pay'} on your site. `) +\n `Replies go to ${contact || 'your email'}.`}\n </Typography>\n {replacesLink ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'This sends a new pay link. The link in your earlier email will say the quote was updated.'}\n </Typography>\n ) : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setOpen(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !to.trim()} onClick={() => void send()}>\n {busy ? 'Sending…' : 'Send'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuoteSendSection.displayName = 'QuoteSendSection'\n\nexport default QuoteSendSection\n"],"names":["CommerceModel","commerceSitePermissionRefusal","siteContactEmail","resolveHostToken","BlockedControl","useSnackbar","authorizedFetch","useFirestore","useFirestoreDoc","useUser","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","TextField","Typography","doc","useCallback","useEffect","useRef","useState","InvoiceSendDialog","invoiceSentLine","PayLinkReadinessNoticeFor","SEND_REFUSAL","sentAt","atMs","Date","toLocaleString","dateStyle","timeStyle","QuoteSendSection","props","hostId","quoteId","quote","canSend","edited","firestore","data","user","enqueueSnackbar","host","businessName","String","trim","section","unpaid","isUnpaidQuote","last","lastQuoteSend","revision","Number","proofOnly","quoteIsProofOnly","label","quoteSendLabel","replacesLink","quoteSendReplacesLink","approvalFirst","quotePaymentBlockedByApproval","proofCount","currentQuoteProofs","length","nothingToSend","listed","contact","test","open","setOpen","invoicing","setInvoicing","invoiceLine","closed","status","busy","setBusy","to","setTo","subject","setSubject","message","setMessage","attemptKey","current","openForm","quoteSendPrefill","quoteEmailDefaultSubject","send","payload","globalThis","crypto","randomUUID","now","Math","random","toString","slice","response","method","headers","body","JSON","stringify","action","json","catch","ok","error","variant","allowDuplicate","formatQuoteNumber","linkReplaced","persist","spacing","color","direction","blocked","reason","quoteSendRefusalMessage","size","disabled","onClick","onClose","orderId","order","undefined","maxWidth","fullWidth","aria-labelledby","id","sx","pt","noun","type","value","onChange","event","target","required","slotProps","htmlInput","maxLength","QUOTE_MAX_SEND_SUBJECT","helperText","emailThread","multiline","minRows","QUOTE_MAX_SEND_MESSAGE","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,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,eAAe,EAAEC,OAAO,QAAQ,iCAAgC;AACvF,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,GAAG,QAAQ,qBAAoB;AACxC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,8BAA0B;AAC7E,SAASC,yBAAyB,QAAQ,2CAAuC;AAEjF,MAAMC,eAAezB,8BAA8B;AAYnD,6BAA6B,GAC7B,MAAM0B,SAAS,CAACC,OACd,IAAIC,KAA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*#__PURE__*/ _jsx(Typography, {
202
202
  variant: "body2",
203
203
  color: "text.secondary",
204
- children: 'Order history needs the editor or admin role on this site.'
204
+ children: 'Order history takes the "See orders and webhooks" permission on this site.'
205
205
  }) : orders.length === 0 ? /*#__PURE__*/ _jsx(Typography, {
206
206
  variant: "body2",
207
207
  color: "text.secondary",