@aglyn/plugins-commerce 1.0.0-beta.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +10 -0
- package/package.json +57 -0
- package/src/index.d.ts +38 -0
- package/src/index.js +38 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/account.d.ts +31 -0
- package/src/lib/components/account.js +645 -0
- package/src/lib/components/account.js.map +1 -0
- package/src/lib/components/cart.d.ts +38 -0
- package/src/lib/components/cart.js +851 -0
- package/src/lib/components/cart.js.map +1 -0
- package/src/lib/components/commerce-console-page.d.ts +32 -0
- package/src/lib/components/commerce-console-page.js +296 -0
- package/src/lib/components/commerce-console-page.js.map +1 -0
- package/src/lib/components/commerce-console-sections.d.ts +34 -0
- package/src/lib/components/commerce-console-sections.js +62 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -0
- package/src/lib/components/console/catalog-organization-card.component.d.ts +14 -0
- package/src/lib/components/console/catalog-organization-card.component.js +1087 -0
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -0
- package/src/lib/components/console/commerce-analytics-card.component.d.ts +27 -0
- package/src/lib/components/console/commerce-analytics-card.component.js +310 -0
- package/src/lib/components/console/commerce-analytics-card.component.js.map +1 -0
- package/src/lib/components/console/commerce-glance-card.component.d.ts +20 -0
- package/src/lib/components/console/commerce-glance-card.component.js +340 -0
- package/src/lib/components/console/commerce-glance-card.component.js.map +1 -0
- package/src/lib/components/console/commerce-stat-tile.component.d.ts +37 -0
- package/src/lib/components/console/commerce-stat-tile.component.js +72 -0
- package/src/lib/components/console/commerce-stat-tile.component.js.map +1 -0
- package/src/lib/components/console/discounts-card.component.d.ts +14 -0
- package/src/lib/components/console/discounts-card.component.js +443 -0
- package/src/lib/components/console/discounts-card.component.js.map +1 -0
- package/src/lib/components/console/entitlement-gate.component.d.ts +76 -0
- package/src/lib/components/console/entitlement-gate.component.js +115 -0
- package/src/lib/components/console/entitlement-gate.component.js.map +1 -0
- package/src/lib/components/console/gift-cards-card.component.d.ts +29 -0
- package/src/lib/components/console/gift-cards-card.component.js +379 -0
- package/src/lib/components/console/gift-cards-card.component.js.map +1 -0
- package/src/lib/components/console/host-coupons-card.component.d.ts +14 -0
- package/src/lib/components/console/host-coupons-card.component.js +252 -0
- package/src/lib/components/console/host-coupons-card.component.js.map +1 -0
- package/src/lib/components/console/host-orders-card.component.d.ts +13 -0
- package/src/lib/components/console/host-orders-card.component.js +861 -0
- package/src/lib/components/console/host-orders-card.component.js.map +1 -0
- package/src/lib/components/console/locations-card.component.d.ts +14 -0
- package/src/lib/components/console/locations-card.component.js +256 -0
- package/src/lib/components/console/locations-card.component.js.map +1 -0
- package/src/lib/components/console/member-posts-card.component.d.ts +8 -0
- package/src/lib/components/console/member-posts-card.component.js +283 -0
- package/src/lib/components/console/member-posts-card.component.js.map +1 -0
- package/src/lib/components/console/newest-site-users-card.component.d.ts +36 -0
- package/src/lib/components/console/newest-site-users-card.component.js +126 -0
- package/src/lib/components/console/newest-site-users-card.component.js.map +1 -0
- package/src/lib/components/console/order-detail-dialog.component.d.ts +28 -0
- package/src/lib/components/console/order-detail-dialog.component.js +976 -0
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/paid-media.d.ts +127 -0
- package/src/lib/components/console/paid-media.js +397 -0
- package/src/lib/components/console/paid-media.js.map +1 -0
- package/src/lib/components/console/payments-settings-card.component.d.ts +13 -0
- package/src/lib/components/console/payments-settings-card.component.js +295 -0
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -0
- package/src/lib/components/console/pos-page.component.d.ts +13 -0
- package/src/lib/components/console/pos-page.component.js +916 -0
- package/src/lib/components/console/pos-page.component.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.d.ts +32 -0
- package/src/lib/components/console/product-editor-dialog.component.js +1374 -0
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -0
- package/src/lib/components/console/products-hub-card.component.d.ts +16 -0
- package/src/lib/components/console/products-hub-card.component.js +1280 -0
- package/src/lib/components/console/products-hub-card.component.js.map +1 -0
- package/src/lib/components/console/products-hub-zone.component.d.ts +50 -0
- package/src/lib/components/console/products-hub-zone.component.js +200 -0
- package/src/lib/components/console/products-hub-zone.component.js.map +1 -0
- package/src/lib/components/console/recovery-queue-card.component.d.ts +39 -0
- package/src/lib/components/console/recovery-queue-card.component.js +262 -0
- package/src/lib/components/console/recovery-queue-card.component.js.map +1 -0
- package/src/lib/components/console/registers-card.component.d.ts +21 -0
- package/src/lib/components/console/registers-card.component.js +296 -0
- package/src/lib/components/console/registers-card.component.js.map +1 -0
- package/src/lib/components/console/reservations-card.component.d.ts +14 -0
- package/src/lib/components/console/reservations-card.component.js +650 -0
- package/src/lib/components/console/reservations-card.component.js.map +1 -0
- package/src/lib/components/console/reviews-moderation-card.component.d.ts +8 -0
- package/src/lib/components/console/reviews-moderation-card.component.js +235 -0
- package/src/lib/components/console/reviews-moderation-card.component.js.map +1 -0
- package/src/lib/components/console/shipping-settings-card.component.d.ts +38 -0
- package/src/lib/components/console/shipping-settings-card.component.js +560 -0
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -0
- package/src/lib/components/console/stock-movements-card.component.d.ts +31 -0
- package/src/lib/components/console/stock-movements-card.component.js +333 -0
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -0
- package/src/lib/components/console/store-settings-card.component.d.ts +14 -0
- package/src/lib/components/console/store-settings-card.component.js +300 -0
- package/src/lib/components/console/store-settings-card.component.js.map +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.d.ts +73 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js +408 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -0
- package/src/lib/components/console/suppliers-card.component.d.ts +8 -0
- package/src/lib/components/console/suppliers-card.component.js +328 -0
- package/src/lib/components/console/suppliers-card.component.js.map +1 -0
- package/src/lib/components/console/tax-settings-card.component.d.ts +14 -0
- package/src/lib/components/console/tax-settings-card.component.js +473 -0
- package/src/lib/components/console/tax-settings-card.component.js.map +1 -0
- package/src/lib/components/gate.d.ts +39 -0
- package/src/lib/components/gate.js +202 -0
- package/src/lib/components/gate.js.map +1 -0
- package/src/lib/components/gated-video.d.ts +40 -0
- package/src/lib/components/gated-video.js +366 -0
- package/src/lib/components/gated-video.js.map +1 -0
- package/src/lib/components/member-feed.d.ts +32 -0
- package/src/lib/components/member-feed.js +198 -0
- package/src/lib/components/member-feed.js.map +1 -0
- package/src/lib/components/member-recovery.d.ts +35 -0
- package/src/lib/components/member-recovery.js +313 -0
- package/src/lib/components/member-recovery.js.map +1 -0
- package/src/lib/components/member-signin.d.ts +35 -0
- package/src/lib/components/member-signin.js +257 -0
- package/src/lib/components/member-signin.js.map +1 -0
- package/src/lib/components/member-signup.d.ts +34 -0
- package/src/lib/components/member-signup.js +287 -0
- package/src/lib/components/member-signup.js.map +1 -0
- package/src/lib/components/newsletter-signup.d.ts +39 -0
- package/src/lib/components/newsletter-signup.js +229 -0
- package/src/lib/components/newsletter-signup.js.map +1 -0
- package/src/lib/components/product-detail.d.ts +38 -0
- package/src/lib/components/product-detail.js +1022 -0
- package/src/lib/components/product-detail.js.map +1 -0
- package/src/lib/components/product-grid.d.ts +67 -0
- package/src/lib/components/product-grid.js +909 -0
- package/src/lib/components/product-grid.js.map +1 -0
- package/src/lib/components/product-reviews.d.ts +32 -0
- package/src/lib/components/product-reviews.js +349 -0
- package/src/lib/components/product-reviews.js.map +1 -0
- package/src/lib/components/related-products.d.ts +33 -0
- package/src/lib/components/related-products.js +232 -0
- package/src/lib/components/related-products.js.map +1 -0
- package/src/lib/components/reservation-widget.d.ts +33 -0
- package/src/lib/components/reservation-widget.js +418 -0
- package/src/lib/components/reservation-widget.js.map +1 -0
- package/src/lib/components/storefront-payment-element-fallback.d.ts +18 -0
- package/src/lib/components/storefront-payment-element-fallback.js +51 -0
- package/src/lib/components/storefront-payment-element-fallback.js.map +1 -0
- package/src/lib/components/storefront-payment-element.d.ts +78 -0
- package/src/lib/components/storefront-payment-element.js +156 -0
- package/src/lib/components/storefront-payment-element.js.map +1 -0
- package/src/lib/components/wishlist.d.ts +46 -0
- package/src/lib/components/wishlist.js +304 -0
- package/src/lib/components/wishlist.js.map +1 -0
- package/src/lib/constants/bundle-common.d.ts +18 -0
- package/src/lib/constants/bundle-common.js +18 -0
- package/src/lib/constants/bundle-common.js.map +1 -0
- package/src/lib/constants/product-filters.d.ts +35 -0
- package/src/lib/constants/product-filters.js +109 -0
- package/src/lib/constants/product-filters.js.map +1 -0
- package/src/lib/model/commerce-cart.d.ts +52 -0
- package/src/lib/model/commerce-cart.js +102 -0
- package/src/lib/model/commerce-cart.js.map +1 -0
- package/src/lib/model/commerce-connect-transfer.d.ts +243 -0
- package/src/lib/model/commerce-connect-transfer.js +231 -0
- package/src/lib/model/commerce-connect-transfer.js.map +1 -0
- package/src/lib/model/commerce-discounts.d.ts +164 -0
- package/src/lib/model/commerce-discounts.js +231 -0
- package/src/lib/model/commerce-discounts.js.map +1 -0
- package/src/lib/model/commerce-dispute.d.ts +124 -0
- package/src/lib/model/commerce-dispute.js +225 -0
- package/src/lib/model/commerce-dispute.js.map +1 -0
- package/src/lib/model/commerce-gift-cards.d.ts +107 -0
- package/src/lib/model/commerce-gift-cards.js +121 -0
- package/src/lib/model/commerce-gift-cards.js.map +1 -0
- package/src/lib/model/commerce-io.d.ts +36 -0
- package/src/lib/model/commerce-io.js +245 -0
- package/src/lib/model/commerce-io.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +1040 -0
- package/src/lib/model/commerce-orders.js +1022 -0
- package/src/lib/model/commerce-orders.js.map +1 -0
- package/src/lib/model/commerce-promotions.d.ts +188 -0
- package/src/lib/model/commerce-promotions.js +199 -0
- package/src/lib/model/commerce-promotions.js.map +1 -0
- package/src/lib/model/commerce-reservations.d.ts +175 -0
- package/src/lib/model/commerce-reservations.js +157 -0
- package/src/lib/model/commerce-reservations.js.map +1 -0
- package/src/lib/model/commerce-shipping.d.ts +316 -0
- package/src/lib/model/commerce-shipping.js +484 -0
- package/src/lib/model/commerce-shipping.js.map +1 -0
- package/src/lib/model/commerce-stock-holds.d.ts +199 -0
- package/src/lib/model/commerce-stock-holds.js +190 -0
- package/src/lib/model/commerce-stock-holds.js.map +1 -0
- package/src/lib/model/commerce-subscription-status.d.ts +67 -0
- package/src/lib/model/commerce-subscription-status.js +76 -0
- package/src/lib/model/commerce-subscription-status.js.map +1 -0
- package/src/lib/model/commerce-tax-decision.d.ts +222 -0
- package/src/lib/model/commerce-tax-decision.js +165 -0
- package/src/lib/model/commerce-tax-decision.js.map +1 -0
- package/src/lib/model/commerce-tax.d.ts +176 -0
- package/src/lib/model/commerce-tax.js +92 -0
- package/src/lib/model/commerce-tax.js.map +1 -0
- package/src/lib/model/commerce.d.ts +551 -0
- package/src/lib/model/commerce.js +739 -0
- package/src/lib/model/commerce.js.map +1 -0
- package/src/lib/model/index.d.ts +40 -0
- package/src/lib/model/index.js +40 -0
- package/src/lib/model/index.js.map +1 -0
- package/src/lib/model/order-figures.d.ts +48 -0
- package/src/lib/model/order-figures.js +74 -0
- package/src/lib/model/order-figures.js.map +1 -0
- package/src/lib/model/plugin-permissions.d.ts +23 -0
- package/src/lib/model/plugin-permissions.js +34 -0
- package/src/lib/model/plugin-permissions.js.map +1 -0
- package/src/lib/model/purchase-analytics.d.ts +186 -0
- package/src/lib/model/purchase-analytics.js +216 -0
- package/src/lib/model/purchase-analytics.js.map +1 -0
- package/src/lib/plugin-config.d.ts +62 -0
- package/src/lib/plugin-config.js +78 -0
- package/src/lib/plugin-config.js.map +1 -0
- package/src/lib/plugin.d.ts +28 -0
- package/src/lib/plugin.js +147 -0
- package/src/lib/plugin.js.map +1 -0
- package/src/lib/server/billing-webhook.d.ts +26 -0
- package/src/lib/server/billing-webhook.js +4011 -0
- package/src/lib/server/billing-webhook.js.map +1 -0
- package/src/lib/server/cancel-order.d.ts +87 -0
- package/src/lib/server/cancel-order.js +368 -0
- package/src/lib/server/cancel-order.js.map +1 -0
- package/src/lib/server/cart-checkout.d.ts +25 -0
- package/src/lib/server/cart-checkout.js +976 -0
- package/src/lib/server/cart-checkout.js.map +1 -0
- package/src/lib/server/cart-cookie.d.ts +32 -0
- package/src/lib/server/cart-cookie.js +77 -0
- package/src/lib/server/cart-cookie.js.map +1 -0
- package/src/lib/server/cart.d.ts +34 -0
- package/src/lib/server/cart.js +181 -0
- package/src/lib/server/cart.js.map +1 -0
- package/src/lib/server/catalog.d.ts +127 -0
- package/src/lib/server/catalog.js +277 -0
- package/src/lib/server/catalog.js.map +1 -0
- package/src/lib/server/checkout.d.ts +36 -0
- package/src/lib/server/checkout.js +915 -0
- package/src/lib/server/checkout.js.map +1 -0
- package/src/lib/server/connect.d.ts +26 -0
- package/src/lib/server/connect.js +238 -0
- package/src/lib/server/connect.js.map +1 -0
- package/src/lib/server/contact-refund.d.ts +117 -0
- package/src/lib/server/contact-refund.js +196 -0
- package/src/lib/server/contact-refund.js.map +1 -0
- package/src/lib/server/download.d.ts +39 -0
- package/src/lib/server/download.js +206 -0
- package/src/lib/server/download.js.map +1 -0
- package/src/lib/server/draft-order.d.ts +26 -0
- package/src/lib/server/draft-order.js +706 -0
- package/src/lib/server/draft-order.js.map +1 -0
- package/src/lib/server/feed.d.ts +24 -0
- package/src/lib/server/feed.js +59 -0
- package/src/lib/server/feed.js.map +1 -0
- package/src/lib/server/fulfill-order.d.ts +97 -0
- package/src/lib/server/fulfill-order.js +235 -0
- package/src/lib/server/fulfill-order.js.map +1 -0
- package/src/lib/server/gate.d.ts +36 -0
- package/src/lib/server/gate.js +112 -0
- package/src/lib/server/gate.js.map +1 -0
- package/src/lib/server/gift-cards.d.ts +42 -0
- package/src/lib/server/gift-cards.js +219 -0
- package/src/lib/server/gift-cards.js.map +1 -0
- package/src/lib/server/low-stock.d.ts +49 -0
- package/src/lib/server/low-stock.js +60 -0
- package/src/lib/server/low-stock.js.map +1 -0
- package/src/lib/server/manual-tax-rate.d.ts +82 -0
- package/src/lib/server/manual-tax-rate.js +113 -0
- package/src/lib/server/manual-tax-rate.js.map +1 -0
- package/src/lib/server/member-feed.d.ts +24 -0
- package/src/lib/server/member-feed.js +72 -0
- package/src/lib/server/member-feed.js.map +1 -0
- package/src/lib/server/member-name-search.d.ts +37 -0
- package/src/lib/server/member-name-search.js +42 -0
- package/src/lib/server/member-name-search.js.map +1 -0
- package/src/lib/server/member-post.d.ts +23 -0
- package/src/lib/server/member-post.js +166 -0
- package/src/lib/server/member-post.js.map +1 -0
- package/src/lib/server/membership-account.d.ts +37 -0
- package/src/lib/server/membership-account.js +148 -0
- package/src/lib/server/membership-account.js.map +1 -0
- package/src/lib/server/membership-admin-password.d.ts +33 -0
- package/src/lib/server/membership-admin-password.js +202 -0
- package/src/lib/server/membership-admin-password.js.map +1 -0
- package/src/lib/server/membership-content.d.ts +23 -0
- package/src/lib/server/membership-content.js +105 -0
- package/src/lib/server/membership-content.js.map +1 -0
- package/src/lib/server/membership-login.d.ts +19 -0
- package/src/lib/server/membership-login.js +137 -0
- package/src/lib/server/membership-login.js.map +1 -0
- package/src/lib/server/membership-logout.d.ts +19 -0
- package/src/lib/server/membership-logout.js +35 -0
- package/src/lib/server/membership-logout.js.map +1 -0
- package/src/lib/server/membership-recover.d.ts +60 -0
- package/src/lib/server/membership-recover.js +244 -0
- package/src/lib/server/membership-recover.js.map +1 -0
- package/src/lib/server/membership-register.d.ts +22 -0
- package/src/lib/server/membership-register.js +241 -0
- package/src/lib/server/membership-register.js.map +1 -0
- package/src/lib/server/membership-reset.d.ts +26 -0
- package/src/lib/server/membership-reset.js +88 -0
- package/src/lib/server/membership-reset.js.map +1 -0
- package/src/lib/server/membership-wishlist.d.ts +23 -0
- package/src/lib/server/membership-wishlist.js +89 -0
- package/src/lib/server/membership-wishlist.js.map +1 -0
- package/src/lib/server/membership.d.ts +96 -0
- package/src/lib/server/membership.js +222 -0
- package/src/lib/server/membership.js.map +1 -0
- package/src/lib/server/native-checkout.d.ts +170 -0
- package/src/lib/server/native-checkout.js +193 -0
- package/src/lib/server/native-checkout.js.map +1 -0
- package/src/lib/server/newsletter.d.ts +23 -0
- package/src/lib/server/newsletter.js +323 -0
- package/src/lib/server/newsletter.js.map +1 -0
- package/src/lib/server/notify-restock.d.ts +22 -0
- package/src/lib/server/notify-restock.js +84 -0
- package/src/lib/server/notify-restock.js.map +1 -0
- package/src/lib/server/order-analytics.d.ts +134 -0
- package/src/lib/server/order-analytics.js +263 -0
- package/src/lib/server/order-analytics.js.map +1 -0
- package/src/lib/server/order-figures.d.ts +33 -0
- package/src/lib/server/order-figures.js +220 -0
- package/src/lib/server/order-figures.js.map +1 -0
- package/src/lib/server/paid-media-delivery.d.ts +173 -0
- package/src/lib/server/paid-media-delivery.js +212 -0
- package/src/lib/server/paid-media-delivery.js.map +1 -0
- package/src/lib/server/pos-order.d.ts +54 -0
- package/src/lib/server/pos-order.js +1137 -0
- package/src/lib/server/pos-order.js.map +1 -0
- package/src/lib/server/process-abandoned.d.ts +54 -0
- package/src/lib/server/process-abandoned.js +222 -0
- package/src/lib/server/process-abandoned.js.map +1 -0
- package/src/lib/server/process-restock.d.ts +42 -0
- package/src/lib/server/process-restock.js +219 -0
- package/src/lib/server/process-restock.js.map +1 -0
- package/src/lib/server/product-card.d.ts +29 -0
- package/src/lib/server/product-card.js +54 -0
- package/src/lib/server/product-card.js.map +1 -0
- package/src/lib/server/product.d.ts +70 -0
- package/src/lib/server/product.js +105 -0
- package/src/lib/server/product.js.map +1 -0
- package/src/lib/server/promotion-hold.d.ts +144 -0
- package/src/lib/server/promotion-hold.js +174 -0
- package/src/lib/server/promotion-hold.js.map +1 -0
- package/src/lib/server/reconcile-stock.d.ts +106 -0
- package/src/lib/server/reconcile-stock.js +349 -0
- package/src/lib/server/reconcile-stock.js.map +1 -0
- package/src/lib/server/refund.d.ts +45 -0
- package/src/lib/server/refund.js +607 -0
- package/src/lib/server/refund.js.map +1 -0
- package/src/lib/server/related.d.ts +24 -0
- package/src/lib/server/related.js +104 -0
- package/src/lib/server/related.js.map +1 -0
- package/src/lib/server/reservation-availability.d.ts +23 -0
- package/src/lib/server/reservation-availability.js +111 -0
- package/src/lib/server/reservation-availability.js.map +1 -0
- package/src/lib/server/reserve-stock.d.ts +156 -0
- package/src/lib/server/reserve-stock.js +146 -0
- package/src/lib/server/reserve-stock.js.map +1 -0
- package/src/lib/server/reserve.d.ts +25 -0
- package/src/lib/server/reserve.js +426 -0
- package/src/lib/server/reserve.js.map +1 -0
- package/src/lib/server/restock-flag.d.ts +202 -0
- package/src/lib/server/restock-flag.js +449 -0
- package/src/lib/server/restock-flag.js.map +1 -0
- package/src/lib/server/reviews.d.ts +51 -0
- package/src/lib/server/reviews.js +132 -0
- package/src/lib/server/reviews.js.map +1 -0
- package/src/lib/server/site-page-enricher.d.ts +42 -0
- package/src/lib/server/site-page-enricher.js +149 -0
- package/src/lib/server/site-page-enricher.js.map +1 -0
- package/src/lib/server/site-page-resolver.d.ts +26 -0
- package/src/lib/server/site-page-resolver.js +223 -0
- package/src/lib/server/site-page-resolver.js.map +1 -0
- package/src/lib/server/stock-hold.d.ts +127 -0
- package/src/lib/server/stock-hold.js +258 -0
- package/src/lib/server/stock-hold.js.map +1 -0
- package/src/lib/server/storefront-tax-record.d.ts +22 -0
- package/src/lib/server/storefront-tax-record.js +218 -0
- package/src/lib/server/storefront-tax-record.js.map +1 -0
- package/src/lib/server/storefront-tax.d.ts +197 -0
- package/src/lib/server/storefront-tax.js +245 -0
- package/src/lib/server/storefront-tax.js.map +1 -0
- package/src/lib/server/stream.d.ts +25 -0
- package/src/lib/server/stream.js +191 -0
- package/src/lib/server/stream.js.map +1 -0
- package/src/lib/server/subscription-portal.d.ts +24 -0
- package/src/lib/server/subscription-portal.js +91 -0
- package/src/lib/server/subscription-portal.js.map +1 -0
- package/src/lib/server/supplier-outbox.d.ts +190 -0
- package/src/lib/server/supplier-outbox.js +342 -0
- package/src/lib/server/supplier-outbox.js.map +1 -0
- package/src/lib/server/supplier-update.d.ts +23 -0
- package/src/lib/server/supplier-update.js +289 -0
- package/src/lib/server/supplier-update.js.map +1 -0
- package/src/lib/server/tax-profile.d.ts +29 -0
- package/src/lib/server/tax-profile.js +40 -0
- package/src/lib/server/tax-profile.js.map +1 -0
- package/src/lib/server.d.ts +32 -0
- package/src/lib/server.js +311 -0
- package/src/lib/server.js.map +1 -0
- package/src/lib/site.d.ts +27 -0
- package/src/lib/site.js +134 -0
- package/src/lib/site.js.map +1 -0
- package/src/lib/utils/escape-html.d.ts +41 -0
- package/src/lib/utils/escape-html.js +41 -0
- package/src/lib/utils/escape-html.js.map +1 -0
- package/src/lib/utils/generate-preset-id.d.ts +19 -0
- package/src/lib/utils/generate-preset-id.js +25 -0
- package/src/lib/utils/generate-preset-id.js.map +1 -0
- package/src/lib/utils/member-continue.d.ts +45 -0
- package/src/lib/utils/member-continue.js +49 -0
- package/src/lib/utils/member-continue.js.map +1 -0
- package/src/lib/utils/use-storefront-purchase-event.d.ts +60 -0
- package/src/lib/utils/use-storefront-purchase-event.js +142 -0
- package/src/lib/utils/use-storefront-purchase-event.js.map +1 -0
|
@@ -0,0 +1,340 @@
|
|
|
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 { formatOrderNumber, isLowStock, liftLegacyProduct, orderIsTestMode } from "../../model/index.js";
|
|
20
|
+
import { checkEntitlement, pluginDocsHelp } from "@aglyn/aglyn";
|
|
21
|
+
import { AppLink, CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
22
|
+
import { Alert, Button, Chip, Divider, Stack, Typography } from "@mui/material";
|
|
23
|
+
import { collection, limit, orderBy, query, where } from "firebase/firestore";
|
|
24
|
+
import { useMemo } from "react";
|
|
25
|
+
import { ceilingedWindow, collectionCeiling, useConsoleHostRoute, useFirestore, useOrgPlan } from "@aglyn/tenant-feature-instance";
|
|
26
|
+
import { useFirestoreCollection } from "@aglyn/tenant-feature-instance";
|
|
27
|
+
const THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000;
|
|
28
|
+
/**
|
|
29
|
+
* How many orders the 30-day figures may be computed from, and how many
|
|
30
|
+
* products the low-stock count may scan.
|
|
31
|
+
*
|
|
32
|
+
* Both tiles are aggregates, so neither can be paged: a sum over page one is
|
|
33
|
+
* not a sum. What bounds them instead is the window itself — the orders query
|
|
34
|
+
* asks for thirty days rather than for a count, so a store reads what it sold
|
|
35
|
+
* rather than a fixed slab, and only a store selling more than this in a month
|
|
36
|
+
* meets the ceiling at all.
|
|
37
|
+
*
|
|
38
|
+
* A ceiling that bites makes every figure under it an UNDERSTATEMENT, which is
|
|
39
|
+
* why `truncated` is rendered rather than logged. Revenue quietly short is the
|
|
40
|
+
* one failure a reader cannot detect from the number itself.
|
|
41
|
+
*/ const GLANCE_ORDER_CEILING = 250;
|
|
42
|
+
const GLANCE_PRODUCT_CEILING = 250;
|
|
43
|
+
/**
|
|
44
|
+
* Commerce at a glance (AGL-353): 30-day revenue, orders, AOV, low-stock
|
|
45
|
+
* count and the five latest orders. Renders nothing for hosts without a
|
|
46
|
+
* catalog so non-commerce dashboards stay clean.
|
|
47
|
+
*
|
|
48
|
+
* The figures are the `commerceAnalytics` entitlement — `/pricing` sells
|
|
49
|
+
* "Commerce analytics" as Pro-and-up, and `/product/commerce` calls it "a
|
|
50
|
+
* built-in commerce analytics dashboard". Until AGL-1938 the flag was
|
|
51
|
+
* inert: its ONLY occurrence outside `plan-entitlements.ts` was its own
|
|
52
|
+
* type declaration, and this card carried no check, so every commerce org
|
|
53
|
+
* — Starter included — got the Pro surface for free. The store link and
|
|
54
|
+
* card shell stay ungated; only the measured numbers are the paid part.
|
|
55
|
+
*/ export function CommerceGlanceCard(props) {
|
|
56
|
+
const { hostId } = props;
|
|
57
|
+
// Console routes are /[orgSlug]/hosts/[subdomain]/… (AGL-673); this
|
|
58
|
+
// component only has a host doc id.
|
|
59
|
+
const consoleRoute = useConsoleHostRoute(hostId);
|
|
60
|
+
const { org, ready: orgReady } = useOrgPlan(hostId);
|
|
61
|
+
const entitled = checkEntitlement(org, 'commerceAnalytics');
|
|
62
|
+
const firestore = useFirestore();
|
|
63
|
+
/*
|
|
64
|
+
* Anchored once per mount so the query identity is stable. Recomputing it
|
|
65
|
+
* per render would rebuild the listener on every pass, which re-reads the
|
|
66
|
+
* whole window each time.
|
|
67
|
+
*/ const since = useMemo(()=>Date.now() - THIRTY_DAYS_MS, []);
|
|
68
|
+
/**
|
|
69
|
+
* The thirty days the tiles claim, asked for as thirty days.
|
|
70
|
+
*
|
|
71
|
+
* `createdAtMs` is the field every order writer in the plugin stamps — cart,
|
|
72
|
+
* buy-now, draft, POS cash, POS card and subscription cycle — and the one
|
|
73
|
+
* `reconcile-stock` already walks the collection by. `createdAt` is not
|
|
74
|
+
* interchangeable: the orders collection group is indexed on `createdAtMs`
|
|
75
|
+
* alone, and a range on a field a document lacks drops that document rather
|
|
76
|
+
* than mis-placing it.
|
|
77
|
+
*
|
|
78
|
+
* The range and the order are the same field, so this needs no composite
|
|
79
|
+
* index beyond the `createdAtMs` override already declared.
|
|
80
|
+
*/ const { data: orderDocs } = useFirestoreCollection(()=>query(collection(firestore, 'hosts', hostId, 'orders'), where('createdAtMs', '>=', since), orderBy('createdAtMs', 'desc'), limit(GLANCE_ORDER_CEILING + 1)), [
|
|
81
|
+
firestore,
|
|
82
|
+
hostId,
|
|
83
|
+
since
|
|
84
|
+
], {
|
|
85
|
+
idField: '$id'
|
|
86
|
+
});
|
|
87
|
+
const { data: productDocs } = useFirestoreCollection(()=>collectionCeiling(collection(firestore, 'hosts', hostId, 'products'), GLANCE_PRODUCT_CEILING), [
|
|
88
|
+
firestore,
|
|
89
|
+
hostId
|
|
90
|
+
], {
|
|
91
|
+
idField: '$id'
|
|
92
|
+
});
|
|
93
|
+
const orderWindow = useMemo(()=>ceilingedWindow(orderDocs != null ? orderDocs : undefined, GLANCE_ORDER_CEILING), [
|
|
94
|
+
orderDocs
|
|
95
|
+
]);
|
|
96
|
+
const productWindow = useMemo(()=>ceilingedWindow(productDocs != null ? productDocs : undefined, GLANCE_PRODUCT_CEILING), [
|
|
97
|
+
productDocs
|
|
98
|
+
]);
|
|
99
|
+
const summary = useMemo(()=>{
|
|
100
|
+
// The query returns the window already ordered newest-first; re-sorting a
|
|
101
|
+
// ceilinged read would only restate the order it arrived in.
|
|
102
|
+
const orders = orderWindow.rows;
|
|
103
|
+
// ONE DEFINITION OF 30-DAY REVENUE, NOT TWO.
|
|
104
|
+
//
|
|
105
|
+
// This card and `commerce-analytics-card` read the same orders collection
|
|
106
|
+
// over the same window and disagreed three ways, so one dashboard showed a
|
|
107
|
+
// store two different revenues:
|
|
108
|
+
//
|
|
109
|
+
// - `pending` orders, which have taken no money, were counted here as
|
|
110
|
+
// revenue and excluded there.
|
|
111
|
+
// - `cancelled` was tested with the American spelling, which never
|
|
112
|
+
// matches the persisted `OrderStatus`, so every cancelled order was
|
|
113
|
+
// booked. The value is a PERSISTED enum and is not the place to apply
|
|
114
|
+
// the American-spelling rule; the comparison follows the data.
|
|
115
|
+
// - A refund was all-or-nothing: a fully-refunded order was dropped
|
|
116
|
+
// whole while a 99%-refunded one counted in full.
|
|
117
|
+
//
|
|
118
|
+
// The filter and the per-order figure now match that card line for line,
|
|
119
|
+
// so the two cannot drift again without someone editing both.
|
|
120
|
+
const recentWindow = orders.filter((order)=>order.status !== 'pending' && order.status !== 'cancelled' && // A rehearsal is not revenue — the same exclusion the
|
|
121
|
+
// analytics card applies, from the same helper.
|
|
122
|
+
!orderIsTestMode(order));
|
|
123
|
+
// Net of what went back, rather than dropping the order. The legacy flat
|
|
124
|
+
// `amountCents` is the fallback, matching every other money reader
|
|
125
|
+
// (AGL-1747): this card had the modern read but not the fallback, so a
|
|
126
|
+
// Commerce Starter order (AGL-90) rendered as $0.00.
|
|
127
|
+
const orderNetCents = (order)=>{
|
|
128
|
+
var _ref, _ref1, _order_refundedCents;
|
|
129
|
+
var _order_totals;
|
|
130
|
+
return Number((_ref = (_ref1 = (_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents) != null ? _ref1 : order.amountCents) != null ? _ref : 0) - Number((_order_refundedCents = order.refundedCents) != null ? _order_refundedCents : 0);
|
|
131
|
+
};
|
|
132
|
+
const revenueCents = recentWindow.reduce((sum, order)=>sum + orderNetCents(order), 0);
|
|
133
|
+
const lowStock = productWindow.rows.filter((product)=>{
|
|
134
|
+
try {
|
|
135
|
+
return isLowStock(liftLegacyProduct(product));
|
|
136
|
+
} catch (unused) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}).length;
|
|
140
|
+
return {
|
|
141
|
+
latest: orders.slice(0, 5),
|
|
142
|
+
orders30d: recentWindow.length,
|
|
143
|
+
revenueCents,
|
|
144
|
+
aovCents: recentWindow.length ? Math.round(revenueCents / recentWindow.length) : 0,
|
|
145
|
+
lowStock
|
|
146
|
+
};
|
|
147
|
+
}, [
|
|
148
|
+
orderWindow,
|
|
149
|
+
productWindow
|
|
150
|
+
]);
|
|
151
|
+
// No catalog and nothing sold in the window — this host doesn't sell; stay
|
|
152
|
+
// invisible.
|
|
153
|
+
if (!(productWindow.rows.length || orderWindow.rows.length)) return null;
|
|
154
|
+
const money = (cents)=>`$${(cents / 100).toFixed(2)}`;
|
|
155
|
+
const openStoreAction = /*#__PURE__*/ _jsx(Button, _extends({
|
|
156
|
+
component: AppLink
|
|
157
|
+
}, {
|
|
158
|
+
componentVariant: 'naked',
|
|
159
|
+
nativeButton: false
|
|
160
|
+
}, {
|
|
161
|
+
href: consoleRoute.base ? `${consoleRoute.base}/products` : undefined,
|
|
162
|
+
size: "small",
|
|
163
|
+
color: "primary",
|
|
164
|
+
children: 'Open store'
|
|
165
|
+
}));
|
|
166
|
+
if (!orgReady) {
|
|
167
|
+
// `checkEntitlement(undefined)` resolves the FREE tier rather than
|
|
168
|
+
// "unknown" (see `useOrgPlan`), and this card's "no" is an upsell —
|
|
169
|
+
// never accuse a paying org of being unentitled while the plan doc is
|
|
170
|
+
// still in flight.
|
|
171
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
172
|
+
header: 'Commerce',
|
|
173
|
+
help: pluginDocsHelp('commerce'),
|
|
174
|
+
contentGutterX: true,
|
|
175
|
+
contentGutterY: true,
|
|
176
|
+
HeaderProps: {
|
|
177
|
+
action: openStoreAction
|
|
178
|
+
},
|
|
179
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
180
|
+
variant: "body2",
|
|
181
|
+
color: "text.secondary",
|
|
182
|
+
children: 'Checking your plan…'
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (!entitled) {
|
|
187
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
188
|
+
header: 'Commerce',
|
|
189
|
+
help: pluginDocsHelp('commerce'),
|
|
190
|
+
contentGutterX: true,
|
|
191
|
+
contentGutterY: true,
|
|
192
|
+
HeaderProps: {
|
|
193
|
+
action: openStoreAction
|
|
194
|
+
},
|
|
195
|
+
children: /*#__PURE__*/ _jsx(Alert, {
|
|
196
|
+
severity: "info",
|
|
197
|
+
action: consoleRoute.orgSlug ? /*#__PURE__*/ _jsx(AppLink, {
|
|
198
|
+
componentVariant: "button",
|
|
199
|
+
color: "inherit",
|
|
200
|
+
size: "small",
|
|
201
|
+
href: `/${consoleRoute.orgSlug}/billing`,
|
|
202
|
+
children: 'Upgrade'
|
|
203
|
+
}) : undefined,
|
|
204
|
+
children: 'Commerce analytics — revenue, orders and average order value — ' + 'is a Pro feature. Every order is still being recorded, so the ' + 'numbers are waiting the moment you upgrade.'
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
209
|
+
header: 'Commerce',
|
|
210
|
+
help: pluginDocsHelp('commerce'),
|
|
211
|
+
contentGutterX: true,
|
|
212
|
+
contentGutterY: true,
|
|
213
|
+
HeaderProps: {
|
|
214
|
+
action: openStoreAction
|
|
215
|
+
},
|
|
216
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
217
|
+
spacing: 1.5,
|
|
218
|
+
children: [
|
|
219
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
220
|
+
direction: "row",
|
|
221
|
+
spacing: 3,
|
|
222
|
+
children: [
|
|
223
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
224
|
+
children: [
|
|
225
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
226
|
+
variant: "h6",
|
|
227
|
+
children: money(summary.revenueCents)
|
|
228
|
+
}),
|
|
229
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
230
|
+
variant: "caption",
|
|
231
|
+
color: "text.secondary",
|
|
232
|
+
children: 'Revenue · 30d'
|
|
233
|
+
})
|
|
234
|
+
]
|
|
235
|
+
}),
|
|
236
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
237
|
+
children: [
|
|
238
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
239
|
+
variant: "h6",
|
|
240
|
+
children: summary.orders30d
|
|
241
|
+
}),
|
|
242
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
243
|
+
variant: "caption",
|
|
244
|
+
color: "text.secondary",
|
|
245
|
+
children: 'Orders · 30d'
|
|
246
|
+
})
|
|
247
|
+
]
|
|
248
|
+
}),
|
|
249
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
250
|
+
children: [
|
|
251
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
252
|
+
variant: "h6",
|
|
253
|
+
children: money(summary.aovCents)
|
|
254
|
+
}),
|
|
255
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
256
|
+
variant: "caption",
|
|
257
|
+
color: "text.secondary",
|
|
258
|
+
children: 'Avg order'
|
|
259
|
+
})
|
|
260
|
+
]
|
|
261
|
+
}),
|
|
262
|
+
summary.lowStock ? /*#__PURE__*/ _jsxs(Stack, {
|
|
263
|
+
children: [
|
|
264
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
265
|
+
variant: "h6",
|
|
266
|
+
color: "warning.main",
|
|
267
|
+
children: summary.lowStock
|
|
268
|
+
}),
|
|
269
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
270
|
+
variant: "caption",
|
|
271
|
+
color: "text.secondary",
|
|
272
|
+
children: 'Low stock'
|
|
273
|
+
})
|
|
274
|
+
]
|
|
275
|
+
}) : null
|
|
276
|
+
]
|
|
277
|
+
}),
|
|
278
|
+
orderWindow.truncated || productWindow.truncated ? /*#__PURE__*/ _jsx(Typography, {
|
|
279
|
+
variant: "caption",
|
|
280
|
+
color: "text.secondary",
|
|
281
|
+
children: orderWindow.truncated ? `Counted from the ${GLANCE_ORDER_CEILING} most recent orders of the last 30 days. Open the store for the full figures.` : `Low stock counted across ${GLANCE_PRODUCT_CEILING} products. Open the store for the full catalog.`
|
|
282
|
+
}) : null,
|
|
283
|
+
summary.latest.length ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
284
|
+
children: [
|
|
285
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
286
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
287
|
+
spacing: 0.5,
|
|
288
|
+
children: summary.latest.map((order)=>{
|
|
289
|
+
var _ref, _ref1, _order_status;
|
|
290
|
+
var _order_totals;
|
|
291
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
292
|
+
direction: "row",
|
|
293
|
+
spacing: 1,
|
|
294
|
+
sx: {
|
|
295
|
+
justifyContent: 'space-between',
|
|
296
|
+
alignItems: 'center'
|
|
297
|
+
},
|
|
298
|
+
children: [
|
|
299
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
300
|
+
variant: "body2",
|
|
301
|
+
noWrap: true,
|
|
302
|
+
sx: {
|
|
303
|
+
minWidth: 0
|
|
304
|
+
},
|
|
305
|
+
children: [
|
|
306
|
+
order.orderNumber ? formatOrderNumber(order.orderNumber) : order.$id.slice(0, 8),
|
|
307
|
+
order.email ? ` · ${order.email}` : ''
|
|
308
|
+
]
|
|
309
|
+
}),
|
|
310
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
311
|
+
direction: "row",
|
|
312
|
+
spacing: 1,
|
|
313
|
+
sx: {
|
|
314
|
+
alignItems: 'center'
|
|
315
|
+
},
|
|
316
|
+
children: [
|
|
317
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
318
|
+
variant: "caption",
|
|
319
|
+
children: money(Number((_ref = (_ref1 = (_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents) != null ? _ref1 : order.amountCents) != null ? _ref : 0))
|
|
320
|
+
}),
|
|
321
|
+
/*#__PURE__*/ _jsx(Chip, {
|
|
322
|
+
size: "small",
|
|
323
|
+
label: (_order_status = order.status) != null ? _order_status : 'paid'
|
|
324
|
+
})
|
|
325
|
+
]
|
|
326
|
+
})
|
|
327
|
+
]
|
|
328
|
+
}, order.$id);
|
|
329
|
+
})
|
|
330
|
+
})
|
|
331
|
+
]
|
|
332
|
+
}) : null
|
|
333
|
+
]
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
CommerceGlanceCard.displayName = 'CommerceGlanceCard';
|
|
338
|
+
export default CommerceGlanceCard;
|
|
339
|
+
|
|
340
|
+
//# sourceMappingURL=commerce-glance-card.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/commerce-glance-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 {\n formatOrderNumber,\n isLowStock,\n liftLegacyProduct,\n orderIsTestMode,\n} from '../../model'\nimport { checkEntitlement, pluginDocsHelp } from '@aglyn/aglyn'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { Alert, Button, Chip, Divider, Stack, Typography } from '@mui/material'\nimport { collection, limit, orderBy, query, where } from 'firebase/firestore'\nimport { useMemo } from 'react'\nimport {\n ceilingedWindow,\n collectionCeiling,\n useConsoleHostRoute,\n useFirestore,\n useOrgPlan,\n} from '@aglyn/tenant-feature-instance'\nimport { useFirestoreCollection } from '@aglyn/tenant-feature-instance'\n\nconst THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000\n\n/**\n * How many orders the 30-day figures may be computed from, and how many\n * products the low-stock count may scan.\n *\n * Both tiles are aggregates, so neither can be paged: a sum over page one is\n * not a sum. What bounds them instead is the window itself — the orders query\n * asks for thirty days rather than for a count, so a store reads what it sold\n * rather than a fixed slab, and only a store selling more than this in a month\n * meets the ceiling at all.\n *\n * A ceiling that bites makes every figure under it an UNDERSTATEMENT, which is\n * why `truncated` is rendered rather than logged. Revenue quietly short is the\n * one failure a reader cannot detect from the number itself.\n */\nconst GLANCE_ORDER_CEILING = 250\nconst GLANCE_PRODUCT_CEILING = 250\n\n/**\n * Commerce at a glance (AGL-353): 30-day revenue, orders, AOV, low-stock\n * count and the five latest orders. Renders nothing for hosts without a\n * catalog so non-commerce dashboards stay clean.\n *\n * The figures are the `commerceAnalytics` entitlement — `/pricing` sells\n * \"Commerce analytics\" as Pro-and-up, and `/product/commerce` calls it \"a\n * built-in commerce analytics dashboard\". Until AGL-1938 the flag was\n * inert: its ONLY occurrence outside `plan-entitlements.ts` was its own\n * type declaration, and this card carried no check, so every commerce org\n * — Starter included — got the Pro surface for free. The store link and\n * card shell stay ungated; only the measured numbers are the paid part.\n */\nexport function CommerceGlanceCard(props: { hostId: string }) {\n const { hostId } = props\n // Console routes are /[orgSlug]/hosts/[subdomain]/… (AGL-673); this\n // component only has a host doc id.\n const consoleRoute = useConsoleHostRoute(hostId)\n const { org, ready: orgReady } = useOrgPlan(hostId)\n const entitled = checkEntitlement(org as never, 'commerceAnalytics')\n const firestore = useFirestore()\n /*\n * Anchored once per mount so the query identity is stable. Recomputing it\n * per render would rebuild the listener on every pass, which re-reads the\n * whole window each time.\n */\n const since = useMemo(() => Date.now() - THIRTY_DAYS_MS, [])\n /**\n * The thirty days the tiles claim, asked for as thirty days.\n *\n * `createdAtMs` is the field every order writer in the plugin stamps — cart,\n * buy-now, draft, POS cash, POS card and subscription cycle — and the one\n * `reconcile-stock` already walks the collection by. `createdAt` is not\n * interchangeable: the orders collection group is indexed on `createdAtMs`\n * alone, and a range on a field a document lacks drops that document rather\n * than mis-placing it.\n *\n * The range and the order are the same field, so this needs no composite\n * index beyond the `createdAtMs` override already declared.\n */\n const { data: orderDocs } = useFirestoreCollection<any>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'orders'),\n where('createdAtMs', '>=', since),\n orderBy('createdAtMs', 'desc'),\n limit(GLANCE_ORDER_CEILING + 1),\n ),\n [firestore, hostId, since],\n { idField: '$id' },\n )\n const { data: productDocs } = useFirestoreCollection<any>(\n () =>\n collectionCeiling(\n collection(firestore, 'hosts', hostId, 'products'),\n GLANCE_PRODUCT_CEILING,\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const orderWindow = useMemo(\n () => ceilingedWindow<any>(orderDocs ?? undefined, GLANCE_ORDER_CEILING),\n [orderDocs],\n )\n const productWindow = useMemo(\n () =>\n ceilingedWindow<any>(productDocs ?? undefined, GLANCE_PRODUCT_CEILING),\n [productDocs],\n )\n\n const summary = useMemo(() => {\n // The query returns the window already ordered newest-first; re-sorting a\n // ceilinged read would only restate the order it arrived in.\n const orders = orderWindow.rows\n // ONE DEFINITION OF 30-DAY REVENUE, NOT TWO.\n //\n // This card and `commerce-analytics-card` read the same orders collection\n // over the same window and disagreed three ways, so one dashboard showed a\n // store two different revenues:\n //\n // - `pending` orders, which have taken no money, were counted here as\n // revenue and excluded there.\n // - `cancelled` was tested with the American spelling, which never\n // matches the persisted `OrderStatus`, so every cancelled order was\n // booked. The value is a PERSISTED enum and is not the place to apply\n // the American-spelling rule; the comparison follows the data.\n // - A refund was all-or-nothing: a fully-refunded order was dropped\n // whole while a 99%-refunded one counted in full.\n //\n // The filter and the per-order figure now match that card line for line,\n // so the two cannot drift again without someone editing both.\n const recentWindow = orders.filter(\n (order) =>\n order.status !== 'pending' &&\n order.status !== 'cancelled' &&\n // A rehearsal is not revenue — the same exclusion the\n // analytics card applies, from the same helper.\n !orderIsTestMode(order),\n )\n // Net of what went back, rather than dropping the order. The legacy flat\n // `amountCents` is the fallback, matching every other money reader\n // (AGL-1747): this card had the modern read but not the fallback, so a\n // Commerce Starter order (AGL-90) rendered as $0.00.\n const orderNetCents = (order: any) =>\n Number(order.totals?.totalCents ?? order.amountCents ?? 0) -\n Number(order.refundedCents ?? 0)\n const revenueCents = recentWindow.reduce(\n (sum, order) => sum + orderNetCents(order),\n 0,\n )\n const lowStock = productWindow.rows.filter((product: any) => {\n try {\n return isLowStock(liftLegacyProduct(product))\n } catch {\n return false\n }\n }).length\n return {\n latest: orders.slice(0, 5),\n orders30d: recentWindow.length,\n revenueCents,\n aovCents: recentWindow.length\n ? Math.round(revenueCents / recentWindow.length)\n : 0,\n lowStock,\n }\n }, [orderWindow, productWindow])\n\n // No catalog and nothing sold in the window — this host doesn't sell; stay\n // invisible.\n if (!(productWindow.rows.length || orderWindow.rows.length)) return null\n\n const money = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n const openStoreAction = (\n <Button\n component={AppLink as any}\n {...({ componentVariant: 'naked', nativeButton: false } as any)}\n href={consoleRoute.base ? `${consoleRoute.base}/products` : undefined}\n size=\"small\"\n color=\"primary\"\n >\n {'Open store'}\n </Button>\n )\n\n if (!orgReady) {\n // `checkEntitlement(undefined)` resolves the FREE tier rather than\n // \"unknown\" (see `useOrgPlan`), and this card's \"no\" is an upsell —\n // never accuse a paying org of being unentitled while the plan doc is\n // still in flight.\n return (\n <CardDisplay\n header={'Commerce'}\n help={pluginDocsHelp('commerce')}\n contentGutterX\n contentGutterY\n HeaderProps={{ action: openStoreAction }}\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Checking your plan…'}\n </Typography>\n </CardDisplay>\n )\n }\n\n if (!entitled) {\n return (\n <CardDisplay\n header={'Commerce'}\n help={pluginDocsHelp('commerce')}\n contentGutterX\n contentGutterY\n HeaderProps={{ action: openStoreAction }}\n >\n <Alert\n severity=\"info\"\n action={\n consoleRoute.orgSlug ? (\n <AppLink\n componentVariant=\"button\"\n color=\"inherit\"\n size=\"small\"\n href={`/${consoleRoute.orgSlug}/billing`}\n >\n {'Upgrade'}\n </AppLink>\n ) : undefined\n }\n >\n {'Commerce analytics — revenue, orders and average order value — ' +\n 'is a Pro feature. Every order is still being recorded, so the ' +\n 'numbers are waiting the moment you upgrade.'}\n </Alert>\n </CardDisplay>\n )\n }\n\n return (\n <CardDisplay\n header={'Commerce'}\n help={pluginDocsHelp('commerce')}\n contentGutterX\n contentGutterY\n HeaderProps={{ action: openStoreAction }}\n >\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={3}>\n <Stack>\n <Typography variant=\"h6\">{money(summary.revenueCents)}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Revenue · 30d'}\n </Typography>\n </Stack>\n <Stack>\n <Typography variant=\"h6\">{summary.orders30d}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Orders · 30d'}\n </Typography>\n </Stack>\n <Stack>\n <Typography variant=\"h6\">{money(summary.aovCents)}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Avg order'}\n </Typography>\n </Stack>\n {summary.lowStock ? (\n <Stack>\n <Typography variant=\"h6\" color=\"warning.main\">\n {summary.lowStock}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Low stock'}\n </Typography>\n </Stack>\n ) : null}\n </Stack>\n {orderWindow.truncated || productWindow.truncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {orderWindow.truncated\n ? `Counted from the ${GLANCE_ORDER_CEILING} most recent orders of the last 30 days. Open the store for the full figures.`\n : `Low stock counted across ${GLANCE_PRODUCT_CEILING} products. Open the store for the full catalog.`}\n </Typography>\n ) : null}\n {summary.latest.length ? (\n <>\n <Divider />\n <Stack spacing={0.5}>\n {summary.latest.map((order: any) => (\n <Stack\n key={order.$id}\n direction=\"row\"\n spacing={1}\n sx={{\n justifyContent: 'space-between',\n alignItems: 'center',\n }}\n >\n <Typography variant=\"body2\" noWrap sx={{ minWidth: 0 }}>\n {order.orderNumber\n ? formatOrderNumber(order.orderNumber)\n : order.$id.slice(0, 8)}\n {order.email ? ` · ${order.email}` : ''}\n </Typography>\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Typography variant=\"caption\">\n {money(\n Number(\n order.totals?.totalCents ?? order.amountCents ?? 0,\n ),\n )}\n </Typography>\n <Chip size=\"small\" label={order.status ?? 'paid'} />\n </Stack>\n </Stack>\n ))}\n </Stack>\n </>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n}\nCommerceGlanceCard.displayName = 'CommerceGlanceCard'\n\nexport default CommerceGlanceCard\n"],"names":["formatOrderNumber","isLowStock","liftLegacyProduct","orderIsTestMode","checkEntitlement","pluginDocsHelp","AppLink","CardDisplay","Alert","Button","Chip","Divider","Stack","Typography","collection","limit","orderBy","query","where","useMemo","ceilingedWindow","collectionCeiling","useConsoleHostRoute","useFirestore","useOrgPlan","useFirestoreCollection","THIRTY_DAYS_MS","GLANCE_ORDER_CEILING","GLANCE_PRODUCT_CEILING","CommerceGlanceCard","props","hostId","consoleRoute","org","ready","orgReady","entitled","firestore","since","Date","now","data","orderDocs","idField","productDocs","orderWindow","undefined","productWindow","summary","orders","rows","recentWindow","filter","order","status","orderNetCents","Number","totals","totalCents","amountCents","refundedCents","revenueCents","reduce","sum","lowStock","product","length","latest","slice","orders30d","aovCents","Math","round","money","cents","toFixed","openStoreAction","component","componentVariant","nativeButton","href","base","size","color","header","help","contentGutterX","contentGutterY","HeaderProps","action","variant","severity","orgSlug","spacing","direction","truncated","map","sx","justifyContent","alignItems","noWrap","minWidth","orderNumber","$id","email","label","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,iBAAiB,EACjBC,UAAU,EACVC,iBAAiB,EACjBC,eAAe,QACV,uBAAa;AACpB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,eAAc;AAC/D,SAASC,OAAO,EAAEC,WAAW,QAAQ,uBAAsB;AAC3D,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AAC/E,SAASC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAEC,KAAK,QAAQ,qBAAoB;AAC7E,SAASC,OAAO,QAAQ,QAAO;AAC/B,SACEC,eAAe,EACfC,iBAAiB,EACjBC,mBAAmB,EACnBC,YAAY,EACZC,UAAU,QACL,iCAAgC;AACvC,SAASC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AAC5F;4CACCkF,WAAU;4CACVD,SAAS;4CACTI,IAAI;gDAAEE,YAAY;4CAAS;;8DAE3B,KAACtF;oDAAW6E,SAAQ;8DACjBjB,MACCjB,QACEH,iBAAAA,gBAAAA,MAAMI,MAAM,qBAAZJ,cAAcK,UAAU,oBAAIL,MAAMM,WAAW,YAA7CN,OAAiD;;8DAIvD,KAAC3C;oDAAKwE,MAAK;oDAAQuB,KAAK,GAAEpD,gBAAAA,MAAMC,MAAM,YAAZD,gBAAgB;;;;;mCA1BvCA,MAAMkD,GAAG;;;;qBAgCpB;;;;AAIZ;AACA1E,mBAAmB6E,WAAW,GAAG;AAEjC,eAAe7E,mBAAkB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface CommerceStatTileProps {
|
|
2
|
+
/** Caption above the figure, e.g. `Revenue`. */
|
|
3
|
+
label: string;
|
|
4
|
+
/** The figure itself, already formatted. */
|
|
5
|
+
value: string;
|
|
6
|
+
/**
|
|
7
|
+
* Percentage change against the immediately preceding window of the same
|
|
8
|
+
* length, or `null` when there is no baseline. `null` renders NOTHING —
|
|
9
|
+
* see below.
|
|
10
|
+
*/
|
|
11
|
+
deltaPct?: number | null;
|
|
12
|
+
/** What the delta is measured against, for the tooltip. */
|
|
13
|
+
deltaCaption?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a rise is good. Revenue up is good; nothing on this surface is
|
|
16
|
+
* inverted yet, but a refund-rate tile would be, and baking "up is green"
|
|
17
|
+
* into the component is how that gets rendered backwards later.
|
|
18
|
+
*/
|
|
19
|
+
riseIsGood?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One money tile with a period-over-period delta (AGL-2136).
|
|
23
|
+
*
|
|
24
|
+
* Every commerce and console mockup we publish shows the figures carrying a
|
|
25
|
+
* delta — `Revenue $26,540 +8.1%`, `Orders 1,204 +5.6%` — and the product
|
|
26
|
+
* had no prior-window computation at all, so no surface could render one.
|
|
27
|
+
*
|
|
28
|
+
* **A `null` delta renders nothing, not `+0%` and not `—`.** The delta is
|
|
29
|
+
* `null` exactly when the prior window held no orders, and every way of
|
|
30
|
+
* drawing that is a lie: `+100%` reads as growth, `+0%` reads as flat, and
|
|
31
|
+
* `—` reads as "we could not work it out". A first sale has no growth rate.
|
|
32
|
+
*/
|
|
33
|
+
export declare function CommerceStatTile(props: CommerceStatTileProps): import("react").JSX.Element;
|
|
34
|
+
export declare namespace CommerceStatTile {
|
|
35
|
+
var displayName: string;
|
|
36
|
+
}
|
|
37
|
+
export default CommerceStatTile;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { Box, Stack, Tooltip, Typography } from "@mui/material";
|
|
19
|
+
/**
|
|
20
|
+
* One money tile with a period-over-period delta (AGL-2136).
|
|
21
|
+
*
|
|
22
|
+
* Every commerce and console mockup we publish shows the figures carrying a
|
|
23
|
+
* delta — `Revenue $26,540 +8.1%`, `Orders 1,204 +5.6%` — and the product
|
|
24
|
+
* had no prior-window computation at all, so no surface could render one.
|
|
25
|
+
*
|
|
26
|
+
* **A `null` delta renders nothing, not `+0%` and not `—`.** The delta is
|
|
27
|
+
* `null` exactly when the prior window held no orders, and every way of
|
|
28
|
+
* drawing that is a lie: `+100%` reads as growth, `+0%` reads as flat, and
|
|
29
|
+
* `—` reads as "we could not work it out". A first sale has no growth rate.
|
|
30
|
+
*/ export function CommerceStatTile(props) {
|
|
31
|
+
const { label, value, deltaPct = null, deltaCaption = 'vs the previous period', riseIsGood = true } = props;
|
|
32
|
+
const rose = (deltaPct != null ? deltaPct : 0) > 0;
|
|
33
|
+
const flat = deltaPct === 0;
|
|
34
|
+
const color = flat ? 'text.secondary' : rose === riseIsGood ? 'success.main' : 'error.main';
|
|
35
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
38
|
+
variant: "caption",
|
|
39
|
+
color: "text.secondary",
|
|
40
|
+
children: label
|
|
41
|
+
}),
|
|
42
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
43
|
+
direction: "row",
|
|
44
|
+
spacing: 0.75,
|
|
45
|
+
sx: {
|
|
46
|
+
alignItems: 'baseline'
|
|
47
|
+
},
|
|
48
|
+
children: [
|
|
49
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
50
|
+
variant: "h6",
|
|
51
|
+
children: value
|
|
52
|
+
}),
|
|
53
|
+
deltaPct === null ? null : /*#__PURE__*/ _jsx(Tooltip, {
|
|
54
|
+
title: deltaCaption,
|
|
55
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
56
|
+
variant: "caption",
|
|
57
|
+
sx: {
|
|
58
|
+
color,
|
|
59
|
+
fontWeight: 600
|
|
60
|
+
},
|
|
61
|
+
children: `${deltaPct > 0 ? '+' : ''}${deltaPct}%`
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
CommerceStatTile.displayName = 'CommerceStatTile';
|
|
70
|
+
export default CommerceStatTile;
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=commerce-stat-tile.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/commerce-stat-tile.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 { Box, Stack, Tooltip, Typography } from '@mui/material'\n\nexport interface CommerceStatTileProps {\n /** Caption above the figure, e.g. `Revenue`. */\n label: string\n /** The figure itself, already formatted. */\n value: string\n /**\n * Percentage change against the immediately preceding window of the same\n * length, or `null` when there is no baseline. `null` renders NOTHING —\n * see below.\n */\n deltaPct?: number | null\n /** What the delta is measured against, for the tooltip. */\n deltaCaption?: string\n /**\n * Whether a rise is good. Revenue up is good; nothing on this surface is\n * inverted yet, but a refund-rate tile would be, and baking \"up is green\"\n * into the component is how that gets rendered backwards later.\n */\n riseIsGood?: boolean\n}\n\n/**\n * One money tile with a period-over-period delta (AGL-2136).\n *\n * Every commerce and console mockup we publish shows the figures carrying a\n * delta — `Revenue $26,540 +8.1%`, `Orders 1,204 +5.6%` — and the product\n * had no prior-window computation at all, so no surface could render one.\n *\n * **A `null` delta renders nothing, not `+0%` and not `—`.** The delta is\n * `null` exactly when the prior window held no orders, and every way of\n * drawing that is a lie: `+100%` reads as growth, `+0%` reads as flat, and\n * `—` reads as \"we could not work it out\". A first sale has no growth rate.\n */\nexport function CommerceStatTile(props: CommerceStatTileProps) {\n const {\n label,\n value,\n deltaPct = null,\n deltaCaption = 'vs the previous period',\n riseIsGood = true,\n } = props\n const rose = (deltaPct ?? 0) > 0\n const flat = deltaPct === 0\n const color = flat\n ? 'text.secondary'\n : rose === riseIsGood\n ? 'success.main'\n : 'error.main'\n return (\n <Box>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {label}\n </Typography>\n <Stack direction=\"row\" spacing={0.75} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"h6\">{value}</Typography>\n {deltaPct === null ? null : (\n <Tooltip title={deltaCaption}>\n <Typography variant=\"caption\" sx={{ color, fontWeight: 600 }}>\n {`${deltaPct > 0 ? '+' : ''}${deltaPct}%`}\n </Typography>\n </Tooltip>\n )}\n </Stack>\n </Box>\n )\n}\nCommerceStatTile.displayName = 'CommerceStatTile'\n\nexport default CommerceStatTile\n"],"names":["Box","Stack","Tooltip","Typography","CommerceStatTile","props","label","value","deltaPct","deltaCaption","riseIsGood","rose","flat","color","variant","direction","spacing","sx","alignItems","title","fontWeight","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,GAAG,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,QAAQ,gBAAe;AAuB/D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EACJC,KAAK,EACLC,KAAK,EACLC,WAAW,IAAI,EACfC,eAAe,wBAAwB,EACvCC,aAAa,IAAI,EAClB,GAAGL;IACJ,MAAMM,OAAO,CAACH,mBAAAA,WAAY,KAAK;IAC/B,MAAMI,OAAOJ,aAAa;IAC1B,MAAMK,QAAQD,OACV,mBACAD,SAASD,aACP,iBACA;IACN,qBACE,MAACV;;0BACC,KAACG;gBAAWW,SAAQ;gBAAUD,OAAM;0BACjCP;;0BAEH,MAACL;gBAAMc,WAAU;gBAAMC,SAAS;gBAAMC,IAAI;oBAAEC,YAAY;gBAAW;;kCACjE,KAACf;wBAAWW,SAAQ;kCAAMP;;oBACzBC,aAAa,OAAO,qBACnB,KAACN;wBAAQiB,OAAOV;kCACd,cAAA,KAACN;4BAAWW,SAAQ;4BAAUG,IAAI;gCAAEJ;gCAAOO,YAAY;4BAAI;sCACxD,GAAGZ,WAAW,IAAI,MAAM,KAAKA,SAAS,CAAC,CAAC;;;;;;;AAOvD;AACAJ,iBAAiBiB,WAAW,GAAG;AAE/B,eAAejB,iBAAgB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface DiscountsCardProps {
|
|
2
|
+
hostId: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Discounts hub (AGL-305): code and automatic promotions with value,
|
|
6
|
+
* min-subtotal, schedule, and usage-limit controls, resolved at
|
|
7
|
+
* checkout/POS by the shared engine. Supersedes the simple coupons
|
|
8
|
+
* card (which keeps working for existing codes).
|
|
9
|
+
*/
|
|
10
|
+
export declare function DiscountsCard(props: DiscountsCardProps): import("react").JSX.Element;
|
|
11
|
+
export declare namespace DiscountsCard {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export default DiscountsCard;
|