@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,976 @@
|
|
|
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 * as CommerceModel from "../../model/index.js";
|
|
20
|
+
import { escapeHtml } from "../../utils/escape-html.js";
|
|
21
|
+
// The CRM's address from the SHARED builder, not the plugin (AGL-2622): the
|
|
22
|
+
// CRM already reaches marketing, and marketing reaches commerce, so an
|
|
23
|
+
// import of the CRM from here would close a cycle between the three
|
|
24
|
+
// plugins. The shared builder is pinned against the CRM's own routes by a
|
|
25
|
+
// spec, so the address is the same one the hub resolves.
|
|
26
|
+
import { crmContactByEmailHref } from "@aglyn/aglyn";
|
|
27
|
+
import { AppLink, useConfirmationContext } from "@aglyn/shared-ui-jsx";
|
|
28
|
+
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
29
|
+
import { Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Divider, Stack, TextField, Tooltip, Typography } from "@mui/material";
|
|
30
|
+
import { doc, runTransaction, updateDoc } from "firebase/firestore";
|
|
31
|
+
import { useParams } from "next/navigation";
|
|
32
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
33
|
+
import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
|
|
34
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
35
|
+
const STATUS_COLOR = {
|
|
36
|
+
pending: 'warning',
|
|
37
|
+
paid: 'info',
|
|
38
|
+
partially_fulfilled: 'info',
|
|
39
|
+
fulfilled: 'success',
|
|
40
|
+
delivered: 'success',
|
|
41
|
+
cancelled: 'default',
|
|
42
|
+
refunded: 'error'
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The dispute chip's colour (AGL-1796).
|
|
46
|
+
*
|
|
47
|
+
* `open` is WARNING rather than error because it is the case that still has a
|
|
48
|
+
* deadline on it — the merchant can still act, and a red chip on a case they
|
|
49
|
+
* might win says the money is gone when it is not. `lost` is the one that took
|
|
50
|
+
* the money, and shares `refunded`'s red for that reason.
|
|
51
|
+
*/ export const DISPUTE_COLOR = {
|
|
52
|
+
open: 'warning',
|
|
53
|
+
lost: 'error',
|
|
54
|
+
won: 'success',
|
|
55
|
+
settled: 'default'
|
|
56
|
+
};
|
|
57
|
+
const usd = (cents)=>`$${((cents != null ? cents : 0) / 100).toFixed(2)}`;
|
|
58
|
+
/**
|
|
59
|
+
* Order detail (AGL-287): timeline, line items, totals, and the actions
|
|
60
|
+
* the status machine allows — fulfill with tracking, refund, cancel, mark
|
|
61
|
+
* delivered (each a server route that re-asks the transition under the
|
|
62
|
+
* write), notes, printable packing slip.
|
|
63
|
+
*/ export function OrderDetailDialog(props) {
|
|
64
|
+
var _STATUS_COLOR_order_status, _order_lineItems, _order_timeline;
|
|
65
|
+
var _restock_lines;
|
|
66
|
+
const { hostId, order: rawOrder, onClose } = props;
|
|
67
|
+
const firestore = useFirestore();
|
|
68
|
+
const { data: user } = useUser();
|
|
69
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
70
|
+
const { confirm } = useConfirmationContext();
|
|
71
|
+
const [tracking, setTracking] = useState(null);
|
|
72
|
+
const [note, setNote] = useState('');
|
|
73
|
+
const [busy, setBusy] = useState(false);
|
|
74
|
+
const order = rawOrder ? CommerceModel.liftLegacyOrder(rawOrder) : null;
|
|
75
|
+
const orderId = rawOrder == null ? void 0 : rawOrder.$id;
|
|
76
|
+
/*
|
|
77
|
+
* Where the buyer's CONTACT is (AGL-2622). A checkout that carried an
|
|
78
|
+
* address updated a person in the CRM — a customer, with this order on
|
|
79
|
+
* their timeline — and the dialog links there by the address, because
|
|
80
|
+
* the contact's id is minted at capture and nothing on the order holds
|
|
81
|
+
* it. The Contacts list is the lookup and opens the record on one match.
|
|
82
|
+
* A guest checkout with no address updated nobody, so there is no link.
|
|
83
|
+
* Built from the route params already in the URL — no document is read
|
|
84
|
+
* to draw a link — and absent until they settle, so the dialog never
|
|
85
|
+
* offers a link to a half-built address.
|
|
86
|
+
*/ const params = useParams();
|
|
87
|
+
const customerCrmHref = (params == null ? void 0 : params.orgSlug) && (params == null ? void 0 : params.host) && (order == null ? void 0 : order.customerEmail) ? crmContactByEmailHref({
|
|
88
|
+
orgSlug: String(params.orgSlug),
|
|
89
|
+
host: String(params.host)
|
|
90
|
+
}, String(order.customerEmail)) : null;
|
|
91
|
+
/**
|
|
92
|
+
* The one client write left in this dialog, and it is timeline-only ON
|
|
93
|
+
* PURPOSE: notes carry no status, so `ORDER_TRANSITIONS` has nothing to say
|
|
94
|
+
* about them and they stay out of the server routes' way. Every status
|
|
95
|
+
* write goes through a route that re-asks the transition under the write —
|
|
96
|
+
* cancel (AGL-1818), fulfil and mark-delivered (AGL-1819), refund
|
|
97
|
+
* (AGL-1696). The moment a status rides along with a note, it must move
|
|
98
|
+
* too; `order-fulfill-wiring.spec.tsx` pins the patch to `timeline` alone.
|
|
99
|
+
*/ const write = useCallback(async (patch)=>{
|
|
100
|
+
if (!orderId) return;
|
|
101
|
+
await updateDoc(doc(firestore, 'hosts', hostId, 'orders', orderId), patch);
|
|
102
|
+
}, [
|
|
103
|
+
firestore,
|
|
104
|
+
hostId,
|
|
105
|
+
orderId
|
|
106
|
+
]);
|
|
107
|
+
/**
|
|
108
|
+
* Fulfil and mark-delivered go through `/api/commerce/fulfill-order`
|
|
109
|
+
* (AGL-1819), not a client write — the same stale-dialog hole the cancel
|
|
110
|
+
* swap (AGL-1818) closed: `can(…)` below only decides whether to RENDER
|
|
111
|
+
* the buttons, so a dialog held open while the order was refunded in
|
|
112
|
+
* another tab used to write `fulfilled` straight onto it. The route
|
|
113
|
+
* re-asks `canTransitionOrder` inside the transaction that writes the
|
|
114
|
+
* status, and that race now comes back as a 409 carrying the state that
|
|
115
|
+
* refused.
|
|
116
|
+
*
|
|
117
|
+
* The messages follow the AGL-1784/1786 contract — say what happened: a
|
|
118
|
+
* 409 is the guard refusing, not the machinery failing; the route's own
|
|
119
|
+
* 500 is a rolled-back transaction (nothing landed, retry is safe and
|
|
120
|
+
* correct); an answer with no JSON word from the handler, or no answer at
|
|
121
|
+
* all, is NOT KNOWN — never "nothing happened". A retry is safe in every
|
|
122
|
+
* case because the route writes once: a repeat finds the order already in
|
|
123
|
+
* the target status and returns `already` without appending a second copy
|
|
124
|
+
* of the same fulfillment.
|
|
125
|
+
*/ const transition = useCallback(async (to, extra, copy)=>{
|
|
126
|
+
if (!orderId) return false;
|
|
127
|
+
setBusy(true);
|
|
128
|
+
try {
|
|
129
|
+
let response;
|
|
130
|
+
try {
|
|
131
|
+
response = await authorizedFetch(user, '/api/commerce/fulfill-order', {
|
|
132
|
+
method: 'POST',
|
|
133
|
+
headers: {
|
|
134
|
+
'Content-Type': 'application/json'
|
|
135
|
+
},
|
|
136
|
+
body: JSON.stringify(_extends({
|
|
137
|
+
hostId,
|
|
138
|
+
orderId,
|
|
139
|
+
to
|
|
140
|
+
}, extra))
|
|
141
|
+
});
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error(error);
|
|
144
|
+
enqueueSnackbar(`The request did not complete, so it is NOT known whether ${copy.subject}. ` + 'Reopen the order to check — retrying is safe, the server ' + 'writes it once.', {
|
|
145
|
+
variant: 'error',
|
|
146
|
+
allowDuplicate: true
|
|
147
|
+
});
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
const payload = await response.json().catch(()=>({}));
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
if (response.status === 409) {
|
|
153
|
+
var _ref;
|
|
154
|
+
// The transition guard refusing: the order moved on (refunded,
|
|
155
|
+
// cancelled) while this dialog was open. The route's message
|
|
156
|
+
// names the state that refused it, and nothing was written.
|
|
157
|
+
enqueueSnackbar((_ref = payload == null ? void 0 : payload.error) != null ? _ref : `This order can no longer be ${to}`, {
|
|
158
|
+
variant: 'warning',
|
|
159
|
+
allowDuplicate: true
|
|
160
|
+
});
|
|
161
|
+
} else if ((payload == null ? void 0 : payload.error) && response.status < 500) {
|
|
162
|
+
// A refusal that wrote nothing — session, role, or an order that
|
|
163
|
+
// is not there. The route's own word, verbatim.
|
|
164
|
+
enqueueSnackbar(payload.error, {
|
|
165
|
+
variant: 'error',
|
|
166
|
+
allowDuplicate: true
|
|
167
|
+
});
|
|
168
|
+
} else if (payload == null ? void 0 : payload.error) {
|
|
169
|
+
// The route's 500 is a rolled-back transaction: nothing landed.
|
|
170
|
+
// Only the handler's own JSON word licenses saying so.
|
|
171
|
+
enqueueSnackbar(`${payload.error} — nothing changed, the order is as it was. Retrying is safe.`, {
|
|
172
|
+
variant: 'error',
|
|
173
|
+
allowDuplicate: true
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
// No JSON word from the handler (a gateway page, a proxy
|
|
177
|
+
// timeout): whether the write landed is NOT known.
|
|
178
|
+
enqueueSnackbar(`The ${copy.action} failed (${response.status}) and it is NOT ` + 'known whether it landed. Reopen the order to check — ' + 'retrying is safe, the server writes it once.', {
|
|
179
|
+
variant: 'error',
|
|
180
|
+
allowDuplicate: true
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
enqueueSnackbar((payload == null ? void 0 : payload.already) ? copy.already : copy.done, {
|
|
186
|
+
variant: 'success',
|
|
187
|
+
persist: false
|
|
188
|
+
});
|
|
189
|
+
return true;
|
|
190
|
+
} finally{
|
|
191
|
+
setBusy(false);
|
|
192
|
+
}
|
|
193
|
+
}, [
|
|
194
|
+
orderId,
|
|
195
|
+
user,
|
|
196
|
+
hostId,
|
|
197
|
+
enqueueSnackbar
|
|
198
|
+
]);
|
|
199
|
+
const handleFulfill = useCallback(async ()=>{
|
|
200
|
+
if (!order || !tracking) return;
|
|
201
|
+
const done = await transition('fulfilled', _extends({}, tracking.carrier ? {
|
|
202
|
+
carrier: tracking.carrier
|
|
203
|
+
} : {}, tracking.number ? {
|
|
204
|
+
trackingNumber: tracking.number
|
|
205
|
+
} : {}), {
|
|
206
|
+
done: 'Order fulfilled',
|
|
207
|
+
already: 'Order was already fulfilled',
|
|
208
|
+
subject: 'the order was fulfilled',
|
|
209
|
+
action: 'fulfillment'
|
|
210
|
+
});
|
|
211
|
+
// The refused or unknown case keeps the form open — there is nothing to
|
|
212
|
+
// celebrate, and the tracking is not yet recorded anywhere.
|
|
213
|
+
if (done) setTracking(null);
|
|
214
|
+
}, [
|
|
215
|
+
order,
|
|
216
|
+
tracking,
|
|
217
|
+
transition
|
|
218
|
+
]);
|
|
219
|
+
const handleDelivered = useCallback(async ()=>{
|
|
220
|
+
if (!order) return;
|
|
221
|
+
await transition('delivered', {}, {
|
|
222
|
+
done: 'Order marked delivered',
|
|
223
|
+
already: 'Order was already marked delivered',
|
|
224
|
+
subject: 'the order was marked delivered',
|
|
225
|
+
action: 'delivery update'
|
|
226
|
+
});
|
|
227
|
+
}, [
|
|
228
|
+
order,
|
|
229
|
+
transition
|
|
230
|
+
]);
|
|
231
|
+
/**
|
|
232
|
+
* Cancel goes through `/api/commerce/cancel-order` (AGL-1818), not a client
|
|
233
|
+
* write. The status flip and the stock release are one transaction there,
|
|
234
|
+
* and the route re-asks `canTransitionOrder` under the same lock — the
|
|
235
|
+
* `can('cancelled')` gate below only decides whether to RENDER the button,
|
|
236
|
+
* so a dialog held open while the order ships in another tab used to write
|
|
237
|
+
* `cancelled` straight onto a `fulfilled` order. Now that race comes back
|
|
238
|
+
* as a 409 carrying the state that refused it.
|
|
239
|
+
*
|
|
240
|
+
* The messages follow the AGL-1784/1786 contract — say what happened:
|
|
241
|
+
* a 409 is the guard refusing, not the cancel machinery failing; the
|
|
242
|
+
* route's own 500 is a rolled-back transaction (nothing landed, retry is
|
|
243
|
+
* safe and correct); an answer with no JSON word from the handler, or no
|
|
244
|
+
* answer at all, is NOT KNOWN — never "nothing happened". A retry is safe
|
|
245
|
+
* in every case because the route cancels once: a second cancel finds
|
|
246
|
+
* `cancelled` and returns success without touching stock.
|
|
247
|
+
*/ const handleCancel = useCallback(async ()=>{
|
|
248
|
+
if (!order || !orderId) return;
|
|
249
|
+
const confirmed = await confirm({
|
|
250
|
+
title: 'Cancel this order?',
|
|
251
|
+
description: 'The buyer is NOT refunded automatically — refund first if they paid.',
|
|
252
|
+
confirmationText: 'Cancel order',
|
|
253
|
+
confirmationButtonProps: {
|
|
254
|
+
color: 'error'
|
|
255
|
+
}
|
|
256
|
+
}).then(()=>true).catch(()=>false);
|
|
257
|
+
if (!confirmed) return;
|
|
258
|
+
setBusy(true);
|
|
259
|
+
try {
|
|
260
|
+
var _ref;
|
|
261
|
+
let response;
|
|
262
|
+
try {
|
|
263
|
+
response = await authorizedFetch(user, '/api/commerce/cancel-order', {
|
|
264
|
+
method: 'POST',
|
|
265
|
+
headers: {
|
|
266
|
+
'Content-Type': 'application/json'
|
|
267
|
+
},
|
|
268
|
+
body: JSON.stringify({
|
|
269
|
+
hostId,
|
|
270
|
+
orderId
|
|
271
|
+
})
|
|
272
|
+
});
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error(error);
|
|
275
|
+
enqueueSnackbar('The request did not complete, so it is NOT known whether the ' + 'order was canceled. Reopen the order to check — retrying is ' + 'safe, the server cancels once.', {
|
|
276
|
+
variant: 'error',
|
|
277
|
+
allowDuplicate: true
|
|
278
|
+
});
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const payload = await response.json().catch(()=>({}));
|
|
282
|
+
if (!response.ok) {
|
|
283
|
+
if (response.status === 409) {
|
|
284
|
+
var _ref1;
|
|
285
|
+
// The transition guard refusing: the order moved on (shipped,
|
|
286
|
+
// refunded) while this dialog was open. The route's message names
|
|
287
|
+
// the state that refused it, and nothing was written.
|
|
288
|
+
enqueueSnackbar((_ref1 = payload == null ? void 0 : payload.error) != null ? _ref1 : 'This order can no longer be canceled', {
|
|
289
|
+
variant: 'warning',
|
|
290
|
+
allowDuplicate: true
|
|
291
|
+
});
|
|
292
|
+
} else if ((payload == null ? void 0 : payload.error) && response.status < 500) {
|
|
293
|
+
// A refusal that wrote nothing — session, role, or an order that
|
|
294
|
+
// is not there. The route's own word, verbatim.
|
|
295
|
+
enqueueSnackbar(payload.error, {
|
|
296
|
+
variant: 'error',
|
|
297
|
+
allowDuplicate: true
|
|
298
|
+
});
|
|
299
|
+
} else if (payload == null ? void 0 : payload.error) {
|
|
300
|
+
// The route's 500 is a rolled-back transaction: nothing landed and
|
|
301
|
+
// the order is still open. Only the handler's own JSON word
|
|
302
|
+
// licenses saying so.
|
|
303
|
+
enqueueSnackbar(`${payload.error} — nothing changed, the order is still open. Retrying is safe.`, {
|
|
304
|
+
variant: 'error',
|
|
305
|
+
allowDuplicate: true
|
|
306
|
+
});
|
|
307
|
+
} else {
|
|
308
|
+
// No JSON word from the handler (a gateway page, a proxy timeout):
|
|
309
|
+
// whether the cancel landed is NOT known.
|
|
310
|
+
enqueueSnackbar(`The cancel failed (${response.status}) and it is NOT known ` + 'whether it landed. Reopen the order to check — retrying is ' + 'safe, the server cancels once.', {
|
|
311
|
+
variant: 'error',
|
|
312
|
+
allowDuplicate: true
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const units = Number((_ref = payload == null ? void 0 : payload.units) != null ? _ref : 0);
|
|
318
|
+
enqueueSnackbar((payload == null ? void 0 : payload.alreadyCancelled) ? 'Order was already canceled' : units > 0 ? `Order canceled — ${units} ${units === 1 ? 'unit' : 'units'} returned to stock` : 'Order canceled', {
|
|
319
|
+
variant: 'success',
|
|
320
|
+
persist: false
|
|
321
|
+
});
|
|
322
|
+
} finally{
|
|
323
|
+
setBusy(false);
|
|
324
|
+
}
|
|
325
|
+
}, [
|
|
326
|
+
order,
|
|
327
|
+
orderId,
|
|
328
|
+
user,
|
|
329
|
+
hostId,
|
|
330
|
+
confirm,
|
|
331
|
+
enqueueSnackbar
|
|
332
|
+
]);
|
|
333
|
+
/**
|
|
334
|
+
* Idempotency key for ONE refund attempt (AGL-1696), the same shape the POS
|
|
335
|
+
* register uses for a sale (AGL-1691).
|
|
336
|
+
*
|
|
337
|
+
* Minted lazily so a retry of this attempt — a lost response, a second
|
|
338
|
+
* click, the admin reopening the dialog after a timeout — reuses it and the
|
|
339
|
+
* server replays instead of sending the money again. Retired on a definitive
|
|
340
|
+
* answer, which makes the NEXT refund a new attempt: two partial refunds of
|
|
341
|
+
* the same amount on the same order are two real refunds, and keying on the
|
|
342
|
+
* order (or the amount) would silently swallow the second.
|
|
343
|
+
*
|
|
344
|
+
* NOT retired on a network failure or a 5xx — that is precisely the window
|
|
345
|
+
* the key exists to cover.
|
|
346
|
+
*/ const attemptKey = useRef('');
|
|
347
|
+
useEffect(()=>{
|
|
348
|
+
attemptKey.current = '';
|
|
349
|
+
}, [
|
|
350
|
+
orderId
|
|
351
|
+
]);
|
|
352
|
+
/**
|
|
353
|
+
* `lineItemIds` scopes the refund to named lines (AGL-2454).
|
|
354
|
+
*
|
|
355
|
+
* Without it a partial refund is an AMOUNT and nothing else, so the product
|
|
356
|
+
* cannot know which goods came back and revokes nothing — a 99%-refunded
|
|
357
|
+
* order kept its downloads, licence keys, gated pages and verified review.
|
|
358
|
+
* Naming the lines is the only way that question gets an honest answer, and
|
|
359
|
+
* the route derives the amount FROM the lines rather than trusting a figure
|
|
360
|
+
* typed beside them.
|
|
361
|
+
*/ const handleRefund = useCallback(async (lineItemIds)=>{
|
|
362
|
+
var _order_lineItems, _ref, _ref1, _order_refundedCents;
|
|
363
|
+
var _order_totals;
|
|
364
|
+
if (!order || !orderId) return;
|
|
365
|
+
const lines = (_order_lineItems = order.lineItems) != null ? _order_lineItems : [];
|
|
366
|
+
const scoped = (lineItemIds != null ? lineItemIds : []).length > 0;
|
|
367
|
+
// The SERVER's figure, not a second derivation of it. This was
|
|
368
|
+
// the list value `unitAmountCents x quantity`, which on a discounted order
|
|
369
|
+
// is more than the buyer paid — so the dialog quoted one number and the
|
|
370
|
+
// route refunded another. One function answers both.
|
|
371
|
+
const scopedCents = CommerceModel.orderLineRefundCents(order, lineItemIds != null ? lineItemIds : []);
|
|
372
|
+
const confirmed = await confirm({
|
|
373
|
+
title: scoped ? 'Refund this line?' : 'Refund this order?',
|
|
374
|
+
description: (scoped ? `Refunds ${usd(scopedCents)} for ${(lineItemIds != null ? lineItemIds : []).map((index)=>{
|
|
375
|
+
var _ref;
|
|
376
|
+
var _lines_index;
|
|
377
|
+
return (_ref = (_lines_index = lines[index]) == null ? void 0 : _lines_index.name) != null ? _ref : `line ${index}`;
|
|
378
|
+
}).join(', ')} through Stripe, and withdraws that line's ` + 'downloads, license keys and gated content. A license key already ' + 'sent to the buyer is retired, not returned to your pool — they ' + 'still hold the string, so reissuing it would give two people one ' + 'working key.' : `Refunds ${usd(((_ref = (_ref1 = (_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents) != null ? _ref1 : order.amountCents) != null ? _ref : 0) - ((_order_refundedCents = order.refundedCents) != null ? _order_refundedCents : 0))} to the buyer through Stripe.`) + // An open INQUIRY keeps this button live on purpose (AGL-1820):
|
|
379
|
+
// Stripe names a full refund as the way to resolve one before it
|
|
380
|
+
// escalates to a chargeback. Said here so the admin reads the refund
|
|
381
|
+
// as the documented exit, not a risk taken against the badge.
|
|
382
|
+
(CommerceModel.orderHasOpenDispute(order) && !CommerceModel.orderDisputeBlocksRefund(order) ? ' An inquiry is open on this charge — a full refund resolves it' + ' before it can become a chargeback.' : ''),
|
|
383
|
+
confirmationText: 'Refund',
|
|
384
|
+
confirmationButtonProps: {
|
|
385
|
+
color: 'error'
|
|
386
|
+
}
|
|
387
|
+
}).then(()=>true).catch(()=>false);
|
|
388
|
+
if (!confirmed) return;
|
|
389
|
+
setBusy(true);
|
|
390
|
+
// `randomUUID` needs a secure context, which the console always is, but
|
|
391
|
+
// fall back rather than throw on a refund.
|
|
392
|
+
if (!attemptKey.current) {
|
|
393
|
+
var _ref2;
|
|
394
|
+
var _globalThis_crypto_randomUUID, _globalThis_crypto;
|
|
395
|
+
attemptKey.current = (_ref2 = (_globalThis_crypto = globalThis.crypto) == null ? void 0 : (_globalThis_crypto_randomUUID = _globalThis_crypto.randomUUID) == null ? void 0 : _globalThis_crypto_randomUUID.call(_globalThis_crypto)) != null ? _ref2 : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
396
|
+
}
|
|
397
|
+
try {
|
|
398
|
+
const response = await authorizedFetch(user, '/api/commerce/refund', {
|
|
399
|
+
method: 'POST',
|
|
400
|
+
headers: {
|
|
401
|
+
'Content-Type': 'application/json',
|
|
402
|
+
'Idempotency-Key': attemptKey.current
|
|
403
|
+
},
|
|
404
|
+
body: JSON.stringify(_extends({
|
|
405
|
+
hostId,
|
|
406
|
+
orderId
|
|
407
|
+
}, scoped ? {
|
|
408
|
+
lineItemIds
|
|
409
|
+
} : {}))
|
|
410
|
+
});
|
|
411
|
+
const payload = await response.json();
|
|
412
|
+
// A definitive answer ends this attempt either way: the next refund is a
|
|
413
|
+
// new one and must get a new key. A 5xx or a thrown fetch keeps the key,
|
|
414
|
+
// so pressing Refund again dedupes rather than sends a second transfer.
|
|
415
|
+
if (response.status < 500) attemptKey.current = '';
|
|
416
|
+
if (!response.ok) {
|
|
417
|
+
var _ref3;
|
|
418
|
+
// A 409 is a guard REFUSING — the status machine, or the open-dispute
|
|
419
|
+
// block (AGL-1809), whose body explains what to do instead — not the
|
|
420
|
+
// refund machinery failing. The route wrote nothing, so it surfaces
|
|
421
|
+
// verbatim as a warning, same as the cancel path's 409 (AGL-1818).
|
|
422
|
+
enqueueSnackbar((_ref3 = payload == null ? void 0 : payload.error) != null ? _ref3 : 'Refund failed', {
|
|
423
|
+
variant: response.status === 409 ? 'warning' : 'error',
|
|
424
|
+
allowDuplicate: true
|
|
425
|
+
});
|
|
426
|
+
} else {
|
|
427
|
+
enqueueSnackbar('Refund issued', {
|
|
428
|
+
variant: 'success',
|
|
429
|
+
persist: false
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
} finally{
|
|
433
|
+
setBusy(false);
|
|
434
|
+
}
|
|
435
|
+
}, [
|
|
436
|
+
order,
|
|
437
|
+
orderId,
|
|
438
|
+
user,
|
|
439
|
+
hostId,
|
|
440
|
+
confirm,
|
|
441
|
+
enqueueSnackbar
|
|
442
|
+
]);
|
|
443
|
+
/**
|
|
444
|
+
* Answer the restock question a reversal flagged (AGL-1806).
|
|
445
|
+
*
|
|
446
|
+
* The answer MOVES NO STOCK, which is AGL-1797's ledger argument and it is
|
|
447
|
+
* binding: the products hub's "Adjust stock" is the one stock writer (it
|
|
448
|
+
* writes the counts AND the `InventoryAdjustment` row the hub renders as
|
|
449
|
+
* history), so "Restocked" here is clicked AFTER the merchant used it, and
|
|
450
|
+
* "No restock" says the goods are not recoverable. Either answer only sets
|
|
451
|
+
* the `resolution` triple `OrderRestockCheck` declares and says so on the
|
|
452
|
+
* timeline.
|
|
453
|
+
*
|
|
454
|
+
* A TRANSACTION rather than the dialog's plain `write`, keyed on the
|
|
455
|
+
* rendered `flaggedAtMs`, because an answer must land ONCE. The flag writer
|
|
456
|
+
* re-asks an ANSWERED question after the next reversal, and the cancel
|
|
457
|
+
* route (AGL-1808) answers an open one itself when it returns the stock —
|
|
458
|
+
* so a stale dialog writing blind would either re-answer a settled question
|
|
459
|
+
* or replace a brand-new one with a resolved copy of the old. The
|
|
460
|
+
* transaction re-reads on the server (the web SDK will not run one from
|
|
461
|
+
* cache — the products hub's `writeGuardedBySeed` refusal of unconfirmed
|
|
462
|
+
* data, by other means) and refuses both cases with the truth: nothing was
|
|
463
|
+
* written.
|
|
464
|
+
*/ const handleRestockAnswer = useCallback(async (resolution)=>{
|
|
465
|
+
const check = order == null ? void 0 : order.restockCheck;
|
|
466
|
+
if (!order || !orderId || !check || check.resolution) return;
|
|
467
|
+
setBusy(true);
|
|
468
|
+
try {
|
|
469
|
+
const reference = doc(firestore, 'hosts', hostId, 'orders', orderId);
|
|
470
|
+
const verdict = await runTransaction(firestore, async (transaction)=>{
|
|
471
|
+
var _snapshot_data, _ref;
|
|
472
|
+
const snapshot = await transaction.get(reference);
|
|
473
|
+
if (!snapshot.exists()) return 'gone';
|
|
474
|
+
const current = CommerceModel.liftLegacyOrder((_snapshot_data = snapshot.data()) != null ? _snapshot_data : {});
|
|
475
|
+
const fresh = current.restockCheck;
|
|
476
|
+
if (!fresh || fresh.resolution) return 'answered';
|
|
477
|
+
if (fresh.flaggedAtMs !== check.flaggedAtMs) return 'changed';
|
|
478
|
+
const resolvedAtMs = Date.now();
|
|
479
|
+
const uid = String((_ref = user == null ? void 0 : user.uid) != null ? _ref : '');
|
|
480
|
+
transaction.update(reference, {
|
|
481
|
+
restockCheck: _extends({}, fresh, {
|
|
482
|
+
resolution,
|
|
483
|
+
resolvedAtMs
|
|
484
|
+
}, uid ? {
|
|
485
|
+
resolvedBy: uid
|
|
486
|
+
} : {}),
|
|
487
|
+
// The SERVER's timeline, not the dialog's — a note landed from
|
|
488
|
+
// another tab must survive the append.
|
|
489
|
+
timeline: CommerceModel.appendOrderEvent(current, 'restock-check', resolution === 'restocked' ? 'answered — restocked' : 'answered — no restock', resolvedAtMs)
|
|
490
|
+
});
|
|
491
|
+
return 'recorded';
|
|
492
|
+
});
|
|
493
|
+
if (verdict === 'recorded') {
|
|
494
|
+
enqueueSnackbar(resolution === 'restocked' ? 'Recorded as restocked' : 'Recorded — no restock', {
|
|
495
|
+
variant: 'success',
|
|
496
|
+
persist: false
|
|
497
|
+
});
|
|
498
|
+
} else if (verdict === 'answered') {
|
|
499
|
+
// The cancel route, or another admin, got there first.
|
|
500
|
+
enqueueSnackbar('This restock question was already answered — nothing changed.', {
|
|
501
|
+
variant: 'info',
|
|
502
|
+
persist: false
|
|
503
|
+
});
|
|
504
|
+
} else if (verdict === 'changed') {
|
|
505
|
+
// A later reversal re-asked; this dialog shows the OLD question.
|
|
506
|
+
enqueueSnackbar('The restock question changed while this dialog was open — ' + 'nothing was written. Reopen the order to see the current one.', {
|
|
507
|
+
variant: 'warning',
|
|
508
|
+
allowDuplicate: true
|
|
509
|
+
});
|
|
510
|
+
} else {
|
|
511
|
+
enqueueSnackbar('This order no longer exists — nothing was written.', {
|
|
512
|
+
variant: 'warning',
|
|
513
|
+
allowDuplicate: true
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
} catch (error) {
|
|
517
|
+
// A transaction is all-or-nothing, and a thrown one did not commit.
|
|
518
|
+
console.error(error);
|
|
519
|
+
enqueueSnackbar('The answer was not recorded — it needs a live connection and the ' + 'editor or admin role. Nothing changed; answering again is safe.', {
|
|
520
|
+
variant: 'error',
|
|
521
|
+
allowDuplicate: true
|
|
522
|
+
});
|
|
523
|
+
} finally{
|
|
524
|
+
setBusy(false);
|
|
525
|
+
}
|
|
526
|
+
}, [
|
|
527
|
+
order,
|
|
528
|
+
orderId,
|
|
529
|
+
firestore,
|
|
530
|
+
hostId,
|
|
531
|
+
user,
|
|
532
|
+
enqueueSnackbar
|
|
533
|
+
]);
|
|
534
|
+
const handleNote = useCallback(async ()=>{
|
|
535
|
+
if (!order || !note.trim()) return;
|
|
536
|
+
await write({
|
|
537
|
+
timeline: CommerceModel.appendOrderEvent(order, 'note', note.trim().slice(0, 500))
|
|
538
|
+
});
|
|
539
|
+
setNote('');
|
|
540
|
+
}, [
|
|
541
|
+
order,
|
|
542
|
+
note,
|
|
543
|
+
write
|
|
544
|
+
]);
|
|
545
|
+
const handlePackingSlip = useCallback(()=>{
|
|
546
|
+
var _order_lineItems, _address_city, _address_state, _address_postalCode;
|
|
547
|
+
if (!order) return;
|
|
548
|
+
const win = window.open('', '_blank', 'width=600,height=800');
|
|
549
|
+
if (!win) return;
|
|
550
|
+
// ESCAPED (AGL-2283). This is `document.write` into an `about:blank`
|
|
551
|
+
// popup, which INHERITS the console's origin — and `order.shippingAddress`
|
|
552
|
+
// is copied verbatim from Stripe's `shipping_details`, i.e. typed by the
|
|
553
|
+
// SHOPPER. A name of `<img src=x onerror=…>` ran script against the
|
|
554
|
+
// merchant's own authenticated session. React guards nothing here because
|
|
555
|
+
// none of this is React. Line names and SKUs are merchant-authored and
|
|
556
|
+
// lower severity, but they are the same construction and get the same
|
|
557
|
+
// treatment rather than a case-by-case argument.
|
|
558
|
+
const rows = ((_order_lineItems = order.lineItems) != null ? _order_lineItems : []).map((line)=>{
|
|
559
|
+
var _line_sku;
|
|
560
|
+
return `<tr><td>${escapeHtml(line.quantity)}×</td><td>${escapeHtml(line.name)}${line.variantLabel ? ` — ${escapeHtml(line.variantLabel)}` : ''}</td><td>${escapeHtml((_line_sku = line.sku) != null ? _line_sku : '')}</td></tr>`;
|
|
561
|
+
}).join('');
|
|
562
|
+
const address = order.shippingAddress;
|
|
563
|
+
win.document.write(`<h2>Packing slip ${escapeHtml(CommerceModel.formatOrderNumber(order, orderId))}</h2>` + (address ? `<p>${[
|
|
564
|
+
address.name,
|
|
565
|
+
address.line1,
|
|
566
|
+
address.line2,
|
|
567
|
+
`${(_address_city = address.city) != null ? _address_city : ''} ${(_address_state = address.state) != null ? _address_state : ''} ${(_address_postalCode = address.postalCode) != null ? _address_postalCode : ''}`,
|
|
568
|
+
address.country
|
|
569
|
+
].filter(Boolean).map((part)=>escapeHtml(part)).join('<br/>')}</p>` : '') + `<table border="0" cellpadding="6">${rows}</table>`);
|
|
570
|
+
win.document.close();
|
|
571
|
+
// Print from the opener, not from an injected inline script (AGL-523) —
|
|
572
|
+
// the popup inherits this document's CSP, where an un-nonced inline
|
|
573
|
+
// script is blocked under the enforcing policy. Same reasoning as the POS
|
|
574
|
+
// receipt.
|
|
575
|
+
win.focus();
|
|
576
|
+
win.print();
|
|
577
|
+
}, [
|
|
578
|
+
order,
|
|
579
|
+
orderId
|
|
580
|
+
]);
|
|
581
|
+
if (!order) return null;
|
|
582
|
+
const totals = order.totals;
|
|
583
|
+
const can = (to)=>CommerceModel.canTransitionOrder(order.status, to);
|
|
584
|
+
// A lost chargeback leaves `status: 'refunded'` (AGL-1787), so the status
|
|
585
|
+
// chip alone tells the merchant they chose this. The badge is the correction.
|
|
586
|
+
const dispute = CommerceModel.describeOrderDispute(order);
|
|
587
|
+
const reversal = CommerceModel.splitOrderReversal(order);
|
|
588
|
+
// The restock question a reversal flagged, while it is still open
|
|
589
|
+
// (AGL-1806). Absent `resolution` IS the open state — the writer only ever
|
|
590
|
+
// re-flags an answered check (AGL-1797).
|
|
591
|
+
const restock = order.restockCheck && !order.restockCheck.resolution ? order.restockCheck : null;
|
|
592
|
+
// Whether the reversal NAMED the lines this question is about (AGL-2325).
|
|
593
|
+
// AGL-2454 gave a refund a line selection, and `flagOrderRestock` now scopes
|
|
594
|
+
// the question to it — so the "we cannot tell which goods came back" caveat
|
|
595
|
+
// below is true of an amount-only reversal and false of this one. Asked of
|
|
596
|
+
// the order's own withdrawal record rather than of a flag on the check, so a
|
|
597
|
+
// prompt written before line indexes existed reads as the amount-only case
|
|
598
|
+
// it was.
|
|
599
|
+
const restockLinesNamed = Boolean((restock == null ? void 0 : (_restock_lines = restock.lines) == null ? void 0 : _restock_lines.length) && restock.lines.every((line)=>line.lineIndex != null && CommerceModel.orderLineRefunded(order, line.lineIndex)));
|
|
600
|
+
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
601
|
+
open: true,
|
|
602
|
+
onClose: onClose,
|
|
603
|
+
maxWidth: "sm",
|
|
604
|
+
fullWidth: true,
|
|
605
|
+
children: [
|
|
606
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
607
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
608
|
+
direction: "row",
|
|
609
|
+
spacing: 1,
|
|
610
|
+
sx: {
|
|
611
|
+
alignItems: 'center'
|
|
612
|
+
},
|
|
613
|
+
children: [
|
|
614
|
+
/*#__PURE__*/ _jsx("span", {
|
|
615
|
+
children: `Order ${CommerceModel.formatOrderNumber(order, orderId)}`
|
|
616
|
+
}),
|
|
617
|
+
/*#__PURE__*/ _jsx(Chip, {
|
|
618
|
+
label: order.status.replace('_', ' '),
|
|
619
|
+
size: "small",
|
|
620
|
+
color: (_STATUS_COLOR_order_status = STATUS_COLOR[order.status]) != null ? _STATUS_COLOR_order_status : 'default',
|
|
621
|
+
variant: "outlined"
|
|
622
|
+
}),
|
|
623
|
+
dispute ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
624
|
+
title: dispute.detail,
|
|
625
|
+
children: /*#__PURE__*/ _jsx(Chip, {
|
|
626
|
+
label: dispute.label,
|
|
627
|
+
size: "small",
|
|
628
|
+
color: DISPUTE_COLOR[dispute.tone],
|
|
629
|
+
variant: "filled"
|
|
630
|
+
})
|
|
631
|
+
}) : null,
|
|
632
|
+
order.channel && order.channel !== 'online' ? /*#__PURE__*/ _jsx(Chip, {
|
|
633
|
+
label: order.channel,
|
|
634
|
+
size: "small",
|
|
635
|
+
variant: "outlined"
|
|
636
|
+
}) : null
|
|
637
|
+
]
|
|
638
|
+
})
|
|
639
|
+
}),
|
|
640
|
+
/*#__PURE__*/ _jsxs(DialogContent, {
|
|
641
|
+
sx: {
|
|
642
|
+
display: 'flex',
|
|
643
|
+
flexDirection: 'column',
|
|
644
|
+
gap: 1.5
|
|
645
|
+
},
|
|
646
|
+
children: [
|
|
647
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
648
|
+
variant: "body2",
|
|
649
|
+
color: "text.secondary",
|
|
650
|
+
children: [
|
|
651
|
+
order.customerName,
|
|
652
|
+
order.customerEmail
|
|
653
|
+
].filter(Boolean).join(' · ') || 'Guest buyer'
|
|
654
|
+
}),
|
|
655
|
+
((_order_lineItems = order.lineItems) != null ? _order_lineItems : []).map((line, index)=>{
|
|
656
|
+
// WHAT THIS LINE IS STILL ENTITLED TO, per line (AGL-2454). A refund
|
|
657
|
+
// used to be a number on the order and nothing more, so the merchant
|
|
658
|
+
// could not see — and the product could not enforce — which goods had
|
|
659
|
+
// come back.
|
|
660
|
+
const withdrawn = CommerceModel.orderLineRefunded(order, index);
|
|
661
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
662
|
+
direction: "row",
|
|
663
|
+
spacing: 1,
|
|
664
|
+
sx: {
|
|
665
|
+
alignItems: 'center'
|
|
666
|
+
},
|
|
667
|
+
children: [
|
|
668
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
669
|
+
variant: "body2",
|
|
670
|
+
sx: _extends({
|
|
671
|
+
flex: 1
|
|
672
|
+
}, withdrawn ? {
|
|
673
|
+
textDecoration: 'line-through'
|
|
674
|
+
} : {}),
|
|
675
|
+
color: withdrawn ? 'text.secondary' : 'text.primary',
|
|
676
|
+
children: `${line.quantity}× ${line.name}` + (line.variantLabel ? ` — ${line.variantLabel}` : '')
|
|
677
|
+
}),
|
|
678
|
+
withdrawn ? /*#__PURE__*/ _jsx(Chip, {
|
|
679
|
+
label: "refunded",
|
|
680
|
+
size: "small",
|
|
681
|
+
color: "error",
|
|
682
|
+
variant: "outlined"
|
|
683
|
+
}) : can('refunded') && !CommerceModel.orderDisputeBlocksRefund(order) ? /*#__PURE__*/ _jsx(Button, {
|
|
684
|
+
size: "small",
|
|
685
|
+
color: "error",
|
|
686
|
+
disabled: busy,
|
|
687
|
+
onClick: ()=>handleRefund([
|
|
688
|
+
index
|
|
689
|
+
]),
|
|
690
|
+
children: 'Refund line'
|
|
691
|
+
}) : null,
|
|
692
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
693
|
+
variant: "body2",
|
|
694
|
+
children: usd(line.unitAmountCents * line.quantity)
|
|
695
|
+
})
|
|
696
|
+
]
|
|
697
|
+
}, index);
|
|
698
|
+
}),
|
|
699
|
+
CommerceModel.orderRefundState(order) !== 'none' ? // The state, said in words (AGL-2454). "Partially refunded, no lines
|
|
700
|
+
// withdrawn" is the honest reading of an amount-only refund, and it
|
|
701
|
+
// is what tells a merchant their buyer still has the downloads.
|
|
702
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
703
|
+
variant: "caption",
|
|
704
|
+
color: "error",
|
|
705
|
+
children: CommerceModel.orderRefundSummary(order)
|
|
706
|
+
}) : null,
|
|
707
|
+
totals ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
708
|
+
children: [
|
|
709
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
710
|
+
[
|
|
711
|
+
[
|
|
712
|
+
'Items',
|
|
713
|
+
totals.itemsCents
|
|
714
|
+
],
|
|
715
|
+
[
|
|
716
|
+
'Shipping',
|
|
717
|
+
totals.shippingCents
|
|
718
|
+
],
|
|
719
|
+
[
|
|
720
|
+
'Tax',
|
|
721
|
+
totals.taxCents
|
|
722
|
+
],
|
|
723
|
+
[
|
|
724
|
+
'Discount',
|
|
725
|
+
-totals.discountCents
|
|
726
|
+
],
|
|
727
|
+
[
|
|
728
|
+
'Total',
|
|
729
|
+
totals.totalCents
|
|
730
|
+
]
|
|
731
|
+
].map(([label, cents])=>/*#__PURE__*/ _jsxs(Stack, {
|
|
732
|
+
direction: "row",
|
|
733
|
+
children: [
|
|
734
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
735
|
+
variant: "body2",
|
|
736
|
+
sx: {
|
|
737
|
+
flex: 1
|
|
738
|
+
},
|
|
739
|
+
color: label === 'Total' ? 'text.primary' : 'text.secondary',
|
|
740
|
+
children: label
|
|
741
|
+
}),
|
|
742
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
743
|
+
variant: "body2",
|
|
744
|
+
sx: {
|
|
745
|
+
fontWeight: label === 'Total' ? 600 : 400
|
|
746
|
+
},
|
|
747
|
+
children: `${cents < 0 ? '-' : ''}${usd(Math.abs(cents))}`
|
|
748
|
+
})
|
|
749
|
+
]
|
|
750
|
+
}, label)),
|
|
751
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
752
|
+
variant: "caption",
|
|
753
|
+
color: "text.secondary",
|
|
754
|
+
children: CommerceModel.describeOrderTaxMode(order.taxMode)
|
|
755
|
+
}),
|
|
756
|
+
reversal.refundedCents ? /*#__PURE__*/ _jsx(Typography, {
|
|
757
|
+
variant: "caption",
|
|
758
|
+
color: "error",
|
|
759
|
+
children: `Refunded ${usd(reversal.refundedCents)}`
|
|
760
|
+
}) : null,
|
|
761
|
+
reversal.chargedBackCents ? /*#__PURE__*/ _jsx(Typography, {
|
|
762
|
+
variant: "caption",
|
|
763
|
+
color: "error",
|
|
764
|
+
children: `Charged back ${usd(reversal.chargedBackCents)}`
|
|
765
|
+
}) : null
|
|
766
|
+
]
|
|
767
|
+
}) : null,
|
|
768
|
+
restock ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
769
|
+
children: [
|
|
770
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
771
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
772
|
+
spacing: 0.5,
|
|
773
|
+
children: [
|
|
774
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
775
|
+
variant: "subtitle2",
|
|
776
|
+
children: 'Restock check'
|
|
777
|
+
}),
|
|
778
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
779
|
+
variant: "body2",
|
|
780
|
+
color: "text.secondary",
|
|
781
|
+
children: `${restock.units} ${restock.units === 1 ? 'unit' : 'units'} may need restocking after this ${restock.kind === 'chargeback' ? 'chargeback' : 'refund'}.` + // The chargeback default is NO, same as the timeline's
|
|
782
|
+
// wording: the shopper kept the item and took the money.
|
|
783
|
+
(restock.kind === 'chargeback' ? ' The shopper kept the goods unless they actually came back.' : '') + // On a partial the flagged units are the MOST it could be —
|
|
784
|
+
// UNLESS the refund named its lines (AGL-2325), in which
|
|
785
|
+
// case the question is scoped to exactly those and the
|
|
786
|
+
// merchant is only being asked whether the goods came back.
|
|
787
|
+
(restock.fullyReversed ? '' : restockLinesNamed ? ' Only part of the money came back: these are the lines withdrawn by this refund, so the units are theirs — only you know whether the goods came back.' : ' Only part of the money came back, so these units are an upper bound — only you know which goods returned.')
|
|
788
|
+
}),
|
|
789
|
+
restock.lines.map((line, index)=>{
|
|
790
|
+
var _line_name;
|
|
791
|
+
return /*#__PURE__*/ _jsx(Typography, {
|
|
792
|
+
variant: "caption",
|
|
793
|
+
color: "text.secondary",
|
|
794
|
+
children: `${line.quantity}× ${(_line_name = line.name) != null ? _line_name : line.productId}` + (line.variantLabel ? ` — ${line.variantLabel}` : '')
|
|
795
|
+
}, index);
|
|
796
|
+
}),
|
|
797
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
798
|
+
variant: "caption",
|
|
799
|
+
color: "text.secondary",
|
|
800
|
+
children: 'If goods came back, put them on the shelf with "Adjust ' + 'stock" in the products hub first — these answers move no ' + 'stock, they only clear this question.'
|
|
801
|
+
}),
|
|
802
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
803
|
+
direction: "row",
|
|
804
|
+
spacing: 1,
|
|
805
|
+
children: [
|
|
806
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
807
|
+
size: "small",
|
|
808
|
+
variant: "outlined",
|
|
809
|
+
disabled: busy,
|
|
810
|
+
onClick: ()=>handleRestockAnswer('restocked'),
|
|
811
|
+
children: 'Restocked'
|
|
812
|
+
}),
|
|
813
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
814
|
+
size: "small",
|
|
815
|
+
disabled: busy,
|
|
816
|
+
onClick: ()=>handleRestockAnswer('dismissed'),
|
|
817
|
+
children: 'No restock'
|
|
818
|
+
})
|
|
819
|
+
]
|
|
820
|
+
})
|
|
821
|
+
]
|
|
822
|
+
})
|
|
823
|
+
]
|
|
824
|
+
}) : null,
|
|
825
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
826
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
827
|
+
variant: "subtitle2",
|
|
828
|
+
children: 'Timeline'
|
|
829
|
+
}),
|
|
830
|
+
((_order_timeline = order.timeline) != null ? _order_timeline : []).slice().reverse().map((event, index)=>/*#__PURE__*/ _jsx(Typography, {
|
|
831
|
+
variant: "caption",
|
|
832
|
+
color: "text.secondary",
|
|
833
|
+
children: `${new Date(event.atMs).toLocaleString()} — ${event.event}` + (event.detail ? `: ${event.detail}` : '')
|
|
834
|
+
}, index)),
|
|
835
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
836
|
+
direction: "row",
|
|
837
|
+
spacing: 1,
|
|
838
|
+
children: [
|
|
839
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
840
|
+
label: "Add note",
|
|
841
|
+
value: note,
|
|
842
|
+
onChange: (event)=>setNote(event.target.value),
|
|
843
|
+
size: "small",
|
|
844
|
+
sx: {
|
|
845
|
+
flex: 1
|
|
846
|
+
}
|
|
847
|
+
}),
|
|
848
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
849
|
+
size: "small",
|
|
850
|
+
disabled: !note.trim(),
|
|
851
|
+
onClick: handleNote,
|
|
852
|
+
children: 'Add'
|
|
853
|
+
})
|
|
854
|
+
]
|
|
855
|
+
}),
|
|
856
|
+
tracking ? /*#__PURE__*/ _jsxs(Stack, {
|
|
857
|
+
direction: "row",
|
|
858
|
+
spacing: 1,
|
|
859
|
+
children: [
|
|
860
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
861
|
+
label: "Carrier",
|
|
862
|
+
value: tracking.carrier,
|
|
863
|
+
onChange: (event)=>setTracking(_extends({}, tracking, {
|
|
864
|
+
carrier: event.target.value
|
|
865
|
+
})),
|
|
866
|
+
size: "small",
|
|
867
|
+
sx: {
|
|
868
|
+
width: 140
|
|
869
|
+
},
|
|
870
|
+
placeholder: "UPS"
|
|
871
|
+
}),
|
|
872
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
873
|
+
label: "Tracking number",
|
|
874
|
+
value: tracking.number,
|
|
875
|
+
onChange: (event)=>setTracking(_extends({}, tracking, {
|
|
876
|
+
number: event.target.value
|
|
877
|
+
})),
|
|
878
|
+
size: "small",
|
|
879
|
+
sx: {
|
|
880
|
+
flex: 1
|
|
881
|
+
}
|
|
882
|
+
}),
|
|
883
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
884
|
+
size: "small",
|
|
885
|
+
variant: "contained",
|
|
886
|
+
color: "primary",
|
|
887
|
+
disabled: busy,
|
|
888
|
+
onClick: handleFulfill,
|
|
889
|
+
children: 'Fulfill'
|
|
890
|
+
})
|
|
891
|
+
]
|
|
892
|
+
}) : null,
|
|
893
|
+
order.paymentLinkUrl && order.status === 'pending' ? /*#__PURE__*/ _jsx(Button, {
|
|
894
|
+
size: "small",
|
|
895
|
+
sx: {
|
|
896
|
+
alignSelf: 'flex-start'
|
|
897
|
+
},
|
|
898
|
+
onClick: ()=>{
|
|
899
|
+
navigator.clipboard.writeText(String(order.paymentLinkUrl));
|
|
900
|
+
enqueueSnackbar('Payment link copied', {
|
|
901
|
+
variant: 'success',
|
|
902
|
+
persist: false
|
|
903
|
+
});
|
|
904
|
+
},
|
|
905
|
+
children: 'Copy payment link'
|
|
906
|
+
}) : null
|
|
907
|
+
]
|
|
908
|
+
}),
|
|
909
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
910
|
+
children: [
|
|
911
|
+
customerCrmHref ? /*#__PURE__*/ _jsx(Button, _extends({
|
|
912
|
+
component: AppLink
|
|
913
|
+
}, {
|
|
914
|
+
componentVariant: 'naked',
|
|
915
|
+
nativeButton: false
|
|
916
|
+
}, {
|
|
917
|
+
href: customerCrmHref,
|
|
918
|
+
children: 'View customer in CRM'
|
|
919
|
+
})) : null,
|
|
920
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
921
|
+
onClick: handlePackingSlip,
|
|
922
|
+
children: 'Packing slip'
|
|
923
|
+
}),
|
|
924
|
+
can('cancelled') ? /*#__PURE__*/ _jsx(Button, {
|
|
925
|
+
color: "error",
|
|
926
|
+
disabled: busy,
|
|
927
|
+
onClick: handleCancel,
|
|
928
|
+
children: 'Cancel order'
|
|
929
|
+
}) : null,
|
|
930
|
+
can('refunded') ? // Disabled on `orderDisputeBlocksRefund`, NOT the badge's broader
|
|
931
|
+
// `orderHasOpenDispute` (AGL-1820): a formal open dispute means the
|
|
932
|
+
// bank already pulled the funds and the route answers 409
|
|
933
|
+
// (AGL-1809), while an open INQUIRY shows the badge but must keep
|
|
934
|
+
// this button live — a full refund is how an inquiry is resolved.
|
|
935
|
+
CommerceModel.orderDisputeBlocksRefund(order) ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
936
|
+
title: 'A chargeback is open on this order, and refunding would not' + ' withdraw it — the bank has already taken the disputed' + ' amount, so a refund on top would pay the shopper twice.' + ' Respond to the dispute or accept it in the Stripe' + ' dashboard; refund any remainder once it settles.',
|
|
937
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
938
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
939
|
+
color: "error",
|
|
940
|
+
disabled: true,
|
|
941
|
+
children: 'Refund'
|
|
942
|
+
})
|
|
943
|
+
})
|
|
944
|
+
}) : /*#__PURE__*/ _jsx(Button, {
|
|
945
|
+
color: "error",
|
|
946
|
+
disabled: busy,
|
|
947
|
+
onClick: ()=>handleRefund(),
|
|
948
|
+
children: 'Refund'
|
|
949
|
+
}) : null,
|
|
950
|
+
(can('fulfilled') || can('partially_fulfilled')) && !tracking ? /*#__PURE__*/ _jsx(Button, {
|
|
951
|
+
variant: "contained",
|
|
952
|
+
color: "primary",
|
|
953
|
+
onClick: ()=>setTracking({
|
|
954
|
+
carrier: '',
|
|
955
|
+
number: ''
|
|
956
|
+
}),
|
|
957
|
+
children: 'Fulfill…'
|
|
958
|
+
}) : null,
|
|
959
|
+
can('delivered') ? /*#__PURE__*/ _jsx(Button, {
|
|
960
|
+
disabled: busy,
|
|
961
|
+
onClick: handleDelivered,
|
|
962
|
+
children: 'Mark delivered'
|
|
963
|
+
}) : null,
|
|
964
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
965
|
+
onClick: onClose,
|
|
966
|
+
children: 'Close'
|
|
967
|
+
})
|
|
968
|
+
]
|
|
969
|
+
})
|
|
970
|
+
]
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
OrderDetailDialog.displayName = 'OrderDetailDialog';
|
|
974
|
+
export default OrderDetailDialog;
|
|
975
|
+
|
|
976
|
+
//# sourceMappingURL=order-detail-dialog.component.js.map
|