@aglyn/plugins-commerce 1.0.0-beta.288 → 1.0.0-beta.290

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 (129) hide show
  1. package/README.md +2 -2
  2. package/package.json +13 -13
  3. package/src/lib/components/commerce-console-page.js +29 -2
  4. package/src/lib/components/commerce-console-page.js.map +1 -1
  5. package/src/lib/components/console/commerce-analytics-card.component.js +4 -2
  6. package/src/lib/components/console/commerce-analytics-card.component.js.map +1 -1
  7. package/src/lib/components/console/commerce-pdf-download.d.ts +30 -0
  8. package/src/lib/components/console/commerce-pdf-download.js +53 -0
  9. package/src/lib/components/console/commerce-pdf-download.js.map +1 -0
  10. package/src/lib/components/console/host-orders-card.component.js +5 -1
  11. package/src/lib/components/console/host-orders-card.component.js.map +1 -1
  12. package/src/lib/components/console/host-quotes-card.component.d.ts +34 -0
  13. package/src/lib/components/console/host-quotes-card.component.js +263 -0
  14. package/src/lib/components/console/host-quotes-card.component.js.map +1 -0
  15. package/src/lib/components/console/order-invoice.component.d.ts +6 -4
  16. package/src/lib/components/console/order-invoice.component.js +67 -11
  17. package/src/lib/components/console/order-invoice.component.js.map +1 -1
  18. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +33 -28
  19. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
  20. package/src/lib/components/console/quote-editor-dialog.component.d.ts +45 -0
  21. package/src/lib/components/console/quote-editor-dialog.component.js +1317 -0
  22. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -0
  23. package/src/lib/components/console/quote-pay-link.component.d.ts +38 -0
  24. package/src/lib/components/console/quote-pay-link.component.js +213 -0
  25. package/src/lib/components/console/quote-pay-link.component.js.map +1 -0
  26. package/src/lib/components/console/quote-proofs.component.d.ts +37 -0
  27. package/src/lib/components/console/quote-proofs.component.js +626 -0
  28. package/src/lib/components/console/quote-proofs.component.js.map +1 -0
  29. package/src/lib/components/console/quote-settings-card.component.d.ts +29 -0
  30. package/src/lib/components/console/quote-settings-card.component.js +121 -0
  31. package/src/lib/components/console/quote-settings-card.component.js.map +1 -0
  32. package/src/lib/components/console/tax-settings-card.component.js +4 -1
  33. package/src/lib/components/console/tax-settings-card.component.js.map +1 -1
  34. package/src/lib/components/quote-page-body.d.ts +33 -0
  35. package/src/lib/components/quote-page-body.js +724 -0
  36. package/src/lib/components/quote-page-body.js.map +1 -0
  37. package/src/lib/components/quote-page.d.ts +29 -0
  38. package/src/lib/components/quote-page.js +96 -0
  39. package/src/lib/components/quote-page.js.map +1 -0
  40. package/src/lib/components/quote-proof-panel.d.ts +42 -0
  41. package/src/lib/components/quote-proof-panel.js +436 -0
  42. package/src/lib/components/quote-proof-panel.js.map +1 -0
  43. package/src/lib/components/storefront-payment-element.d.ts +7 -1
  44. package/src/lib/components/storefront-payment-element.js +8 -3
  45. package/src/lib/components/storefront-payment-element.js.map +1 -1
  46. package/src/lib/constants/orders-list-query.js +6 -1
  47. package/src/lib/constants/orders-list-query.js.map +1 -1
  48. package/src/lib/constants/quote-page.d.ts +30 -0
  49. package/src/lib/constants/quote-page.js +35 -0
  50. package/src/lib/constants/quote-page.js.map +1 -0
  51. package/src/lib/model/commerce-orders.d.ts +25 -2
  52. package/src/lib/model/commerce-orders.js +10 -1
  53. package/src/lib/model/commerce-orders.js.map +1 -1
  54. package/src/lib/model/commerce-quote-pay.d.ts +256 -0
  55. package/src/lib/model/commerce-quote-pay.js +426 -0
  56. package/src/lib/model/commerce-quote-pay.js.map +1 -0
  57. package/src/lib/model/commerce-quote-proofs.d.ts +159 -0
  58. package/src/lib/model/commerce-quote-proofs.js +348 -0
  59. package/src/lib/model/commerce-quote-proofs.js.map +1 -0
  60. package/src/lib/model/commerce-quotes.d.ts +335 -0
  61. package/src/lib/model/commerce-quotes.js +522 -0
  62. package/src/lib/model/commerce-quotes.js.map +1 -0
  63. package/src/lib/model/index.d.ts +3 -0
  64. package/src/lib/model/index.js +3 -0
  65. package/src/lib/model/index.js.map +1 -1
  66. package/src/lib/model/plugin-permissions.d.ts +1 -1
  67. package/src/lib/model/plugin-permissions.js +20 -0
  68. package/src/lib/model/plugin-permissions.js.map +1 -1
  69. package/src/lib/server/api-v1/orders-and-products.js +6 -2
  70. package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
  71. package/src/lib/server/billing-webhook.js +127 -52
  72. package/src/lib/server/billing-webhook.js.map +1 -1
  73. package/src/lib/server/checkout-session-expiry.d.ts +36 -0
  74. package/src/lib/server/checkout-session-expiry.js +63 -0
  75. package/src/lib/server/checkout-session-expiry.js.map +1 -0
  76. package/src/lib/server/commerce-pdf.d.ts +100 -0
  77. package/src/lib/server/commerce-pdf.js +283 -0
  78. package/src/lib/server/commerce-pdf.js.map +1 -0
  79. package/src/lib/server/draft-order.js +16 -8
  80. package/src/lib/server/draft-order.js.map +1 -1
  81. package/src/lib/server/order-print.d.ts +6 -0
  82. package/src/lib/server/order-print.js +22 -5
  83. package/src/lib/server/order-print.js.map +1 -1
  84. package/src/lib/server/pdf-response.d.ts +31 -0
  85. package/src/lib/server/pdf-response.js +30 -0
  86. package/src/lib/server/pdf-response.js.map +1 -0
  87. package/src/lib/server/person-eraser.d.ts +7 -0
  88. package/src/lib/server/person-eraser.js +24 -2
  89. package/src/lib/server/person-eraser.js.map +1 -1
  90. package/src/lib/server/pos-reader-splash.d.ts +2 -18
  91. package/src/lib/server/pos-reader-splash.js +8 -93
  92. package/src/lib/server/pos-reader-splash.js.map +1 -1
  93. package/src/lib/server/pos-return.js +3 -1
  94. package/src/lib/server/pos-return.js.map +1 -1
  95. package/src/lib/server/quote-link-token.d.ts +39 -0
  96. package/src/lib/server/quote-link-token.js +97 -0
  97. package/src/lib/server/quote-link-token.js.map +1 -0
  98. package/src/lib/server/quote-pay.d.ts +110 -0
  99. package/src/lib/server/quote-pay.js +606 -0
  100. package/src/lib/server/quote-pay.js.map +1 -0
  101. package/src/lib/server/quote-proofs.d.ts +51 -0
  102. package/src/lib/server/quote-proofs.js +500 -0
  103. package/src/lib/server/quote-proofs.js.map +1 -0
  104. package/src/lib/server/quote-uploads.d.ts +33 -0
  105. package/src/lib/server/quote-uploads.js +29 -0
  106. package/src/lib/server/quote-uploads.js.map +1 -0
  107. package/src/lib/server/quote.d.ts +63 -0
  108. package/src/lib/server/quote.js +846 -0
  109. package/src/lib/server/quote.js.map +1 -0
  110. package/src/lib/server/related.js +2 -0
  111. package/src/lib/server/related.js.map +1 -1
  112. package/src/lib/server/site-image-source.d.ts +38 -0
  113. package/src/lib/server/site-image-source.js +130 -0
  114. package/src/lib/server/site-image-source.js.map +1 -0
  115. package/src/lib/server/site-page-resolver.d.ts +2 -0
  116. package/src/lib/server/site-page-resolver.js +75 -0
  117. package/src/lib/server/site-page-resolver.js.map +1 -1
  118. package/src/lib/server.js +33 -1
  119. package/src/lib/server.js.map +1 -1
  120. package/src/lib/site.js +6 -0
  121. package/src/lib/site.js.map +1 -1
  122. package/src/lib/transfer/tracking.server.js +6 -0
  123. package/src/lib/transfer/tracking.server.js.map +1 -1
  124. package/src/lib/utils/commerce-document-pdf.d.ts +77 -0
  125. package/src/lib/utils/commerce-document-pdf.js +608 -0
  126. package/src/lib/utils/commerce-document-pdf.js.map +1 -0
  127. package/src/lib/utils/order-invoice.d.ts +52 -3
  128. package/src/lib/utils/order-invoice.js +116 -64
  129. package/src/lib/utils/order-invoice.js.map +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-editor-dialog.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { posMoney } from '../../model/commerce-pos-ops'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport {\n useFirestore,\n useFirestoreDoc,\n useStoreSettingsHref,\n useUser,\n} from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Divider,\n FormControlLabel,\n List,\n ListItemButton,\n ListItemText,\n MenuItem,\n Paper,\n Stack,\n Switch,\n TextField,\n Typography,\n type Theme,\n} from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { downloadCommercePdf } from './commerce-pdf-download'\nimport { QuotePayLinkSection } from './quote-pay-link.component'\nimport { QuoteProofsSection } from './quote-proofs.component'\n\n/** A quote as the list reads it: the order document and its id. */\nexport type QuoteRow = CommerceModel.HostOrder & { $id: string }\n\nexport interface QuoteEditorDialogProps {\n hostId: string\n /** The quote to edit, or `null` for a new one. */\n quote: QuoteRow | null\n /** The store's products, for the product picker. */\n products: readonly Record<string, any>[]\n /** Holds \"Create and edit quotes\" (`commerce.quotes`). */\n canEdit: boolean\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n onClose: () => void\n}\n\nconst REFUSAL = commerceSitePermissionRefusal('commerce.quotes')\nconst SEARCH_DEBOUNCE_MS = 250\n\nconst money = (cents: number): string => posMoney(cents)\n\n/** Field widths on a wide screen, from the theme's spacing; full width on a phone. */\nconst narrowField = (theme: Theme) => ({ maxWidth: { sm: theme.spacing(16) } })\nconst mediumField = (theme: Theme) => ({ minWidth: { sm: theme.spacing(20) }, maxWidth: { sm: theme.spacing(24) } })\n\n/** Dollars typed into a field, as whole cents, or `null` when it is not an amount. */\nfunction centsOf(text: string): number | null {\n const trimmed = text.trim()\n if (!trimmed) return 0\n if (!/^\\d+(\\.\\d{0,2})?$/.test(trimmed)) return null\n return Math.round(Number(trimmed) * 100)\n}\n\nconst dollarsOf = (cents: number | undefined): string =>\n cents ? (cents / 100).toFixed(2).replace(/\\.00$/, '') : ''\n\ntype AddressForm = Record<'name' | 'line1' | 'line2' | 'city' | 'state' | 'postalCode' | 'country', string>\n\nfunction addressForm(address: CommerceModel.OrderAddress | null | undefined): AddressForm {\n return {\n name: address?.name ?? '',\n line1: address?.line1 ?? '',\n line2: address?.line2 ?? '',\n city: address?.city ?? '',\n state: address?.state ?? '',\n postalCode: address?.postalCode ?? '',\n country: address?.country ?? '',\n }\n}\n\ntype LineForm =\n | {\n key: string\n kind: 'catalog'\n productId: string\n variantId: string\n quantity: string\n modifiers: CommerceModel.ModifierSelection[]\n description: string\n included: boolean\n }\n | {\n key: string\n kind: 'custom'\n name: string\n description: string\n sku: string\n price: string\n quantity: string\n ships: boolean\n included: boolean\n }\n\ninterface QuoteForm {\n lines: LineForm[]\n customer: { record: { kind: string; id: string } | null; name: string; company: string; email: string; phone: string }\n shipTo: AddressForm\n billTo: AddressForm\n discountKind: 'none' | 'amount' | 'percent'\n discountValue: string\n shipping: string\n notes: string\n terms: string\n requireProofApproval: boolean\n}\n\nlet lineSequence = 0\nconst nextLineKey = () => `line-${++lineSequence}`\n\nfunction formFromQuote(quote: QuoteRow | null, requireProofApproval: boolean): QuoteForm {\n const section = quote?.quote\n const discount = section?.discount ?? null\n return {\n lines: (quote?.lineItems ?? []).map((line): LineForm => {\n const request = CommerceModel.quoteLineRequestFromLine(line)\n return request.kind === 'custom'\n ? {\n key: nextLineKey(),\n kind: 'custom',\n name: request.name,\n description: request.description ?? '',\n sku: request.sku ?? '',\n price: dollarsOf(request.unitAmountCents),\n quantity: String(request.quantity),\n ships: request.ships !== false,\n included: request.included === true,\n }\n : {\n key: nextLineKey(),\n kind: 'catalog',\n productId: request.productId,\n variantId: request.variantId ?? '',\n quantity: String(request.quantity),\n modifiers: request.modifiers ?? [],\n description: request.description ?? '',\n included: request.included === true,\n }\n }),\n customer: {\n record: section?.customer?.record ?? null,\n name: section?.customer?.name ?? '',\n company: section?.customer?.company ?? '',\n email: section?.customer?.email ?? '',\n phone: section?.customer?.phone ?? '',\n },\n shipTo: addressForm(section?.shipTo),\n billTo: addressForm(section?.billTo),\n discountKind: discount?.kind ?? 'none',\n discountValue:\n discount?.kind === 'amount' ? dollarsOf(discount.amountCents) : discount?.kind === 'percent' ? String(discount.pct) : '',\n shipping: dollarsOf(section?.shipping?.amountCents),\n notes: section?.notes ?? '',\n terms: section?.terms ?? '',\n requireProofApproval: section ? section.requireProofApproval === true : requireProofApproval,\n }\n}\n\nfunction lineRequest(line: LineForm): CommerceModel.QuoteLineRequest {\n const quantity = Number(line.quantity)\n if (line.kind === 'catalog') {\n return {\n kind: 'catalog',\n productId: line.productId,\n ...(line.variantId ? { variantId: line.variantId } : {}),\n quantity,\n ...(line.modifiers.length ? { modifiers: line.modifiers } : {}),\n ...(line.included ? { included: true } : {}),\n ...(line.description.trim() ? { description: line.description.trim() } : {}),\n }\n }\n return {\n kind: 'custom',\n name: line.name.trim(),\n ...(line.description.trim() ? { description: line.description.trim() } : {}),\n ...(line.sku.trim() ? { sku: line.sku.trim() } : {}),\n unitAmountCents: line.included ? 0 : (centsOf(line.price) ?? Number.NaN),\n quantity,\n ships: line.ships,\n ...(line.included ? { included: true } : {}),\n }\n}\n\nfunction addressBody(address: AddressForm): Partial<AddressForm> | null {\n const entries = Object.entries(address).filter(([, value]) => value.trim())\n return entries.length ? Object.fromEntries(entries.map(([key, value]) => [key, value.trim()])) : null\n}\n\n/** What the server is sent: choices, never what a product costs. */\nfunction quoteBody(form: QuoteForm): Record<string, unknown> {\n const discountCents = centsOf(form.discountValue)\n return {\n lines: form.lines.map(lineRequest),\n customer: {\n ...(form.customer.record ? { record: form.customer.record } : {}),\n name: form.customer.name,\n company: form.customer.company,\n email: form.customer.email,\n phone: form.customer.phone,\n },\n shipTo: addressBody(form.shipTo),\n billTo: addressBody(form.billTo),\n discount:\n form.discountKind === 'amount'\n ? { kind: 'amount', amountCents: discountCents ?? Number.NaN }\n : form.discountKind === 'percent'\n ? { kind: 'percent', pct: Number(form.discountValue || 0) }\n : null,\n shipping: form.shipping.trim() ? { amountCents: centsOf(form.shipping) ?? Number.NaN } : null,\n notes: form.notes,\n terms: form.terms,\n requireProofApproval: form.requireProofApproval,\n }\n}\n\ninterface FoundCustomer {\n record: { kind: string; id: string }\n name: string\n company: string\n email: string | null\n phone: string | null\n}\n\n/**\n * The quote editor (AGL-4093): who it is for, its lines (products with their\n * options and add-ons, typed items, things included at no charge), discount,\n * shipping, notes and terms, with the totals worked out as it is edited. The\n * server prices and saves it; the totals here are the same function's answer\n * over the same inputs, and a connected tax service's figure arrives on save.\n */\nexport function QuoteEditorDialog(props: QuoteEditorDialogProps) {\n const { hostId, quote, products, canEdit, canSend, onClose } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const taxesHref = useStoreSettingsHref(hostId, 'taxes')\n const { data: store } = useFirestoreDoc<any>(\n () => doc(firestore, 'hosts', hostId, 'settings', 'store'),\n [firestore, hostId],\n )\n const storeDefault = CommerceModel.quoteRequiresProofApprovalByDefault(store?.quotes)\n const [form, setForm] = useState<QuoteForm>(() => formFromQuote(quote, storeDefault))\n // The version this form was opened on. A change saved elsewhere while it is\n // open arrives on `quote`; the save still names this one, so the server\n // refuses rather than overwrite that change. A proof added or a revision\n // started here (AGL-4096) moves it, and the save names the new one.\n const [baseUpdatedAtMs, setBaseUpdatedAtMs] = useState(() => quote?.quote?.updatedAtMs)\n const [busy, setBusy] = useState(false)\n const [confirmingDelete, setConfirmingDelete] = useState(false)\n /** Whether anything has been changed since the dialog opened. */\n const [edited, setEdited] = useState(false)\n /** Whether the proof-approval switch was set by hand. */\n const [approvalSet, setApprovalSet] = useState(false)\n // A new quote starts with the store's default, which may arrive after the\n // dialog opens; a switch set by hand keeps its setting.\n const requireProofApproval = quote || approvalSet ? form.requireProofApproval : storeDefault\n\n const update = useCallback((patch: Partial<QuoteForm>) => {\n setEdited(true)\n if ('requireProofApproval' in patch) setApprovalSet(true)\n setForm((prev) => ({ ...prev, ...patch }))\n }, [])\n const updateLine = useCallback((key: string, patch: Partial<LineForm>) => {\n setEdited(true)\n setForm((prev) => ({\n ...prev,\n lines: prev.lines.map((line) => (line.key === key ? ({ ...line, ...patch } as LineForm) : line)),\n }))\n }, [])\n\n /*\n * One attempt per change (AGL-1697's rule): a retried Save presents the same\n * key and is answered from the first, an edited quote is a new attempt.\n */\n const attemptKey = useRef('')\n useEffect(() => {\n attemptKey.current = ''\n }, [form])\n\n const productsById = useMemo(\n () => new Map(products.map((product) => [String(product.$id), product])),\n [products],\n )\n\n /** Each line priced as the server will price it, or why it cannot be. */\n const priced = useMemo(\n () =>\n form.lines.map((line) => {\n const request = lineRequest(line)\n if (request.kind === 'custom') {\n if (!request.name) return { error: 'Name the item.' }\n if (!Number.isInteger(request.unitAmountCents)) return { error: 'Enter a price.' }\n if (!(request.quantity >= 1)) return { error: 'Enter a quantity.' }\n return { line: CommerceModel.priceQuoteCustomLine(request) }\n }\n if (!request.productId) return { error: 'Choose a product.' }\n if (!(request.quantity >= 1)) return { error: 'Enter a quantity.' }\n const answer = CommerceModel.priceQuoteCatalogLine(productsById.get(request.productId) as never, request)\n return 'error' in answer ? { error: answer.error } : { line: answer.line }\n }),\n [form.lines, productsById],\n )\n\n const discountCents = centsOf(form.discountValue)\n const discount: CommerceModel.QuoteDiscount | null =\n form.discountKind === 'amount' && discountCents\n ? { kind: 'amount', amountCents: discountCents }\n : form.discountKind === 'percent' && Number(form.discountValue) > 0\n ? { kind: 'percent', pct: Math.min(100, Number(form.discountValue)) }\n : null\n const shippingCents = centsOf(form.shipping) ?? 0\n const taxBasis = CommerceModel.quoteTaxBasisFromSettings(store?.tax, {\n country: form.shipTo.country.trim().toUpperCase(),\n state: form.shipTo.state.trim(),\n })\n const pricedLines = priced.flatMap((entry) => ('line' in entry && entry.line ? [entry.line] : []))\n const totals = CommerceModel.computeQuoteTotals({ lines: pricedLines, discount, shippingCents, tax: taxBasis })\n const problems = priced.some((entry) => 'error' in entry)\n const savedService = quote?.quote?.tax?.kind === 'service' ? quote.quote.tax : null\n\n const save = 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({\n action: quote ? 'update' : 'create',\n hostId,\n ...(quote ? { quoteId: quote.$id, baseUpdatedAtMs } : {}),\n quote: quoteBody({ ...form, requireProofApproval }),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'The quote could not be saved', { variant: 'error', allowDuplicate: true })\n }\n enqueueSnackbar(`${CommerceModel.formatQuoteNumber({ number: payload.number ?? undefined }, payload.quoteId)} saved`, {\n variant: 'success',\n persist: false,\n })\n onClose()\n } finally {\n setBusy(false)\n }\n }, [user, quote, hostId, baseUpdatedAtMs, form, requireProofApproval, enqueueSnackbar, onClose])\n\n const remove = useCallback(async () => {\n if (!quote) return\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: 'delete', hostId, quoteId: quote.$id }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'The quote could not be deleted', { variant: 'error', allowDuplicate: true })\n }\n enqueueSnackbar(`${CommerceModel.formatQuoteNumber(quote, quote.$id)} deleted`, { variant: 'success', persist: false })\n setConfirmingDelete(false)\n onClose()\n } finally {\n setBusy(false)\n }\n }, [user, quote, hostId, enqueueSnackbar, onClose])\n\n const [downloading, setDownloading] = useState(false)\n const downloadPdf = useCallback(async () => {\n if (!quote) return\n setDownloading(true)\n try {\n const refused = await downloadCommercePdf(\n user,\n '/api/commerce/quote',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action: 'pdf', hostId, quoteId: quote.$id }),\n },\n `quote-${quote.number ?? quote.$id.slice(-6)}.pdf`,\n )\n if (refused) enqueueSnackbar(refused, { variant: 'error', allowDuplicate: true })\n } finally {\n setDownloading(false)\n }\n }, [user, quote, hostId, enqueueSnackbar])\n\n const readOnly = !canEdit || busy\n const paid = quote ? !CommerceModel.isUnpaidQuote(quote) : false\n const title = quote ? CommerceModel.formatQuoteNumber(quote, quote.$id) : 'New quote'\n const status = quote ? CommerceModel.quoteDisplayStatus(quote) : null\n const deletable = Boolean(quote) && !paid && (quote?.quote?.stage ?? 'draft') === 'draft'\n\n return (\n <Dialog open onClose={busy ? undefined : onClose} maxWidth=\"md\" fullWidth scroll=\"paper\" aria-labelledby=\"quote-editor-title\">\n <DialogTitle id=\"quote-editor-title\">\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <span>{title}</span>\n {status ? (\n <Chip size=\"small\" variant=\"outlined\" label={status.label} color={CommerceModel.QUOTE_STATUS_COLOR[status.key]} />\n ) : null}\n </Stack>\n </DialogTitle>\n <DialogContent dividers>\n <Stack spacing={3}>\n {paid ? (\n <Alert severity=\"success\">\n {quote?.quote?.paidAtMs\n ? `Paid ${new Date(quote.quote.paidAtMs).toLocaleDateString()}. It is an order now and can no longer be changed.`\n : 'This quote has been paid, so it is an order now and can no longer be changed.'}\n </Alert>\n ) : null}\n {quote ? (\n <QuotePayLinkSection hostId={hostId} quoteId={quote.$id} quote={quote} canSend={canSend} edited={edited} />\n ) : null}\n {quote ? (\n <QuoteProofsSection\n hostId={hostId}\n quoteId={quote.$id}\n quote={quote}\n canEdit={canEdit}\n onEdited={(updatedAtMs) => {\n if (updatedAtMs) setBaseUpdatedAtMs(updatedAtMs)\n }}\n />\n ) : null}\n {taxBasis.kind === 'none' && taxBasis.reason === 'undecided' ? (\n <PrerequisiteNotice href={taxesHref ?? undefined} actionLabel=\"Open Taxes\">\n {'This store has not chosen how it handles sales tax, so this quote shows no tax. Choose it in Taxes.'}\n </PrerequisiteNotice>\n ) : null}\n\n <QuoteCustomerSection\n hostId={hostId}\n form={form}\n disabled={readOnly || paid}\n onChange={(customer) => update({ customer })}\n />\n\n <Stack spacing={1.5}>\n <Typography variant=\"subtitle2\">{'Items'}</Typography>\n {form.lines.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Add products from your catalog, or type an item that is made to order.'}\n </Typography>\n ) : null}\n {form.lines.map((line, index) => (\n <QuoteLineEditor\n key={line.key}\n line={line}\n priced={priced[index]}\n products={products}\n disabled={readOnly || paid}\n onChange={(patch) => updateLine(line.key, patch)}\n onRemove={() => update({ lines: form.lines.filter((entry) => entry.key !== line.key) })}\n />\n ))}\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Button\n size=\"small\"\n disabled={readOnly || paid || products.length === 0}\n onClick={() =>\n update({\n lines: [\n ...form.lines,\n { key: nextLineKey(), kind: 'catalog', productId: '', variantId: '', quantity: '1', modifiers: [], description: '', included: false },\n ],\n })\n }\n >\n {'Add product'}\n </Button>\n <Button\n size=\"small\"\n disabled={readOnly || paid}\n onClick={() =>\n update({\n lines: [\n ...form.lines,\n { key: nextLineKey(), kind: 'custom', name: '', description: '', sku: '', price: '', quantity: '1', ships: true, included: false },\n ],\n })\n }\n >\n {'Add custom item'}\n </Button>\n </Stack>\n </Stack>\n\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField\n label=\"Discount\"\n select\n size=\"small\"\n value={form.discountKind}\n disabled={readOnly || paid}\n onChange={(event) => update({ discountKind: event.target.value as QuoteForm['discountKind'] })}\n sx={mediumField}\n >\n <MenuItem value=\"none\">{'None'}</MenuItem>\n <MenuItem value=\"amount\">{'Amount off'}</MenuItem>\n <MenuItem value=\"percent\">{'Percent off'}</MenuItem>\n </TextField>\n {form.discountKind !== 'none' ? (\n <TextField\n label={form.discountKind === 'amount' ? 'Amount ($)' : 'Percent (%)'}\n size=\"small\"\n value={form.discountValue}\n disabled={readOnly || paid}\n onChange={(event) => update({ discountValue: event.target.value })}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n error={form.discountKind === 'amount' ? centsOf(form.discountValue) === null : !(Number(form.discountValue) >= 0 && Number(form.discountValue) <= 100)}\n />\n ) : null}\n <TextField\n label=\"Shipping ($)\"\n size=\"small\"\n value={form.shipping}\n disabled={readOnly || paid}\n onChange={(event) => update({ shipping: event.target.value })}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n error={centsOf(form.shipping) === null}\n helperText=\"Leave empty when nothing ships.\"\n />\n </Stack>\n\n <QuoteAddressFields\n label=\"Ship to\"\n value={form.shipTo}\n disabled={readOnly || paid}\n helperText=\"Where the order goes. Store tax rates use its state and country.\"\n onChange={(shipTo) => update({ shipTo })}\n />\n <QuoteAddressFields\n label=\"Bill to\"\n value={form.billTo}\n disabled={readOnly || paid}\n onChange={(billTo) => update({ billTo })}\n />\n\n <Stack spacing={2}>\n <TextField\n label=\"Notes for the customer\"\n multiline\n minRows={2}\n value={form.notes}\n disabled={readOnly || paid}\n onChange={(event) => update({ notes: event.target.value })}\n />\n <TextField\n label=\"Terms\"\n multiline\n minRows={2}\n value={form.terms}\n disabled={readOnly || paid}\n onChange={(event) => update({ terms: event.target.value })}\n />\n <FormControlLabel\n control={\n <Switch\n checked={requireProofApproval}\n disabled={readOnly || paid}\n onChange={(event) => update({ requireProofApproval: event.target.checked })}\n />\n }\n label=\"Customers approve the proof before they can pay\"\n />\n </Stack>\n\n <Divider />\n <QuoteTotalsSummary\n totals={totals}\n tax={taxBasis}\n savedService={edited ? null : savedService}\n savedTotals={edited ? null : (quote?.totals ?? null)}\n />\n </Stack>\n </DialogContent>\n <DialogActions sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n {deletable ? (\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button color=\"error\" disabled={busy} onClick={() => setConfirmingDelete(true)} sx={{ mr: 'auto' }}>\n {'Delete'}\n </Button>\n </BlockedControl>\n ) : null}\n {quote ? (\n <BlockedControl\n blocked={!canEdit || edited}\n reason={edited ? 'Save your changes first: the PDF shows the quote as it was last saved.' : REFUSAL}\n >\n <Button disabled={busy || downloading} onClick={() => void downloadPdf()}>\n {downloading ? 'Making PDF…' : 'Download PDF'}\n </Button>\n </BlockedControl>\n ) : null}\n <Button onClick={onClose} disabled={busy}>\n {paid || !canEdit ? 'Close' : 'Cancel'}\n </Button>\n {paid ? null : (\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button\n variant=\"contained\"\n disabled={busy || form.lines.length === 0 || problems}\n onClick={() => void save()}\n >\n {quote ? 'Save' : 'Create quote'}\n </Button>\n </BlockedControl>\n )}\n </DialogActions>\n <Dialog open={confirmingDelete} onClose={() => setConfirmingDelete(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Delete ${title}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>{'The quote and everything on it is removed. This can’t be undone.'}</DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingDelete(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button color=\"error\" variant=\"contained\" disabled={busy} onClick={() => void remove()}>\n {'Delete'}\n </Button>\n </DialogActions>\n </Dialog>\n </Dialog>\n )\n}\nQuoteEditorDialog.displayName = 'QuoteEditorDialog'\n\n/** Who the quote is for: a person the workspace keeps, or details typed here. */\nfunction QuoteCustomerSection(props: {\n hostId: string\n form: QuoteForm\n disabled: boolean\n onChange: (customer: QuoteForm['customer']) => void\n}) {\n const { hostId, form, disabled, onChange } = props\n const { data: user } = useUser()\n const [text, setText] = useState('')\n const [found, setFound] = useState<FoundCustomer[]>([])\n const [available, setAvailable] = useState(true)\n const ticket = useRef(0)\n const customer = form.customer\n\n useEffect(() => {\n const typed = text.trim()\n if (typed.length < 2 || !user) {\n // Only when something is listed, so an effect that re-runs settles.\n setFound((prev) => (prev.length ? [] : prev))\n return\n }\n const mine = ++ticket.current\n const timer = window.setTimeout(() => {\n void authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action: 'search-customers', hostId, text: typed }),\n })\n .then((response) => response.json().catch(() => ({})))\n .then((payload) => {\n if (mine !== ticket.current) return\n setAvailable(payload?.available !== false)\n setFound(Array.isArray(payload?.customers) ? payload.customers : [])\n })\n .catch(() => undefined)\n }, SEARCH_DEBOUNCE_MS)\n return () => window.clearTimeout(timer)\n }, [text, user, hostId])\n\n const pick = (person: FoundCustomer) => {\n onChange({\n record: person.record,\n name: person.name,\n company: person.company,\n email: person.email ?? '',\n phone: person.phone ?? '',\n })\n setText('')\n setFound([])\n }\n\n return (\n <Stack spacing={1.5}>\n <Typography variant=\"subtitle2\">{'Customer'}</Typography>\n {customer.record ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Chip\n color=\"primary\"\n variant=\"outlined\"\n label={customer.name || customer.email || 'Contact'}\n onDelete={disabled ? undefined : () => onChange({ ...customer, record: null })}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'From your contacts'}\n </Typography>\n </Stack>\n ) : available ? (\n <Box>\n <TextField\n size=\"small\"\n fullWidth\n label=\"Find a contact\"\n placeholder=\"Name, email or phone\"\n value={text}\n disabled={disabled}\n onChange={(event) => setText(event.target.value)}\n />\n {found.length ? (\n <Paper variant=\"outlined\" sx={{ mt: 0.5 }}>\n <List dense disablePadding>\n {found.map((person) => (\n <ListItemButton key={`${person.record.kind}:${person.record.id}`} onClick={() => pick(person)}>\n <ListItemText\n primary={person.name || person.email || 'Contact'}\n secondary={[person.company, person.email, person.phone].filter(Boolean).join(' · ')}\n />\n </ListItemButton>\n ))}\n </List>\n </Paper>\n ) : null}\n </Box>\n ) : null}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField size=\"small\" fullWidth label=\"Name\" value={customer.name} disabled={disabled} onChange={(event) => onChange({ ...customer, name: event.target.value })} />\n <TextField size=\"small\" fullWidth label=\"Company\" value={customer.company} disabled={disabled} onChange={(event) => onChange({ ...customer, company: event.target.value })} />\n </Stack>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField size=\"small\" fullWidth label=\"Email\" type=\"email\" value={customer.email} disabled={disabled} onChange={(event) => onChange({ ...customer, email: event.target.value })} />\n <TextField size=\"small\" fullWidth label=\"Phone\" value={customer.phone} disabled={disabled} onChange={(event) => onChange({ ...customer, phone: event.target.value })} />\n </Stack>\n </Stack>\n )\n}\n\n/** One address on the quote. */\nfunction QuoteAddressFields(props: {\n label: string\n value: AddressForm\n disabled: boolean\n helperText?: string\n onChange: (value: AddressForm) => void\n}) {\n const { label, value, disabled, helperText, onChange } = props\n const field = (key: keyof AddressForm, fieldLabel: string, extra: Record<string, unknown> = {}) => (\n <TextField\n size=\"small\"\n fullWidth\n label={fieldLabel}\n value={value[key]}\n disabled={disabled}\n onChange={(event) => onChange({ ...value, [key]: event.target.value })}\n {...extra}\n />\n )\n return (\n <Stack spacing={1.5}>\n <Typography variant=\"subtitle2\">{label}</Typography>\n {helperText ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {helperText}\n </Typography>\n ) : null}\n {field('name', 'Name')}\n {field('line1', 'Address')}\n {field('line2', 'Apartment, suite, unit')}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n {field('city', 'City')}\n {field('state', 'State or region')}\n {field('postalCode', 'Postal code')}\n {field('country', 'Country code', { placeholder: 'US', slotProps: { htmlInput: { maxLength: 2 } } })}\n </Stack>\n </Stack>\n )\n}\n\n/** One line of the quote: a product with its options and add-ons, or a typed item. */\nfunction QuoteLineEditor(props: {\n line: LineForm\n priced: { line?: CommerceModel.PricedQuoteLine; error?: string } | undefined\n products: readonly Record<string, any>[]\n disabled: boolean\n onChange: (patch: Partial<LineForm>) => void\n onRemove: () => void\n}) {\n const { line, priced, products, disabled, onChange, onRemove } = props\n const product = line.kind === 'catalog' ? products.find((entry) => String(entry.$id) === line.productId) : undefined\n const lifted = product ? CommerceModel.liftLegacyProduct(product) : null\n const groups = lifted ? CommerceModel.productModifierGroups(lifted) : []\n const lineCents = priced?.line ? CommerceModel.quoteLineCents(priced.line) : 0\n\n return (\n <Paper variant=\"outlined\" sx={{ p: 2 }}>\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start' }}>\n <Stack spacing={1.5} sx={{ flex: 1, minWidth: 0 }}>\n {line.kind === 'catalog' ? (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField\n label=\"Product\"\n select\n size=\"small\"\n fullWidth\n value={line.productId}\n disabled={disabled}\n onChange={(event) => onChange({ productId: event.target.value, variantId: '', modifiers: [] })}\n >\n {products.map((entry) => (\n <MenuItem key={String(entry.$id)} value={String(entry.$id)}>\n {String(entry.name ?? entry.$id)}\n </MenuItem>\n ))}\n </TextField>\n {lifted && lifted.variants.length > 1 ? (\n <TextField\n label=\"Option\"\n select\n size=\"small\"\n fullWidth\n value={line.variantId || lifted.variants[0]?.id || ''}\n disabled={disabled}\n onChange={(event) => onChange({ variantId: event.target.value })}\n >\n {lifted.variants.map((variant) => (\n <MenuItem key={variant.id} value={variant.id}>\n {Object.values(variant.options ?? {}).join(' / ') || 'Default'}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n </Stack>\n ) : (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField\n label=\"Item\"\n size=\"small\"\n fullWidth\n value={line.name}\n disabled={disabled}\n onChange={(event) => onChange({ name: event.target.value })}\n />\n <TextField\n label=\"SKU (optional)\"\n size=\"small\"\n value={line.sku}\n disabled={disabled}\n onChange={(event) => onChange({ sku: event.target.value })}\n />\n </Stack>\n )}\n {groups.map((group) => {\n const chosen = line.kind === 'catalog' ? line.modifiers.filter((pick) => pick.groupId === group.id).map((pick) => pick.optionId) : []\n return (\n <TextField\n key={group.id}\n label={CommerceModel.modifierGroupRequired(group) ? group.name : `${group.name} (optional)`}\n select\n size=\"small\"\n fullWidth\n value={group.max > 1 ? chosen : (chosen[0] ?? '')}\n disabled={disabled}\n slotProps={{ select: { multiple: group.max > 1 } }}\n onChange={(event) => {\n const raw = event.target.value as unknown\n const picked = (Array.isArray(raw) ? raw : raw ? [raw] : []).map(String)\n if (line.kind !== 'catalog') return\n onChange({\n modifiers: [\n ...line.modifiers.filter((pick) => pick.groupId !== group.id),\n ...picked.map((optionId) => ({ groupId: group.id, optionId })),\n ],\n })\n }}\n >\n {group.max > 1 ? null : <MenuItem value=\"\">{'None'}</MenuItem>}\n {group.options.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {option.priceCents ? `${option.name} (+${money(option.priceCents)})` : option.name}\n </MenuItem>\n ))}\n </TextField>\n )\n })}\n <TextField\n label=\"Description (optional)\"\n size=\"small\"\n fullWidth\n multiline\n value={line.description}\n disabled={disabled}\n onChange={(event) => onChange({ description: event.target.value })}\n />\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n <TextField\n label=\"Quantity\"\n size=\"small\"\n value={line.quantity}\n disabled={disabled}\n onChange={(event) => onChange({ quantity: event.target.value.replace(/[^0-9]/g, '') })}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n sx={narrowField}\n />\n {line.kind === 'custom' ? (\n <TextField\n label=\"Unit price ($)\"\n size=\"small\"\n value={line.included ? '' : line.price}\n disabled={disabled || line.included}\n onChange={(event) => onChange({ price: event.target.value })}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n error={!line.included && centsOf(line.price) === null}\n sx={mediumField}\n />\n ) : null}\n {line.kind === 'custom' ? (\n <FormControlLabel\n control={<Switch checked={line.ships} disabled={disabled} onChange={(event) => onChange({ ships: event.target.checked })} />}\n label=\"Ships\"\n />\n ) : null}\n <FormControlLabel\n control={\n <Switch checked={line.included} disabled={disabled} onChange={(event) => onChange({ included: event.target.checked })} />\n }\n label=\"Included at no charge\"\n />\n </Stack>\n </Stack>\n <Stack sx={{ alignItems: 'flex-end', flexShrink: 0 }}>\n <Button size=\"small\" color=\"inherit\" disabled={disabled} onClick={onRemove}>\n {'Remove'}\n </Button>\n <Typography variant=\"body2\" sx={{ fontWeight: 'fontWeightMedium' }}>\n {line.included ? 'Included' : money(lineCents)}\n </Typography>\n {priced?.line && !line.included && priced.line.quantity > 1 ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${money(priced.line.unitAmountCents)} each`}\n </Typography>\n ) : null}\n </Stack>\n </Stack>\n {priced?.error ? (\n <Typography variant=\"caption\" color=\"error\">\n {priced.error}\n </Typography>\n ) : null}\n </Stack>\n </Paper>\n )\n}\n\n/** The quote's totals, as the customer will read them. */\nfunction QuoteTotalsSummary(props: {\n totals: CommerceModel.QuoteTotals\n tax: CommerceModel.QuoteTaxBasis\n /** A saved quote's tax service answer, shown until the quote is edited. */\n savedService: CommerceModel.QuoteTaxBasis | null\n savedTotals: CommerceModel.OrderTotals | null\n}) {\n const { totals, tax, savedService, savedTotals } = props\n const shown = savedService && savedTotals ? { ...totals, ...savedTotals } : totals\n const taxLabel = CommerceModel.describeQuoteTax(savedService ?? tax)\n const row = (label: string, value: string, strong = false) => (\n <Stack direction=\"row\" sx={{ justifyContent: 'space-between' }}>\n <Typography variant={strong ? 'subtitle1' : 'body2'} color={strong ? 'text.primary' : 'text.secondary'}>\n {label}\n </Typography>\n <Typography variant={strong ? 'subtitle1' : 'body2'}>{value}</Typography>\n </Stack>\n )\n return (\n <Stack spacing={0.5} sx={(theme) => ({ alignSelf: { sm: 'flex-end' }, minWidth: { sm: theme.spacing(40) } })}>\n {row('Items', money(shown.itemsCents))}\n {shown.discountCents ? row('Discount', `−${money(shown.discountCents)}`) : null}\n {shown.shippingCents ? row('Shipping', money(shown.shippingCents)) : null}\n {tax.kind === 'at-payment' && !savedService ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {taxLabel}\n </Typography>\n ) : (\n row(taxLabel, money(shown.taxCents))\n )}\n {row(totals.taxAtPayment && !savedService ? 'Total before tax' : 'Total', money(shown.totalCents), true)}\n </Stack>\n )\n}\n\nexport default QuoteEditorDialog\n"],"names":["CommerceModel","posMoney","commerceSitePermissionRefusal","BlockedControl","PrerequisiteNotice","useSnackbar","authorizedFetch","useFirestore","useFirestoreDoc","useStoreSettingsHref","useUser","Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Divider","FormControlLabel","List","ListItemButton","ListItemText","MenuItem","Paper","Stack","Switch","TextField","Typography","doc","useCallback","useEffect","useMemo","useRef","useState","downloadCommercePdf","QuotePayLinkSection","QuoteProofsSection","REFUSAL","SEARCH_DEBOUNCE_MS","money","cents","narrowField","theme","maxWidth","sm","spacing","mediumField","minWidth","centsOf","text","trimmed","trim","test","Math","round","Number","dollarsOf","toFixed","replace","addressForm","address","name","line1","line2","city","state","postalCode","country","lineSequence","nextLineKey","formFromQuote","quote","requireProofApproval","section","discount","lines","lineItems","map","line","request","quoteLineRequestFromLine","kind","key","description","sku","price","unitAmountCents","quantity","String","ships","included","productId","variantId","modifiers","customer","record","company","email","phone","shipTo","billTo","discountKind","discountValue","amountCents","pct","shipping","notes","terms","lineRequest","length","NaN","addressBody","entries","Object","filter","value","fromEntries","quoteBody","form","discountCents","QuoteEditorDialog","props","hostId","products","canEdit","canSend","onClose","firestore","data","user","enqueueSnackbar","taxesHref","store","storeDefault","quoteRequiresProofApprovalByDefault","quotes","setForm","baseUpdatedAtMs","setBaseUpdatedAtMs","updatedAtMs","busy","setBusy","confirmingDelete","setConfirmingDelete","edited","setEdited","approvalSet","setApprovalSet","update","patch","prev","updateLine","attemptKey","current","productsById","Map","product","$id","priced","error","isInteger","priceQuoteCustomLine","answer","priceQuoteCatalogLine","get","min","shippingCents","taxBasis","quoteTaxBasisFromSettings","tax","toUpperCase","pricedLines","flatMap","entry","totals","computeQuoteTotals","problems","some","savedService","save","payload","globalThis","crypto","randomUUID","Date","now","random","toString","slice","response","method","headers","body","JSON","stringify","action","quoteId","json","catch","ok","variant","allowDuplicate","formatQuoteNumber","number","undefined","persist","remove","downloading","setDownloading","downloadPdf","refused","readOnly","paid","isUnpaidQuote","title","status","quoteDisplayStatus","deletable","Boolean","stage","open","fullWidth","scroll","aria-labelledby","id","direction","sx","alignItems","span","size","label","color","QUOTE_STATUS_COLOR","dividers","severity","paidAtMs","toLocaleDateString","onEdited","reason","href","actionLabel","QuoteCustomerSection","disabled","onChange","index","QuoteLineEditor","onRemove","useFlexGap","flexWrap","onClick","xs","select","event","target","slotProps","htmlInput","inputMode","helperText","QuoteAddressFields","multiline","minRows","control","checked","QuoteTotalsSummary","savedTotals","rowGap","blocked","mr","displayName","setText","found","setFound","available","setAvailable","ticket","typed","mine","timer","window","setTimeout","then","Array","isArray","customers","clearTimeout","pick","person","onDelete","placeholder","mt","dense","disablePadding","primary","secondary","join","type","field","fieldLabel","extra","maxLength","lifted","find","liftLegacyProduct","groups","productModifierGroups","lineCents","quoteLineCents","p","flex","variants","values","options","group","chosen","groupId","optionId","modifierGroupRequired","max","multiple","raw","picked","option","priceCents","flexShrink","fontWeight","shown","taxLabel","describeQuoteTax","row","strong","justifyContent","alignSelf","itemsCents","taxCents","taxAtPayment","totalCents"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,QAAQ,QAAQ,kCAA8B;AACvD,SAASC,6BAA6B,QAAQ,oCAAgC;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,IAAI1J,OAAOgK,YAAY,IAAI,CAAC5J,eAAe,qBAAqB,SAAS3I,MAAM8R,MAAMU,UAAU,GAAG;;;AAGzG;AAEA,eAAevN,kBAAiB"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as CommerceModel from '../../model';
18
+ export interface QuotePayLinkSectionProps {
19
+ hostId: string;
20
+ quoteId: string;
21
+ quote: Pick<CommerceModel.HostOrder, 'status' | 'channel' | 'number'>;
22
+ /** Holds "Send quotes and invoices to customers" (`commerce.quotes.send`). */
23
+ canSend: boolean;
24
+ /** The editor holds changes not saved yet, which the link does not show. */
25
+ edited: boolean;
26
+ }
27
+ /**
28
+ * A quote's pay link (AGL-4094): the address the business sends the
29
+ * customer, which opens the quote on the business's own site with a Pay
30
+ * button. "Copy pay link" asks the server for it (it is signed there) and puts
31
+ * it on the clipboard and on screen; "Replace link" makes a new one and the
32
+ * one sent before stops opening the quote.
33
+ */
34
+ export declare function QuotePayLinkSection(props: QuotePayLinkSectionProps): import("react").JSX.Element;
35
+ export declare namespace QuotePayLinkSection {
36
+ var displayName: string;
37
+ }
38
+ export default QuotePayLinkSection;
@@ -0,0 +1,213 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ import * as CommerceModel from "../../model/index.js";
19
+ import { commerceSitePermissionRefusal } from "../../model/plugin-permissions.js";
20
+ import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
21
+ import { useSnackbar } from "@aglyn/shared-ui-snackstack";
22
+ import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
23
+ import { useUser } from "@aglyn/tenant-feature-instance";
24
+ import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Stack, TextField, Typography } from "@mui/material";
25
+ import { useCallback, useState } from "react";
26
+ const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
27
+ /**
28
+ * A quote's pay link (AGL-4094): the address the business sends the
29
+ * customer, which opens the quote on the business's own site with a Pay
30
+ * button. "Copy pay link" asks the server for it (it is signed there) and puts
31
+ * it on the clipboard and on screen; "Replace link" makes a new one and the
32
+ * one sent before stops opening the quote.
33
+ */ export function QuotePayLinkSection(props) {
34
+ const { hostId, quoteId, quote, canSend, edited } = props;
35
+ const { data: user } = useUser();
36
+ const { enqueueSnackbar } = useSnackbar();
37
+ const [url, setUrl] = useState('');
38
+ const [busy, setBusy] = useState(false);
39
+ const [confirmingReplace, setConfirmingReplace] = useState(false);
40
+ const unpaid = CommerceModel.isUnpaidQuote(quote);
41
+ const ask = useCallback(async (action)=>{
42
+ setBusy(true);
43
+ try {
44
+ const response = await authorizedFetch(user, '/api/commerce/quote', {
45
+ method: 'POST',
46
+ headers: {
47
+ 'Content-Type': 'application/json'
48
+ },
49
+ body: JSON.stringify({
50
+ action,
51
+ hostId,
52
+ quoteId
53
+ })
54
+ });
55
+ const payload = await response.json().catch(()=>({}));
56
+ if (!response.ok || !(payload == null ? void 0 : payload.url)) {
57
+ var _ref;
58
+ enqueueSnackbar((_ref = payload == null ? void 0 : payload.error) != null ? _ref : 'The pay link could not be made', {
59
+ variant: 'error',
60
+ allowDuplicate: true
61
+ });
62
+ return null;
63
+ }
64
+ setUrl(String(payload.url));
65
+ return String(payload.url);
66
+ } finally{
67
+ setBusy(false);
68
+ }
69
+ }, [
70
+ user,
71
+ hostId,
72
+ quoteId,
73
+ enqueueSnackbar
74
+ ]);
75
+ const copy = useCallback(async (link, done)=>{
76
+ try {
77
+ await navigator.clipboard.writeText(link);
78
+ enqueueSnackbar(done, {
79
+ variant: 'success',
80
+ persist: false
81
+ });
82
+ } catch (unused) {
83
+ // The link is on screen to copy by hand when the clipboard is refused.
84
+ enqueueSnackbar('Copy the link below to send it', {
85
+ variant: 'info',
86
+ persist: false
87
+ });
88
+ }
89
+ }, [
90
+ enqueueSnackbar
91
+ ]);
92
+ const copyLink = useCallback(async ()=>{
93
+ const link = url || await ask('pay-link');
94
+ if (link) await copy(link, 'Pay link copied');
95
+ }, [
96
+ url,
97
+ ask,
98
+ copy
99
+ ]);
100
+ const replaceLink = useCallback(async ()=>{
101
+ const link = await ask('replace-link');
102
+ setConfirmingReplace(false);
103
+ if (link) await copy(link, 'New pay link copied. The earlier link no longer opens the quote.');
104
+ }, [
105
+ ask,
106
+ copy
107
+ ]);
108
+ return /*#__PURE__*/ _jsxs(Stack, {
109
+ spacing: 1.5,
110
+ children: [
111
+ /*#__PURE__*/ _jsxs(Stack, {
112
+ spacing: 0.5,
113
+ children: [
114
+ /*#__PURE__*/ _jsx(Typography, {
115
+ variant: "subtitle2",
116
+ children: 'Pay link'
117
+ }),
118
+ /*#__PURE__*/ _jsx(Typography, {
119
+ variant: "body2",
120
+ color: "text.secondary",
121
+ children: unpaid ? 'Send this link to the customer. It opens the quote on your site, where they can pay it.' : 'The link opens the paid quote and the customer’s order.'
122
+ }),
123
+ edited && unpaid ? /*#__PURE__*/ _jsx(Typography, {
124
+ variant: "body2",
125
+ color: "text.secondary",
126
+ children: 'Save your changes first: the link opens the quote as it was last saved.'
127
+ }) : null
128
+ ]
129
+ }),
130
+ url ? /*#__PURE__*/ _jsx(TextField, {
131
+ label: "Pay link",
132
+ value: url,
133
+ size: "small",
134
+ fullWidth: true,
135
+ slotProps: {
136
+ htmlInput: {
137
+ readOnly: true
138
+ },
139
+ inputLabel: {
140
+ shrink: true
141
+ }
142
+ },
143
+ onFocus: (event)=>event.target.select()
144
+ }) : null,
145
+ /*#__PURE__*/ _jsxs(Stack, {
146
+ direction: "row",
147
+ spacing: 1,
148
+ sx: {
149
+ flexWrap: 'wrap',
150
+ rowGap: 1
151
+ },
152
+ children: [
153
+ /*#__PURE__*/ _jsx(BlockedControl, {
154
+ blocked: !canSend,
155
+ reason: SEND_REFUSAL,
156
+ children: /*#__PURE__*/ _jsx(Button, {
157
+ variant: "outlined",
158
+ size: "small",
159
+ disabled: busy,
160
+ onClick: ()=>void copyLink(),
161
+ children: 'Copy pay link'
162
+ })
163
+ }),
164
+ unpaid ? /*#__PURE__*/ _jsx(BlockedControl, {
165
+ blocked: !canSend,
166
+ reason: SEND_REFUSAL,
167
+ children: /*#__PURE__*/ _jsx(Button, {
168
+ size: "small",
169
+ disabled: busy,
170
+ onClick: ()=>setConfirmingReplace(true),
171
+ children: 'Replace link'
172
+ })
173
+ }) : null
174
+ ]
175
+ }),
176
+ /*#__PURE__*/ _jsxs(Dialog, {
177
+ open: confirmingReplace,
178
+ onClose: ()=>setConfirmingReplace(false),
179
+ maxWidth: "xs",
180
+ fullWidth: true,
181
+ children: [
182
+ /*#__PURE__*/ _jsx(DialogTitle, {
183
+ children: 'Replace the pay link?'
184
+ }),
185
+ /*#__PURE__*/ _jsx(DialogContent, {
186
+ children: /*#__PURE__*/ _jsx(DialogContentText, {
187
+ children: 'The link you sent before will stop working: it will tell the customer the quote was updated, ' + 'and show nothing of it. Send them the new link.'
188
+ })
189
+ }),
190
+ /*#__PURE__*/ _jsxs(DialogActions, {
191
+ children: [
192
+ /*#__PURE__*/ _jsx(Button, {
193
+ onClick: ()=>setConfirmingReplace(false),
194
+ disabled: busy,
195
+ children: 'Cancel'
196
+ }),
197
+ /*#__PURE__*/ _jsx(Button, {
198
+ variant: "contained",
199
+ disabled: busy,
200
+ onClick: ()=>void replaceLink(),
201
+ children: 'Replace link'
202
+ })
203
+ ]
204
+ })
205
+ ]
206
+ })
207
+ ]
208
+ });
209
+ }
210
+ QuotePayLinkSection.displayName = 'QuotePayLinkSection';
211
+ export default QuotePayLinkSection;
212
+
213
+ //# sourceMappingURL=quote-pay-link.component.js.map
@@ -0,0 +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, useState } from 'react'\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'>\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 */\nexport function QuotePayLinkSection(props: QuotePayLinkSectionProps) {\n const { hostId, quoteId, quote, canSend, edited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [url, setUrl] = useState('')\n const [busy, setBusy] = useState(false)\n const [confirmingReplace, setConfirmingReplace] = useState(false)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\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 setUrl(String(payload.url))\n return String(payload.url)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\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 {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","useState","SEND_REFUSAL","QuotePayLinkSection","props","hostId","quoteId","quote","canSend","edited","data","user","enqueueSnackbar","url","setUrl","busy","setBusy","confirmingReplace","setConfirmingReplace","unpaid","isUnpaidQuote","ask","action","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","variant","allowDuplicate","String","copy","link","done","navigator","clipboard","writeText","persist","copyLink","replaceLink","spacing","color","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,QAAQ,QAAQ,QAAO;AAE7C,MAAMC,eAAehB,8BAA8B;AAYnD;;;;;;CAMC,GACD,OAAO,SAASiB,oBAAoBC,KAA+B;IACjE,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IACpD,MAAM,EAAEM,MAAMC,IAAI,EAAE,GAAGrB;IACvB,MAAM,EAAEsB,eAAe,EAAE,GAAGxB;IAC5B,MAAM,CAACyB,KAA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d,KAACF;kCACC,cAAA,KAACC;sCACE,kGACC;;;kCAGN,MAACF;;0CACC,KAACF;gCAAO6E,SAAS,IAAMlD,qBAAqB;gCAAQiD,UAAUpD;0CAC3D;;0CAEH,KAACxB;gCAAO2C,SAAQ;gCAAYiC,UAAUpD;gCAAMqD,SAAS,IAAM,KAAKvB;0CAC7D;;;;;;;;AAMb;AACA1C,oBAAoBqE,WAAW,GAAG;AAElC,eAAerE,oBAAmB"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as CommerceModel from '../../model';
18
+ export interface QuoteProofsSectionProps {
19
+ hostId: string;
20
+ quoteId: string;
21
+ quote: CommerceModel.HostOrder;
22
+ /** Holds "Create and edit quotes" (`commerce.quotes`). */
23
+ canEdit: boolean;
24
+ /** A change here moved the quote's edit stamp; the editor saves against the new one. */
25
+ onEdited: (updatedAtMs: number) => void;
26
+ }
27
+ /**
28
+ * A quote's proofs and revisions (AGL-4096), in its editor: the current
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.
32
+ */
33
+ export declare function QuoteProofsSection(props: QuoteProofsSectionProps): import("react").JSX.Element;
34
+ export declare namespace QuoteProofsSection {
35
+ var displayName: string;
36
+ }
37
+ export default QuoteProofsSection;