@aglyn/plugins-commerce 1.33.1 → 1.34.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 (104) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/cart.js +3 -1
  3. package/src/lib/components/cart.js.map +1 -1
  4. package/src/lib/components/console/catalog-organization-card.component.js +82 -69
  5. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
  6. package/src/lib/components/console/discounts-card.component.js +46 -25
  7. package/src/lib/components/console/discounts-card.component.js.map +1 -1
  8. package/src/lib/components/console/gift-cards-card.component.js +81 -55
  9. package/src/lib/components/console/gift-cards-card.component.js.map +1 -1
  10. package/src/lib/components/console/host-coupons-card.component.js +36 -25
  11. package/src/lib/components/console/host-coupons-card.component.js.map +1 -1
  12. package/src/lib/components/console/locations-card.component.js +53 -32
  13. package/src/lib/components/console/locations-card.component.js.map +1 -1
  14. package/src/lib/components/console/member-posts-card.component.js +35 -32
  15. package/src/lib/components/console/member-posts-card.component.js.map +1 -1
  16. package/src/lib/components/console/new-store-tax-question.component.d.ts +17 -0
  17. package/src/lib/components/console/new-store-tax-question.component.js +197 -0
  18. package/src/lib/components/console/new-store-tax-question.component.js.map +1 -0
  19. package/src/lib/components/console/payments-settings-card.component.js +132 -5
  20. package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
  21. package/src/lib/components/console/pos/pos-api.d.ts +6 -0
  22. package/src/lib/components/console/pos/pos-api.js.map +1 -1
  23. package/src/lib/components/console/pos/pos-tax-notice.component.d.ts +21 -0
  24. package/src/lib/components/console/pos/pos-tax-notice.component.js +59 -0
  25. package/src/lib/components/console/pos/pos-tax-notice.component.js.map +1 -0
  26. package/src/lib/components/console/pos-page.component.js +65 -17
  27. package/src/lib/components/console/pos-page.component.js.map +1 -1
  28. package/src/lib/components/console/registers-card.component.js +21 -13
  29. package/src/lib/components/console/registers-card.component.js.map +1 -1
  30. package/src/lib/components/console/reviews-moderation-card.component.js +108 -68
  31. package/src/lib/components/console/reviews-moderation-card.component.js.map +1 -1
  32. package/src/lib/components/console/site-member-purchases.component.js +5 -3
  33. package/src/lib/components/console/site-member-purchases.component.js.map +1 -1
  34. package/src/lib/components/console/subscription-detail-dialog.component.d.ts +2 -0
  35. package/src/lib/components/console/subscription-detail-dialog.component.js +1 -1
  36. package/src/lib/components/console/subscription-detail-dialog.component.js.map +1 -1
  37. package/src/lib/components/console/subscriptions-card.component.js +13 -5
  38. package/src/lib/components/console/subscriptions-card.component.js.map +1 -1
  39. package/src/lib/components/console/suppliers-card.component.js +47 -40
  40. package/src/lib/components/console/suppliers-card.component.js.map +1 -1
  41. package/src/lib/components/product-choice-cards.js +2 -1
  42. package/src/lib/components/product-choice-cards.js.map +1 -1
  43. package/src/lib/components/product-detail.js +9 -4
  44. package/src/lib/components/product-detail.js.map +1 -1
  45. package/src/lib/components/product-grid.js +3 -1
  46. package/src/lib/components/product-grid.js.map +1 -1
  47. package/src/lib/components/related-products.js +2 -1
  48. package/src/lib/components/related-products.js.map +1 -1
  49. package/src/lib/components/store-image-sizing.d.ts +46 -0
  50. package/src/lib/components/store-image-sizing.js +53 -0
  51. package/src/lib/components/store-image-sizing.js.map +1 -0
  52. package/src/lib/components/wishlist.js +2 -1
  53. package/src/lib/components/wishlist.js.map +1 -1
  54. package/src/lib/declarations.console-server.js +10 -0
  55. package/src/lib/declarations.console-server.js.map +1 -1
  56. package/src/lib/model/commerce-tax-step.d.ts +123 -0
  57. package/src/lib/model/commerce-tax-step.js +185 -0
  58. package/src/lib/model/commerce-tax-step.js.map +1 -0
  59. package/src/lib/model/index.d.ts +1 -0
  60. package/src/lib/model/index.js +1 -0
  61. package/src/lib/model/index.js.map +1 -1
  62. package/src/lib/model/payments-setup-status.d.ts +40 -0
  63. package/src/lib/model/payments-setup-status.js +63 -0
  64. package/src/lib/model/payments-setup-status.js.map +1 -1
  65. package/src/lib/model/subscription-view.d.ts +19 -0
  66. package/src/lib/model/subscription-view.js +16 -0
  67. package/src/lib/model/subscription-view.js.map +1 -1
  68. package/src/lib/model/tap-to-pay-launch.d.ts +103 -0
  69. package/src/lib/model/tap-to-pay-launch.js +148 -0
  70. package/src/lib/model/tap-to-pay-launch.js.map +1 -0
  71. package/src/lib/plugin.js +12 -0
  72. package/src/lib/plugin.js.map +1 -1
  73. package/src/lib/server/billing-webhook.js +140 -116
  74. package/src/lib/server/billing-webhook.js.map +1 -1
  75. package/src/lib/server/checkout.js +15 -4
  76. package/src/lib/server/checkout.js.map +1 -1
  77. package/src/lib/server/connect-return.d.ts +83 -0
  78. package/src/lib/server/connect-return.js +105 -0
  79. package/src/lib/server/connect-return.js.map +1 -0
  80. package/src/lib/server/connect.d.ts +18 -0
  81. package/src/lib/server/connect.js +60 -6
  82. package/src/lib/server/connect.js.map +1 -1
  83. package/src/lib/server/new-store-tax.d.ts +10 -0
  84. package/src/lib/server/new-store-tax.js +43 -0
  85. package/src/lib/server/new-store-tax.js.map +1 -0
  86. package/src/lib/server/pos-payment.js +3 -2
  87. package/src/lib/server/pos-payment.js.map +1 -1
  88. package/src/lib/server/pos-tax-step.d.ts +43 -0
  89. package/src/lib/server/pos-tax-step.js +55 -0
  90. package/src/lib/server/pos-tax-step.js.map +1 -0
  91. package/src/lib/server/pos-terminal-connection-token.d.ts +10 -1
  92. package/src/lib/server/pos-terminal-connection-token.js +18 -7
  93. package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
  94. package/src/lib/server/pos-terminal.d.ts +9 -0
  95. package/src/lib/server/pos-terminal.js +17 -1
  96. package/src/lib/server/pos-terminal.js.map +1 -1
  97. package/src/lib/server/tap-to-pay-launch-admin.d.ts +18 -0
  98. package/src/lib/server/tap-to-pay-launch-admin.js +204 -0
  99. package/src/lib/server/tap-to-pay-launch-admin.js.map +1 -0
  100. package/src/lib/server/tap-to-pay-launch.d.ts +114 -0
  101. package/src/lib/server/tap-to-pay-launch.js +408 -0
  102. package/src/lib/server/tap-to-pay-launch.js.map +1 -0
  103. package/src/lib/server.js +15 -0
  104. package/src/lib/server.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/host-coupons-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { collection, doc, limit, query, setDoc, updateDoc } from 'firebase/firestore'\nimport { useCallback, useState } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport { usePagedCollection } from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport TransferHeaderActions from '../../transfer/transfer-header-actions.component'\nimport { COMMERCE_COUPONS_TRANSFER } from '../../transfer/transfer-keys'\n\nexport interface HostCouponsCardProps {\n hostId: string\n}\n\n/**\n * Coupon codes (AGL-96), extracted from the retired Commerce Starter\n * card when the products hub landed (AGL-279). Percent-off codes at\n * `hosts/{hostId}/coupons/{CODE}`; the discounts engine (AGL-305)\n * supersedes these.\n */\nexport function HostCouponsCard(props: HostCouponsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n /*\n * A growing window rather than a hard hundred, which a shop with more\n * codes than that could not see past.\n *\n * No `orderBy`: a coupon's document ID is its CODE, and document-ID order\n * is what Firestore returns by default — so the window is already the\n * alphabetical front of the list, which is what the sort below wants. The\n * sort is kept because it makes that dependency explicit rather than\n * relying on the default holding.\n */\n const {\n rows: couponDocs,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n } = usePagedCollection<any>(\n (pageLimit) =>\n query(collection(firestore, 'hosts', hostId, 'coupons'), limit(pageLimit)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const coupons = [...couponDocs].sort((a: any, b: any) =>\n String(a.$id).localeCompare(String(b.$id)),\n )\n const [couponDraft, setCouponDraft] = useState<{\n code: string\n percentOff: string\n maxRedemptions: string\n /** `YYYY-MM-DD` from a native date input, or '' for no expiry. */\n expiresOn: string\n } | null>(null)\n\n const handleCouponSave = useCallback(async () => {\n if (!couponDraft) return\n const code = couponDraft.code\n .trim()\n .toUpperCase()\n .replace(/[^A-Z0-9_-]/g, '')\n .slice(0, 40)\n const percentOff = Math.round(Number(couponDraft.percentOff))\n if (!code || !(percentOff > 0 && percentOff <= 100)) return\n // An unparseable value is dropped rather than written: a NaN here would\n // be a coupon that never expires or one that is born dead, depending on\n // how the server coerced it, and neither is what anyone typed.\n const expiresOn = couponDraft.expiresOn.trim()\n const parsedExpiry = expiresOn\n ? Date.parse(`${expiresOn}T23:59:59.999`)\n : NaN\n const expiresAtMs = Number.isFinite(parsedExpiry) ? parsedExpiry : null\n await setDoc(doc(firestore, 'hosts', hostId, 'coupons', code), {\n percentOff,\n enabled: true,\n redemptions: 0,\n ...(couponDraft.maxRedemptions.trim()\n ? {\n maxRedemptions: Math.max(\n 1,\n Math.round(Number(couponDraft.maxRedemptions)),\n ),\n }\n : {}),\n // THE FIELD THE CHECKOUTS ALREADY GATE ON.\n //\n // `checkout.ts` and `cart-checkout.ts` both refuse a coupon whose\n // `expiresAtMs` has passed, and nothing wrote it — so the gate read as\n // enforcement while every coupon ever created was immortal. A launch\n // code stays redeemable forever, which is a discount the merchant\n // believed they had withdrawn.\n //\n // The END of the chosen day, in the merchant's own timezone: \"expires\n // September 5th\" has to mean the 5th still works. The comparison on the\n // server is absolute epoch, so the local end-of-day is what carries that\n // meaning across.\n ...(expiresAtMs != null ? { expiresAtMs } : {}),\n createdAt: Timestamp.now(),\n })\n setCouponDraft(null)\n enqueueSnackbar(`Coupon ${code} created`, {\n variant: 'success',\n persist: false,\n })\n }, [couponDraft, firestore, hostId, enqueueSnackbar])\n\n const handleCouponToggle = useCallback(\n (coupon: any) => () =>\n updateDoc(doc(firestore, 'hosts', hostId, 'coupons', coupon.$id), {\n enabled: coupon.enabled === false,\n }),\n [firestore, hostId],\n )\n\n return (\n <CardDisplay\n header={'Coupons'}\n HeaderProps={{\n action: <TransferHeaderActions resource={COMMERCE_COUPONS_TRANSFER} hostId={hostId} />,\n }}\n help={pluginDocsHelp('discountsAndCoupons', { anchor: '#coupons' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {coupons.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Percent-off codes buyers can enter at checkout.'}\n </Typography>\n ) : (\n coupons.map((coupon: any) => (\n <Stack\n key={coupon.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {`${coupon.$id} · ${coupon.percentOff}% off · ` +\n // Held slots are named separately (AGL-2453) — see the\n // discounts card for why the used figure alone now misleads.\n CommerceModel.promotionUsageLabel(coupon, Date.now()) +\n // An expiry nobody can see is one the merchant cannot act\n // on, and an EXPIRED coupon still listed as live is the\n // question this card exists to answer.\n (coupon.expiresAtMs != null\n ? Number(coupon.expiresAtMs) < Date.now()\n ? ' · expired'\n : ` · expires ${new Date(\n Number(coupon.expiresAtMs),\n ).toLocaleDateString()}`\n : '') +\n (coupon.enabled === false ? ' · disabled' : '')}\n </Typography>\n <Button size=\"small\" onClick={handleCouponToggle(coupon)}>\n {coupon.enabled === false ? 'Enable' : 'Disable'}\n </Button>\n </Stack>\n ))\n )}\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={coupons.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n setCouponDraft({\n code: '',\n percentOff: '',\n maxRedemptions: '',\n expiresOn: '',\n })\n }\n >\n {'Add coupon'}\n </Button>\n </Stack>\n <Dialog\n open={Boolean(couponDraft)}\n onClose={() => setCouponDraft(null)}\n maxWidth=\"xs\"\n fullWidth\n >\n <DialogTitle>{'New coupon'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Code\"\n value={couponDraft?.code ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, code: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n helperText=\"Letters/numbers; stored uppercase, e.g. LAUNCH20\"\n />\n <TextField\n label=\"Percent off\"\n type=\"number\"\n value={couponDraft?.percentOff ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, percentOff: event.target.value } : prev,\n )\n }\n size=\"small\"\n />\n <TextField\n label=\"Max redemptions\"\n type=\"number\"\n placeholder=\"Blank = unlimited\"\n value={couponDraft?.maxRedemptions ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, maxRedemptions: event.target.value } : prev,\n )\n }\n size=\"small\"\n />\n <TextField\n label=\"Expires\"\n type=\"date\"\n value={couponDraft?.expiresOn ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, expiresOn: event.target.value } : prev,\n )\n }\n size=\"small\"\n slotProps={{ inputLabel: { shrink: true } }}\n helperText=\"Blank = never expires. The code works through this day.\"\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setCouponDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={\n !couponDraft?.code.trim() ||\n !(Number(couponDraft?.percentOff) > 0) ||\n Number(couponDraft?.percentOff) > 100\n }\n onClick={handleCouponSave}\n >\n {'Create'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n )\n}\nHostCouponsCard.displayName = 'HostCouponsCard'\n\nexport default HostCouponsCard\n"],"names":["CommerceModel","CardDisplay","ListPagination","useSnackbar","Timestamp","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","TextField","Typography","collection","doc","limit","query","setDoc","updateDoc","useCallback","useState","useFirestore","usePagedCollection","pluginDocsHelp","TransferHeaderActions","COMMERCE_COUPONS_TRANSFER","HostCouponsCard","props","hostId","firestore","enqueueSnackbar","rows","couponDocs","hasMore","page","setPage","pageSize","setPageSize","pageLimit","idField","coupons","sort","a","b","String","$id","localeCompare","couponDraft","setCouponDraft","handleCouponSave","code","trim","toUpperCase","replace","slice","percentOff","Math","round","Number","expiresOn","parsedExpiry","Date","parse","NaN","expiresAtMs","isFinite","enabled","redemptions","maxRedemptions","max","createdAt","now","variant","persist","handleCouponToggle","coupon","header","HeaderProps","action","resource","help","anchor","contentGutterX","contentGutterY","spacing","length","color","map","direction","sx","alignItems","flex","noWrap","promotionUsageLabel","toLocaleDateString","size","onClick","rowCount","onPageChange","onPageSizeChange","alignSelf","open","Boolean","onClose","maxWidth","fullWidth","display","flexDirection","gap","label","value","onChange","event","prev","target","autoFocus","mt","helperText","type","placeholder","slotProps","inputLabel","shrink","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,SAAS,QAAQ,+BAA8B;AACxD,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC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5E,+BAAAA,YAAaG,IAAI,CAACC,IAAI,OACvB,CAAEO,CAAAA,OAAOX,+BAAAA,YAAaQ,UAAU,IAAI,CAAA,KACpCG,OAAOX,+BAAAA,YAAaQ,UAAU,IAAI;gCAEpCyC,SAAS/C;0CAER;;;;;;;;AAMb;AACAvB,gBAAgBkG,WAAW,GAAG;AAE9B,eAAelG,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/host-coupons-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { OpenableListRow } from '@aglyn/shared-ui-jsx/components/openable-list-row.component'\nimport { mdiToggleSwitchOffOutline, mdiToggleSwitchOutline } from '@aglyn/shared-data-mdi'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { collection, doc, limit, query, setDoc, updateDoc } from 'firebase/firestore'\nimport { useCallback, useState } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport { usePagedCollection } from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport TransferHeaderActions from '../../transfer/transfer-header-actions.component'\nimport { COMMERCE_COUPONS_TRANSFER } from '../../transfer/transfer-keys'\n\nexport interface HostCouponsCardProps {\n hostId: string\n}\n\n/**\n * Coupon codes (AGL-96), extracted from the retired Commerce Starter\n * card when the products hub landed (AGL-279). Percent-off codes at\n * `hosts/{hostId}/coupons/{CODE}`; the discounts engine (AGL-305)\n * supersedes these.\n */\nexport function HostCouponsCard(props: HostCouponsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n /*\n * A growing window rather than a hard hundred, which a shop with more\n * codes than that could not see past.\n *\n * No `orderBy`: a coupon's document ID is its CODE, and document-ID order\n * is what Firestore returns by default — so the window is already the\n * alphabetical front of the list, which is what the sort below wants. The\n * sort is kept because it makes that dependency explicit rather than\n * relying on the default holding.\n */\n const {\n rows: couponDocs,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n } = usePagedCollection<any>(\n (pageLimit) =>\n query(collection(firestore, 'hosts', hostId, 'coupons'), limit(pageLimit)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const coupons = [...couponDocs].sort((a: any, b: any) =>\n String(a.$id).localeCompare(String(b.$id)),\n )\n const [couponDraft, setCouponDraft] = useState<{\n code: string\n percentOff: string\n maxRedemptions: string\n /** `YYYY-MM-DD` from a native date input, or '' for no expiry. */\n expiresOn: string\n } | null>(null)\n\n const handleCouponSave = useCallback(async () => {\n if (!couponDraft) return\n const code = couponDraft.code\n .trim()\n .toUpperCase()\n .replace(/[^A-Z0-9_-]/g, '')\n .slice(0, 40)\n const percentOff = Math.round(Number(couponDraft.percentOff))\n if (!code || !(percentOff > 0 && percentOff <= 100)) return\n // An unparseable value is dropped rather than written: a NaN here would\n // be a coupon that never expires or one that is born dead, depending on\n // how the server coerced it, and neither is what anyone typed.\n const expiresOn = couponDraft.expiresOn.trim()\n const parsedExpiry = expiresOn\n ? Date.parse(`${expiresOn}T23:59:59.999`)\n : NaN\n const expiresAtMs = Number.isFinite(parsedExpiry) ? parsedExpiry : null\n await setDoc(doc(firestore, 'hosts', hostId, 'coupons', code), {\n percentOff,\n enabled: true,\n redemptions: 0,\n ...(couponDraft.maxRedemptions.trim()\n ? {\n maxRedemptions: Math.max(\n 1,\n Math.round(Number(couponDraft.maxRedemptions)),\n ),\n }\n : {}),\n // THE FIELD THE CHECKOUTS ALREADY GATE ON.\n //\n // `checkout.ts` and `cart-checkout.ts` both refuse a coupon whose\n // `expiresAtMs` has passed, and nothing wrote it — so the gate read as\n // enforcement while every coupon ever created was immortal. A launch\n // code stays redeemable forever, which is a discount the merchant\n // believed they had withdrawn.\n //\n // The END of the chosen day, in the merchant's own timezone: \"expires\n // September 5th\" has to mean the 5th still works. The comparison on the\n // server is absolute epoch, so the local end-of-day is what carries that\n // meaning across.\n ...(expiresAtMs != null ? { expiresAtMs } : {}),\n createdAt: Timestamp.now(),\n })\n setCouponDraft(null)\n enqueueSnackbar(`Coupon ${code} created`, {\n variant: 'success',\n persist: false,\n })\n }, [couponDraft, firestore, hostId, enqueueSnackbar])\n\n const handleCouponToggle = useCallback(\n (coupon: any) => () =>\n updateDoc(doc(firestore, 'hosts', hostId, 'coupons', coupon.$id), {\n enabled: coupon.enabled === false,\n }),\n [firestore, hostId],\n )\n\n return (\n <CardDisplay\n header={'Coupons'}\n HeaderProps={{\n action: <TransferHeaderActions resource={COMMERCE_COUPONS_TRANSFER} hostId={hostId} />,\n }}\n help={pluginDocsHelp('discountsAndCoupons', { anchor: '#coupons' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {coupons.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Percent-off codes buyers can enter at checkout.'}\n </Typography>\n ) : (\n coupons.map((coupon: any) => (\n // A coupon has no editor, so the row opens nothing and its ⋮\n // menu holds the one action it has.\n <OpenableListRow\n key={coupon.$id}\n label={coupon.$id}\n items={[\n coupon.enabled === false\n ? {\n key: 'enable',\n label: 'Enable',\n icon: { path: mdiToggleSwitchOutline.path },\n onClick: () => void handleCouponToggle(coupon)(),\n }\n : {\n key: 'disable',\n label: 'Disable',\n icon: { path: mdiToggleSwitchOffOutline.path },\n onClick: () => void handleCouponToggle(coupon)(),\n },\n ]}\n >\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 0 }} noWrap>\n {`${coupon.$id} · ${coupon.percentOff}% off · ` +\n // Held slots are named separately (AGL-2453) — see the\n // discounts card for why the used figure alone now misleads.\n CommerceModel.promotionUsageLabel(coupon, Date.now()) +\n // An expiry nobody can see is one the merchant cannot act\n // on, and an EXPIRED coupon still listed as live is the\n // question this card exists to answer.\n (coupon.expiresAtMs != null\n ? Number(coupon.expiresAtMs) < Date.now()\n ? ' · expired'\n : ` · expires ${new Date(\n Number(coupon.expiresAtMs),\n ).toLocaleDateString()}`\n : '') +\n (coupon.enabled === false ? ' · disabled' : '')}\n </Typography>\n </OpenableListRow>\n ))\n )}\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={coupons.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n setCouponDraft({\n code: '',\n percentOff: '',\n maxRedemptions: '',\n expiresOn: '',\n })\n }\n >\n {'Add coupon'}\n </Button>\n </Stack>\n <Dialog\n open={Boolean(couponDraft)}\n onClose={() => setCouponDraft(null)}\n maxWidth=\"xs\"\n fullWidth\n >\n <DialogTitle>{'New coupon'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Code\"\n value={couponDraft?.code ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, code: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n helperText=\"Letters/numbers; stored uppercase, e.g. LAUNCH20\"\n />\n <TextField\n label=\"Percent off\"\n type=\"number\"\n value={couponDraft?.percentOff ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, percentOff: event.target.value } : prev,\n )\n }\n size=\"small\"\n />\n <TextField\n label=\"Max redemptions\"\n type=\"number\"\n placeholder=\"Blank = unlimited\"\n value={couponDraft?.maxRedemptions ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, maxRedemptions: event.target.value } : prev,\n )\n }\n size=\"small\"\n />\n <TextField\n label=\"Expires\"\n type=\"date\"\n value={couponDraft?.expiresOn ?? ''}\n onChange={(event) =>\n setCouponDraft((prev) =>\n prev ? { ...prev, expiresOn: event.target.value } : prev,\n )\n }\n size=\"small\"\n slotProps={{ inputLabel: { shrink: true } }}\n helperText=\"Blank = never expires. The code works through this day.\"\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setCouponDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={\n !couponDraft?.code.trim() ||\n !(Number(couponDraft?.percentOff) > 0) ||\n Number(couponDraft?.percentOff) > 100\n }\n onClick={handleCouponSave}\n >\n {'Create'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n )\n}\nHostCouponsCard.displayName = 'HostCouponsCard'\n\nexport default HostCouponsCard\n"],"names":["CommerceModel","CardDisplay","ListPagination","OpenableListRow","mdiToggleSwitchOffOutline","mdiToggleSwitchOutline","useSnackbar","Timestamp","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","TextField","Typography","collection","doc","limit","query","setDoc","updateDoc","useCallback","useState","useFirestore","usePagedCollection","pluginDocsHelp","TransferHeaderActions","COMMERCE_COUPONS_TRANSFER","HostCouponsCard","props","hostId","firestore","enqueueSnackbar","rows","couponDocs","hasMore","page","setPage","pageSize","setPageSize","pageLimit","idField","coupons","sort","a","b","String","$id","localeCompare","couponDraft","setCouponDraft","handleCouponSave","code","trim","toUpperCase","replace","slice","percentOff","Math","round","Number","expiresOn","parsedExpiry","Date","parse","NaN","expiresAtMs","isFinite","enabled","redemptions","maxRedemptions","max","createdAt","now","variant","persist","handleCouponToggle","coupon","header","HeaderProps","action","resource","help","anchor","contentGutterX","contentGutterY","spacing","length","color","map","label","items","key","icon","path","onClick","sx","flex","minWidth","noWrap","promotionUsageLabel","toLocaleDateString","rowCount","onPageChange","onPageSizeChange","size","alignSelf","open","Boolean","onClose","maxWidth","fullWidth","display","flexDirection","gap","value","onChange","event","prev","target","autoFocus","mt","helperText","type","placeholder","slotProps","inputLabel","shrink","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,eAAe,QAAQ,8DAA6D;AAC7F,SAASC,yBAAyB,EAAEC,sBAAsB,QAAQ,yBAAwB;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,SAAS,QAAQ,+BAA8B;AACxD,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,UAAU,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,QAAQ,qBAAoB;AACrF,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAC7C,SAASC,YAAY,QAAQ,iCAAgC;AAC7D,SAASC,kBAAkB,QAAQ,iCAAgC;AACnE,SAASC,cAAc,QAAQ,eAAc;AAC7C,OAAOC,2BAA2B,sDAAkD;AACpF,SAASC,yBAAyB,QAAQ,kCAA8B;AAMxE;;;;;CAKC,GACD,OAAO,SAASC,gBAAgBC,KAA2B;;IACzD,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,MAAME,YAAYR;IAClB,MAAM,EAAES,eAAe,EAAE,GAAG3B;IAC5B;;;;;;;;;GASC,GACD,MAAM,EACJ4B,MAAMC,UAAU,EAChBC,OAAO,EACPC,IAAI,EACJC,OAAO,EACPC,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AA,YAAaQ,UAAU,oBAAI;gCAClC2D,UAAU,CAACC,QACTnE,eAAe,CAACoE,OACdA,OAAO,aAAKA;4CAAM7D,YAAY4D,MAAME,MAAM,CAACJ,KAAK;6CAAKG;gCAGzDb,MAAK;;0CAEP,KAAC5F;gCACC6E,OAAM;gCACNiC,MAAK;gCACLC,aAAY;gCACZT,KAAK,WAAElE,+BAAAA,YAAaqB,cAAc,oBAAI;gCACtC8C,UAAU,CAACC,QACTnE,eAAe,CAACoE,OACdA,OAAO,aAAKA;4CAAMhD,gBAAgB+C,MAAME,MAAM,CAACJ,KAAK;6CAAKG;gCAG7Db,MAAK;;0CAEP,KAAC5F;gCACC6E,OAAM;gCACNiC,MAAK;gCACLR,KAAK,WAAElE,+BAAAA,YAAaY,SAAS,oBAAI;gCACjCuD,UAAU,CAACC,QACTnE,eAAe,CAACoE,OACdA,OAAO,aAAKA;4CAAMzD,WAAWwD,MAAME,MAAM,CAACJ,KAAK;6CAAKG;gCAGxDb,MAAK;gCACLoB,WAAW;oCAAEC,YAAY;wCAAEC,QAAQ;oCAAK;gCAAE;gCAC1CL,YAAW;;;;kCAGf,MAACjH;;0CACC,KAACF;gCAAOwF,SAAS,IAAM7C,eAAe;0CAAQ;;0CAC9C,KAAC3C;gCACCmE,SAAQ;gCACRc,OAAM;gCACNwC,UACE,EAAC/E,+BAAAA,YAAaG,IAAI,CAACC,IAAI,OACvB,CAAEO,CAAAA,OAAOX,+BAAAA,YAAaQ,UAAU,IAAI,CAAA,KACpCG,OAAOX,+BAAAA,YAAaQ,UAAU,IAAI;gCAEpCsC,SAAS5C;0CAER;;;;;;;;AAMb;AACAvB,gBAAgBqG,WAAW,GAAG;AAE9B,eAAerG,gBAAe"}
@@ -20,6 +20,8 @@ import * as Aglyn from "@aglyn/aglyn";
20
20
  import * as CommerceModel from "../../model/index.js";
21
21
  import { CardDisplay, useConfirmationContext } from "@aglyn/shared-ui-jsx";
22
22
  import QuotaReadoutComponent from "@aglyn/shared-ui-jsx/components/quota-readout.component";
23
+ import { OpenableListRow } from "@aglyn/shared-ui-jsx/components/openable-list-row.component";
24
+ import { mdiDeleteOutline, mdiMapMarkerOutline, mdiStarOutline, mdiStorefrontOutline } from "@aglyn/shared-data-mdi";
23
25
  import { OpeningHoursPicker } from "@aglyn/shared-ui-jsx/components/weekly-hours-picker.component";
24
26
  import { useSnackbar } from "@aglyn/shared-ui-snackstack";
25
27
  import { Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, MenuItem, Stack, Switch, TextField, Typography } from "@mui/material";
@@ -256,6 +258,49 @@ import { pluginDocsHelp } from "@aglyn/aglyn";
256
258
  pickupDraft,
257
259
  pickupFor
258
260
  ]);
261
+ /**
262
+ * Every action a location row offers, in its ⋮ menu. A row click opens
263
+ * its address, the location's own details.
264
+ */ const locationRowActions = (location)=>{
265
+ var _location_postalAddress;
266
+ return [
267
+ {
268
+ key: 'address',
269
+ label: ((_location_postalAddress = location.postalAddress) == null ? void 0 : _location_postalAddress.line1) ? 'Edit address' : 'Add address',
270
+ icon: {
271
+ path: mdiMapMarkerOutline.path
272
+ },
273
+ onClick: openAddress(location)
274
+ },
275
+ {
276
+ key: 'pickup',
277
+ label: 'Pickup',
278
+ icon: {
279
+ path: mdiStorefrontOutline.path
280
+ },
281
+ onClick: openPickup(location)
282
+ },
283
+ {
284
+ key: 'default',
285
+ label: 'Make default',
286
+ icon: {
287
+ path: mdiStarOutline.path
288
+ },
289
+ disabled: Boolean(location.isDefault),
290
+ disabledReason: location.isDefault ? 'Already the default' : undefined,
291
+ onClick: ()=>void handleMakeDefault(location)()
292
+ },
293
+ {
294
+ key: 'remove',
295
+ label: 'Remove',
296
+ icon: {
297
+ path: mdiDeleteOutline.path
298
+ },
299
+ destructive: true,
300
+ onClick: ()=>void handleDelete(location)()
301
+ }
302
+ ];
303
+ };
259
304
  return /*#__PURE__*/ _jsxs(CardDisplay, {
260
305
  header: 'Inventory locations',
261
306
  help: pluginDocsHelp('commerce', {
@@ -271,19 +316,16 @@ import { pluginDocsHelp } from "@aglyn/aglyn";
271
316
  variant: "body2",
272
317
  color: "text.secondary",
273
318
  children: 'Track stock per warehouse or storefront. Without locations, ' + 'every variant has a single stock count.'
274
- }) : locations.map((location)=>{
275
- var _location_postalAddress;
276
- return /*#__PURE__*/ _jsxs(Stack, {
277
- direction: "row",
278
- spacing: 1,
279
- sx: {
280
- alignItems: 'center'
281
- },
319
+ }) : locations.map((location)=>/*#__PURE__*/ _jsxs(OpenableListRow, {
320
+ label: location.name,
321
+ onOpen: openAddress(location),
322
+ items: locationRowActions(location),
282
323
  children: [
283
324
  /*#__PURE__*/ _jsx(Typography, {
284
325
  variant: "body2",
285
326
  sx: {
286
- flex: 1
327
+ flex: 1,
328
+ minWidth: 0
287
329
  },
288
330
  noWrap: true,
289
331
  children: location.name
@@ -294,34 +336,13 @@ import { pluginDocsHelp } from "@aglyn/aglyn";
294
336
  color: "primary",
295
337
  variant: "outlined"
296
338
  }) : null,
297
- /*#__PURE__*/ _jsx(Button, {
298
- size: "small",
299
- onClick: openPickup(location),
300
- children: 'Pickup'
301
- }),
302
- /*#__PURE__*/ _jsx(Button, {
303
- size: "small",
304
- onClick: openAddress(location),
305
- children: ((_location_postalAddress = location.postalAddress) == null ? void 0 : _location_postalAddress.line1) ? 'Edit address' : 'Add address'
306
- }),
307
339
  location.isDefault ? /*#__PURE__*/ _jsx(Chip, {
308
340
  label: "Default",
309
341
  size: "small",
310
342
  variant: "outlined"
311
- }) : /*#__PURE__*/ _jsx(Button, {
312
- size: "small",
313
- onClick: handleMakeDefault(location),
314
- children: 'Make default'
315
- }),
316
- /*#__PURE__*/ _jsx(Button, {
317
- size: "small",
318
- color: "error",
319
- onClick: handleDelete(location),
320
- children: 'Remove'
321
- })
343
+ }) : null
322
344
  ]
323
- }, location.$id);
324
- }),
345
+ }, location.$id)),
325
346
  /*#__PURE__*/ _jsxs(Stack, {
326
347
  direction: "row",
327
348
  spacing: 1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/locations-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport * as CommerceModel from '../../model'\nimport { CardDisplay, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport QuotaReadoutComponent from '@aglyn/shared-ui-jsx/components/quota-readout.component'\nimport { OpeningHoursPicker } from '@aglyn/shared-ui-jsx/components/weekly-hours-picker.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { invalidOpeningHoursLines } from '@aglyn/aglyn/app-utils/local-business'\nimport {\n collection,\n deleteDoc,\n doc,\n getCountFromServer,\n limit,\n query,\n setDoc,\n updateDoc,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useState } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport { useFirestoreCollection } from '@aglyn/tenant-feature-instance'\nimport { useHostResourceApi } from '@aglyn/tenant-feature-instance'\nimport { useOrgPlan } from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\n\nexport interface LocationsCardProps {\n hostId: string\n}\n\n/**\n * Inventory locations (AGL-286): named stock buckets under\n * `hosts/{hostId}/locations`, capped by the plan's `inventoryLocations`\n * quota (AGL-278). Variant stock splits per location in the products\n * hub; POS registers sell from their location (AGL-312).\n */\nexport function LocationsCard(props: LocationsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n const createHostResource = useHostResourceApi()\n const { org, ready: planReady } = useOrgPlan(hostId)\n const { data: locationDocs } = useFirestoreCollection<any>(\n () => query(collection(firestore, 'hosts', hostId, 'locations'), limit(25)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const locations = [...(locationDocs ?? [])].sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n /**\n * The location HEAD-COUNT is a server aggregate, not the length of the\n * capped listener (AGL-1716, the AGL-1706 shape).\n *\n * The smallest margin of the eight, and real for exactly one plan: the\n * listener is `limit(25)` and `inventoryLocations` runs 1 / 1 / 2 / 4 / 6 /\n * 10 / 50, so only Agency's 50 sits above the window. An agency with more\n * than 25 stock buckets read its cap as satisfiable, and\n * `api/hosts/resources` — which counts the collection — refused the add.\n *\n * Re-read after an add AND a delete: locations are hard-deleted here, so\n * unlike the soft-deleting cards a removal really does free a slot on both\n * sides, and a one-shot that missed it would keep refusing.\n *\n * `locations.length === 0` below still decides the FIRST location's\n * `isDefault` flag off the loaded rows, which is the right question for it\n * — that one is about what this card can see, not about the site's total.\n */\n const [locationCountEpoch, setLocationCountEpoch] = useState(0)\n const [serverLocationCount, setServerLocationCount] = useState<number | null>(\n null,\n )\n useEffect(() => {\n let active = true\n void getCountFromServer(collection(firestore, 'hosts', hostId, 'locations'))\n .then((snapshot) => {\n if (active) setServerLocationCount(snapshot.data().count)\n })\n .catch(() => {\n // Falls back to the loaded rows — a LOWER bound and the prior\n // behaviour, never 0, which reads as \"no locations used\" on a site\n // that is over its band.\n })\n return () => {\n active = false\n }\n }, [firestore, hostId, locationCountEpoch])\n const locationCount = serverLocationCount ?? locations.length\n const quota = Aglyn.checkQuota(org, 'inventoryLocations', locationCount)\n const [name, setName] = useState('')\n\n const handleAdd = useCallback(async () => {\n if (!name.trim()) return\n // Held until the org doc lands (AGL-1064): an absent org resolves to\n // the free tier's `inventoryLocations: 1`, so a site that already has\n // its default location would be refused with an upgrade prompt it does\n // not need. The button is disabled too; this guards the race.\n if (!planReady) return\n if (!quota.allowed) {\n return void enqueueSnackbar(\n `Your plan includes ${quota.limit} locations — upgrade for more`,\n { variant: 'info', persist: false },\n )\n }\n try {\n // Creation rides the quota-enforcing resources API (AGL-473).\n await createHostResource({\n hostId,\n resource: 'location',\n data: {\n name: name.trim().slice(0, 80),\n ...(locations.length === 0 ? { isDefault: true } : {}),\n } satisfies CommerceModel.InventoryLocation,\n })\n setName('')\n setLocationCountEpoch((epoch) => epoch + 1)\n } catch (error: any) {\n enqueueSnackbar(error?.message ?? 'Could not add location', {\n variant: 'warning',\n persist: false,\n })\n }\n }, [\n name,\n planReady,\n quota,\n locations.length,\n hostId,\n createHostResource,\n enqueueSnackbar,\n ])\n\n const handleDelete = useCallback(\n (location: any) => async () => {\n const confirmed = await confirm({\n title: 'Remove this location?',\n description:\n `Stock bucketed under \"${location.name}\" folds back into the ` +\n 'flat totals; adjust counts afterward if needed.',\n confirmationText: 'Remove',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await deleteDoc(doc(firestore, 'hosts', hostId, 'locations', location.$id))\n // A HARD delete, so the slot really is freed on both sides — the\n // one-shot aggregate has to be told (AGL-1716).\n setLocationCountEpoch((epoch) => epoch + 1)\n },\n [confirm, firestore, hostId],\n )\n\n const handleMakeDefault = useCallback(\n (location: any) => async () => {\n for (const other of locations) {\n if (other.isDefault && other.$id !== location.$id) {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'locations', other.$id),\n { isDefault: false },\n { merge: true },\n )\n }\n }\n await setDoc(\n doc(firestore, 'hosts', hostId, 'locations', location.$id),\n { isDefault: true },\n { merge: true },\n )\n },\n [locations, firestore, hostId],\n )\n\n /*\n * A location's postal address (AGL-3612): where parcels can leave from,\n * for anything that ships. Optional, written beside the free-text name.\n */\n const [addressFor, setAddressFor] = useState<any | null>(null)\n const [addressDraft, setAddressDraft] = useState<CommerceModel.PostalAddress>({})\n const openAddress = useCallback(\n (location: any) => () => {\n setAddressFor(location)\n setAddressDraft(CommerceModel.normalizePostalAddress(location.postalAddress) ?? {})\n },\n [],\n )\n const handleSaveAddress = useCallback(async () => {\n if (!addressFor) return\n try {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'locations', addressFor.$id),\n { postalAddress: CommerceModel.normalizePostalAddress(addressDraft) ?? {} },\n { merge: true },\n )\n setAddressFor(null)\n } catch (error: any) {\n enqueueSnackbar(error?.message ?? 'Could not save the address', {\n variant: 'warning',\n persist: false,\n })\n }\n }, [addressDraft, addressFor, enqueueSnackbar, firestore, hostId])\n const addressField = (field: keyof CommerceModel.PostalAddress, label: string) => (\n <TextField\n label={label}\n value={addressDraft[field] ?? ''}\n onChange={(event) =>\n setAddressDraft((prior) => ({\n ...prior,\n [field]: field === 'country' ? event.target.value.toUpperCase().slice(0, 2) : event.target.value,\n }))\n }\n size=\"small\"\n />\n )\n\n /*\n * Pickup at a location (AGL-3624): whether buyers may collect orders here,\n * its hours and what to do on arrival. Checkout offers every location that\n * has it on, and routes the order and its stock there.\n */\n const [pickupFor, setPickupFor] = useState<any | null>(null)\n const [pickupDraft, setPickupDraft] = useState<CommerceModel.PickupLocationSettings>({})\n const openPickup = useCallback(\n (location: any) => () => {\n setPickupFor(location)\n setPickupDraft(CommerceModel.normalizePickupSettings(location.pickup))\n },\n [],\n )\n const badHourLines = invalidOpeningHoursLines(pickupDraft.hours ?? '')\n const handleSavePickup = useCallback(async () => {\n if (!pickupFor) return\n try {\n // `updateDoc` replaces the map whole, so a cleared field is cleared;\n // a merge-set would deep-merge it back.\n await updateDoc(doc(firestore, 'hosts', hostId, 'locations', pickupFor.$id), {\n pickup: CommerceModel.normalizePickupSettings(pickupDraft),\n })\n setPickupFor(null)\n } catch (error: any) {\n enqueueSnackbar(error?.message ?? 'Could not save pickup', {\n variant: 'warning',\n persist: false,\n })\n }\n }, [enqueueSnackbar, firestore, hostId, pickupDraft, pickupFor])\n\n return (\n <CardDisplay\n header={'Inventory locations'}\n help={pluginDocsHelp('commerce', { anchor: '#inventory-locations' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {locations.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Track stock per warehouse or storefront. Without locations, ' +\n 'every variant has a single stock count.'}\n </Typography>\n ) : (\n locations.map((location: any) => (\n <Stack\n key={location.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {location.name}\n </Typography>\n {CommerceModel.normalizePickupSettings(location.pickup).enabled ? (\n <Chip label=\"Pickup\" size=\"small\" color=\"primary\" variant=\"outlined\" />\n ) : null}\n <Button size=\"small\" onClick={openPickup(location)}>\n {'Pickup'}\n </Button>\n <Button size=\"small\" onClick={openAddress(location)}>\n {location.postalAddress?.line1 ? 'Edit address' : 'Add address'}\n </Button>\n {location.isDefault ? (\n <Chip label=\"Default\" size=\"small\" variant=\"outlined\" />\n ) : (\n <Button size=\"small\" onClick={handleMakeDefault(location)}>\n {'Make default'}\n </Button>\n )}\n <Button size=\"small\" color=\"error\" onClick={handleDelete(location)}>\n {'Remove'}\n </Button>\n </Stack>\n ))\n )}\n <Stack direction=\"row\" spacing={1}>\n <TextField\n label=\"New location\"\n value={name}\n onChange={(event) => setName(event.target.value)}\n size=\"small\"\n sx={{ flex: 1 }}\n placeholder=\"Main warehouse\"\n />\n <Button\n size=\"small\"\n disabled={!name.trim() || !planReady}\n onClick={handleAdd}\n >\n {'Add'}\n </Button>\n </Stack>\n {/* The site's locations, not this card's rows (AGL-1716) — the\n readout and the gate must agree, and the gate now counts.\n The wording moved to the shared component in AGL-2113 so the five\n sibling cards that were missing it render the identical string\n rather than five near-misses; the output here is unchanged. */}\n <QuotaReadoutComponent\n ready={planReady}\n used={locationCount}\n limit={quota.limit}\n noun=\"location\"\n />\n </Stack>\n <Dialog open={Boolean(addressFor)} onClose={() => setAddressFor(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{`Address of ${addressFor?.name ?? 'this location'}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n {addressField('line1', 'Street address')}\n {addressField('line2', 'Apartment, suite (optional)')}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5}>\n {addressField('city', 'City')}\n {addressField('state', 'State or region')}\n {addressField('postalCode', 'Postal code')}\n {addressField('country', 'Country (two letters)')}\n </Stack>\n {addressField('phone', 'Phone')}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setAddressFor(null)}>{'Cancel'}</Button>\n <Button variant=\"contained\" onClick={handleSaveAddress}>\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog open={Boolean(pickupFor)} onClose={() => setPickupFor(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{`Pickup at ${pickupFor?.name ?? 'this location'}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <FormControlLabel\n control={\n <Switch\n checked={Boolean(pickupDraft.enabled)}\n onChange={(event) =>\n setPickupDraft((prior) => ({ ...prior, enabled: event.target.checked }))\n }\n />\n }\n label=\"Buyers can pick up orders here\"\n />\n {pickupDraft.enabled && !pickupFor?.postalAddress?.line1 && !pickupFor?.address ? (\n <Typography variant=\"caption\" color=\"warning.main\">\n {'Add this location’s address so buyers know where to go.'}\n </Typography>\n ) : null}\n <OpeningHoursPicker\n label=\"Pickup hours\"\n value={pickupDraft.hours ?? ''}\n onChange={(hours) => setPickupDraft((prior) => ({ ...prior, hours }))}\n helperText=\"Switch on each day buyers can collect, then pick the times.\"\n />\n <TextField\n label=\"Arrival instructions\"\n value={pickupDraft.instructions ?? ''}\n onChange={(event) =>\n setPickupDraft((prior) => ({ ...prior, instructions: event.target.value }))\n }\n multiline\n minRows={2}\n size=\"small\"\n placeholder=\"Ring the bell at the side door and give your order number.\"\n slotProps={{ htmlInput: { maxLength: CommerceModel.PICKUP_INSTRUCTIONS_MAX } }}\n />\n <TextField\n select\n label=\"Usually ready in\"\n value={String(pickupDraft.readyWithinMinutes ?? '')}\n onChange={(event) =>\n setPickupDraft((prior) => ({\n ...prior,\n readyWithinMinutes: event.target.value ? Number(event.target.value) : undefined,\n }))\n }\n size=\"small\"\n >\n <MenuItem value=\"\">{'Don’t say'}</MenuItem>\n {[\n [30, '30 minutes'],\n [60, '1 hour'],\n [120, '2 hours'],\n [240, '4 hours'],\n [1440, '1 day'],\n [2880, '2 days'],\n ].map(([minutes, label]) => (\n <MenuItem key={minutes} value={String(minutes)}>\n {label}\n </MenuItem>\n ))}\n </TextField>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Buyers choose this location at checkout. The order’s stock comes off this location, ' +\n 'and the buyer is emailed when you mark the order ready.'}\n </Typography>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPickupFor(null)}>{'Cancel'}</Button>\n <Button variant=\"contained\" disabled={badHourLines.length > 0} onClick={handleSavePickup}>\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n )\n}\nLocationsCard.displayName = 'LocationsCard'\n\nexport default LocationsCard\n"],"names":["Aglyn","CommerceModel","CardDisplay","useConfirmationContext","QuotaReadoutComponent","OpeningHoursPicker","useSnackbar","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","MenuItem","Stack","Switch","TextField","Typography","invalidOpeningHoursLines","collection","deleteDoc","doc","getCountFromServer","limit","query","setDoc","updateDoc","useCallback","useEffect","useState","useFirestore","useFirestoreCollection","useHostResourceApi","useOrgPlan","pluginDocsHelp","LocationsCard","props","pickupDraft","pickupFor","hostId","firestore","enqueueSnackbar","confirm","createHostResource","org","ready","planReady","data","locationDocs","idField","locations","sort","a","b","String","name","localeCompare","locationCountEpoch","setLocationCountEpoch","serverLocationCount","setServerLocationCount","active","then","snapshot","count","catch","locationCount","length","quota","checkQuota","setName","handleAdd","trim","allowed","variant","persist","resource","slice","isDefault","epoch","error","message","handleDelete","location","confirmed","title","description","confirmationText","confirmationButtonProps","color","$id","handleMakeDefault","other","merge","addressFor","setAddressFor","addressDraft","setAddressDraft","openAddress","normalizePostalAddress","postalAddress","handleSaveAddress","addressField","field","label","value","onChange","event","prior","target","toUpperCase","size","setPickupFor","setPickupDraft","openPickup","normalizePickupSettings","pickup","badHourLines","hours","handleSavePickup","header","help","anchor","contentGutterX","contentGutterY","spacing","map","direction","sx","alignItems","flex","noWrap","enabled","onClick","line1","placeholder","disabled","used","noun","open","Boolean","onClose","fullWidth","maxWidth","pt","xs","sm","control","checked","address","helperText","instructions","multiline","minRows","slotProps","htmlInput","maxLength","PICKUP_INSTRUCTIONS_MAX","select","readyWithinMinutes","Number","undefined","minutes","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,YAAYC,mBAAmB,uBAAa;AAC5C,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,uBAAsB;AAC1E,OAAOC,2BAA2B,0DAAyD;AAC3F,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SACEC,UAAU,EACVC,SAAS,EACTC,GAAG,EACHC,kBAAkB,EAClBC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,SAAS,QACJ,qBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxD,SAASC,YAAY,QAAQ,iC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AAS4F,OAAM;sDAAI;;wCACnB;4CACC;gDAAC;gDAAI;6CAAa;4CAClB;gDAAC;gDAAI;6CAAS;4CACd;gDAAC;gDAAK;6CAAU;4CAChB;gDAAC;gDAAK;6CAAU;4CAChB;gDAAC;gDAAM;6CAAQ;4CACf;gDAAC;gDAAM;6CAAS;yCACjB,CAACqB,GAAG,CAAC,CAAC,CAACoC,SAAS1D,MAAM,iBACrB,KAAC3F;gDAAuB4F,OAAOnD,OAAO4G;0DACnC1D;+CADY0D;;;8CAKnB,KAACjJ;oCAAWyD,SAAQ;oCAAUe,OAAM;8CACjC,yFACC;;;;;kCAIR,MAAChF;;0CACC,KAACH;gCAAO+H,SAAS,IAAMrB,aAAa;0CAAQ;;0CAC5C,KAAC1G;gCAAOoE,SAAQ;gCAAY8D,UAAUnB,aAAalD,MAAM,GAAG;gCAAGkE,SAASd;0CACrE;;;;;;;;AAMb;AACApF,cAAcgI,WAAW,GAAG;AAE5B,eAAehI,cAAa"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/locations-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport * as CommerceModel from '../../model'\nimport { CardDisplay, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport QuotaReadoutComponent from '@aglyn/shared-ui-jsx/components/quota-readout.component'\nimport { OpenableListRow } from '@aglyn/shared-ui-jsx/components/openable-list-row.component'\nimport type { RowActionsMenuItem } from '@aglyn/shared-ui-jsx/components/row-actions-menu.component'\nimport {\n mdiDeleteOutline,\n mdiMapMarkerOutline,\n mdiStarOutline,\n mdiStorefrontOutline,\n} from '@aglyn/shared-data-mdi'\nimport { OpeningHoursPicker } from '@aglyn/shared-ui-jsx/components/weekly-hours-picker.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { invalidOpeningHoursLines } from '@aglyn/aglyn/app-utils/local-business'\nimport {\n collection,\n deleteDoc,\n doc,\n getCountFromServer,\n limit,\n query,\n setDoc,\n updateDoc,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useState } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport { useFirestoreCollection } from '@aglyn/tenant-feature-instance'\nimport { useHostResourceApi } from '@aglyn/tenant-feature-instance'\nimport { useOrgPlan } from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\n\nexport interface LocationsCardProps {\n hostId: string\n}\n\n/**\n * Inventory locations (AGL-286): named stock buckets under\n * `hosts/{hostId}/locations`, capped by the plan's `inventoryLocations`\n * quota (AGL-278). Variant stock splits per location in the products\n * hub; POS registers sell from their location (AGL-312).\n */\nexport function LocationsCard(props: LocationsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n const createHostResource = useHostResourceApi()\n const { org, ready: planReady } = useOrgPlan(hostId)\n const { data: locationDocs } = useFirestoreCollection<any>(\n () => query(collection(firestore, 'hosts', hostId, 'locations'), limit(25)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const locations = [...(locationDocs ?? [])].sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n /**\n * The location HEAD-COUNT is a server aggregate, not the length of the\n * capped listener (AGL-1716, the AGL-1706 shape).\n *\n * The smallest margin of the eight, and real for exactly one plan: the\n * listener is `limit(25)` and `inventoryLocations` runs 1 / 1 / 2 / 4 / 6 /\n * 10 / 50, so only Agency's 50 sits above the window. An agency with more\n * than 25 stock buckets read its cap as satisfiable, and\n * `api/hosts/resources` — which counts the collection — refused the add.\n *\n * Re-read after an add AND a delete: locations are hard-deleted here, so\n * unlike the soft-deleting cards a removal really does free a slot on both\n * sides, and a one-shot that missed it would keep refusing.\n *\n * `locations.length === 0` below still decides the FIRST location's\n * `isDefault` flag off the loaded rows, which is the right question for it\n * — that one is about what this card can see, not about the site's total.\n */\n const [locationCountEpoch, setLocationCountEpoch] = useState(0)\n const [serverLocationCount, setServerLocationCount] = useState<number | null>(\n null,\n )\n useEffect(() => {\n let active = true\n void getCountFromServer(collection(firestore, 'hosts', hostId, 'locations'))\n .then((snapshot) => {\n if (active) setServerLocationCount(snapshot.data().count)\n })\n .catch(() => {\n // Falls back to the loaded rows — a LOWER bound and the prior\n // behaviour, never 0, which reads as \"no locations used\" on a site\n // that is over its band.\n })\n return () => {\n active = false\n }\n }, [firestore, hostId, locationCountEpoch])\n const locationCount = serverLocationCount ?? locations.length\n const quota = Aglyn.checkQuota(org, 'inventoryLocations', locationCount)\n const [name, setName] = useState('')\n\n const handleAdd = useCallback(async () => {\n if (!name.trim()) return\n // Held until the org doc lands (AGL-1064): an absent org resolves to\n // the free tier's `inventoryLocations: 1`, so a site that already has\n // its default location would be refused with an upgrade prompt it does\n // not need. The button is disabled too; this guards the race.\n if (!planReady) return\n if (!quota.allowed) {\n return void enqueueSnackbar(\n `Your plan includes ${quota.limit} locations — upgrade for more`,\n { variant: 'info', persist: false },\n )\n }\n try {\n // Creation rides the quota-enforcing resources API (AGL-473).\n await createHostResource({\n hostId,\n resource: 'location',\n data: {\n name: name.trim().slice(0, 80),\n ...(locations.length === 0 ? { isDefault: true } : {}),\n } satisfies CommerceModel.InventoryLocation,\n })\n setName('')\n setLocationCountEpoch((epoch) => epoch + 1)\n } catch (error: any) {\n enqueueSnackbar(error?.message ?? 'Could not add location', {\n variant: 'warning',\n persist: false,\n })\n }\n }, [\n name,\n planReady,\n quota,\n locations.length,\n hostId,\n createHostResource,\n enqueueSnackbar,\n ])\n\n const handleDelete = useCallback(\n (location: any) => async () => {\n const confirmed = await confirm({\n title: 'Remove this location?',\n description:\n `Stock bucketed under \"${location.name}\" folds back into the ` +\n 'flat totals; adjust counts afterward if needed.',\n confirmationText: 'Remove',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await deleteDoc(doc(firestore, 'hosts', hostId, 'locations', location.$id))\n // A HARD delete, so the slot really is freed on both sides — the\n // one-shot aggregate has to be told (AGL-1716).\n setLocationCountEpoch((epoch) => epoch + 1)\n },\n [confirm, firestore, hostId],\n )\n\n const handleMakeDefault = useCallback(\n (location: any) => async () => {\n for (const other of locations) {\n if (other.isDefault && other.$id !== location.$id) {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'locations', other.$id),\n { isDefault: false },\n { merge: true },\n )\n }\n }\n await setDoc(\n doc(firestore, 'hosts', hostId, 'locations', location.$id),\n { isDefault: true },\n { merge: true },\n )\n },\n [locations, firestore, hostId],\n )\n\n /*\n * A location's postal address (AGL-3612): where parcels can leave from,\n * for anything that ships. Optional, written beside the free-text name.\n */\n const [addressFor, setAddressFor] = useState<any | null>(null)\n const [addressDraft, setAddressDraft] = useState<CommerceModel.PostalAddress>({})\n const openAddress = useCallback(\n (location: any) => () => {\n setAddressFor(location)\n setAddressDraft(CommerceModel.normalizePostalAddress(location.postalAddress) ?? {})\n },\n [],\n )\n const handleSaveAddress = useCallback(async () => {\n if (!addressFor) return\n try {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'locations', addressFor.$id),\n { postalAddress: CommerceModel.normalizePostalAddress(addressDraft) ?? {} },\n { merge: true },\n )\n setAddressFor(null)\n } catch (error: any) {\n enqueueSnackbar(error?.message ?? 'Could not save the address', {\n variant: 'warning',\n persist: false,\n })\n }\n }, [addressDraft, addressFor, enqueueSnackbar, firestore, hostId])\n const addressField = (field: keyof CommerceModel.PostalAddress, label: string) => (\n <TextField\n label={label}\n value={addressDraft[field] ?? ''}\n onChange={(event) =>\n setAddressDraft((prior) => ({\n ...prior,\n [field]: field === 'country' ? event.target.value.toUpperCase().slice(0, 2) : event.target.value,\n }))\n }\n size=\"small\"\n />\n )\n\n /*\n * Pickup at a location (AGL-3624): whether buyers may collect orders here,\n * its hours and what to do on arrival. Checkout offers every location that\n * has it on, and routes the order and its stock there.\n */\n const [pickupFor, setPickupFor] = useState<any | null>(null)\n const [pickupDraft, setPickupDraft] = useState<CommerceModel.PickupLocationSettings>({})\n const openPickup = useCallback(\n (location: any) => () => {\n setPickupFor(location)\n setPickupDraft(CommerceModel.normalizePickupSettings(location.pickup))\n },\n [],\n )\n const badHourLines = invalidOpeningHoursLines(pickupDraft.hours ?? '')\n const handleSavePickup = useCallback(async () => {\n if (!pickupFor) return\n try {\n // `updateDoc` replaces the map whole, so a cleared field is cleared;\n // a merge-set would deep-merge it back.\n await updateDoc(doc(firestore, 'hosts', hostId, 'locations', pickupFor.$id), {\n pickup: CommerceModel.normalizePickupSettings(pickupDraft),\n })\n setPickupFor(null)\n } catch (error: any) {\n enqueueSnackbar(error?.message ?? 'Could not save pickup', {\n variant: 'warning',\n persist: false,\n })\n }\n }, [enqueueSnackbar, firestore, hostId, pickupDraft, pickupFor])\n\n /**\n * Every action a location row offers, in its ⋮ menu. A row click opens\n * its address, the location's own details.\n */\n const locationRowActions = (location: any): RowActionsMenuItem[] => [\n {\n key: 'address',\n label: location.postalAddress?.line1 ? 'Edit address' : 'Add address',\n icon: { path: mdiMapMarkerOutline.path },\n onClick: openAddress(location),\n },\n {\n key: 'pickup',\n label: 'Pickup',\n icon: { path: mdiStorefrontOutline.path },\n onClick: openPickup(location),\n },\n {\n key: 'default',\n label: 'Make default',\n icon: { path: mdiStarOutline.path },\n disabled: Boolean(location.isDefault),\n disabledReason: location.isDefault ? 'Already the default' : undefined,\n onClick: () => void handleMakeDefault(location)(),\n },\n {\n key: 'remove',\n label: 'Remove',\n icon: { path: mdiDeleteOutline.path },\n destructive: true,\n onClick: () => void handleDelete(location)(),\n },\n ]\n\n return (\n <CardDisplay\n header={'Inventory locations'}\n help={pluginDocsHelp('commerce', { anchor: '#inventory-locations' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {locations.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Track stock per warehouse or storefront. Without locations, ' +\n 'every variant has a single stock count.'}\n </Typography>\n ) : (\n locations.map((location: any) => (\n <OpenableListRow\n key={location.$id}\n label={location.name}\n onOpen={openAddress(location)}\n items={locationRowActions(location)}\n >\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 0 }} noWrap>\n {location.name}\n </Typography>\n {CommerceModel.normalizePickupSettings(location.pickup).enabled ? (\n <Chip label=\"Pickup\" size=\"small\" color=\"primary\" variant=\"outlined\" />\n ) : null}\n {location.isDefault ? (\n <Chip label=\"Default\" size=\"small\" variant=\"outlined\" />\n ) : null}\n </OpenableListRow>\n ))\n )}\n <Stack direction=\"row\" spacing={1}>\n <TextField\n label=\"New location\"\n value={name}\n onChange={(event) => setName(event.target.value)}\n size=\"small\"\n sx={{ flex: 1 }}\n placeholder=\"Main warehouse\"\n />\n <Button\n size=\"small\"\n disabled={!name.trim() || !planReady}\n onClick={handleAdd}\n >\n {'Add'}\n </Button>\n </Stack>\n {/* The site's locations, not this card's rows (AGL-1716) — the\n readout and the gate must agree, and the gate now counts.\n The wording moved to the shared component in AGL-2113 so the five\n sibling cards that were missing it render the identical string\n rather than five near-misses; the output here is unchanged. */}\n <QuotaReadoutComponent\n ready={planReady}\n used={locationCount}\n limit={quota.limit}\n noun=\"location\"\n />\n </Stack>\n <Dialog open={Boolean(addressFor)} onClose={() => setAddressFor(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{`Address of ${addressFor?.name ?? 'this location'}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n {addressField('line1', 'Street address')}\n {addressField('line2', 'Apartment, suite (optional)')}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5}>\n {addressField('city', 'City')}\n {addressField('state', 'State or region')}\n {addressField('postalCode', 'Postal code')}\n {addressField('country', 'Country (two letters)')}\n </Stack>\n {addressField('phone', 'Phone')}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setAddressFor(null)}>{'Cancel'}</Button>\n <Button variant=\"contained\" onClick={handleSaveAddress}>\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog open={Boolean(pickupFor)} onClose={() => setPickupFor(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{`Pickup at ${pickupFor?.name ?? 'this location'}`}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <FormControlLabel\n control={\n <Switch\n checked={Boolean(pickupDraft.enabled)}\n onChange={(event) =>\n setPickupDraft((prior) => ({ ...prior, enabled: event.target.checked }))\n }\n />\n }\n label=\"Buyers can pick up orders here\"\n />\n {pickupDraft.enabled && !pickupFor?.postalAddress?.line1 && !pickupFor?.address ? (\n <Typography variant=\"caption\" color=\"warning.main\">\n {'Add this location’s address so buyers know where to go.'}\n </Typography>\n ) : null}\n <OpeningHoursPicker\n label=\"Pickup hours\"\n value={pickupDraft.hours ?? ''}\n onChange={(hours) => setPickupDraft((prior) => ({ ...prior, hours }))}\n helperText=\"Switch on each day buyers can collect, then pick the times.\"\n />\n <TextField\n label=\"Arrival instructions\"\n value={pickupDraft.instructions ?? ''}\n onChange={(event) =>\n setPickupDraft((prior) => ({ ...prior, instructions: event.target.value }))\n }\n multiline\n minRows={2}\n size=\"small\"\n placeholder=\"Ring the bell at the side door and give your order number.\"\n slotProps={{ htmlInput: { maxLength: CommerceModel.PICKUP_INSTRUCTIONS_MAX } }}\n />\n <TextField\n select\n label=\"Usually ready in\"\n value={String(pickupDraft.readyWithinMinutes ?? '')}\n onChange={(event) =>\n setPickupDraft((prior) => ({\n ...prior,\n readyWithinMinutes: event.target.value ? Number(event.target.value) : undefined,\n }))\n }\n size=\"small\"\n >\n <MenuItem value=\"\">{'Don’t say'}</MenuItem>\n {[\n [30, '30 minutes'],\n [60, '1 hour'],\n [120, '2 hours'],\n [240, '4 hours'],\n [1440, '1 day'],\n [2880, '2 days'],\n ].map(([minutes, label]) => (\n <MenuItem key={minutes} value={String(minutes)}>\n {label}\n </MenuItem>\n ))}\n </TextField>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Buyers choose this location at checkout. The order’s stock comes off this location, ' +\n 'and the buyer is emailed when you mark the order ready.'}\n </Typography>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPickupFor(null)}>{'Cancel'}</Button>\n <Button variant=\"contained\" disabled={badHourLines.length > 0} onClick={handleSavePickup}>\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n )\n}\nLocationsCard.displayName = 'LocationsCard'\n\nexport default LocationsCard\n"],"names":["Aglyn","CommerceModel","CardDisplay","useConfirmationContext","QuotaReadoutComponent","OpenableListRow","mdiDeleteOutline","mdiMapMarkerOutline","mdiStarOutline","mdiStorefrontOutline","OpeningHoursPicker","useSnackbar","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","MenuItem","Stack","Switch","TextField","Typography","invalidOpeningHoursLines","collection","deleteDoc","doc","getCountFromServer","limit","query","setDoc","updateDoc","useCallback","useEffect","useState","useFirestore","useFirestoreCollection","useHostResourceApi","useOrgPlan","pluginDocsHelp","LocationsCard","props","pickupDraft","pickupFor","hostId","firestore","enqueueSnackbar","confirm","createHostResource","org","ready","planReady","data","locationDocs","idField","locations","sort","a","b","String","name","localeCompare","locationCountEpoch","setLocationCountEpoch","serverLocationCount","setServerLocationCount","active","then","snapshot","count","catch","locationCount","length","quota","checkQuota","setName","handleAdd","trim","allowed","variant","persist","resource","slice","isDefault","epoch","error","message","handleDelete","location","confirmed","title","description","confirmationText","confirmationButtonProps","color","$id","handleMakeDefault","other","merge","addressFor","setAddressFor","addressDraft","setAddressDraft","openAddress","normalizePostalAddress","postalAddress","handleSaveAddress","addressField","field","label","value","onChange","event","prior","target","toUpperCase","size","setPickupFor","setPickupDraft","openPickup","normalizePickupSettings","pickup","badHourLines","hours","handleSavePickup","locationRowActions","key","line1","icon","path","onClick","disabled","Boolean","disabledReason","undefined","destructive","header","help","anchor","contentGutterX","contentGutterY","spacing","map","onOpen","items","sx","flex","minWidth","noWrap","enabled","direction","placeholder","used","noun","open","onClose","fullWidth","maxWidth","pt","xs","sm","control","checked","address","helperText","instructions","multiline","minRows","slotProps","htmlInput","maxLength","PICKUP_INSTRUCTIONS_MAX","select","readyWithinMinutes","Number","minutes","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,YAAYC,mBAAmB,uBAAa;AAC5C,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,uBAAsB;AAC1E,OAAOC,2BAA2B,0DAAyD;AAC3F,SAASC,eAAe,QAAQ,8DAA6D;AAE7F,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,cAAc,EACdC,oBAAoB,QACf,yBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SACEC,UAAU,EACVC,SAAS,EACTC,GAAG,EACHC,kBAAkB,EAClBC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,SAAS,QACJ,qBAAoB;AAC3B,SAASC,WAA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L,QAAW,aAAKA;gDAAOoD,cAAcrD,MAAME,MAAM,CAACJ,KAAK;;oCAEzEwD,SAAS;oCACTC,SAAS;oCACTnD,MAAK;oCACLmC,aAAY;oCACZiB,WAAW;wCAAEC,WAAW;4CAAEC,WAAW1K,cAAc2K,uBAAuB;wCAAC;oCAAE;;8CAE/E,MAACtJ;oCACCuJ,MAAM;oCACN/D,OAAM;oCACNC,OAAOnD,QAAOjB,kCAAAA,YAAYmI,kBAAkB,YAA9BnI,kCAAkC;oCAChDqE,UAAU,CAACC,QACTM,eAAe,CAACL,QAAW,aACtBA;gDACH4D,oBAAoB7D,MAAME,MAAM,CAACJ,KAAK,GAAGgE,OAAO9D,MAAME,MAAM,CAACJ,KAAK,IAAIwB;;oCAG1ElB,MAAK;;sDAEL,KAAClG;4CAAS4F,OAAM;sDAAI;;wCACnB;4CACC;gDAAC;gDAAI;6CAAa;4CAClB;gDAAC;gDAAI;6CAAS;4CACd;gDAAC;gDAAK;6CAAU;4CAChB;gDAAC;gDAAK;6CAAU;4CAChB;gDAAC;gDAAM;6CAAQ;4CACf;gDAAC;gDAAM;6CAAS;yCACjB,CAACgC,GAAG,CAAC,CAAC,CAACiC,SAASlE,MAAM,iBACrB,KAAC3F;gDAAuB4F,OAAOnD,OAAOoH;0DACnClE;+CADYkE;;;8CAKnB,KAACzJ;oCAAWyD,SAAQ;oCAAUe,OAAM;8CACjC,yFACC;;;;;kCAIR,MAAChF;;0CACC,KAACH;gCAAOuH,SAAS,IAAMb,aAAa;0CAAQ;;0CAC5C,KAAC1G;gCAAOoE,SAAQ;gCAAYoD,UAAUT,aAAalD,MAAM,GAAG;gCAAG0D,SAASN;0CACrE;;;;;;;;AAMb;AACApF,cAAcwI,WAAW,GAAG;AAE5B,eAAexI,cAAa"}
@@ -18,6 +18,8 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
18
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  import { CardDisplay } from "@aglyn/shared-ui-jsx";
20
20
  import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
21
+ import { OpenableListRow } from "@aglyn/shared-ui-jsx/components/openable-list-row.component";
22
+ import { mdiDeleteOutline } from "@aglyn/shared-data-mdi";
21
23
  import { useSnackbar } from "@aglyn/shared-ui-snackstack";
22
24
  import { Button, Checkbox, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, MenuItem, Stack, TextField, Typography } from "@mui/material";
23
25
  import { collection, deleteDoc, doc, limit, orderBy, query } from "firebase/firestore";
@@ -130,39 +132,40 @@ export function MemberPostsCard(props) {
130
132
  children: 'Post updates only your subscribers can see (and optionally ' + 'email them). Add a Member feed block to a members-only page.'
131
133
  }) : posts.map((post)=>{
132
134
  var _post_createdAtMs;
133
- return /*#__PURE__*/ _jsxs(Stack, {
134
- direction: "row",
135
- spacing: 1,
136
- sx: {
137
- alignItems: 'center'
138
- },
139
- children: [
140
- /*#__PURE__*/ _jsxs(Stack, {
141
- sx: {
142
- flex: 1,
143
- minWidth: 0
135
+ return(// A post has no editor here, so the row opens nothing and its
136
+ // one action sits in the ⋮ menu.
137
+ /*#__PURE__*/ _jsx(OpenableListRow, {
138
+ label: post.title || 'Update',
139
+ items: [
140
+ {
141
+ key: 'delete',
142
+ label: 'Delete',
143
+ icon: {
144
+ path: mdiDeleteOutline.path
144
145
  },
145
- children: [
146
- /*#__PURE__*/ _jsx(Typography, {
147
- variant: "body2",
148
- noWrap: true,
149
- children: post.title
150
- }),
151
- /*#__PURE__*/ _jsx(Typography, {
152
- variant: "caption",
153
- color: "text.secondary",
154
- children: new Date((_post_createdAtMs = post.createdAtMs) != null ? _post_createdAtMs : 0).toLocaleDateString()
155
- })
156
- ]
157
- }),
158
- /*#__PURE__*/ _jsx(Button, {
159
- size: "small",
160
- color: "error",
161
- onClick: ()=>deleteDoc(doc(firestore, 'hosts', hostId, 'memberPosts', post.$id)),
162
- children: 'Delete'
163
- })
164
- ]
165
- }, post.$id);
146
+ destructive: true,
147
+ onClick: ()=>void deleteDoc(doc(firestore, 'hosts', hostId, 'memberPosts', post.$id))
148
+ }
149
+ ],
150
+ children: /*#__PURE__*/ _jsxs(Stack, {
151
+ sx: {
152
+ flex: 1,
153
+ minWidth: 0
154
+ },
155
+ children: [
156
+ /*#__PURE__*/ _jsx(Typography, {
157
+ variant: "body2",
158
+ noWrap: true,
159
+ children: post.title
160
+ }),
161
+ /*#__PURE__*/ _jsx(Typography, {
162
+ variant: "caption",
163
+ color: "text.secondary",
164
+ children: new Date((_post_createdAtMs = post.createdAtMs) != null ? _post_createdAtMs : 0).toLocaleDateString()
165
+ })
166
+ ]
167
+ })
168
+ }, post.$id));
166
169
  }),
167
170
  /*#__PURE__*/ _jsx(ListPagination, {
168
171
  page: page,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/member-posts-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Button,\n Checkbox,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n deleteDoc,\n doc,\n limit,\n orderBy,\n query,\n} from 'firebase/firestore'\nimport { useCallback, useState } from 'react'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n useFirestoreCollection,\n usePagedCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { EntitlementGatedCard } from './entitlement-gate.component'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\n\nexport interface MemberPostsCardProps {\n hostId: string\n}\n\n/**\n * Member updates (AGL-316): posts for entitled subscribers, published\n * through a manager-gated API that can also email the audience. The\n * member-feed block renders them on the site.\n *\n * Gated on `contentGating` since AGL-2080, and this is the one of the five\n * that failed OPEN. `server/gate.ts:48` (`hostHasContentGating`) is what\n * decides whether `membership-content.ts`, `member-feed.ts` and `stream.ts`\n * withhold anything; without the entitlement it withholds nothing. So an\n * unentitled operator could mark a post members-only, see it accepted, and\n * have the renderer serve it to the public — believing content was protected\n * while it was not. A refusal the operator can see is the fix.\n */\n\nconst memberPostsHelp = pluginDocsHelp('commerceEndToEnd', {\n anchor: '#member-updates',\n})\n\nexport function MemberPostsCard(props: MemberPostsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n /*\n * Ordered by the SERVER, and a growing window rather than a fixed read.\n *\n * This was `limit(50)` with no `orderBy`, rendering `.slice(0, 8)`. A\n * Firestore query with a limit and no ordering returns DOCUMENT-ID order,\n * and posts are created with `.add()`, so those fifty were a pseudo-random\n * sample of the feed — the client sort below then ordered the sample and\n * showed eight of it, which looks newest-first and is not. Past fifty\n * posts, one written this morning could simply never appear.\n */\n const {\n rows: posts,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n } = usePagedCollection<any>(\n (pageLimit) =>\n query(\n collection(firestore, 'hosts', hostId, 'memberPosts'),\n orderBy('createdAtMs', 'desc'),\n limit(pageLimit),\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { data: productDocs } = useFirestoreCollection<any>(\n () => query(collection(firestore, 'hosts', hostId, 'products'), limit(200)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const [draft, setDraft] = useState<{\n title: string\n body: string\n productId: string\n emailSubscribers: boolean\n busy?: boolean\n } | null>(null)\n\n const handlePublish = useCallback(async () => {\n if (!draft?.title.trim()) return\n setDraft((prev) => (prev ? { ...prev, busy: true } : prev))\n try {\n const response = await authorizedFetch(\n user,\n '/api/commerce/member-post',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, ...draft }),\n },\n )\n const payload = await response.json()\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Publish failed', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n enqueueSnackbar(\n payload.emailed\n ? `Published — emailed ${payload.emailed} subscribers`\n : 'Published',\n { variant: 'success', persist: false },\n )\n setDraft(null)\n } finally {\n setDraft((prev) => (prev ? { ...prev, busy: false } : prev))\n }\n }, [draft, user, hostId, enqueueSnackbar])\n\n return (\n <EntitlementGatedCard\n help={memberPostsHelp}\n hostId={hostId}\n feature=\"contentGating\"\n header={'Member updates'}\n upsell={\n 'Memberships and gated content keep posts, pages and video behind ' +\n 'a subscription, and publish updates to the members entitled to ' +\n 'them.'\n }\n >\n <CardDisplay\n header={'Member updates'}\n help={memberPostsHelp}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {posts.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Post updates only your subscribers can see (and optionally ' +\n 'email them). Add a Member feed block to a members-only page.'}\n </Typography>\n ) : (\n posts.map((post: any) => (\n <Stack\n key={post.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {post.title}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {new Date(post.createdAtMs ?? 0).toLocaleDateString()}\n </Typography>\n </Stack>\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() =>\n deleteDoc(\n doc(firestore, 'hosts', hostId, 'memberPosts', post.$id),\n )\n }\n >\n {'Delete'}\n </Button>\n </Stack>\n ))\n )}\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={posts.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n setDraft({\n title: '',\n body: '',\n productId: '',\n emailSubscribers: true,\n })\n }\n >\n {'New update'}\n </Button>\n </Stack>\n <Dialog\n open={Boolean(draft)}\n onClose={() => setDraft(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>{'New member update'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Title\"\n value={draft?.title ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, title: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n />\n <TextField\n label=\"Body\"\n value={draft?.body ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, body: event.target.value } : prev,\n )\n }\n size=\"small\"\n multiline\n minRows={4}\n />\n <TextField\n label=\"Audience\"\n value={draft?.productId ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, productId: event.target.value } : prev,\n )\n }\n size=\"small\"\n select\n >\n <MenuItem value=\"\">{'All live subscribers'}</MenuItem>\n {(productDocs ?? [])\n .filter((product: any) => product.subscription)\n .map((product: any) => (\n <MenuItem key={product.$id} value={product.$id}>\n {`Subscribers of ${product.name}`}\n </MenuItem>\n ))}\n </TextField>\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={draft?.emailSubscribers ?? true}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, emailSubscribers: event.target.checked }\n : prev,\n )\n }\n />\n }\n label=\"Email subscribers\"\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!draft?.title.trim() || draft?.busy}\n onClick={handlePublish}\n >\n {'Publish'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n </EntitlementGatedCard>\n )\n}\nMemberPostsCard.displayName = 'MemberPostsCard'\n\nexport default MemberPostsCard\n"],"names":["CardDisplay","ListPagination","useSnackbar","Button","Checkbox","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","MenuItem","Stack","TextField","Typography","collection","deleteDoc","doc","limit","orderBy","query","useCallback","useState","useFirestore","useUser","useFirestoreCollection","usePagedCollection","EntitlementGatedCard","pluginDocsHelp","authorizedFetch","memberPostsHelp","anchor","MemberPostsCard","props","hostId","firestore","data","user","enqueueSnackbar","rows","posts","hasMore","page","setPage","pageSize","setPageSize","pageLimit","idField","productDocs","draft","setDraft","handlePublish","title","trim","prev","busy","response","method","headers","body","JSON","stringify","payload","json","ok","error","variant","allowDuplicate","emailed","persist","help","feature","header","upsell","contentGutterX","contentGutterY","spacing","length","color","map","post","direction","sx","alignItems","flex","minWidth","noWrap","Date","createdAtMs","toLocaleDateString","size","onClick","$id","rowCount","onPageChange","onPageSizeChange","alignSelf","productId","emailSubscribers","open","Boolean","onClose","maxWidth","fullWidth","display","flexDirection","gap","label","value","onChange","event","target","autoFocus","mt","multiline","minRows","select","filter","product","subscription","name","control","checked","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SACEC,UAAU,EACVC,SAAS,EACTC,GAAG,EACHC,KAAK,EACLC,OAAO,EACPC,KAAK,QACA,qBAAoB;A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BAAI;oCAC3BY,UAAU,CAACC,QACT5D,SAAS,CAACI,OACRA,OAAO,aAAKA;gDAAM2C,WAAWa,MAAMC,MAAM,CAACH,KAAK;iDAAKtD;oCAGxDoC,MAAK;oCACL0B,MAAM;;sDAEN,KAACzG;4CAASiG,OAAM;sDAAI;;wCACnB,CAAC5D,sBAAAA,cAAe,EAAE,EAChBqE,MAAM,CAAC,CAACC,UAAiBA,QAAQC,YAAY,EAC7CxC,GAAG,CAAC,CAACuC,wBACJ,KAAC3G;gDAA2BiG,OAAOU,QAAQ1B,GAAG;0DAC3C,CAAC,eAAe,EAAE0B,QAAQE,IAAI,EAAE;+CADpBF,QAAQ1B,GAAG;;;8CAKhC,KAAClF;oCACC+G,uBACE,KAACpH;wCACCqF,MAAK;wCACLgC,OAAO,WAAEzE,yBAAAA,MAAOiD,gBAAgB,oBAAI;wCACpCW,UAAU,CAACC,QACT5D,SAAS,CAACI,OACRA,OACI,aAAKA;oDAAM4C,kBAAkBY,MAAMC,MAAM,CAACW,OAAO;qDACjDpE;;oCAKZqD,OAAM;;;;sCAGV,MAACpG;;8CACC,KAACH;oCAAOuF,SAAS,IAAMzC,SAAS;8CAAQ;;8CACxC,KAAC9C;oCACC8D,SAAQ;oCACRY,OAAM;oCACN6C,UAAU,EAAC1E,yBAAAA,MAAOG,KAAK,CAACC,IAAI,QAAMJ,yBAAAA,MAAOM,IAAI;oCAC7CoC,SAASxC;8CAER;;;;;;;;;AAOb;AACAnB,gBAAgB4F,WAAW,GAAG;AAE9B,eAAe5F,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/member-posts-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { OpenableListRow } from '@aglyn/shared-ui-jsx/components/openable-list-row.component'\nimport { mdiDeleteOutline } from '@aglyn/shared-data-mdi'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Button,\n Checkbox,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n deleteDoc,\n doc,\n limit,\n orderBy,\n query,\n} from 'firebase/firestore'\nimport { useCallback, useState } from 'react'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n useFirestoreCollection,\n usePagedCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { EntitlementGatedCard } from './entitlement-gate.component'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\n\nexport interface MemberPostsCardProps {\n hostId: string\n}\n\n/**\n * Member updates (AGL-316): posts for entitled subscribers, published\n * through a manager-gated API that can also email the audience. The\n * member-feed block renders them on the site.\n *\n * Gated on `contentGating` since AGL-2080, and this is the one of the five\n * that failed OPEN. `server/gate.ts:48` (`hostHasContentGating`) is what\n * decides whether `membership-content.ts`, `member-feed.ts` and `stream.ts`\n * withhold anything; without the entitlement it withholds nothing. So an\n * unentitled operator could mark a post members-only, see it accepted, and\n * have the renderer serve it to the public — believing content was protected\n * while it was not. A refusal the operator can see is the fix.\n */\n\nconst memberPostsHelp = pluginDocsHelp('commerceEndToEnd', {\n anchor: '#member-updates',\n})\n\nexport function MemberPostsCard(props: MemberPostsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n /*\n * Ordered by the SERVER, and a growing window rather than a fixed read.\n *\n * This was `limit(50)` with no `orderBy`, rendering `.slice(0, 8)`. A\n * Firestore query with a limit and no ordering returns DOCUMENT-ID order,\n * and posts are created with `.add()`, so those fifty were a pseudo-random\n * sample of the feed — the client sort below then ordered the sample and\n * showed eight of it, which looks newest-first and is not. Past fifty\n * posts, one written this morning could simply never appear.\n */\n const {\n rows: posts,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n } = usePagedCollection<any>(\n (pageLimit) =>\n query(\n collection(firestore, 'hosts', hostId, 'memberPosts'),\n orderBy('createdAtMs', 'desc'),\n limit(pageLimit),\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { data: productDocs } = useFirestoreCollection<any>(\n () => query(collection(firestore, 'hosts', hostId, 'products'), limit(200)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const [draft, setDraft] = useState<{\n title: string\n body: string\n productId: string\n emailSubscribers: boolean\n busy?: boolean\n } | null>(null)\n\n const handlePublish = useCallback(async () => {\n if (!draft?.title.trim()) return\n setDraft((prev) => (prev ? { ...prev, busy: true } : prev))\n try {\n const response = await authorizedFetch(\n user,\n '/api/commerce/member-post',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, ...draft }),\n },\n )\n const payload = await response.json()\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Publish failed', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n enqueueSnackbar(\n payload.emailed\n ? `Published — emailed ${payload.emailed} subscribers`\n : 'Published',\n { variant: 'success', persist: false },\n )\n setDraft(null)\n } finally {\n setDraft((prev) => (prev ? { ...prev, busy: false } : prev))\n }\n }, [draft, user, hostId, enqueueSnackbar])\n\n return (\n <EntitlementGatedCard\n help={memberPostsHelp}\n hostId={hostId}\n feature=\"contentGating\"\n header={'Member updates'}\n upsell={\n 'Memberships and gated content keep posts, pages and video behind ' +\n 'a subscription, and publish updates to the members entitled to ' +\n 'them.'\n }\n >\n <CardDisplay\n header={'Member updates'}\n help={memberPostsHelp}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {posts.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Post updates only your subscribers can see (and optionally ' +\n 'email them). Add a Member feed block to a members-only page.'}\n </Typography>\n ) : (\n posts.map((post: any) => (\n // A post has no editor here, so the row opens nothing and its\n // one action sits in the ⋮ menu.\n <OpenableListRow\n key={post.$id}\n label={post.title || 'Update'}\n items={[\n {\n key: 'delete',\n label: 'Delete',\n icon: { path: mdiDeleteOutline.path },\n destructive: true,\n onClick: () =>\n void deleteDoc(\n doc(firestore, 'hosts', hostId, 'memberPosts', post.$id),\n ),\n },\n ]}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {post.title}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {new Date(post.createdAtMs ?? 0).toLocaleDateString()}\n </Typography>\n </Stack>\n </OpenableListRow>\n ))\n )}\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={posts.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n setDraft({\n title: '',\n body: '',\n productId: '',\n emailSubscribers: true,\n })\n }\n >\n {'New update'}\n </Button>\n </Stack>\n <Dialog\n open={Boolean(draft)}\n onClose={() => setDraft(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>{'New member update'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Title\"\n value={draft?.title ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, title: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n />\n <TextField\n label=\"Body\"\n value={draft?.body ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, body: event.target.value } : prev,\n )\n }\n size=\"small\"\n multiline\n minRows={4}\n />\n <TextField\n label=\"Audience\"\n value={draft?.productId ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, productId: event.target.value } : prev,\n )\n }\n size=\"small\"\n select\n >\n <MenuItem value=\"\">{'All live subscribers'}</MenuItem>\n {(productDocs ?? [])\n .filter((product: any) => product.subscription)\n .map((product: any) => (\n <MenuItem key={product.$id} value={product.$id}>\n {`Subscribers of ${product.name}`}\n </MenuItem>\n ))}\n </TextField>\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={draft?.emailSubscribers ?? true}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, emailSubscribers: event.target.checked }\n : prev,\n )\n }\n />\n }\n label=\"Email subscribers\"\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!draft?.title.trim() || draft?.busy}\n onClick={handlePublish}\n >\n {'Publish'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n </EntitlementGatedCard>\n )\n}\nMemberPostsCard.displayName = 'MemberPostsCard'\n\nexport default MemberPostsCard\n"],"names":["CardDisplay","ListPagination","OpenableListRow","mdiDeleteOutline","useSnackbar","Button","Checkbox","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","MenuItem","Stack","TextField","Typography","collection","deleteDoc","doc","limit","orderBy","query","useCallback","useState","useFirestore","useUser","useFirestoreCollection","usePagedCollection","EntitlementGatedCard","pluginDocsHelp","authorizedFetch","memberPostsHelp","anchor","MemberPostsCard","props","hostId","firestore","data","user","enqueueSnackbar","rows","posts","hasMore","page","setPage","pageSize","setPageSize","pageLimit","idField","productDocs","draft","setDraft","handlePublish","title","trim","prev","busy","response","method","headers","body","JSON","stringify","payload","json","ok","error","variant","allowDuplicate","emailed","persist","help","feature","header","upsell","contentGutterX","contentGutterY","spacing","length","color","map","post","label","items","key","icon","path","destructive","onClick","$id","sx","flex","minWidth","noWrap","Date","createdAtMs","toLocaleDateString","rowCount","onPageChange","onPageSizeChange","size","alignSelf","productId","emailSubscribers","open","Boolean","onClose","maxWidth","fullWidth","display","flexDirection","gap","value","onChange","event","target","autoFocus","mt","multiline","minRows","select","filter","product","subscription","name","control","checked","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,eAAe,QAAQ,8DAA6D;AAC7F,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SACEC,UAAU,EACVC,SAAS,EACTC,GAAG,EACHC,KAAK,EACLC,OAAO,EACPC,KAAK,QACA,qBAAoB;AAC3B,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAC7C,SAASC,YAAY,EAAEC,OAAO,QAAQ,iCAAgC;AACtE,SACEC,sBAAsB,EACtBC,kBAAkB,QACb,iCAAgC;AACvC,SAASC,oBAAoB,QAAQ,kCAA8B;AACnE,SAASC,cAAc,QAAQ,eAAc;AAC7C,SAASC,eAAe,QAAQ,2CAA0C;AAM1E;;;;;;;;;;;;CAYC,GAED,MAAMC,kBAAkBF,eAAe,oBAAoB;IACzDG,QAAQ;AACV;AAEA,OAAO,SAASC,gBAAgBC,KAA2B;;IACzD,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,MAAME,YAAYZ;IAClB,MAAM,EAAEa,MAAMC,IAAI,EAAE,GAAGb;IACvB,MAAM,EAAEc,eAAe,EAAE,GAAGnC;IAC5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,GAAG;;;8CAKhC,KAAC9E;oCACCkH,uBACE,KAACvH;wCACC8F,MAAK;wCACL0B,OAAO,WAAE5E,yBAAAA,MAAOqD,gBAAgB,oBAAI;wCACpCU,UAAU,CAACC,QACT/D,SAAS,CAACI,OACRA,OACI,aAAKA;oDAAMgD,kBAAkBW,MAAMC,MAAM,CAACW,OAAO;qDACjDvE;;oCAKZ2B,OAAM;;;;sCAGV,MAAC1E;;8CACC,KAACH;oCAAOmF,SAAS,IAAMrC,SAAS;8CAAQ;;8CACxC,KAAC9C;oCACC8D,SAAQ;oCACRY,OAAM;oCACNgD,UAAU,EAAC7E,yBAAAA,MAAOG,KAAK,CAACC,IAAI,QAAMJ,yBAAAA,MAAOM,IAAI;oCAC7CgC,SAASpC;8CAER;;;;;;;;;AAOb;AACAnB,gBAAgB+F,WAAW,GAAG;AAE9B,eAAe/F,gBAAe"}
@@ -0,0 +1,17 @@
1
+ import type { ConsoleHostCreateQuestionsZoneProps } from '@aglyn/aglyn';
2
+ /**
3
+ * "Do you charge sales tax?" in Create site (AGL-4061): the `hostCreateQuestions`
4
+ * zone, drawn where Commerce runs for the workspace, so on the store the site
5
+ * will have. Nothing is chosen for anyone: left unanswered, the store decides
6
+ * later in Products → Taxes, and its register and Card readers ask before the
7
+ * first sale. Answered, it is handed to the shell and saved once the site
8
+ * exists, as the Taxes editor saves it (`newStoreTaxSettings`).
9
+ *
10
+ * The three answers are the editor's three modes; Stripe Tax is offered on the
11
+ * same terms as there.
12
+ */
13
+ export declare function NewStoreTaxQuestion(props: ConsoleHostCreateQuestionsZoneProps): import("react").JSX.Element;
14
+ export declare namespace NewStoreTaxQuestion {
15
+ var displayName: string;
16
+ }
17
+ export default NewStoreTaxQuestion;