@aglyn/plugins-commerce 1.31.0 → 1.33.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 (123) hide show
  1. package/README.md +4 -0
  2. package/package.json +13 -13
  3. package/src/lib/components/cart.js +35 -15
  4. package/src/lib/components/cart.js.map +1 -1
  5. package/src/lib/components/commerce-console-page.js +6 -0
  6. package/src/lib/components/commerce-console-page.js.map +1 -1
  7. package/src/lib/components/console/currencies-card.component.d.ts +21 -0
  8. package/src/lib/components/console/currencies-card.component.js +408 -0
  9. package/src/lib/components/console/currencies-card.component.js.map +1 -0
  10. package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
  11. package/src/lib/components/console/product-add-ons-fields.component.js +74 -2
  12. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  13. package/src/lib/components/console/product-editor-dialog.component.js +42 -1
  14. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  15. package/src/lib/components/console/product-fixed-prices-fields.component.d.ts +25 -0
  16. package/src/lib/components/console/product-fixed-prices-fields.component.js +112 -0
  17. package/src/lib/components/console/product-fixed-prices-fields.component.js.map +1 -0
  18. package/src/lib/components/console/reservations-card.component.js +32 -15
  19. package/src/lib/components/console/reservations-card.component.js.map +1 -1
  20. package/src/lib/components/console/shipping-settings-card.component.js +337 -10
  21. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
  22. package/src/lib/components/console/store-settings-card.component.js +1 -1
  23. package/src/lib/components/console/store-settings-card.component.js.map +1 -1
  24. package/src/lib/components/console/use-currency-setup.d.ts +20 -0
  25. package/src/lib/components/console/use-currency-setup.js +61 -0
  26. package/src/lib/components/console/use-currency-setup.js.map +1 -0
  27. package/src/lib/components/currency-selector.d.ts +36 -0
  28. package/src/lib/components/currency-selector.js +157 -0
  29. package/src/lib/components/currency-selector.js.map +1 -0
  30. package/src/lib/components/product-add-ons.d.ts +9 -1
  31. package/src/lib/components/product-add-ons.js +8 -4
  32. package/src/lib/components/product-add-ons.js.map +1 -1
  33. package/src/lib/components/product-choice-cards.d.ts +13 -1
  34. package/src/lib/components/product-choice-cards.js +5 -4
  35. package/src/lib/components/product-choice-cards.js.map +1 -1
  36. package/src/lib/components/product-detail.d.ts +8 -0
  37. package/src/lib/components/product-detail.js +38 -11
  38. package/src/lib/components/product-detail.js.map +1 -1
  39. package/src/lib/components/product-grid.d.ts +2 -0
  40. package/src/lib/components/product-grid.js +22 -9
  41. package/src/lib/components/product-grid.js.map +1 -1
  42. package/src/lib/components/related-products.js +6 -2
  43. package/src/lib/components/related-products.js.map +1 -1
  44. package/src/lib/components/shopper-currency.d.ts +108 -0
  45. package/src/lib/components/shopper-currency.js +262 -0
  46. package/src/lib/components/shopper-currency.js.map +1 -0
  47. package/src/lib/components/wishlist.js +7 -1
  48. package/src/lib/components/wishlist.js.map +1 -1
  49. package/src/lib/declarations.server.js +39 -0
  50. package/src/lib/declarations.server.js.map +1 -1
  51. package/src/lib/model/commerce-currency-setup.d.ts +79 -0
  52. package/src/lib/model/commerce-currency-setup.js +124 -0
  53. package/src/lib/model/commerce-currency-setup.js.map +1 -0
  54. package/src/lib/model/commerce-currency.d.ts +215 -0
  55. package/src/lib/model/commerce-currency.js +511 -0
  56. package/src/lib/model/commerce-currency.js.map +1 -0
  57. package/src/lib/model/commerce-orders.d.ts +17 -0
  58. package/src/lib/model/commerce-orders.js +10 -5
  59. package/src/lib/model/commerce-orders.js.map +1 -1
  60. package/src/lib/model/commerce-record-routes.js +26 -1
  61. package/src/lib/model/commerce-record-routes.js.map +1 -1
  62. package/src/lib/model/commerce-reservations.d.ts +6 -0
  63. package/src/lib/model/commerce-reservations.js.map +1 -1
  64. package/src/lib/model/commerce-shipping.d.ts +66 -11
  65. package/src/lib/model/commerce-shipping.js +91 -7
  66. package/src/lib/model/commerce-shipping.js.map +1 -1
  67. package/src/lib/model/commerce.d.ts +6 -0
  68. package/src/lib/model/commerce.js.map +1 -1
  69. package/src/lib/model/index.d.ts +2 -0
  70. package/src/lib/model/index.js +2 -0
  71. package/src/lib/model/index.js.map +1 -1
  72. package/src/lib/model/order-figures.js +9 -2
  73. package/src/lib/model/order-figures.js.map +1 -1
  74. package/src/lib/model/product-modifiers.d.ts +5 -0
  75. package/src/lib/model/product-modifiers.js.map +1 -1
  76. package/src/lib/model/store-setup-content.js +23 -2
  77. package/src/lib/model/store-setup-content.js.map +1 -1
  78. package/src/lib/server/billing-webhook.js +37 -24
  79. package/src/lib/server/billing-webhook.js.map +1 -1
  80. package/src/lib/server/carrier-shipping.d.ts +2 -0
  81. package/src/lib/server/carrier-shipping.js +8 -4
  82. package/src/lib/server/carrier-shipping.js.map +1 -1
  83. package/src/lib/server/cart-checkout.js +74 -13
  84. package/src/lib/server/cart-checkout.js.map +1 -1
  85. package/src/lib/server/cart.d.ts +12 -0
  86. package/src/lib/server/cart.js +50 -4
  87. package/src/lib/server/cart.js.map +1 -1
  88. package/src/lib/server/catalog.d.ts +5 -0
  89. package/src/lib/server/catalog.js +7 -0
  90. package/src/lib/server/catalog.js.map +1 -1
  91. package/src/lib/server/checkout.js +53 -12
  92. package/src/lib/server/checkout.js.map +1 -1
  93. package/src/lib/server/currency.d.ts +93 -0
  94. package/src/lib/server/currency.js +182 -0
  95. package/src/lib/server/currency.js.map +1 -0
  96. package/src/lib/server/order-notifications.js +4 -2
  97. package/src/lib/server/order-notifications.js.map +1 -1
  98. package/src/lib/server/product.d.ts +9 -0
  99. package/src/lib/server/product.js +12 -0
  100. package/src/lib/server/product.js.map +1 -1
  101. package/src/lib/server/refund.js +3 -3
  102. package/src/lib/server/refund.js.map +1 -1
  103. package/src/lib/server/site-chat-tools.d.ts +22 -0
  104. package/src/lib/server/site-chat-tools.js +369 -0
  105. package/src/lib/server/site-chat-tools.js.map +1 -0
  106. package/src/lib/server/site-chat-visitor.d.ts +24 -0
  107. package/src/lib/server/site-chat-visitor.js +39 -0
  108. package/src/lib/server/site-chat-visitor.js.map +1 -0
  109. package/src/lib/server/site-offers.d.ts +31 -0
  110. package/src/lib/server/site-offers.js +91 -0
  111. package/src/lib/server/site-offers.js.map +1 -0
  112. package/src/lib/server/stays-site-search.d.ts +20 -0
  113. package/src/lib/server/stays-site-search.js +78 -0
  114. package/src/lib/server/stays-site-search.js.map +1 -0
  115. package/src/lib/server.js +20 -0
  116. package/src/lib/server.js.map +1 -1
  117. package/src/lib/site-chat-tool-definitions.d.ts +26 -0
  118. package/src/lib/site-chat-tool-definitions.js +141 -0
  119. package/src/lib/site-chat-tool-definitions.js.map +1 -0
  120. package/src/lib/site.js +8 -0
  121. package/src/lib/site.js.map +1 -1
  122. package/src/lib/subprocessors.js +7 -0
  123. package/src/lib/subprocessors.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/commerce-console-page.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 type { ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { GridItems } from '@aglyn/shared-ui-jsx'\nimport { HubSections } from '@aglyn/shared-ui-next'\nimport { lazy, Suspense, type ReactNode } from 'react'\nimport { Stack } from '@mui/material'\nimport {\n COMMERCE_SETTINGS_PAGE_ZONES,\n type CommerceConsoleSectionId,\n type CommerceSettingsSectionId,\n} from './commerce-console-sections'\nimport CatalogOrganizationCard from './console/catalog-organization-card.component'\nimport CommerceAnalyticsCard from './console/commerce-analytics-card.component'\nimport CustomerNotificationsCard from './console/customer-notifications-card.component'\nimport DiscountsCard from './console/discounts-card.component'\nimport GiftCardsCard from './console/gift-cards-card.component'\nimport HostCouponsCard from './console/host-coupons-card.component'\nimport HostOrdersCard from './console/host-orders-card.component'\nimport HostQuotesCard from './console/host-quotes-card.component'\nimport LocationsCard from './console/locations-card.component'\nimport LocalDeliverySettingsCard from './console/local-delivery-settings-card.component'\nimport PickupDeliveryQueueCard from './console/pickup-delivery-queue-card.component'\nimport MemberPostsCard from './console/member-posts-card.component'\nimport OrderWebhooksCard from './console/order-webhooks-card.component'\nimport PaymentsSettingsCard from './console/payments-settings-card.component'\nimport PosCheckInsCard from './console/pos-ops/pos-check-ins-card.component'\nimport PosDayTotalsCard from './console/pos-ops/pos-day-totals-card.component'\nimport PosShiftHistoryCard from './console/pos-ops/pos-shift-history-card.component'\nimport PosStaffPinsCard from './console/pos-ops/pos-staff-pins-card.component'\nimport PaymentMethodsCard from './console/payment-methods-card.component'\nimport ProductsHubCard from './console/products-hub-card.component'\nimport QuoteSettingsCard from './console/quote-settings-card.component'\nimport RecoveryQueueCard from './console/recovery-queue-card.component'\nimport RegistersCard from './console/registers-card.component'\nimport RegisterHardwareCards from './console/register-hardware-card.component'\nimport PosDevicesCard from './console/pos-devices-card.component'\nimport PosHardwareCard from './console/pos-hardware-card.component'\n\n/**\n * Card readers the workspace bought in person, waiting to be set up\n * (AGL-4038): its own chunk, drawn only while there is one.\n */\nconst PosHardwareWaitingCard = lazy(() => import('./console/pos-hardware-waiting-card.component'))\nimport { holdsPosPermission, posPermissionRefusal } from '../model/plugin-permissions'\nimport ReservationsCard from './console/reservations-card.component'\nimport ReturnSettingsCard from './console/return-settings-card.component'\nimport ReturnsCard from './console/returns-card.component'\nimport ReviewsModerationCard from './console/reviews-moderation-card.component'\nimport ReviewSettingsCard from './console/review-settings-card.component'\nimport ShippingSettingsCard from './console/shipping-settings-card.component'\nimport ShipStationCard from './console/shipstation-card.component'\nimport ShippingEasyCard from './console/shippingeasy-card.component'\nimport StockMovementsCard from './console/stock-movements-card.component'\nimport StoreSettingsCard from './console/store-settings-card.component'\nimport StorefrontTaxSummaryCard from './console/storefront-tax-summary-card.component'\nimport SubscriptionsCard from './console/subscriptions-card.component'\nimport SuppliersCard from './console/suppliers-card.component'\nimport TaxSettingsCard from './console/tax-settings-card.component'\nimport { COMMERCE_PROMOTIONS_ZONE } from './console/store-zones'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\n\n/**\n * A settings page's zone (AGL-3612, AGL-3713): other plugins' settings for\n * the store — label settings, carrier accounts, a tax service — under the\n * page's own cards. One zone per page, from `COMMERCE_SETTINGS_PAGE_ZONES`;\n * Integrations draws `commerceSettings`, where a widget naming no page lands.\n */\nfunction CommerceSettingsZone(props: {\n hostId: string\n page: CommerceSettingsSectionId\n}) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot\n slot={COMMERCE_SETTINGS_PAGE_ZONES[props.page]}\n hostId={props.hostId}\n orgId={undefined}\n />\n ) : null\n}\n\n/** One settings page: its cards in order, then its zone (AGL-3713). */\nfunction settingsPage(\n page: CommerceSettingsSectionId,\n hostId: string,\n cards: readonly ReactNode[],\n): ReactNode {\n return (\n <GridItems\n spacing={3}\n items={[\n ...cards.map((children) => ({ size: { xs: 12 }, children })),\n {\n size: { xs: 12 },\n children: <CommerceSettingsZone hostId={hostId} page={page} />,\n },\n ]}\n />\n )\n}\n\n/**\n * The `commercePromotions` zone (AGL-3640): other plugins' programs beside\n * the store's own money-off surfaces — a rewards program first.\n */\nfunction CommercePromotionsZone(props: { hostId: string }) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot slot={COMMERCE_PROMOTIONS_ZONE.id} hostId={props.hostId} orgId={undefined} />\n ) : null\n}\n\n/**\n * The body of one commerce section, built only when that section is the one\n * being read (AGL-2501).\n *\n * A function rather than a map of nodes on purpose: a `Record<id, ReactNode>`\n * would CONSTRUCT every section every render, and each card opens its Firestore\n * listens on mount — which is the entire cost this page exists to stop paying.\n * Only the returned branch is ever built.\n */\nfunction sectionBody(\n section: CommerceConsoleSectionId,\n hostId: string,\n canManagePos: boolean,\n /** The register's finer keys this page's cards ask (AGL-4047). */\n pos: { canSetUpDevices: boolean; canBuyHardware: boolean; canCashDrawer: boolean } = {\n canSetUpDevices: canManagePos,\n canBuyHardware: canManagePos,\n canCashDrawer: canManagePos,\n },\n /** The reservation keys this site decides for the member (AGL-4047). */\n reservations: { canManage: boolean; canWalkIn: boolean } = { canManage: true, canWalkIn: true },\n /** \"Create and edit quotes\" and \"Send quotes and invoices to customers\" on this site (AGL-4093, AGL-4094). */\n quotes: { canEdit: boolean; canSend: boolean } = { canEdit: true, canSend: true },\n): ReactNode {\n switch (section) {\n case 'catalog':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <ProductsHubCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <CatalogOrganizationCard hostId={hostId} />,\n },\n // The ledger every stock writer fills and nothing displayed\n // (AGL-2341). Directly under the catalog, because the question\n // it answers — \"why does this count disagree with the shelf\" —\n // is asked while looking at the count.\n {\n size: { xs: 12 },\n children: <StockMovementsCard hostId={hostId} />,\n },\n { size: { xs: 12 }, children: <MemberPostsCard hostId={hostId} /> },\n ]}\n />\n )\n case 'orders':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <HostOrdersCard hostId={hostId} canSendInvoices={quotes.canSend} /> },\n // Prices put to a customer before they buy (AGL-4093), beside the\n // orders they become once paid.\n {\n size: { xs: 12 },\n children: <HostQuotesCard hostId={hostId} canEdit={quotes.canEdit} canSend={quotes.canSend} />,\n },\n // What to prepare, hand over and drive out (AGL-3624). Renders\n // nothing for a store with no pickup and no local delivery.\n {\n size: { xs: 12 },\n children: <PickupDeliveryQueueCard hostId={hostId} />,\n },\n // The two queues that feed orders rather than record them\n // (AGL-2227): checkouts that stalled and shoppers waiting on\n // stock. Beneath the orders list because both are pre-order.\n {\n size: { xs: 12 },\n children: <RecoveryQueueCard hostId={hostId} />,\n },\n // One day's or one event's totals across every register, shift\n // and cashier (AGL-4037), above the shifts it adds up.\n {\n size: { xs: 12 },\n children: <PosDayTotalsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n // Who is due at the window and who checked in (AGL-4043), beside\n // the day's totals.\n {\n size: { xs: 12 },\n children: <PosCheckInsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n {\n size: { xs: 12 },\n children: <PosShiftHistoryCard hostId={hostId} />,\n },\n ]}\n />\n )\n case 'subscriptions':\n // Every subscription, its recurring revenue and its invoices (AGL-4191).\n return <SubscriptionsCard hostId={hostId} />\n case 'returns':\n // Returns (AGL-3611); `?return={id}` opens one on arrival.\n return <ReturnsCard hostId={hostId} />\n case 'promotions':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <DiscountsCard hostId={hostId} /> },\n { size: { xs: 12 }, children: <HostCouponsCard hostId={hostId} /> },\n // Store credit lives with the other money-off surfaces\n // (AGL-2226) — it had no console anywhere before this.\n { size: { xs: 12 }, children: <GiftCardsCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <ReviewsModerationCard hostId={hostId} />,\n },\n // Who may review, and the review-request email (AGL-3736),\n // beside the queue those reviews land in.\n {\n size: { xs: 12 },\n children: <ReviewSettingsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <CommercePromotionsZone hostId={hostId} />,\n },\n ]}\n />\n )\n case 'reservations':\n return (\n <ReservationsCard\n hostId={hostId}\n canManage={reservations.canManage}\n canWalkIn={reservations.canWalkIn}\n />\n )\n /*\n * The store's settings, a page each (AGL-3713). They were one `settings`\n * section — every card below in one column — and its old address opens\n * Payments (`COMMERCE_RETIRED_SECTIONS`). Each page is its cards, then\n * the zone where other plugins' cards for that page land.\n */\n case 'payments':\n return settingsPage(section, hostId, [\n <PaymentsSettingsCard key=\"payments\" hostId={hostId} />,\n // What shoppers may pay with (AGL-3629), beside the account the\n // money lands in.\n <PaymentMethodsCard key=\"methods\" hostId={hostId} />,\n ])\n case 'checkout':\n return settingsPage(section, hostId, [\n <StoreSettingsCard key=\"store\" hostId={hostId} />,\n // Whether buyers may ask for a return online (AGL-3611): the store's\n // policy, beside the terms and guest-checkout rules above it.\n <ReturnSettingsCard key=\"returns\" hostId={hostId} />,\n // What a new quote starts with (AGL-4093).\n <QuoteSettingsCard key=\"quotes\" hostId={hostId} />,\n ])\n case 'taxes':\n return settingsPage(section, hostId, [\n <TaxSettingsCard key=\"tax\" hostId={hostId} />,\n ])\n case 'shipping':\n return settingsPage(section, hostId, [\n <ShippingSettingsCard key=\"shipping\" hostId={hostId} />,\n // Where parcels ship from, and pickup, per location.\n <LocationsCard key=\"locations\" hostId={hostId} />,\n // The store's own delivery (AGL-3624); pickup is per location, on\n // the Inventory locations card above.\n <LocalDeliverySettingsCard key=\"local\" hostId={hostId} />,\n <SuppliersCard key=\"suppliers\" hostId={hostId} />,\n <ShipStationCard key=\"shipstation\" hostId={hostId} />,\n // ShippingEasy, with the merchant's own keys (AGL-3633).\n <ShippingEasyCard key=\"shippingeasy\" hostId={hostId} />,\n ])\n case 'notifications':\n return settingsPage(section, hostId, [\n <CustomerNotificationsCard key=\"customers\" hostId={hostId} />,\n // The store's own endpoints for order events (AGL-3611). Renders\n // nothing for a person who may not manage them.\n <OrderWebhooksCard key=\"webhooks\" hostId={hostId} />,\n ])\n case 'pos':\n return settingsPage(section, hostId, [\n // A reader bought in person waits at the top until it is set up\n // (AGL-4038), in the registers' own grid cell so an empty one\n // leaves no gap.\n <Stack key=\"registers\" spacing={3}>\n <Suspense fallback={null}>\n <PosHardwareWaitingCard\n hostId={hostId}\n {...(pos.canSetUpDevices ? {} : { devicesBlockedReason: posPermissionRefusal('posDevices') })}\n />\n </Suspense>\n <RegistersCard hostId={hostId} />\n </Stack>,\n <PosStaffPinsCard key=\"pins\" hostId={hostId} />,\n // A register's printers, cash drawer and status (AGL-3619), one card\n // per register, after the list that names them.\n <RegisterHardwareCards\n key=\"hardware\"\n hostId={hostId}\n blocked={{\n ...(pos.canSetUpDevices ? {} : { devices: posPermissionRefusal('posDevices') }),\n ...(pos.canCashDrawer ? {} : { drawer: posPermissionRefusal('posCashDrawer') }),\n }}\n />,\n <PosDevicesCard\n key=\"devices\"\n hostId={hostId}\n canManagePos={canManagePos}\n canSetUpDevices={pos.canSetUpDevices}\n />,\n // Card readers bought from the platform (AGL-4038), after the card\n // that registers them. Draws nothing until the deployment opens the\n // shop.\n <PosHardwareCard\n key=\"hardware-shop\"\n hostId={hostId}\n canManagePos={canManagePos}\n canBuyHardware={pos.canBuyHardware}\n />,\n ])\n case 'channels':\n case 'integrations':\n // Other plugins' cards only; the rail leaves either page out while\n // its zone has nothing to draw (`onlyWithZones`).\n return settingsPage(section, hostId, [])\n case 'analytics':\n return (\n // Two cards since AGL-2440. The tax summary lives here rather\n // than on the Taxes settings page because that page CONFIGURES tax and\n // this REPORTS what was collected — a merchant reading a figure\n // they may file from should not be one field away from changing\n // the rate that produced it.\n <GridItems\n spacing={3}\n items={[\n {\n size: { xs: 12 },\n children: <CommerceAnalyticsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <StorefrontTaxSummaryCard hostId={hostId} />,\n },\n ]}\n />\n )\n default:\n return null\n }\n}\n\n/**\n * Commerce console page (AGL-395): the Products management surface, owned by\n * the commerce plugin and rendered by the shell's generic plugin route. The\n * product editor's media browser is supplied by the shell's\n * ConsoleMediaPickerProvider (the media library is org/session coupled and\n * stays in the app).\n *\n * ## Sections are ROUTES (AGL-2501)\n *\n * The sections hold thirty-two Firestore listens between them, and a tab\n * strip mounts every panel: opening Catalog also subscribed the orders,\n * promotions, reservations, settings and analytics cards. The `limit()` on\n * those queries is the bill — several ask for 500, and one load reached a\n * ceiling of ~4,460 documents to render one tab.\n *\n * `HubTabs lazy` bought that back as a flag somebody has to remember. A URL\n * per section makes it structural instead: the page builds one section's body\n * and the others do not exist to subscribe. Three things come with it that the\n * tab version faked — a section is linkable, the back button walks sections,\n * and which one is open is a fact about the URL rather than state kept in sync\n * with it. `commerce-console-read-cost.spec.tsx` meters it at the Firestore\n * boundary and refuses a section that listens before it is opened.\n *\n * The shell resolves the section, gates it and hands back the rail's hrefs;\n * this page only has to say what each section contains.\n */\nexport function CommerceConsolePage(props: ConsolePluginPageProps) {\n const { hostId, section, sections, basePath, permissions } = props\n /*\n * The register's own gate, for the devices card's Pair display (AGL-3712):\n * `managePos` — what the server's `mayWorkRegister` asks. The key decides,\n * not the site role (AGL-4047). The server stays the enforcement point.\n */\n const canManagePos = permissions?.managePos === true\n // The register's finer keys (AGL-4047), each following `managePos` unless a\n // role or the member sets it — what the devices and hardware routes ask.\n // Buying hardware stands on its own: the Hardware card is this page's for a\n // member who holds it without the register.\n const pos = {\n canSetUpDevices: canManagePos && holdsPosPermission(permissions, 'posDevices'),\n canBuyHardware: holdsPosPermission(permissions, 'posBuyHardware'),\n canCashDrawer: canManagePos && holdsPosPermission(permissions, 'posCashDrawer'),\n }\n // The reservation keys (AGL-4047), whose preset is the member's role on\n // this site; the shell decides them for the site in view. A map that does\n // not carry one (a shell that predates them) leaves the card as it was:\n // the rules and the routes decide.\n const reservations = {\n canManage: permissions?.['commerce.reservations'] !== false,\n canWalkIn: permissions?.['commerce.walkIns'] !== false,\n }\n // \"Create and edit quotes\" (AGL-4093), read the same way; the quote route\n // decides.\n const quotes = {\n canEdit: permissions?.['commerce.quotes'] !== false,\n canSend: permissions?.['commerce.quotes.send'] !== false,\n }\n\n /*\n * Nothing, deliberately, while the redirect is in flight.\n *\n * Rendering the default section here instead would issue that section's\n * listens on a URL that is about to be replaced — paying for Catalog on\n * every arrival at `/products`, which is every click of the nav tab.\n */\n if (!section || !sections?.length || !basePath) return null\n\n return (\n <HubSections sections={sections}>\n {sectionBody(section as CommerceConsoleSectionId, hostId, canManagePos, pos, reservations, quotes)}\n </HubSections>\n )\n}\nCommerceConsolePage.displayName = 'CommerceConsolePage'\n\nexport default CommerceConsolePage\n"],"names":["GridItems","HubSections","lazy","Suspense","Stack","COMMERCE_SETTINGS_PAGE_ZONES","CatalogOrganizationCard","CommerceAnalyticsCard","CustomerNotificationsCard","DiscountsCard","GiftCardsCard","HostCouponsCard","HostOrdersCard","HostQuotesCard","LocationsCard","LocalDeliverySettingsCard","PickupDeliveryQueueCard","MemberPostsCard","OrderWebhooksCard","PaymentsSettingsCard","PosCheckInsCard","PosDayTotalsCard","PosShiftHistoryCard","PosStaffPinsCard","PaymentMethodsCard","ProductsHubCard","QuoteSettingsCard","RecoveryQueueCard","RegistersCard","RegisterHardwareCards","PosDevicesCard","PosHardwareCard","PosHardwareWaitingCard","holdsPosPermission","posPermissionRefusal","ReservationsCard","ReturnSettingsCard","ReturnsCard","ReviewsModerationCard","ReviewSettingsCard","ShippingSettingsCard","ShipStationCard","ShippingEasyCard","StockMovementsCard","StoreSettingsCard","StorefrontTaxSummaryCard","SubscriptionsCard","SuppliersCard","TaxSettingsCard","COMMERCE_PROMOTIONS_ZONE","useConsoleWidgetSlot","CommerceSettingsZone","props","WidgetSlot","slot","page","hostId","orgId","undefined","settingsPage","cards","spacing","items","map","children","size","xs","CommercePromotionsZone","id","sectionBody","section","canManagePos","pos","canSetUpDevices","canBuyHardware","canCashDrawer","reservations","canManage","canWalkIn","quotes","canEdit","canSend","canSendInvoices","fallback","devicesBlockedReason","blocked","devices","drawer","CommerceConsolePage","sections","basePath","permissions","managePos","length","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAAQ,uBAAsB;AAChD,SAASC,WAAW,QAAQ,wBAAuB;AACnD,SAASC,IAAI,EAAEC,QAAQ,QAAwB,QAAO;AACtD,SAASC,KAAK,QAAQ,gBAAe;AACrC,SACEC,4BAA4B,QAGvB,iCAA6B;AACpC,OAAOC,6BAA6B,mDAA+C;AACnF,OAAOC,2BAA2B,iDAA6C;AAC/E,OAAOC,+BAA+B,qDAAiD;AACvF,OAAOC,mBAAmB,wCAAoC;AAC9D,OAAOC,mBAAmB,yCAA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AAwE;IACxE,mCAAmC;IACnC,MAAMf,eAAe;QACnBC,WAAWc,CAAAA,+BAAAA,WAAa,CAAC,wBAAwB,MAAK;QACtDb,WAAWa,CAAAA,+BAAAA,WAAa,CAAC,mBAAmB,MAAK;IACnD;IACA,0EAA0E;IAC1E,WAAW;IACX,MAAMZ,SAAS;QACbC,SAASW,CAAAA,+BAAAA,WAAa,CAAC,kBAAkB,MAAK;QAC9CV,SAASU,CAAAA,+BAAAA,WAAa,CAAC,uBAAuB,MAAK;IACrD;IAEA;;;;;;GAMC,GACD,IAAI,CAACrB,WAAW,EAACmB,4BAAAA,SAAUI,MAAM,KAAI,CAACH,UAAU,OAAO;IAEvD,qBACE,KAACzF;QAAYwF,UAAUA;kBACpBpB,YAAYC,SAAqCd,QAAQe,cAAcC,KAAKI,cAAcG;;AAGjG;AACAS,oBAAoBM,WAAW,GAAG;AAElC,eAAeN,oBAAmB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/commerce-console-page.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 type { ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { GridItems } from '@aglyn/shared-ui-jsx'\nimport { HubSections } from '@aglyn/shared-ui-next'\nimport { lazy, Suspense, type ReactNode } from 'react'\nimport { Stack } from '@mui/material'\nimport {\n COMMERCE_SETTINGS_PAGE_ZONES,\n type CommerceConsoleSectionId,\n type CommerceSettingsSectionId,\n} from './commerce-console-sections'\nimport CatalogOrganizationCard from './console/catalog-organization-card.component'\nimport CommerceAnalyticsCard from './console/commerce-analytics-card.component'\nimport CurrenciesCard from './console/currencies-card.component'\nimport CustomerNotificationsCard from './console/customer-notifications-card.component'\nimport DiscountsCard from './console/discounts-card.component'\nimport GiftCardsCard from './console/gift-cards-card.component'\nimport HostCouponsCard from './console/host-coupons-card.component'\nimport HostOrdersCard from './console/host-orders-card.component'\nimport HostQuotesCard from './console/host-quotes-card.component'\nimport LocationsCard from './console/locations-card.component'\nimport LocalDeliverySettingsCard from './console/local-delivery-settings-card.component'\nimport PickupDeliveryQueueCard from './console/pickup-delivery-queue-card.component'\nimport MemberPostsCard from './console/member-posts-card.component'\nimport OrderWebhooksCard from './console/order-webhooks-card.component'\nimport PaymentsSettingsCard from './console/payments-settings-card.component'\nimport PosCheckInsCard from './console/pos-ops/pos-check-ins-card.component'\nimport PosDayTotalsCard from './console/pos-ops/pos-day-totals-card.component'\nimport PosShiftHistoryCard from './console/pos-ops/pos-shift-history-card.component'\nimport PosStaffPinsCard from './console/pos-ops/pos-staff-pins-card.component'\nimport PaymentMethodsCard from './console/payment-methods-card.component'\nimport ProductsHubCard from './console/products-hub-card.component'\nimport QuoteSettingsCard from './console/quote-settings-card.component'\nimport RecoveryQueueCard from './console/recovery-queue-card.component'\nimport RegistersCard from './console/registers-card.component'\nimport RegisterHardwareCards from './console/register-hardware-card.component'\nimport PosDevicesCard from './console/pos-devices-card.component'\nimport PosHardwareCard from './console/pos-hardware-card.component'\n\n/**\n * Card readers the workspace bought in person, waiting to be set up\n * (AGL-4038): its own chunk, drawn only while there is one.\n */\nconst PosHardwareWaitingCard = lazy(() => import('./console/pos-hardware-waiting-card.component'))\nimport { holdsPosPermission, posPermissionRefusal } from '../model/plugin-permissions'\nimport ReservationsCard from './console/reservations-card.component'\nimport ReturnSettingsCard from './console/return-settings-card.component'\nimport ReturnsCard from './console/returns-card.component'\nimport ReviewsModerationCard from './console/reviews-moderation-card.component'\nimport ReviewSettingsCard from './console/review-settings-card.component'\nimport ShippingSettingsCard from './console/shipping-settings-card.component'\nimport ShipStationCard from './console/shipstation-card.component'\nimport ShippingEasyCard from './console/shippingeasy-card.component'\nimport StockMovementsCard from './console/stock-movements-card.component'\nimport StoreSettingsCard from './console/store-settings-card.component'\nimport StorefrontTaxSummaryCard from './console/storefront-tax-summary-card.component'\nimport SubscriptionsCard from './console/subscriptions-card.component'\nimport SuppliersCard from './console/suppliers-card.component'\nimport TaxSettingsCard from './console/tax-settings-card.component'\nimport { COMMERCE_PROMOTIONS_ZONE } from './console/store-zones'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\n\n/**\n * A settings page's zone (AGL-3612, AGL-3713): other plugins' settings for\n * the store — label settings, carrier accounts, a tax service — under the\n * page's own cards. One zone per page, from `COMMERCE_SETTINGS_PAGE_ZONES`;\n * Integrations draws `commerceSettings`, where a widget naming no page lands.\n */\nfunction CommerceSettingsZone(props: {\n hostId: string\n page: CommerceSettingsSectionId\n}) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot\n slot={COMMERCE_SETTINGS_PAGE_ZONES[props.page]}\n hostId={props.hostId}\n orgId={undefined}\n />\n ) : null\n}\n\n/** One settings page: its cards in order, then its zone (AGL-3713). */\nfunction settingsPage(\n page: CommerceSettingsSectionId,\n hostId: string,\n cards: readonly ReactNode[],\n): ReactNode {\n return (\n <GridItems\n spacing={3}\n items={[\n ...cards.map((children) => ({ size: { xs: 12 }, children })),\n {\n size: { xs: 12 },\n children: <CommerceSettingsZone hostId={hostId} page={page} />,\n },\n ]}\n />\n )\n}\n\n/**\n * The `commercePromotions` zone (AGL-3640): other plugins' programs beside\n * the store's own money-off surfaces — a rewards program first.\n */\nfunction CommercePromotionsZone(props: { hostId: string }) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot slot={COMMERCE_PROMOTIONS_ZONE.id} hostId={props.hostId} orgId={undefined} />\n ) : null\n}\n\n/**\n * The body of one commerce section, built only when that section is the one\n * being read (AGL-2501).\n *\n * A function rather than a map of nodes on purpose: a `Record<id, ReactNode>`\n * would CONSTRUCT every section every render, and each card opens its Firestore\n * listens on mount — which is the entire cost this page exists to stop paying.\n * Only the returned branch is ever built.\n */\nfunction sectionBody(\n section: CommerceConsoleSectionId,\n hostId: string,\n canManagePos: boolean,\n /** The register's finer keys this page's cards ask (AGL-4047). */\n pos: { canSetUpDevices: boolean; canBuyHardware: boolean; canCashDrawer: boolean } = {\n canSetUpDevices: canManagePos,\n canBuyHardware: canManagePos,\n canCashDrawer: canManagePos,\n },\n /** The reservation keys this site decides for the member (AGL-4047). */\n reservations: { canManage: boolean; canWalkIn: boolean } = { canManage: true, canWalkIn: true },\n /** \"Create and edit quotes\" and \"Send quotes and invoices to customers\" on this site (AGL-4093, AGL-4094). */\n quotes: { canEdit: boolean; canSend: boolean } = { canEdit: true, canSend: true },\n): ReactNode {\n switch (section) {\n case 'catalog':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <ProductsHubCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <CatalogOrganizationCard hostId={hostId} />,\n },\n // The ledger every stock writer fills and nothing displayed\n // (AGL-2341). Directly under the catalog, because the question\n // it answers — \"why does this count disagree with the shelf\" —\n // is asked while looking at the count.\n {\n size: { xs: 12 },\n children: <StockMovementsCard hostId={hostId} />,\n },\n { size: { xs: 12 }, children: <MemberPostsCard hostId={hostId} /> },\n ]}\n />\n )\n case 'orders':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <HostOrdersCard hostId={hostId} canSendInvoices={quotes.canSend} /> },\n // Prices put to a customer before they buy (AGL-4093), beside the\n // orders they become once paid.\n {\n size: { xs: 12 },\n children: <HostQuotesCard hostId={hostId} canEdit={quotes.canEdit} canSend={quotes.canSend} />,\n },\n // What to prepare, hand over and drive out (AGL-3624). Renders\n // nothing for a store with no pickup and no local delivery.\n {\n size: { xs: 12 },\n children: <PickupDeliveryQueueCard hostId={hostId} />,\n },\n // The two queues that feed orders rather than record them\n // (AGL-2227): checkouts that stalled and shoppers waiting on\n // stock. Beneath the orders list because both are pre-order.\n {\n size: { xs: 12 },\n children: <RecoveryQueueCard hostId={hostId} />,\n },\n // One day's or one event's totals across every register, shift\n // and cashier (AGL-4037), above the shifts it adds up.\n {\n size: { xs: 12 },\n children: <PosDayTotalsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n // Who is due at the window and who checked in (AGL-4043), beside\n // the day's totals.\n {\n size: { xs: 12 },\n children: <PosCheckInsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n {\n size: { xs: 12 },\n children: <PosShiftHistoryCard hostId={hostId} />,\n },\n ]}\n />\n )\n case 'subscriptions':\n // Every subscription, its recurring revenue and its invoices (AGL-4191).\n return <SubscriptionsCard hostId={hostId} />\n case 'returns':\n // Returns (AGL-3611); `?return={id}` opens one on arrival.\n return <ReturnsCard hostId={hostId} />\n case 'promotions':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <DiscountsCard hostId={hostId} /> },\n { size: { xs: 12 }, children: <HostCouponsCard hostId={hostId} /> },\n // Store credit lives with the other money-off surfaces\n // (AGL-2226) — it had no console anywhere before this.\n { size: { xs: 12 }, children: <GiftCardsCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <ReviewsModerationCard hostId={hostId} />,\n },\n // Who may review, and the review-request email (AGL-3736),\n // beside the queue those reviews land in.\n {\n size: { xs: 12 },\n children: <ReviewSettingsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <CommercePromotionsZone hostId={hostId} />,\n },\n ]}\n />\n )\n case 'reservations':\n return (\n <ReservationsCard\n hostId={hostId}\n canManage={reservations.canManage}\n canWalkIn={reservations.canWalkIn}\n />\n )\n /*\n * The store's settings, a page each (AGL-3713). They were one `settings`\n * section — every card below in one column — and its old address opens\n * Payments (`COMMERCE_RETIRED_SECTIONS`). Each page is its cards, then\n * the zone where other plugins' cards for that page land.\n */\n case 'payments':\n return settingsPage(section, hostId, [\n <PaymentsSettingsCard key=\"payments\" hostId={hostId} />,\n // What shoppers may pay with (AGL-3629), beside the account the\n // money lands in.\n <PaymentMethodsCard key=\"methods\" hostId={hostId} />,\n ])\n case 'checkout':\n return settingsPage(section, hostId, [\n <StoreSettingsCard key=\"store\" hostId={hostId} />,\n // Which other currencies shoppers see and pay in (AGL-4248), beside\n // the store currency above.\n <CurrenciesCard key=\"currencies\" hostId={hostId} />,\n // Whether buyers may ask for a return online (AGL-3611): the store's\n // policy, beside the terms and guest-checkout rules above it.\n <ReturnSettingsCard key=\"returns\" hostId={hostId} />,\n // What a new quote starts with (AGL-4093).\n <QuoteSettingsCard key=\"quotes\" hostId={hostId} />,\n ])\n case 'taxes':\n return settingsPage(section, hostId, [\n <TaxSettingsCard key=\"tax\" hostId={hostId} />,\n ])\n case 'shipping':\n return settingsPage(section, hostId, [\n <ShippingSettingsCard key=\"shipping\" hostId={hostId} />,\n // Where parcels ship from, and pickup, per location.\n <LocationsCard key=\"locations\" hostId={hostId} />,\n // The store's own delivery (AGL-3624); pickup is per location, on\n // the Inventory locations card above.\n <LocalDeliverySettingsCard key=\"local\" hostId={hostId} />,\n <SuppliersCard key=\"suppliers\" hostId={hostId} />,\n <ShipStationCard key=\"shipstation\" hostId={hostId} />,\n // ShippingEasy, with the merchant's own keys (AGL-3633).\n <ShippingEasyCard key=\"shippingeasy\" hostId={hostId} />,\n ])\n case 'notifications':\n return settingsPage(section, hostId, [\n <CustomerNotificationsCard key=\"customers\" hostId={hostId} />,\n // The store's own endpoints for order events (AGL-3611). Renders\n // nothing for a person who may not manage them.\n <OrderWebhooksCard key=\"webhooks\" hostId={hostId} />,\n ])\n case 'pos':\n return settingsPage(section, hostId, [\n // A reader bought in person waits at the top until it is set up\n // (AGL-4038), in the registers' own grid cell so an empty one\n // leaves no gap.\n <Stack key=\"registers\" spacing={3}>\n <Suspense fallback={null}>\n <PosHardwareWaitingCard\n hostId={hostId}\n {...(pos.canSetUpDevices ? {} : { devicesBlockedReason: posPermissionRefusal('posDevices') })}\n />\n </Suspense>\n <RegistersCard hostId={hostId} />\n </Stack>,\n <PosStaffPinsCard key=\"pins\" hostId={hostId} />,\n // A register's printers, cash drawer and status (AGL-3619), one card\n // per register, after the list that names them.\n <RegisterHardwareCards\n key=\"hardware\"\n hostId={hostId}\n blocked={{\n ...(pos.canSetUpDevices ? {} : { devices: posPermissionRefusal('posDevices') }),\n ...(pos.canCashDrawer ? {} : { drawer: posPermissionRefusal('posCashDrawer') }),\n }}\n />,\n <PosDevicesCard\n key=\"devices\"\n hostId={hostId}\n canManagePos={canManagePos}\n canSetUpDevices={pos.canSetUpDevices}\n />,\n // Card readers bought from the platform (AGL-4038), after the card\n // that registers them. Draws nothing until the deployment opens the\n // shop.\n <PosHardwareCard\n key=\"hardware-shop\"\n hostId={hostId}\n canManagePos={canManagePos}\n canBuyHardware={pos.canBuyHardware}\n />,\n ])\n case 'channels':\n case 'integrations':\n // Other plugins' cards only; the rail leaves either page out while\n // its zone has nothing to draw (`onlyWithZones`).\n return settingsPage(section, hostId, [])\n case 'analytics':\n return (\n // Two cards since AGL-2440. The tax summary lives here rather\n // than on the Taxes settings page because that page CONFIGURES tax and\n // this REPORTS what was collected — a merchant reading a figure\n // they may file from should not be one field away from changing\n // the rate that produced it.\n <GridItems\n spacing={3}\n items={[\n {\n size: { xs: 12 },\n children: <CommerceAnalyticsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <StorefrontTaxSummaryCard hostId={hostId} />,\n },\n ]}\n />\n )\n default:\n return null\n }\n}\n\n/**\n * Commerce console page (AGL-395): the Products management surface, owned by\n * the commerce plugin and rendered by the shell's generic plugin route. The\n * product editor's media browser is supplied by the shell's\n * ConsoleMediaPickerProvider (the media library is org/session coupled and\n * stays in the app).\n *\n * ## Sections are ROUTES (AGL-2501)\n *\n * The sections hold thirty-two Firestore listens between them, and a tab\n * strip mounts every panel: opening Catalog also subscribed the orders,\n * promotions, reservations, settings and analytics cards. The `limit()` on\n * those queries is the bill — several ask for 500, and one load reached a\n * ceiling of ~4,460 documents to render one tab.\n *\n * `HubTabs lazy` bought that back as a flag somebody has to remember. A URL\n * per section makes it structural instead: the page builds one section's body\n * and the others do not exist to subscribe. Three things come with it that the\n * tab version faked — a section is linkable, the back button walks sections,\n * and which one is open is a fact about the URL rather than state kept in sync\n * with it. `commerce-console-read-cost.spec.tsx` meters it at the Firestore\n * boundary and refuses a section that listens before it is opened.\n *\n * The shell resolves the section, gates it and hands back the rail's hrefs;\n * this page only has to say what each section contains.\n */\nexport function CommerceConsolePage(props: ConsolePluginPageProps) {\n const { hostId, section, sections, basePath, permissions } = props\n /*\n * The register's own gate, for the devices card's Pair display (AGL-3712):\n * `managePos` — what the server's `mayWorkRegister` asks. The key decides,\n * not the site role (AGL-4047). The server stays the enforcement point.\n */\n const canManagePos = permissions?.managePos === true\n // The register's finer keys (AGL-4047), each following `managePos` unless a\n // role or the member sets it — what the devices and hardware routes ask.\n // Buying hardware stands on its own: the Hardware card is this page's for a\n // member who holds it without the register.\n const pos = {\n canSetUpDevices: canManagePos && holdsPosPermission(permissions, 'posDevices'),\n canBuyHardware: holdsPosPermission(permissions, 'posBuyHardware'),\n canCashDrawer: canManagePos && holdsPosPermission(permissions, 'posCashDrawer'),\n }\n // The reservation keys (AGL-4047), whose preset is the member's role on\n // this site; the shell decides them for the site in view. A map that does\n // not carry one (a shell that predates them) leaves the card as it was:\n // the rules and the routes decide.\n const reservations = {\n canManage: permissions?.['commerce.reservations'] !== false,\n canWalkIn: permissions?.['commerce.walkIns'] !== false,\n }\n // \"Create and edit quotes\" (AGL-4093), read the same way; the quote route\n // decides.\n const quotes = {\n canEdit: permissions?.['commerce.quotes'] !== false,\n canSend: permissions?.['commerce.quotes.send'] !== false,\n }\n\n /*\n * Nothing, deliberately, while the redirect is in flight.\n *\n * Rendering the default section here instead would issue that section's\n * listens on a URL that is about to be replaced — paying for Catalog on\n * every arrival at `/products`, which is every click of the nav tab.\n */\n if (!section || !sections?.length || !basePath) return null\n\n return (\n <HubSections sections={sections}>\n {sectionBody(section as CommerceConsoleSectionId, hostId, canManagePos, pos, reservations, quotes)}\n </HubSections>\n )\n}\nCommerceConsolePage.displayName = 'CommerceConsolePage'\n\nexport default CommerceConsolePage\n"],"names":["GridItems","HubSections","lazy","Suspense","Stack","COMMERCE_SETTINGS_PAGE_ZONES","CatalogOrganizationCard","CommerceAnalyticsCard","CurrenciesCard","CustomerNotificationsCard","DiscountsCard","GiftCardsCard","HostCouponsCard","HostOrdersCard","HostQuotesCard","LocationsCard","LocalDeliverySettingsCard","PickupDeliveryQueueCard","MemberPostsCard","OrderWebhooksCard","PaymentsSettingsCard","PosCheckInsCard","PosDayTotalsCard","PosShiftHistoryCard","PosStaffPinsCard","PaymentMethodsCard","ProductsHubCard","QuoteSettingsCard","RecoveryQueueCard","RegistersCard","RegisterHardwareCards","PosDevicesCard","PosHardwareCard","PosHardwareWaitingCard","holdsPosPermission","posPermissionRefusal","ReservationsCard","ReturnSettingsCard","ReturnsCard","ReviewsModerationCard","ReviewSettingsCard","ShippingSettingsCard","ShipStationCard","ShippingEasyCard","StockMovementsCard","StoreSettingsCard","StorefrontTaxSummaryCard","SubscriptionsCard","SuppliersCard","TaxSettingsCard","COMMERCE_PROMOTIONS_ZONE","useConsoleWidgetSlot","CommerceSettingsZone","props","WidgetSlot","slot","page","hostId","orgId","undefined","settingsPage","cards","spacing","items","map","children","size","xs","CommercePromotionsZone","id","sectionBody","section","canManagePos","pos","canSetUpDevices","canBuyHardware","canCashDrawer","reservations","canManage","canWalkIn","quotes","canEdit","canSend","canSendInvoices","fallback","devicesBlockedReason","blocked","devices","drawer","CommerceConsolePage","sections","basePath","permissions","managePos","length","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAAQ,uBAAsB;AAChD,SAASC,WAAW,QAAQ,wBAAuB;AACnD,SAASC,IAAI,EAAEC,QAAQ,QA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GAAGvC;IAC7D;;;;GAIC,GACD,MAAMmB,eAAeoB,CAAAA,+BAAAA,YAAaC,SAAS,MAAK;IAChD,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,4CAA4C;IAC5C,MAAMpB,MAAM;QACVC,iBAAiBF,gBAAgBtC,mBAAmB0D,aAAa;QACjEjB,gBAAgBzC,mBAAmB0D,aAAa;QAChDhB,eAAeJ,gBAAgBtC,mBAAmB0D,aAAa;IACjE;IACA,wEAAwE;IACxE,0EAA0E;IAC1E,wEAAwE;IACxE,mCAAmC;IACnC,MAAMf,eAAe;QACnBC,WAAWc,CAAAA,+BAAAA,WAAa,CAAC,wBAAwB,MAAK;QACtDb,WAAWa,CAAAA,+BAAAA,WAAa,CAAC,mBAAmB,MAAK;IACnD;IACA,0EAA0E;IAC1E,WAAW;IACX,MAAMZ,SAAS;QACbC,SAASW,CAAAA,+BAAAA,WAAa,CAAC,kBAAkB,MAAK;QAC9CV,SAASU,CAAAA,+BAAAA,WAAa,CAAC,uBAAuB,MAAK;IACrD;IAEA;;;;;;GAMC,GACD,IAAI,CAACrB,WAAW,EAACmB,4BAAAA,SAAUI,MAAM,KAAI,CAACH,UAAU,OAAO;IAEvD,qBACE,KAAC1F;QAAYyF,UAAUA;kBACpBpB,YAAYC,SAAqCd,QAAQe,cAAcC,KAAKI,cAAcG;;AAGjG;AACAS,oBAAoBM,WAAW,GAAG;AAElC,eAAeN,oBAAmB"}
@@ -0,0 +1,21 @@
1
+ export interface CurrenciesCardProps {
2
+ hostId: string;
3
+ }
4
+ /**
5
+ * Currencies (AGL-4248), beside Store settings: which other currencies the
6
+ * store sells in, the rate each converts at (daily, or a manual one), its
7
+ * price adjustment and rounding (off until turned on, as on Shopify), whether
8
+ * its prices include tax, and whether shoppers get their own currency from
9
+ * where they browse. Stored on `hosts/{hostId}/settings/store` under
10
+ * `currencies`; the storefront and checkout read it through
11
+ * `GET commerce/currency`.
12
+ *
13
+ * Same write guard as Store settings (AGL-1358): `currencies.currencies` is
14
+ * an array, and a merge replaces an array wholesale, so a save from a seed
15
+ * the server never confirmed would put a stale list back.
16
+ */
17
+ export declare function CurrenciesCard(props: CurrenciesCardProps): import("react").JSX.Element;
18
+ export declare namespace CurrenciesCard {
19
+ var displayName: string;
20
+ }
21
+ export default CurrenciesCard;
@@ -0,0 +1,408 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
19
+ import { CardDisplay } from "@aglyn/shared-ui-jsx";
20
+ import { useSnackbar } from "@aglyn/shared-ui-snackstack";
21
+ import { Box, Button, Divider, FormControlLabel, IconButton, MenuItem, Stack, Switch, TextField, Typography } from "@mui/material";
22
+ import { doc } from "firebase/firestore";
23
+ import { useCallback, useState } from "react";
24
+ import { pluginDocsHelp } from "@aglyn/aglyn";
25
+ import { useFirestore, useFirestoreDoc, useUser, writeGuardedBySeed } from "@aglyn/tenant-feature-instance";
26
+ import { writeSiteWideChange } from "@aglyn/tenant-feature-instance/hooks/helpers/site-wide-change";
27
+ import { heldSaveLabel, isSeedChecking, seedCheckingText, useHeldSave, useSeedEdits } from "@aglyn/tenant-feature-instance/hooks/use-seed-edits";
28
+ import * as CommerceModel from "../../model/index.js";
29
+ import { useCurrencySetup } from "./use-currency-setup.js";
30
+ /** The price each currency's preview converts: 250 of the store currency. */ const SAMPLE_MAJOR = 250;
31
+ /**
32
+ * Currencies (AGL-4248), beside Store settings: which other currencies the
33
+ * store sells in, the rate each converts at (daily, or a manual one), its
34
+ * price adjustment and rounding (off until turned on, as on Shopify), whether
35
+ * its prices include tax, and whether shoppers get their own currency from
36
+ * where they browse. Stored on `hosts/{hostId}/settings/store` under
37
+ * `currencies`; the storefront and checkout read it through
38
+ * `GET commerce/currency`.
39
+ *
40
+ * Same write guard as Store settings (AGL-1358): `currencies.currencies` is
41
+ * an array, and a merge replaces an array wholesale, so a save from a seed
42
+ * the server never confirmed would put a stale list back.
43
+ */ export function CurrenciesCard(props) {
44
+ var _ref, _saved_currencies, _current_currencies;
45
+ const { hostId } = props;
46
+ const firestore = useFirestore();
47
+ const { data: user } = useUser();
48
+ const { enqueueSnackbar } = useSnackbar();
49
+ const { data: store, status: storeStatus, fromCache: storeFromCache, listen: storeListen } = useFirestoreDoc(()=>doc(firestore, 'hosts', hostId, 'settings', 'store'), [
50
+ firestore,
51
+ hostId
52
+ ]);
53
+ const base = CommerceModel.storeBaseCurrency(store);
54
+ const saved = (_ref = store == null ? void 0 : store.currencies) != null ? _ref : {};
55
+ const form = useSeedEdits({
56
+ enabled: saved.enabled === true,
57
+ currencies: (_saved_currencies = saved.currencies) != null ? _saved_currencies : [],
58
+ autoDetect: saved.autoDetect !== false
59
+ });
60
+ const current = form.values;
61
+ const list = (_current_currencies = current.currencies) != null ? _current_currencies : [];
62
+ const checking = isSeedChecking({
63
+ fromCache: storeFromCache,
64
+ unreadable: storeStatus === 'error'
65
+ });
66
+ const { rates } = useCurrencySetup(hostId);
67
+ const [adding, setAdding] = useState('');
68
+ const setEntry = (index, patch)=>{
69
+ const next = [
70
+ ...list
71
+ ];
72
+ if (patch === null) next.splice(index, 1);
73
+ else next[index] = _extends({}, next[index], patch);
74
+ form.edit({
75
+ currencies: next
76
+ });
77
+ };
78
+ // A whole entry, for a field whose clearing removes a key.
79
+ const replaceEntry = (index, entry)=>form.edit({
80
+ currencies: list.map((was, at)=>at === index ? entry : was)
81
+ });
82
+ const addCurrency = (code)=>{
83
+ if (!code) return;
84
+ form.edit({
85
+ currencies: [
86
+ ...list,
87
+ CommerceModel.newStoreCurrency(code)
88
+ ]
89
+ });
90
+ setAdding('');
91
+ };
92
+ const addable = CommerceModel.addableCurrencies(base, list.map((entry)=>entry.code));
93
+ const handleSave = useCallback(async ()=>{
94
+ const written = form.edits;
95
+ const verdict = await writeGuardedBySeed({
96
+ subject: 'currencies',
97
+ unreadable: storeStatus === 'error',
98
+ fromCache: storeFromCache,
99
+ listen: storeListen
100
+ }, async ()=>{
101
+ // Prices on the live store change with no publish step, so the save
102
+ // carries the site's cache drop with it, as Store settings does.
103
+ await writeSiteWideChange({
104
+ firestore,
105
+ user,
106
+ hostId,
107
+ write: (batch)=>{
108
+ var _current_currencies;
109
+ return batch.set(doc(firestore, 'hosts', hostId, 'settings', 'store'), {
110
+ currencies: {
111
+ enabled: current.enabled === true,
112
+ currencies: ((_current_currencies = current.currencies) != null ? _current_currencies : []).map((entry)=>{
113
+ var _entry_rounding, _entry_bufferPct;
114
+ return _extends({
115
+ code: entry.code,
116
+ rounding: (_entry_rounding = entry.rounding) != null ? _entry_rounding : 'none',
117
+ bufferPct: CommerceModel.clampAdjustmentInput(String((_entry_bufferPct = entry.bufferPct) != null ? _entry_bufferPct : 0))
118
+ }, entry.manualRate && entry.manualRate > 0 ? {
119
+ manualRate: entry.manualRate
120
+ } : {}, {
121
+ pricesIncludeTax: entry.pricesIncludeTax === true
122
+ });
123
+ }),
124
+ autoDetect: current.autoDetect !== false
125
+ }
126
+ }, {
127
+ merge: true
128
+ });
129
+ }
130
+ });
131
+ });
132
+ if (!verdict.ok) {
133
+ return void enqueueSnackbar(verdict.message, {
134
+ variant: 'warning',
135
+ persist: false
136
+ });
137
+ }
138
+ form.settle(written);
139
+ enqueueSnackbar('Currencies saved', {
140
+ variant: 'success',
141
+ persist: false
142
+ });
143
+ }, [
144
+ current,
145
+ form,
146
+ firestore,
147
+ hostId,
148
+ user,
149
+ enqueueSnackbar,
150
+ storeStatus,
151
+ storeFromCache,
152
+ storeListen
153
+ ]);
154
+ const held = useHeldSave(handleSave, {
155
+ checking,
156
+ subject: 'currencies',
157
+ onRefused: (message)=>enqueueSnackbar(message, {
158
+ variant: 'warning',
159
+ persist: false
160
+ })
161
+ });
162
+ const sampleMinor = CommerceModel.majorToMinor(SAMPLE_MAJOR, base);
163
+ return /*#__PURE__*/ _jsx(CardDisplay, {
164
+ header: 'Currencies',
165
+ help: pluginDocsHelp('currencies'),
166
+ contentGutterX: true,
167
+ contentGutterY: true,
168
+ children: /*#__PURE__*/ _jsxs(Stack, {
169
+ spacing: 1.5,
170
+ children: [
171
+ /*#__PURE__*/ _jsx(FormControlLabel, {
172
+ control: /*#__PURE__*/ _jsx(Switch, {
173
+ size: "small",
174
+ checked: current.enabled === true,
175
+ onChange: (event)=>form.edit({
176
+ enabled: event.target.checked
177
+ })
178
+ }),
179
+ label: "Sell in other currencies"
180
+ }),
181
+ /*#__PURE__*/ _jsx(Typography, {
182
+ variant: "caption",
183
+ color: "text.secondary",
184
+ children: `Shoppers see and pay prices in their own currency. Stripe converts each payment and ` + `pays you in ${base}, less its conversion fee.`
185
+ }),
186
+ current.enabled ? /*#__PURE__*/ _jsxs(_Fragment, {
187
+ children: [
188
+ /*#__PURE__*/ _jsx(Typography, {
189
+ variant: "body2",
190
+ color: "text.secondary",
191
+ "data-testid": "currency-rates-updated",
192
+ children: (rates == null ? void 0 : rates.asOfMs) ? `Rates updated ${CommerceModel.ratesAsOfLabel(rates)} (European Central Bank, daily)` : 'Daily rates are not in yet: a currency without a manual rate sells in ' + base + ' until they are.'
193
+ }),
194
+ list.map((entry, index)=>{
195
+ var _entry_rounding, _entry_rounding1;
196
+ return /*#__PURE__*/ _jsxs(Box, {
197
+ children: [
198
+ /*#__PURE__*/ _jsx(Divider, {
199
+ sx: {
200
+ mb: 1.5
201
+ }
202
+ }),
203
+ /*#__PURE__*/ _jsxs(Stack, {
204
+ spacing: 1,
205
+ children: [
206
+ /*#__PURE__*/ _jsxs(Stack, {
207
+ direction: "row",
208
+ spacing: 1,
209
+ sx: {
210
+ alignItems: 'center'
211
+ },
212
+ children: [
213
+ /*#__PURE__*/ _jsx(Typography, {
214
+ variant: "subtitle2",
215
+ sx: {
216
+ flex: 1
217
+ },
218
+ children: CommerceModel.currencyOptionLabel(entry.code)
219
+ }),
220
+ /*#__PURE__*/ _jsx(IconButton, {
221
+ size: "small",
222
+ "aria-label": `Remove ${entry.code}`,
223
+ onClick: ()=>setEntry(index, null),
224
+ children: '✕'
225
+ })
226
+ ]
227
+ }),
228
+ /*#__PURE__*/ _jsx(Typography, {
229
+ variant: "body2",
230
+ color: "text.secondary",
231
+ "data-testid": `currency-rate-${entry.code}`,
232
+ children: CommerceModel.currencyRateLabel(rates, base, entry)
233
+ }),
234
+ /*#__PURE__*/ _jsxs(Stack, {
235
+ direction: {
236
+ xs: 'column',
237
+ sm: 'row'
238
+ },
239
+ spacing: 1,
240
+ children: [
241
+ /*#__PURE__*/ _jsx(TextField, {
242
+ label: `Manual exchange rate (${entry.code})`,
243
+ // Kept as typed until the field is left (as below).
244
+ defaultValue: entry.manualRate ? String(entry.manualRate) : '',
245
+ placeholder: "Daily rate",
246
+ onBlur: (event)=>{
247
+ const manualRate = CommerceModel.parseManualRateInput(event.target.value);
248
+ const next = _extends({}, entry);
249
+ if (manualRate) next.manualRate = manualRate;
250
+ else delete next.manualRate;
251
+ replaceEntry(index, next);
252
+ },
253
+ size: "small",
254
+ sx: {
255
+ minWidth: 220
256
+ },
257
+ helperText: `${base} 1 = ${entry.code} this much. Blank uses the ${CommerceModel.dailyRateLabel(rates, base, entry.code).replace(/^Daily rate/, 'daily rate')}`,
258
+ slotProps: {
259
+ htmlInput: {
260
+ inputMode: 'decimal'
261
+ }
262
+ }
263
+ }),
264
+ /*#__PURE__*/ _jsx(TextField, {
265
+ label: `Price adjustment (%) (${entry.code})`,
266
+ // Kept as typed until the field is left, so "2.5" can
267
+ // be typed through "2." without the dot being eaten.
268
+ defaultValue: entry.bufferPct ? String(entry.bufferPct) : '',
269
+ placeholder: "0",
270
+ onBlur: (event)=>setEntry(index, {
271
+ bufferPct: CommerceModel.clampAdjustmentInput(event.target.value)
272
+ }),
273
+ size: "small",
274
+ sx: {
275
+ minWidth: 220
276
+ },
277
+ helperText: '-90 to +100. Stripe’s currency conversion fee (about 1–2%) comes out of your ' + 'payout unless you raise prices here.',
278
+ slotProps: {
279
+ htmlInput: {
280
+ inputMode: 'decimal'
281
+ }
282
+ }
283
+ })
284
+ ]
285
+ }),
286
+ /*#__PURE__*/ _jsxs(Stack, {
287
+ direction: {
288
+ xs: 'column',
289
+ sm: 'row'
290
+ },
291
+ spacing: 1,
292
+ sx: {
293
+ alignItems: {
294
+ sm: 'center'
295
+ }
296
+ },
297
+ children: [
298
+ /*#__PURE__*/ _jsx(FormControlLabel, {
299
+ control: /*#__PURE__*/ _jsx(Switch, {
300
+ size: "small",
301
+ checked: ((_entry_rounding = entry.rounding) != null ? _entry_rounding : 'none') !== 'none',
302
+ onChange: (event)=>setEntry(index, {
303
+ rounding: event.target.checked ? '99' : 'none'
304
+ })
305
+ }),
306
+ label: `Round converted prices (${entry.code})`
307
+ }),
308
+ ((_entry_rounding1 = entry.rounding) != null ? _entry_rounding1 : 'none') !== 'none' ? /*#__PURE__*/ _jsx(TextField, {
309
+ label: `Round up to (${entry.code})`,
310
+ value: entry.rounding,
311
+ onChange: (event)=>setEntry(index, {
312
+ rounding: event.target.value
313
+ }),
314
+ size: "small",
315
+ select: true,
316
+ sx: {
317
+ minWidth: 220
318
+ },
319
+ children: CommerceModel.CURRENCY_ROUNDING_ENDINGS.map((value)=>/*#__PURE__*/ _jsx(MenuItem, {
320
+ value: value,
321
+ children: CommerceModel.CURRENCY_ROUNDING_LABELS[value]
322
+ }, value))
323
+ }) : null
324
+ ]
325
+ }),
326
+ /*#__PURE__*/ _jsx(FormControlLabel, {
327
+ control: /*#__PURE__*/ _jsx(Switch, {
328
+ size: "small",
329
+ checked: entry.pricesIncludeTax === true,
330
+ onChange: (event)=>setEntry(index, {
331
+ pricesIncludeTax: event.target.checked
332
+ })
333
+ }),
334
+ label: `Prices in ${entry.code} include tax`
335
+ }),
336
+ /*#__PURE__*/ _jsx(Typography, {
337
+ variant: "caption",
338
+ color: "text.secondary",
339
+ children: 'For shoppers who expect VAT or GST in the price. Tax is worked out by Stripe Tax, ' + 'so it needs a Stripe Tax registration in each country that pays in this currency.'
340
+ }),
341
+ /*#__PURE__*/ _jsx(Typography, {
342
+ variant: "body2",
343
+ "data-testid": `currency-preview-${entry.code}`,
344
+ children: CommerceModel.currencyPreviewText(sampleMinor, base, entry, rates)
345
+ })
346
+ ]
347
+ })
348
+ ]
349
+ }, entry.code);
350
+ }),
351
+ /*#__PURE__*/ _jsx(Divider, {}),
352
+ /*#__PURE__*/ _jsx(TextField, {
353
+ label: "Add a currency",
354
+ value: adding,
355
+ onChange: (event)=>addCurrency(event.target.value),
356
+ size: "small",
357
+ select: true,
358
+ sx: {
359
+ maxWidth: 320
360
+ },
361
+ disabled: !addable.length,
362
+ children: addable.map((code)=>/*#__PURE__*/ _jsx(MenuItem, {
363
+ value: code,
364
+ children: CommerceModel.currencyOptionLabel(code)
365
+ }, code))
366
+ }),
367
+ /*#__PURE__*/ _jsx(FormControlLabel, {
368
+ control: /*#__PURE__*/ _jsx(Switch, {
369
+ size: "small",
370
+ checked: current.autoDetect !== false,
371
+ onChange: (event)=>form.edit({
372
+ autoDetect: event.target.checked
373
+ })
374
+ }),
375
+ label: "Show each shopper prices in their own currency, picked from where they are browsing"
376
+ }),
377
+ /*#__PURE__*/ _jsx(Typography, {
378
+ variant: "caption",
379
+ color: "text.secondary",
380
+ children: 'Shoppers can always switch with the Currency selector element; add it to your header ' + 'or footer in the Besigner. Rates are the European Central Bank’s, updated daily. Set a ' + 'fixed price in a currency on a product, add-on or shipping rate to skip conversion.'
381
+ })
382
+ ]
383
+ }) : null,
384
+ /*#__PURE__*/ _jsx(Button, {
385
+ variant: "contained",
386
+ color: "primary",
387
+ size: "small",
388
+ disabled: !form.dirty || held.saving,
389
+ onClick: held.press,
390
+ sx: {
391
+ alignSelf: 'flex-start'
392
+ },
393
+ children: heldSaveLabel(held, 'Save currencies')
394
+ }),
395
+ form.dirty && checking ? /*#__PURE__*/ _jsx(Typography, {
396
+ variant: "body2",
397
+ color: "text.secondary",
398
+ role: "status",
399
+ children: seedCheckingText('currencies')
400
+ }) : null
401
+ ]
402
+ })
403
+ });
404
+ }
405
+ CurrenciesCard.displayName = 'CurrenciesCard';
406
+ export default CurrenciesCard;
407
+
408
+ //# sourceMappingURL=currencies-card.component.js.map