@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,560 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
19
|
+
import * as Aglyn from "@aglyn/aglyn";
|
|
20
|
+
import * as CommerceModel from "../../model/index.js";
|
|
21
|
+
import { CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
22
|
+
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
23
|
+
import { Alert, AlertTitle, Button, Divider, FormControlLabel, MenuItem, Stack, Switch, TextField, Typography } from "@mui/material";
|
|
24
|
+
import { doc, setDoc } from "firebase/firestore";
|
|
25
|
+
import { useCallback, useState } from "react";
|
|
26
|
+
import { useFirestore } from "@aglyn/tenant-feature-instance";
|
|
27
|
+
import { useFirestoreDoc, writeGuardedBySeed } from "@aglyn/tenant-feature-instance";
|
|
28
|
+
import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
29
|
+
/**
|
|
30
|
+
* Shipping settings (AGL-288): zones (countries, '*' = rest of world)
|
|
31
|
+
* and rates (flat / free-over / subtotal or weight tiers), stored on
|
|
32
|
+
* `hosts/{hostId}/settings/store` under `shipping`. Cart checkout (AGL-1707)
|
|
33
|
+
* and buy-now (AGL-1720) both read this document and declare the rates as
|
|
34
|
+
* Stripe `shipping_options` (`planCheckoutShipping`) — until those landed
|
|
35
|
+
* nothing read it, and everything saved here was charged to nobody. Buy-now
|
|
36
|
+
* resolves only for physical one-time sales; draft orders and POS still
|
|
37
|
+
* resolve no shipping at all.
|
|
38
|
+
*
|
|
39
|
+
* WHAT A ZONE LAYOUT COSTS THE SHOPPER (AGL-1721). A session's rates are
|
|
40
|
+
* charged as picked and never re-checked against the address, so the checkout
|
|
41
|
+
* can only offer rates that hold for every country it will ship to. Saving
|
|
42
|
+
* zones whose rates DIFFER therefore makes the storefront ask the shopper
|
|
43
|
+
* where the parcel is going before it can price one, and a destination no
|
|
44
|
+
* zone covers is refused outright rather than shipped for free. One zone, or
|
|
45
|
+
* one '*' zone, needs neither: the shopper is asked nothing.
|
|
46
|
+
*
|
|
47
|
+
* AND THE MERCHANT HAS TO BE ABLE TO SEE IT (AGL-1791). Both consequences
|
|
48
|
+
* were invisible here: a merchant saved zones and the checkouts they refused
|
|
49
|
+
* were refused with nothing on this page saying so, which is a support ticket
|
|
50
|
+
* from someone who did nothing wrong. The coverage block reads
|
|
51
|
+
* `summarizeShippingCoverage` off the same `current` object the save writes,
|
|
52
|
+
* so it moves as the form is typed rather than after a round trip.
|
|
53
|
+
*
|
|
54
|
+
* It escalates to a warning ONLY for a merchant who priced some destinations
|
|
55
|
+
* and not others. A merchant whose rates reach nowhere is not misconfigured —
|
|
56
|
+
* that store charges no shipping and refuses nobody — and warning them would
|
|
57
|
+
* nag every store selling downloads.
|
|
58
|
+
*/ export function ShippingSettingsCard(props) {
|
|
59
|
+
var _ref, _current_zones, _current_rates, _ref1;
|
|
60
|
+
var _current_zones1;
|
|
61
|
+
const { hostId } = props;
|
|
62
|
+
const firestore = useFirestore();
|
|
63
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
64
|
+
const { data: store, status: storeStatus, /**
|
|
65
|
+
* The settings doc this form is seeded from is unconfirmed by the server
|
|
66
|
+
* (AGL-1358). `current` is `draft ?? store?.shipping ?? {}` and the save
|
|
67
|
+
* writes `{shipping: current}`, so `merge: true` protects the doc's other
|
|
68
|
+
* maps and nothing inside this one — `zones` and `rates` are arrays, and
|
|
69
|
+
* a merge replaces an array wholesale. Against a cached read, adding one
|
|
70
|
+
* rate restores that snapshot's whole price table, and a zone that
|
|
71
|
+
* disappears with it means `resolveShippingRates` matches nothing, which
|
|
72
|
+
* is a checkout offering no shipping option at all.
|
|
73
|
+
*/ fromCache: storeFromCache } = useFirestoreDoc(()=>doc(firestore, 'hosts', hostId, 'settings', 'store'), [
|
|
74
|
+
firestore,
|
|
75
|
+
hostId
|
|
76
|
+
]);
|
|
77
|
+
const [draft, setDraft] = useState(null);
|
|
78
|
+
const current = (_ref = draft != null ? draft : store == null ? void 0 : store.shipping) != null ? _ref : {};
|
|
79
|
+
const update = (patch)=>setDraft(_extends({}, current, patch));
|
|
80
|
+
const updateZone = (index, patch)=>{
|
|
81
|
+
var _current_zones;
|
|
82
|
+
const zones = [
|
|
83
|
+
...(_current_zones = current.zones) != null ? _current_zones : []
|
|
84
|
+
];
|
|
85
|
+
if (patch === null) {
|
|
86
|
+
var _current_rates;
|
|
87
|
+
const removed = zones.splice(index, 1)[0];
|
|
88
|
+
update({
|
|
89
|
+
zones,
|
|
90
|
+
rates: ((_current_rates = current.rates) != null ? _current_rates : []).filter((rate)=>rate.zoneId !== (removed == null ? void 0 : removed.id))
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
zones[index] = _extends({
|
|
95
|
+
id: Aglyn.createResourceUid(),
|
|
96
|
+
name: '',
|
|
97
|
+
countries: []
|
|
98
|
+
}, zones[index], patch);
|
|
99
|
+
update({
|
|
100
|
+
zones
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const updateRate = (index, patch)=>{
|
|
104
|
+
var _current_rates, _ref;
|
|
105
|
+
var _current_zones_, _current_zones;
|
|
106
|
+
const rates = [
|
|
107
|
+
...(_current_rates = current.rates) != null ? _current_rates : []
|
|
108
|
+
];
|
|
109
|
+
if (patch === null) rates.splice(index, 1);
|
|
110
|
+
else rates[index] = _extends({
|
|
111
|
+
id: Aglyn.createResourceUid(),
|
|
112
|
+
zoneId: (_ref = (_current_zones = current.zones) == null ? void 0 : (_current_zones_ = _current_zones[0]) == null ? void 0 : _current_zones_.id) != null ? _ref : '',
|
|
113
|
+
name: '',
|
|
114
|
+
kind: 'flat'
|
|
115
|
+
}, rates[index], patch);
|
|
116
|
+
update({
|
|
117
|
+
rates
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const handleSave = useCallback(async ()=>{
|
|
121
|
+
/**
|
|
122
|
+
* Refuse a save whose seed the server never confirmed (AGL-1358).
|
|
123
|
+
*
|
|
124
|
+
* No create path to exempt: this is a FIXED document path, so the empty
|
|
125
|
+
* `{}` that `store?.shipping ?? {}` yields when the cache has never seen
|
|
126
|
+
* the map is not the harmless blank a fresh uid would be — it replaces
|
|
127
|
+
* the real zones and rates with nothing.
|
|
128
|
+
*
|
|
129
|
+
* The guard WRAPS the write — an early return is a shape you can keep
|
|
130
|
+
* while losing the protection.
|
|
131
|
+
*/ const verdict = await writeGuardedBySeed({
|
|
132
|
+
subject: 'shipping settings',
|
|
133
|
+
unreadable: storeStatus === 'error',
|
|
134
|
+
fromCache: storeFromCache
|
|
135
|
+
}, async ()=>{
|
|
136
|
+
await setDoc(doc(firestore, 'hosts', hostId, 'settings', 'store'), {
|
|
137
|
+
shipping: current
|
|
138
|
+
}, {
|
|
139
|
+
merge: true
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
// Before `setDraft(null)`, so a refusal keeps every zone and rate that
|
|
143
|
+
// was typed on screen.
|
|
144
|
+
if (!verdict.ok) {
|
|
145
|
+
return void enqueueSnackbar(verdict.message, {
|
|
146
|
+
variant: 'warning',
|
|
147
|
+
persist: false
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
setDraft(null);
|
|
151
|
+
enqueueSnackbar('Shipping settings saved', {
|
|
152
|
+
variant: 'success',
|
|
153
|
+
persist: false
|
|
154
|
+
});
|
|
155
|
+
}, [
|
|
156
|
+
current,
|
|
157
|
+
firestore,
|
|
158
|
+
hostId,
|
|
159
|
+
enqueueSnackbar,
|
|
160
|
+
storeStatus,
|
|
161
|
+
storeFromCache
|
|
162
|
+
]);
|
|
163
|
+
/**
|
|
164
|
+
* Recomputed from `current` on every render, so the block answers for what
|
|
165
|
+
* is typed rather than for what was last saved — a merchant deleting the
|
|
166
|
+
* zone that covered France should see France go uncovered before they
|
|
167
|
+
* commit it, not after.
|
|
168
|
+
*/ const coverage = CommerceModel.summarizeShippingCoverage(current);
|
|
169
|
+
const countryNames = (codes)=>codes.map((code)=>{
|
|
170
|
+
var _CommerceModel_CHECKOUT_SHIPPING_COUNTRY_NAMES_code;
|
|
171
|
+
return (_CommerceModel_CHECKOUT_SHIPPING_COUNTRY_NAMES_code = CommerceModel.CHECKOUT_SHIPPING_COUNTRY_NAMES[code]) != null ? _CommerceModel_CHECKOUT_SHIPPING_COUNTRY_NAMES_code : code;
|
|
172
|
+
}).join(', ');
|
|
173
|
+
/**
|
|
174
|
+
* The one-click half of the fix: a zone claiming everywhere the merchant
|
|
175
|
+
* has not named. It adds the ZONE only — a rate on it prices the parcel,
|
|
176
|
+
* and choosing that price is the merchant's call, not ours. A rate row
|
|
177
|
+
* defaulted here would post at whatever we picked, and a blank flat rate
|
|
178
|
+
* resolves to free.
|
|
179
|
+
*/ const addRestOfWorldZone = ()=>{
|
|
180
|
+
var _ref;
|
|
181
|
+
var _current_zones;
|
|
182
|
+
return updateZone((_ref = (_current_zones = current.zones) == null ? void 0 : _current_zones.length) != null ? _ref : 0, {
|
|
183
|
+
name: 'Rest of world',
|
|
184
|
+
countries: [
|
|
185
|
+
'*'
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
const usd = (cents)=>cents == null ? '' : String(cents / 100);
|
|
190
|
+
const cents = (raw)=>raw.trim() === '' ? undefined : Math.round(Number(raw) * 100);
|
|
191
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
192
|
+
header: 'Shipping',
|
|
193
|
+
help: pluginDocsHelp('commerce', {
|
|
194
|
+
anchor: '#shipping--taxes'
|
|
195
|
+
}),
|
|
196
|
+
contentGutterX: true,
|
|
197
|
+
contentGutterY: true,
|
|
198
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
199
|
+
spacing: 1.5,
|
|
200
|
+
children: [
|
|
201
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
202
|
+
variant: "subtitle2",
|
|
203
|
+
children: 'Zones'
|
|
204
|
+
}),
|
|
205
|
+
((_current_zones = current.zones) != null ? _current_zones : []).map((zone, index)=>/*#__PURE__*/ _jsxs(Stack, {
|
|
206
|
+
direction: "row",
|
|
207
|
+
spacing: 1,
|
|
208
|
+
children: [
|
|
209
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
210
|
+
label: "Zone name",
|
|
211
|
+
value: zone.name,
|
|
212
|
+
onChange: (event)=>updateZone(index, {
|
|
213
|
+
name: event.target.value
|
|
214
|
+
}),
|
|
215
|
+
size: "small",
|
|
216
|
+
sx: {
|
|
217
|
+
width: 180
|
|
218
|
+
}
|
|
219
|
+
}),
|
|
220
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
221
|
+
label: "Countries",
|
|
222
|
+
value: zone.countries.join(', '),
|
|
223
|
+
onChange: (event)=>updateZone(index, {
|
|
224
|
+
countries: event.target.value.split(',').map((code)=>code.trim().toUpperCase()).filter(Boolean)
|
|
225
|
+
}),
|
|
226
|
+
size: "small",
|
|
227
|
+
sx: {
|
|
228
|
+
flex: 1
|
|
229
|
+
},
|
|
230
|
+
placeholder: "US, CA — or * for everywhere else"
|
|
231
|
+
}),
|
|
232
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
233
|
+
size: "small",
|
|
234
|
+
color: "error",
|
|
235
|
+
onClick: ()=>updateZone(index, null),
|
|
236
|
+
children: '✕'
|
|
237
|
+
})
|
|
238
|
+
]
|
|
239
|
+
}, zone.id)),
|
|
240
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
241
|
+
size: "small",
|
|
242
|
+
sx: {
|
|
243
|
+
alignSelf: 'flex-start'
|
|
244
|
+
},
|
|
245
|
+
onClick: ()=>{
|
|
246
|
+
var _ref;
|
|
247
|
+
var _current_zones;
|
|
248
|
+
return updateZone((_ref = (_current_zones = current.zones) == null ? void 0 : _current_zones.length) != null ? _ref : 0, {});
|
|
249
|
+
},
|
|
250
|
+
children: 'Add zone'
|
|
251
|
+
}),
|
|
252
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
253
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
254
|
+
variant: "subtitle2",
|
|
255
|
+
children: 'Rates'
|
|
256
|
+
}),
|
|
257
|
+
((_current_rates = current.rates) != null ? _current_rates : []).map((rate, index)=>{
|
|
258
|
+
var _current_zones, _rate_tiers;
|
|
259
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
260
|
+
spacing: 1,
|
|
261
|
+
children: [
|
|
262
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
263
|
+
direction: "row",
|
|
264
|
+
spacing: 1,
|
|
265
|
+
children: [
|
|
266
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
267
|
+
label: "Zone",
|
|
268
|
+
value: rate.zoneId,
|
|
269
|
+
onChange: (event)=>updateRate(index, {
|
|
270
|
+
zoneId: event.target.value
|
|
271
|
+
}),
|
|
272
|
+
size: "small",
|
|
273
|
+
select: true,
|
|
274
|
+
sx: {
|
|
275
|
+
width: 150
|
|
276
|
+
},
|
|
277
|
+
children: ((_current_zones = current.zones) != null ? _current_zones : []).map((zone)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
278
|
+
value: zone.id,
|
|
279
|
+
children: zone.name || zone.countries.join(',')
|
|
280
|
+
}, zone.id))
|
|
281
|
+
}),
|
|
282
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
283
|
+
label: "Name",
|
|
284
|
+
value: rate.name,
|
|
285
|
+
onChange: (event)=>updateRate(index, {
|
|
286
|
+
name: event.target.value
|
|
287
|
+
}),
|
|
288
|
+
size: "small",
|
|
289
|
+
sx: {
|
|
290
|
+
flex: 1
|
|
291
|
+
},
|
|
292
|
+
placeholder: "Standard",
|
|
293
|
+
/**
|
|
294
|
+
* A rate with no name is DROPPED at checkout, silently
|
|
295
|
+
* (AGL-1791): Stripe requires a `display_name`, so
|
|
296
|
+
* `resolveCheckoutShippingOptions` skips the row rather than
|
|
297
|
+
* emit a session Stripe would reject. Saved blank it looks
|
|
298
|
+
* like a priced rate on this page and is not one anywhere
|
|
299
|
+
* else, which is the same invisibility the coverage block
|
|
300
|
+
* below exists to end — said on the row that causes it,
|
|
301
|
+
* because the block can only report the destination it costs.
|
|
302
|
+
*/ error: !rate.name.trim(),
|
|
303
|
+
helperText: rate.name.trim() ? undefined : 'Needed — checkout drops it'
|
|
304
|
+
}),
|
|
305
|
+
/*#__PURE__*/ _jsxs(TextField, {
|
|
306
|
+
label: "Type",
|
|
307
|
+
value: rate.kind,
|
|
308
|
+
onChange: (event)=>updateRate(index, {
|
|
309
|
+
kind: event.target.value
|
|
310
|
+
}),
|
|
311
|
+
size: "small",
|
|
312
|
+
select: true,
|
|
313
|
+
sx: {
|
|
314
|
+
width: 170
|
|
315
|
+
},
|
|
316
|
+
children: [
|
|
317
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
318
|
+
value: "flat",
|
|
319
|
+
children: 'Flat'
|
|
320
|
+
}),
|
|
321
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
322
|
+
value: "free_over",
|
|
323
|
+
children: 'Free over subtotal'
|
|
324
|
+
}),
|
|
325
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
326
|
+
value: "price_tiers",
|
|
327
|
+
children: 'Subtotal tiers'
|
|
328
|
+
}),
|
|
329
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
330
|
+
value: "weight_tiers",
|
|
331
|
+
children: 'Weight tiers'
|
|
332
|
+
})
|
|
333
|
+
]
|
|
334
|
+
}),
|
|
335
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
336
|
+
size: "small",
|
|
337
|
+
color: "error",
|
|
338
|
+
onClick: ()=>updateRate(index, null),
|
|
339
|
+
children: '✕'
|
|
340
|
+
})
|
|
341
|
+
]
|
|
342
|
+
}),
|
|
343
|
+
rate.kind === 'flat' || rate.kind === 'free_over' ? /*#__PURE__*/ _jsxs(Stack, {
|
|
344
|
+
direction: "row",
|
|
345
|
+
spacing: 1,
|
|
346
|
+
children: [
|
|
347
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
348
|
+
label: "Price ($)",
|
|
349
|
+
value: usd(rate.amountCents),
|
|
350
|
+
onChange: (event)=>updateRate(index, {
|
|
351
|
+
amountCents: cents(event.target.value)
|
|
352
|
+
}),
|
|
353
|
+
size: "small",
|
|
354
|
+
sx: {
|
|
355
|
+
width: 120
|
|
356
|
+
},
|
|
357
|
+
slotProps: {
|
|
358
|
+
htmlInput: {
|
|
359
|
+
inputMode: 'decimal'
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}),
|
|
363
|
+
rate.kind === 'free_over' ? /*#__PURE__*/ _jsx(TextField, {
|
|
364
|
+
label: "Free at subtotal ($)",
|
|
365
|
+
value: usd(rate.freeOverCents),
|
|
366
|
+
onChange: (event)=>updateRate(index, {
|
|
367
|
+
freeOverCents: cents(event.target.value)
|
|
368
|
+
}),
|
|
369
|
+
size: "small",
|
|
370
|
+
sx: {
|
|
371
|
+
width: 160
|
|
372
|
+
},
|
|
373
|
+
slotProps: {
|
|
374
|
+
htmlInput: {
|
|
375
|
+
inputMode: 'decimal'
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}) : null
|
|
379
|
+
]
|
|
380
|
+
}) : /*#__PURE__*/ _jsxs(Stack, {
|
|
381
|
+
spacing: 1,
|
|
382
|
+
sx: {
|
|
383
|
+
pl: 2
|
|
384
|
+
},
|
|
385
|
+
children: [
|
|
386
|
+
((_rate_tiers = rate.tiers) != null ? _rate_tiers : []).map((tier, tierIndex)=>/*#__PURE__*/ _jsxs(Stack, {
|
|
387
|
+
direction: "row",
|
|
388
|
+
spacing: 1,
|
|
389
|
+
children: [
|
|
390
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
391
|
+
label: rate.kind === 'weight_tiers' ? 'Up to (g)' : 'Up to subtotal ($)',
|
|
392
|
+
value: rate.kind === 'weight_tiers' ? tier.upTo : tier.upTo / 100,
|
|
393
|
+
onChange: (event)=>{
|
|
394
|
+
var _rate_tiers;
|
|
395
|
+
const tiers = [
|
|
396
|
+
...(_rate_tiers = rate.tiers) != null ? _rate_tiers : []
|
|
397
|
+
];
|
|
398
|
+
const value = Number(event.target.value) || 0;
|
|
399
|
+
tiers[tierIndex] = _extends({}, tier, {
|
|
400
|
+
upTo: rate.kind === 'weight_tiers' ? Math.round(value) : Math.round(value * 100)
|
|
401
|
+
});
|
|
402
|
+
updateRate(index, {
|
|
403
|
+
tiers
|
|
404
|
+
});
|
|
405
|
+
},
|
|
406
|
+
size: "small",
|
|
407
|
+
sx: {
|
|
408
|
+
width: 160
|
|
409
|
+
},
|
|
410
|
+
slotProps: {
|
|
411
|
+
htmlInput: {
|
|
412
|
+
inputMode: 'decimal'
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}),
|
|
416
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
417
|
+
label: "Price ($)",
|
|
418
|
+
value: tier.amountCents / 100,
|
|
419
|
+
onChange: (event)=>{
|
|
420
|
+
var _rate_tiers;
|
|
421
|
+
const tiers = [
|
|
422
|
+
...(_rate_tiers = rate.tiers) != null ? _rate_tiers : []
|
|
423
|
+
];
|
|
424
|
+
tiers[tierIndex] = _extends({}, tier, {
|
|
425
|
+
amountCents: Math.round((Number(event.target.value) || 0) * 100)
|
|
426
|
+
});
|
|
427
|
+
updateRate(index, {
|
|
428
|
+
tiers
|
|
429
|
+
});
|
|
430
|
+
},
|
|
431
|
+
size: "small",
|
|
432
|
+
sx: {
|
|
433
|
+
width: 120
|
|
434
|
+
},
|
|
435
|
+
slotProps: {
|
|
436
|
+
htmlInput: {
|
|
437
|
+
inputMode: 'decimal'
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}),
|
|
441
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
442
|
+
size: "small",
|
|
443
|
+
color: "error",
|
|
444
|
+
onClick: ()=>{
|
|
445
|
+
var _rate_tiers;
|
|
446
|
+
return updateRate(index, {
|
|
447
|
+
tiers: ((_rate_tiers = rate.tiers) != null ? _rate_tiers : []).filter((_item, itemIndex)=>itemIndex !== tierIndex)
|
|
448
|
+
});
|
|
449
|
+
},
|
|
450
|
+
children: '✕'
|
|
451
|
+
})
|
|
452
|
+
]
|
|
453
|
+
}, tierIndex)),
|
|
454
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
455
|
+
size: "small",
|
|
456
|
+
sx: {
|
|
457
|
+
alignSelf: 'flex-start'
|
|
458
|
+
},
|
|
459
|
+
onClick: ()=>{
|
|
460
|
+
var _rate_tiers;
|
|
461
|
+
return updateRate(index, {
|
|
462
|
+
tiers: [
|
|
463
|
+
...(_rate_tiers = rate.tiers) != null ? _rate_tiers : [],
|
|
464
|
+
{
|
|
465
|
+
upTo: 0,
|
|
466
|
+
amountCents: 0
|
|
467
|
+
}
|
|
468
|
+
]
|
|
469
|
+
});
|
|
470
|
+
},
|
|
471
|
+
children: 'Add tier'
|
|
472
|
+
})
|
|
473
|
+
]
|
|
474
|
+
})
|
|
475
|
+
]
|
|
476
|
+
}, rate.id);
|
|
477
|
+
}),
|
|
478
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
479
|
+
size: "small",
|
|
480
|
+
disabled: ((_ref1 = (_current_zones1 = current.zones) == null ? void 0 : _current_zones1.length) != null ? _ref1 : 0) === 0,
|
|
481
|
+
sx: {
|
|
482
|
+
alignSelf: 'flex-start'
|
|
483
|
+
},
|
|
484
|
+
onClick: ()=>{
|
|
485
|
+
var _ref;
|
|
486
|
+
var _current_rates;
|
|
487
|
+
return updateRate((_ref = (_current_rates = current.rates) == null ? void 0 : _current_rates.length) != null ? _ref : 0, {});
|
|
488
|
+
},
|
|
489
|
+
children: 'Add rate'
|
|
490
|
+
}),
|
|
491
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
492
|
+
spacing: 0,
|
|
493
|
+
children: [
|
|
494
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
495
|
+
control: /*#__PURE__*/ _jsx(Switch, {
|
|
496
|
+
size: "small",
|
|
497
|
+
checked: Boolean(current.localPickup),
|
|
498
|
+
onChange: (event)=>update({
|
|
499
|
+
localPickup: event.target.checked
|
|
500
|
+
})
|
|
501
|
+
}),
|
|
502
|
+
label: "Offer free local pickup"
|
|
503
|
+
}),
|
|
504
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
505
|
+
variant: "caption",
|
|
506
|
+
color: "text.secondary",
|
|
507
|
+
children: 'A free collection choice at checkout. It does not widen where ' + 'you ship — a destination none of your rates reaches is still ' + 'turned away.'
|
|
508
|
+
})
|
|
509
|
+
]
|
|
510
|
+
}),
|
|
511
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
512
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
513
|
+
variant: "subtitle2",
|
|
514
|
+
children: 'Coverage'
|
|
515
|
+
}),
|
|
516
|
+
coverage.unserved.length > 0 ? /*#__PURE__*/ _jsxs(Alert, {
|
|
517
|
+
severity: "warning",
|
|
518
|
+
action: coverage.hasRestOfWorldZone ? undefined : /*#__PURE__*/ _jsx(Button, {
|
|
519
|
+
size: "small",
|
|
520
|
+
color: "inherit",
|
|
521
|
+
onClick: addRestOfWorldZone,
|
|
522
|
+
children: 'Add rest-of-world zone'
|
|
523
|
+
}),
|
|
524
|
+
children: [
|
|
525
|
+
/*#__PURE__*/ _jsx(AlertTitle, {
|
|
526
|
+
children: `Checkout turns away ${coverage.unserved.length} of the ${CommerceModel.CHECKOUT_SHIPPING_COUNTRIES.length} destinations it collects addresses for`
|
|
527
|
+
}),
|
|
528
|
+
`No rate reaches ${countryNames(coverage.unserved)}, so an order shipping there is refused rather than posted for free. `,
|
|
529
|
+
coverage.offersLocalPickup ? 'Local pickup does not cover them: it is a collection choice, not a rate, so it is offered where checkout completes and closes no gap here. ' : '',
|
|
530
|
+
coverage.hasRestOfWorldZone ? 'A rest-of-world zone is already saved, so what those destinations are missing is a rate on the zone that covers them.' : 'Give them a zone with a rate, or add a rest-of-world zone and price one on it.'
|
|
531
|
+
]
|
|
532
|
+
}) : /*#__PURE__*/ _jsx(Typography, {
|
|
533
|
+
variant: "caption",
|
|
534
|
+
color: "text.secondary",
|
|
535
|
+
children: coverage.shipsNowhere ? coverage.offersLocalPickup ? 'No rate reaches any destination, so local pickup is the only delivery choice checkout offers. Nobody is turned away and no shipping is charged.' : 'No rate reaches any destination, so checkout charges no shipping and turns nobody away.' : `Checkout can price shipping to every destination it collects an address for: ${countryNames(coverage.served)}.`
|
|
536
|
+
}),
|
|
537
|
+
coverage.asksDestination ? /*#__PURE__*/ _jsx(Typography, {
|
|
538
|
+
variant: "caption",
|
|
539
|
+
color: "text.secondary",
|
|
540
|
+
children: 'Rates differ by destination, so checkout asks the shopper where the parcel is going before it can price one.'
|
|
541
|
+
}) : null,
|
|
542
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
543
|
+
variant: "contained",
|
|
544
|
+
color: "primary",
|
|
545
|
+
size: "small",
|
|
546
|
+
disabled: !draft,
|
|
547
|
+
onClick: handleSave,
|
|
548
|
+
sx: {
|
|
549
|
+
alignSelf: 'flex-start'
|
|
550
|
+
},
|
|
551
|
+
children: 'Save shipping settings'
|
|
552
|
+
})
|
|
553
|
+
]
|
|
554
|
+
})
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
ShippingSettingsCard.displayName = 'ShippingSettingsCard';
|
|
558
|
+
export default ShippingSettingsCard;
|
|
559
|
+
|
|
560
|
+
//# sourceMappingURL=shipping-settings-card.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/shipping-settings-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport * as CommerceModel from '../../model'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Alert,\n AlertTitle,\n Button,\n Divider,\n FormControlLabel,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { doc, setDoc } from 'firebase/firestore'\nimport { useCallback, useState } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport {\n useFirestoreDoc,\n writeGuardedBySeed,\n} from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\n\nexport interface ShippingSettingsCardProps {\n hostId: string\n}\n\n/**\n * Shipping settings (AGL-288): zones (countries, '*' = rest of world)\n * and rates (flat / free-over / subtotal or weight tiers), stored on\n * `hosts/{hostId}/settings/store` under `shipping`. Cart checkout (AGL-1707)\n * and buy-now (AGL-1720) both read this document and declare the rates as\n * Stripe `shipping_options` (`planCheckoutShipping`) — until those landed\n * nothing read it, and everything saved here was charged to nobody. Buy-now\n * resolves only for physical one-time sales; draft orders and POS still\n * resolve no shipping at all.\n *\n * WHAT A ZONE LAYOUT COSTS THE SHOPPER (AGL-1721). A session's rates are\n * charged as picked and never re-checked against the address, so the checkout\n * can only offer rates that hold for every country it will ship to. Saving\n * zones whose rates DIFFER therefore makes the storefront ask the shopper\n * where the parcel is going before it can price one, and a destination no\n * zone covers is refused outright rather than shipped for free. One zone, or\n * one '*' zone, needs neither: the shopper is asked nothing.\n *\n * AND THE MERCHANT HAS TO BE ABLE TO SEE IT (AGL-1791). Both consequences\n * were invisible here: a merchant saved zones and the checkouts they refused\n * were refused with nothing on this page saying so, which is a support ticket\n * from someone who did nothing wrong. The coverage block reads\n * `summarizeShippingCoverage` off the same `current` object the save writes,\n * so it moves as the form is typed rather than after a round trip.\n *\n * It escalates to a warning ONLY for a merchant who priced some destinations\n * and not others. A merchant whose rates reach nowhere is not misconfigured —\n * that store charges no shipping and refuses nobody — and warning them would\n * nag every store selling downloads.\n */\nexport function ShippingSettingsCard(props: ShippingSettingsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n const {\n data: store,\n status: storeStatus,\n /**\n * The settings doc this form is seeded from is unconfirmed by the server\n * (AGL-1358). `current` is `draft ?? store?.shipping ?? {}` and the save\n * writes `{shipping: current}`, so `merge: true` protects the doc's other\n * maps and nothing inside this one — `zones` and `rates` are arrays, and\n * a merge replaces an array wholesale. Against a cached read, adding one\n * rate restores that snapshot's whole price table, and a zone that\n * disappears with it means `resolveShippingRates` matches nothing, which\n * is a checkout offering no shipping option at all.\n */\n fromCache: storeFromCache,\n } = useFirestoreDoc<any>(\n () => doc(firestore, 'hosts', hostId, 'settings', 'store'),\n [firestore, hostId],\n )\n const [draft, setDraft] = useState<CommerceModel.ShippingSettings | null>(null)\n const current: CommerceModel.ShippingSettings = draft ?? store?.shipping ?? {}\n const update = (patch: Partial<CommerceModel.ShippingSettings>) =>\n setDraft({ ...current, ...patch })\n\n const updateZone = (\n index: number,\n patch: Partial<CommerceModel.ShippingZone> | null,\n ) => {\n const zones = [...(current.zones ?? [])]\n if (patch === null) {\n const removed = zones.splice(index, 1)[0]\n update({\n zones,\n rates: (current.rates ?? []).filter(\n (rate) => rate.zoneId !== removed?.id,\n ),\n })\n return\n }\n zones[index] = {\n id: Aglyn.createResourceUid(),\n name: '',\n countries: [],\n ...zones[index],\n ...patch,\n }\n update({ zones })\n }\n\n const updateRate = (\n index: number,\n patch: Partial<CommerceModel.ShippingRate> | null,\n ) => {\n const rates = [...(current.rates ?? [])]\n if (patch === null) rates.splice(index, 1)\n else\n rates[index] = {\n id: Aglyn.createResourceUid(),\n zoneId: current.zones?.[0]?.id ?? '',\n name: '',\n kind: 'flat',\n ...rates[index],\n ...patch,\n }\n update({ rates })\n }\n\n const handleSave = useCallback(async () => {\n /**\n * Refuse a save whose seed the server never confirmed (AGL-1358).\n *\n * No create path to exempt: this is a FIXED document path, so the empty\n * `{}` that `store?.shipping ?? {}` yields when the cache has never seen\n * the map is not the harmless blank a fresh uid would be — it replaces\n * the real zones and rates with nothing.\n *\n * The guard WRAPS the write — an early return is a shape you can keep\n * while losing the protection.\n */\n const verdict = await writeGuardedBySeed(\n {\n subject: 'shipping settings',\n unreadable: storeStatus === 'error',\n fromCache: storeFromCache,\n },\n async () => {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'settings', 'store'),\n { shipping: current },\n { merge: true },\n )\n },\n )\n // Before `setDraft(null)`, so a refusal keeps every zone and rate that\n // was typed on screen.\n if (!verdict.ok) {\n return void enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n setDraft(null)\n enqueueSnackbar('Shipping settings saved', {\n variant: 'success',\n persist: false,\n })\n }, [current, firestore, hostId, enqueueSnackbar, storeStatus, storeFromCache])\n\n /**\n * Recomputed from `current` on every render, so the block answers for what\n * is typed rather than for what was last saved — a merchant deleting the\n * zone that covered France should see France go uncovered before they\n * commit it, not after.\n */\n const coverage = CommerceModel.summarizeShippingCoverage(current)\n const countryNames = (codes: readonly string[]) =>\n codes\n .map((code) => CommerceModel.CHECKOUT_SHIPPING_COUNTRY_NAMES[code] ?? code)\n .join(', ')\n /**\n * The one-click half of the fix: a zone claiming everywhere the merchant\n * has not named. It adds the ZONE only — a rate on it prices the parcel,\n * and choosing that price is the merchant's call, not ours. A rate row\n * defaulted here would post at whatever we picked, and a blank flat rate\n * resolves to free.\n */\n const addRestOfWorldZone = () =>\n updateZone(current.zones?.length ?? 0, {\n name: 'Rest of world',\n countries: ['*'],\n })\n\n const usd = (cents: number | undefined) =>\n cents == null ? '' : String(cents / 100)\n const cents = (raw: string) =>\n raw.trim() === '' ? undefined : Math.round(Number(raw) * 100)\n\n return (\n <CardDisplay\n header={'Shipping'}\n help={pluginDocsHelp('commerce', { anchor: '#shipping--taxes' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1.5}>\n <Typography variant=\"subtitle2\">{'Zones'}</Typography>\n {(current.zones ?? []).map((zone, index) => (\n <Stack key={zone.id} direction=\"row\" spacing={1}>\n <TextField\n label=\"Zone name\"\n value={zone.name}\n onChange={(event) =>\n updateZone(index, { name: event.target.value })\n }\n size=\"small\"\n sx={{ width: 180 }}\n />\n <TextField\n label=\"Countries\"\n value={zone.countries.join(', ')}\n onChange={(event) =>\n updateZone(index, {\n countries: event.target.value\n .split(',')\n .map((code) => code.trim().toUpperCase())\n .filter(Boolean),\n })\n }\n size=\"small\"\n sx={{ flex: 1 }}\n placeholder=\"US, CA — or * for everywhere else\"\n />\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() => updateZone(index, null)}\n >\n {'✕'}\n </Button>\n </Stack>\n ))}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() => updateZone(current.zones?.length ?? 0, {})}\n >\n {'Add zone'}\n </Button>\n\n <Divider />\n <Typography variant=\"subtitle2\">{'Rates'}</Typography>\n {(current.rates ?? []).map((rate, index) => (\n <Stack key={rate.id} spacing={1}>\n <Stack direction=\"row\" spacing={1}>\n <TextField\n label=\"Zone\"\n value={rate.zoneId}\n onChange={(event) =>\n updateRate(index, { zoneId: event.target.value })\n }\n size=\"small\"\n select\n sx={{ width: 150 }}\n >\n {(current.zones ?? []).map((zone) => (\n <MenuItem key={zone.id} value={zone.id}>\n {zone.name || zone.countries.join(',')}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n label=\"Name\"\n value={rate.name}\n onChange={(event) =>\n updateRate(index, { name: event.target.value })\n }\n size=\"small\"\n sx={{ flex: 1 }}\n placeholder=\"Standard\"\n /**\n * A rate with no name is DROPPED at checkout, silently\n * (AGL-1791): Stripe requires a `display_name`, so\n * `resolveCheckoutShippingOptions` skips the row rather than\n * emit a session Stripe would reject. Saved blank it looks\n * like a priced rate on this page and is not one anywhere\n * else, which is the same invisibility the coverage block\n * below exists to end — said on the row that causes it,\n * because the block can only report the destination it costs.\n */\n error={!rate.name.trim()}\n helperText={\n rate.name.trim() ? undefined : 'Needed — checkout drops it'\n }\n />\n <TextField\n label=\"Type\"\n value={rate.kind}\n onChange={(event) =>\n updateRate(index, {\n kind: event.target.value as CommerceModel.ShippingRate['kind'],\n })\n }\n size=\"small\"\n select\n sx={{ width: 170 }}\n >\n <MenuItem value=\"flat\">{'Flat'}</MenuItem>\n <MenuItem value=\"free_over\">{'Free over subtotal'}</MenuItem>\n <MenuItem value=\"price_tiers\">{'Subtotal tiers'}</MenuItem>\n <MenuItem value=\"weight_tiers\">{'Weight tiers'}</MenuItem>\n </TextField>\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() => updateRate(index, null)}\n >\n {'✕'}\n </Button>\n </Stack>\n {rate.kind === 'flat' || rate.kind === 'free_over' ? (\n <Stack direction=\"row\" spacing={1}>\n <TextField\n label=\"Price ($)\"\n value={usd(rate.amountCents)}\n onChange={(event) =>\n updateRate(index, { amountCents: cents(event.target.value) })\n }\n size=\"small\"\n sx={{ width: 120 }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n {rate.kind === 'free_over' ? (\n <TextField\n label=\"Free at subtotal ($)\"\n value={usd(rate.freeOverCents)}\n onChange={(event) =>\n updateRate(index, {\n freeOverCents: cents(event.target.value),\n })\n }\n size=\"small\"\n sx={{ width: 160 }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n ) : null}\n </Stack>\n ) : (\n <Stack spacing={1} sx={{ pl: 2 }}>\n {(rate.tiers ?? []).map((tier, tierIndex) => (\n <Stack key={tierIndex} direction=\"row\" spacing={1}>\n <TextField\n label={\n rate.kind === 'weight_tiers'\n ? 'Up to (g)'\n : 'Up to subtotal ($)'\n }\n value={\n rate.kind === 'weight_tiers'\n ? tier.upTo\n : tier.upTo / 100\n }\n onChange={(event) => {\n const tiers = [...(rate.tiers ?? [])]\n const value = Number(event.target.value) || 0\n tiers[tierIndex] = {\n ...tier,\n upTo:\n rate.kind === 'weight_tiers'\n ? Math.round(value)\n : Math.round(value * 100),\n }\n updateRate(index, { tiers })\n }}\n size=\"small\"\n sx={{ width: 160 }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n <TextField\n label=\"Price ($)\"\n value={tier.amountCents / 100}\n onChange={(event) => {\n const tiers = [...(rate.tiers ?? [])]\n tiers[tierIndex] = {\n ...tier,\n amountCents: Math.round(\n (Number(event.target.value) || 0) * 100,\n ),\n }\n updateRate(index, { tiers })\n }}\n size=\"small\"\n sx={{ width: 120 }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() =>\n updateRate(index, {\n tiers: (rate.tiers ?? []).filter(\n (_item, itemIndex) => itemIndex !== tierIndex,\n ),\n })\n }\n >\n {'✕'}\n </Button>\n </Stack>\n ))}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n updateRate(index, {\n tiers: [\n ...(rate.tiers ?? []),\n { upTo: 0, amountCents: 0 },\n ],\n })\n }\n >\n {'Add tier'}\n </Button>\n </Stack>\n )}\n </Stack>\n ))}\n <Button\n size=\"small\"\n disabled={(current.zones?.length ?? 0) === 0}\n sx={{ alignSelf: 'flex-start' }}\n onClick={() => updateRate(current.rates?.length ?? 0, {})}\n >\n {'Add rate'}\n </Button>\n\n <Stack spacing={0}>\n <FormControlLabel\n control={\n <Switch\n size=\"small\"\n checked={Boolean(current.localPickup)}\n onChange={(event) =>\n update({ localPickup: event.target.checked })\n }\n />\n }\n label=\"Offer free local pickup\"\n />\n {/*\n What the toggle does NOT do, said on the toggle (AGL-2325). It\n used to silently switch off every \"we don't ship there\" refusal,\n because pickup resolved for every destination and checkout read a\n non-empty list as coverage. It no longer does — but a merchant\n reading one line of label still has to be told that turning\n collection on is not the same as adding a destination.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {\n 'A free collection choice at checkout. It does not widen where ' +\n 'you ship — a destination none of your rates reaches is still ' +\n 'turned away.'\n }\n </Typography>\n </Stack>\n\n <Divider />\n <Typography variant=\"subtitle2\">{'Coverage'}</Typography>\n {coverage.unserved.length > 0 ? (\n <Alert\n severity=\"warning\"\n action={\n coverage.hasRestOfWorldZone ? undefined : (\n <Button\n size=\"small\"\n color=\"inherit\"\n onClick={addRestOfWorldZone}\n >\n {'Add rest-of-world zone'}\n </Button>\n )\n }\n >\n <AlertTitle>\n {`Checkout turns away ${coverage.unserved.length} of the ${CommerceModel.CHECKOUT_SHIPPING_COUNTRIES.length} destinations it collects addresses for`}\n </AlertTitle>\n {`No rate reaches ${countryNames(coverage.unserved)}, so an order shipping there is refused rather than posted for free. `}\n {coverage.offersLocalPickup\n ? 'Local pickup does not cover them: it is a collection choice, not a rate, so it is offered where checkout completes and closes no gap here. '\n : ''}\n {coverage.hasRestOfWorldZone\n ? 'A rest-of-world zone is already saved, so what those destinations are missing is a rate on the zone that covers them.'\n : 'Give them a zone with a rate, or add a rest-of-world zone and price one on it.'}\n </Alert>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {coverage.shipsNowhere\n ? coverage.offersLocalPickup\n ? 'No rate reaches any destination, so local pickup is the only delivery choice checkout offers. Nobody is turned away and no shipping is charged.'\n : 'No rate reaches any destination, so checkout charges no shipping and turns nobody away.'\n : `Checkout can price shipping to every destination it collects an address for: ${countryNames(coverage.served)}.`}\n </Typography>\n )}\n {coverage.asksDestination ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {\n 'Rates differ by destination, so checkout asks the shopper where the parcel is going before it can price one.'\n }\n </Typography>\n ) : null}\n\n <Button\n variant=\"contained\"\n color=\"primary\"\n size=\"small\"\n disabled={!draft}\n onClick={handleSave}\n sx={{ alignSelf: 'flex-start' }}\n >\n {'Save shipping settings'}\n </Button>\n </Stack>\n </CardDisplay>\n )\n}\nShippingSettingsCard.displayName = 'ShippingSettingsCard'\n\nexport default ShippingSettingsCard\n"],"names":["Aglyn","CommerceModel","CardDisplay","useSnackbar","Alert","AlertTitle","Button","Divider","FormControlLabel","MenuItem","Stack","Switch","TextField","Typography","doc","setDoc","useCallback","useState","useFirestore","useFirestoreDoc","writeGuardedBySeed","pluginDocsHelp","ShippingSettingsCard","props","draft","current","hostId","firestore","enqueueSnackbar","data","store","status","storeStatus","fromCache","storeFromCache","setDraft","shipping","update","patch","updateZone","index","zones","removed","splice","rates","filter","rate","zoneId","id","createResourceUid","name","countries","updateRate","kind","handleSave","verdict","subject","unreadable","merge","ok","message","variant","persist","coverage","summarizeShippingCoverage","countryNames","codes","map","code","CHECKOUT_SHIPPING_COUNTRY_NAMES","join","addRestOfWorldZone","length","usd","cents","String","raw","trim","undefined","Math","round","Number","header","help","anchor","contentGutterX","contentGutterY","spacing","zone","direction","label","value","onChange","event","target","size","sx","width","split","toUpperCase","Boolean","flex","placeholder","color","onClick","alignSelf","select","error","helperText","amountCents","slotProps","htmlInput","inputMode","freeOverCents","pl","tiers","tier","tierIndex","upTo","_item","itemIndex","disabled","control","checked","localPickup","unserved","severity","action","hasRestOfWorldZone","CHECKOUT_SHIPPING_COUNTRIES","offersLocalPickup","shipsNowhere","served","asksDestination","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,YAAYC,mBAAmB,uBAAa;AAC5C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,GAAG,EAAEC,MAAM,QAAQ,qBAAoB;AAChD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAC7C,SAASC,YAAY,QAAQ,iCAAgC;AAC7D,SACEC,eAAe,EACfC,kBAAkB,QACb,iCAAgC;AACvC,SAASC,cAAc,QAAQ,eAAc;AAM7C;;;;;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