@aglyn/plugins-commerce 1.0.0-beta.284 → 1.0.0-beta.287
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/README.md +1 -1
- package/package.json +13 -13
- package/src/lib/components/cart.js +25 -12
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +70 -13
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +2 -1
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/payment-methods-card.component.js +1 -1
- package/src/lib/components/console/payment-methods-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +5 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js +18 -12
- package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-api.d.ts +76 -5
- package/src/lib/components/console/pos/pos-hardware-api.js +53 -11
- package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-buyer.component.d.ts +18 -0
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js +629 -0
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +162 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.js +122 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -0
- package/src/lib/components/console/pos/pos-hardware-sale-terms.component.d.ts +39 -0
- package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js +251 -0
- package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js.map +1 -0
- package/src/lib/components/console/pos/use-pos-display.js +50 -0
- package/src/lib/components/console/pos/use-pos-display.js.map +1 -1
- package/src/lib/components/console/pos-cellular-control.component.d.ts +41 -0
- package/src/lib/components/console/pos-cellular-control.component.js +211 -0
- package/src/lib/components/console/pos-cellular-control.component.js.map +1 -0
- package/src/lib/components/console/pos-devices-card.component.d.ts +9 -1
- package/src/lib/components/console/pos-devices-card.component.js +47 -15
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
- package/src/lib/components/console/pos-display/pos-display-api.d.ts +6 -0
- package/src/lib/components/console/pos-display/pos-display-api.js +8 -1
- package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -1
- package/src/lib/components/console/pos-display-page.component.d.ts +13 -0
- package/src/lib/components/console/pos-display-page.component.js +44 -2
- package/src/lib/components/console/pos-display-page.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-card.component.d.ts +12 -4
- package/src/lib/components/console/pos-hardware-card.component.js +157 -36
- package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +360 -80
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-terms-page.component.d.ts +34 -0
- package/src/lib/components/console/pos-hardware-terms-page.component.js +257 -0
- package/src/lib/components/console/pos-hardware-terms-page.component.js.map +1 -0
- package/src/lib/components/console/pos-hardware-terms-sign-page.component.d.ts +27 -0
- package/src/lib/components/console/pos-hardware-terms-sign-page.component.js +104 -0
- package/src/lib/components/console/pos-hardware-terms-sign-page.component.js.map +1 -0
- package/src/lib/components/console/pos-hardware-waiting-card.component.d.ts +24 -0
- package/src/lib/components/console/pos-hardware-waiting-card.component.js +205 -0
- package/src/lib/components/console/pos-hardware-waiting-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js +297 -201
- package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.d.ts +3 -0
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +260 -92
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +9 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +15 -6
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.d.ts +25 -0
- package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js +136 -0
- package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +6 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +48 -31
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -1
- package/src/lib/components/console/pos-page.component.d.ts +1 -1
- package/src/lib/components/console/pos-page.component.js +63 -12
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/pos-reader-splash-setting.component.js +1 -1
- package/src/lib/components/console/pos-reader-splash-setting.component.js.map +1 -1
- package/src/lib/components/console/product-check-in-fields.component.d.ts +4 -2
- package/src/lib/components/console/product-check-in-fields.component.js +60 -14
- package/src/lib/components/console/product-check-in-fields.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +44 -1
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-hardware-sku-field.component.d.ts +19 -0
- package/src/lib/components/console/product-hardware-sku-field.component.js +92 -0
- package/src/lib/components/console/product-hardware-sku-field.component.js.map +1 -0
- package/src/lib/components/console/product-kiosk-offer-field.component.d.ts +22 -0
- package/src/lib/components/console/product-kiosk-offer-field.component.js +94 -0
- package/src/lib/components/console/product-kiosk-offer-field.component.js.map +1 -0
- package/src/lib/components/console/product-register-fields.component.d.ts +4 -0
- package/src/lib/components/console/product-register-fields.component.js +31 -2
- package/src/lib/components/console/product-register-fields.component.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +11 -2
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/register-hardware-card.component.d.ts +11 -0
- package/src/lib/components/console/register-hardware-card.component.js +56 -27
- package/src/lib/components/console/register-hardware-card.component.js.map +1 -1
- package/src/lib/components/console/reservation-guests-dialog.component.d.ts +28 -0
- package/src/lib/components/console/reservation-guests-dialog.component.js +189 -0
- package/src/lib/components/console/reservation-guests-dialog.component.js.map +1 -0
- package/src/lib/components/console/reservations-card.component.d.ts +9 -0
- package/src/lib/components/console/reservations-card.component.js +158 -23
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/shippingeasy-card.component.js +1 -1
- package/src/lib/components/console/shippingeasy-card.component.js.map +1 -1
- package/src/lib/components/console/shipstation-card.component.d.ts +1 -1
- package/src/lib/components/console/shipstation-card.component.js +3 -3
- package/src/lib/components/console/shipstation-card.component.js.map +1 -1
- package/src/lib/components/product-detail.d.ts +4 -0
- package/src/lib/components/product-detail.js +40 -5
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-reviews.js +28 -11
- package/src/lib/components/product-reviews.js.map +1 -1
- package/src/lib/components/reservation-widget.js +28 -5
- package/src/lib/components/reservation-widget.js.map +1 -1
- package/src/lib/components/use-day-picker.d.ts +25 -0
- package/src/lib/components/use-day-picker.js +57 -0
- package/src/lib/components/use-day-picker.js.map +1 -0
- package/src/lib/constants/operator-alerts.d.ts +55 -0
- package/src/lib/constants/operator-alerts.js +156 -1
- package/src/lib/constants/operator-alerts.js.map +1 -1
- package/src/lib/declarations.console-server.js +54 -1
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/declarations.d.ts +4 -2
- package/src/lib/declarations.js +11 -4
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/declarations.server.js +9 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/commerce-cart.d.ts +9 -1
- package/src/lib/model/commerce-cart.js +4 -3
- package/src/lib/model/commerce-cart.js.map +1 -1
- package/src/lib/model/commerce-check-in-product.d.ts +26 -0
- package/src/lib/model/commerce-check-in-product.js +64 -2
- package/src/lib/model/commerce-check-in-product.js.map +1 -1
- package/src/lib/model/commerce-check-in-record.d.ts +127 -0
- package/src/lib/model/commerce-check-in-record.js +36 -0
- package/src/lib/model/commerce-check-in-record.js.map +1 -0
- package/src/lib/model/commerce-check-in.d.ts +91 -87
- package/src/lib/model/commerce-check-in.js +186 -62
- package/src/lib/model/commerce-check-in.js.map +1 -1
- package/src/lib/model/commerce-kiosk-offer.d.ts +31 -0
- package/src/lib/model/commerce-kiosk-offer.js +35 -0
- package/src/lib/model/commerce-kiosk-offer.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +76 -0
- package/src/lib/model/commerce-orders.js +6 -0
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-pos-day-report.d.ts +54 -1
- package/src/lib/model/commerce-pos-day-report.js +39 -2
- package/src/lib/model/commerce-pos-day-report.js.map +1 -1
- package/src/lib/model/commerce-pos-offline.d.ts +1 -1
- package/src/lib/model/commerce-pos-offline.js +6 -1
- package/src/lib/model/commerce-pos-offline.js.map +1 -1
- package/src/lib/model/commerce-pos-ops.js +3 -2
- package/src/lib/model/commerce-pos-ops.js.map +1 -1
- package/src/lib/model/commerce-pos.d.ts +36 -3
- package/src/lib/model/commerce-pos.js +14 -6
- package/src/lib/model/commerce-pos.js.map +1 -1
- package/src/lib/model/commerce-receipt.js +3 -2
- package/src/lib/model/commerce-receipt.js.map +1 -1
- package/src/lib/model/commerce-reservations.d.ts +69 -4
- package/src/lib/model/commerce-reservations.js +57 -5
- package/src/lib/model/commerce-reservations.js.map +1 -1
- package/src/lib/model/commerce.d.ts +66 -0
- package/src/lib/model/commerce.js +15 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/order-list-fields.d.ts +11 -0
- package/src/lib/model/order-list-fields.js +17 -1
- package/src/lib/model/order-list-fields.js.map +1 -1
- package/src/lib/model/own-store-tax-summary.d.ts +152 -0
- package/src/lib/model/own-store-tax-summary.js +288 -0
- package/src/lib/model/own-store-tax-summary.js.map +1 -0
- package/src/lib/model/plugin-permissions.d.ts +67 -0
- package/src/lib/model/plugin-permissions.js +224 -7
- package/src/lib/model/plugin-permissions.js.map +1 -1
- package/src/lib/model/pos-cellular.d.ts +223 -0
- package/src/lib/model/pos-cellular.js +293 -0
- package/src/lib/model/pos-cellular.js.map +1 -0
- package/src/lib/model/pos-hardware-in-person.d.ts +98 -0
- package/src/lib/model/pos-hardware-in-person.js +224 -0
- package/src/lib/model/pos-hardware-in-person.js.map +1 -0
- package/src/lib/model/pos-hardware-tax-summary.d.ts +166 -0
- package/src/lib/model/pos-hardware-tax-summary.js +225 -0
- package/src/lib/model/pos-hardware-tax-summary.js.map +1 -0
- package/src/lib/model/pos-hardware-terms.d.ts +74 -0
- package/src/lib/model/pos-hardware-terms.js +115 -0
- package/src/lib/model/pos-hardware-terms.js.map +1 -0
- package/src/lib/model/pos-hardware.d.ts +349 -7
- package/src/lib/model/pos-hardware.js +291 -20
- package/src/lib/model/pos-hardware.js.map +1 -1
- package/src/lib/model/product-write.d.ts +10 -0
- package/src/lib/model/product-write.js +4 -2
- package/src/lib/model/product-write.js.map +1 -1
- package/src/lib/plugin.js +16 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/billing-webhook.js +25 -1
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +7 -5
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/cart-checkout.js +20 -8
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/cart.js +29 -0
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/checkout.js +42 -13
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/collection-membership.d.ts +4 -0
- package/src/lib/server/collection-membership.js +5 -10
- package/src/lib/server/collection-membership.js.map +1 -1
- package/src/lib/server/commerce-site-keys.d.ts +29 -0
- package/src/lib/server/commerce-site-keys.js +40 -0
- package/src/lib/server/commerce-site-keys.js.map +1 -0
- package/src/lib/server/draft-order.js +8 -5
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/fulfill-order.js +7 -5
- package/src/lib/server/fulfill-order.js.map +1 -1
- package/src/lib/server/gift-cards.js +8 -5
- package/src/lib/server/gift-cards.js.map +1 -1
- package/src/lib/server/local-fulfillment-status.js +9 -6
- package/src/lib/server/local-fulfillment-status.js.map +1 -1
- package/src/lib/server/member-post.js +6 -5
- package/src/lib/server/member-post.js.map +1 -1
- package/src/lib/server/membership-admin-password.d.ts +4 -2
- package/src/lib/server/membership-admin-password.js +10 -8
- package/src/lib/server/membership-admin-password.js.map +1 -1
- package/src/lib/server/membership-admin-remove.d.ts +7 -5
- package/src/lib/server/membership-admin-remove.js +9 -9
- package/src/lib/server/membership-admin-remove.js.map +1 -1
- package/src/lib/server/order-notifications.js +5 -2
- package/src/lib/server/order-notifications.js.map +1 -1
- package/src/lib/server/order-print.js +7 -5
- package/src/lib/server/order-print.js.map +1 -1
- package/src/lib/server/order-receipt-send.js +8 -5
- package/src/lib/server/order-receipt-send.js.map +1 -1
- package/src/lib/server/orders-shipping-prepare.js +9 -6
- package/src/lib/server/orders-shipping-prepare.js.map +1 -1
- package/src/lib/server/own-store-tax-return-source.d.ts +47 -0
- package/src/lib/server/own-store-tax-return-source.js +312 -0
- package/src/lib/server/own-store-tax-return-source.js.map +1 -0
- package/src/lib/server/payment-methods.js +13 -9
- package/src/lib/server/payment-methods.js.map +1 -1
- package/src/lib/server/pos-auth.d.ts +37 -6
- package/src/lib/server/pos-auth.js +40 -15
- package/src/lib/server/pos-auth.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.d.ts +81 -0
- package/src/lib/server/pos-cellular-billing.js +711 -0
- package/src/lib/server/pos-cellular-billing.js.map +1 -0
- package/src/lib/server/pos-cellular-notify.d.ts +47 -0
- package/src/lib/server/pos-cellular-notify.js +150 -0
- package/src/lib/server/pos-cellular-notify.js.map +1 -0
- package/src/lib/server/pos-cellular.d.ts +88 -0
- package/src/lib/server/pos-cellular.js +339 -0
- package/src/lib/server/pos-cellular.js.map +1 -0
- package/src/lib/server/pos-check-in.d.ts +5 -1
- package/src/lib/server/pos-check-in.js +296 -28
- package/src/lib/server/pos-check-in.js.map +1 -1
- package/src/lib/server/pos-day-report.js +29 -3
- package/src/lib/server/pos-day-report.js.map +1 -1
- package/src/lib/server/pos-display.d.ts +16 -0
- package/src/lib/server/pos-display.js +129 -2
- package/src/lib/server/pos-display.js.map +1 -1
- package/src/lib/server/pos-hardware-admin.d.ts +10 -1
- package/src/lib/server/pos-hardware-admin.js +250 -84
- package/src/lib/server/pos-hardware-admin.js.map +1 -1
- package/src/lib/server/pos-hardware-attach.d.ts +105 -0
- package/src/lib/server/pos-hardware-attach.js +443 -0
- package/src/lib/server/pos-hardware-attach.js.map +1 -0
- package/src/lib/server/pos-hardware-buyer-lookup.d.ts +58 -0
- package/src/lib/server/pos-hardware-buyer-lookup.js +180 -0
- package/src/lib/server/pos-hardware-buyer-lookup.js.map +1 -0
- package/src/lib/server/pos-hardware-buyer-record.d.ts +29 -0
- package/src/lib/server/pos-hardware-buyer-record.js +86 -0
- package/src/lib/server/pos-hardware-buyer-record.js.map +1 -0
- package/src/lib/server/pos-hardware-cancel.d.ts +58 -0
- package/src/lib/server/pos-hardware-cancel.js +147 -0
- package/src/lib/server/pos-hardware-cancel.js.map +1 -0
- package/src/lib/server/pos-hardware-closure-notices.d.ts +27 -0
- package/src/lib/server/pos-hardware-closure-notices.js +85 -0
- package/src/lib/server/pos-hardware-closure-notices.js.map +1 -0
- package/src/lib/server/pos-hardware-closure.d.ts +60 -0
- package/src/lib/server/pos-hardware-closure.js +153 -0
- package/src/lib/server/pos-hardware-closure.js.map +1 -0
- package/src/lib/server/pos-hardware-in-person.d.ts +61 -0
- package/src/lib/server/pos-hardware-in-person.js +236 -0
- package/src/lib/server/pos-hardware-in-person.js.map +1 -0
- package/src/lib/server/pos-hardware-notify.d.ts +40 -2
- package/src/lib/server/pos-hardware-notify.js +195 -14
- package/src/lib/server/pos-hardware-notify.js.map +1 -1
- package/src/lib/server/pos-hardware-readers.d.ts +115 -0
- package/src/lib/server/pos-hardware-readers.js +430 -0
- package/src/lib/server/pos-hardware-readers.js.map +1 -0
- package/src/lib/server/pos-hardware-returns.d.ts +116 -0
- package/src/lib/server/pos-hardware-returns.js +502 -0
- package/src/lib/server/pos-hardware-returns.js.map +1 -0
- package/src/lib/server/pos-hardware-sale-fields.d.ts +28 -0
- package/src/lib/server/pos-hardware-sale-fields.js +44 -0
- package/src/lib/server/pos-hardware-sale-fields.js.map +1 -0
- package/src/lib/server/pos-hardware-sale.d.ts +54 -0
- package/src/lib/server/pos-hardware-sale.js +369 -0
- package/src/lib/server/pos-hardware-sale.js.map +1 -0
- package/src/lib/server/pos-hardware-tax-return-source.d.ts +99 -0
- package/src/lib/server/pos-hardware-tax-return-source.js +462 -0
- package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -0
- package/src/lib/server/pos-hardware-terms.d.ts +64 -0
- package/src/lib/server/pos-hardware-terms.js +154 -0
- package/src/lib/server/pos-hardware-terms.js.map +1 -0
- package/src/lib/server/pos-hardware-user-eraser.d.ts +3 -0
- package/src/lib/server/pos-hardware-user-eraser.js +31 -7
- package/src/lib/server/pos-hardware-user-eraser.js.map +1 -1
- package/src/lib/server/pos-hardware-webhook.d.ts +5 -0
- package/src/lib/server/pos-hardware-webhook.js +51 -6
- package/src/lib/server/pos-hardware-webhook.js.map +1 -1
- package/src/lib/server/pos-hardware.d.ts +74 -1
- package/src/lib/server/pos-hardware.js +175 -10
- package/src/lib/server/pos-hardware.js.map +1 -1
- package/src/lib/server/pos-kiosk.d.ts +2 -0
- package/src/lib/server/pos-kiosk.js +17 -12
- package/src/lib/server/pos-kiosk.js.map +1 -1
- package/src/lib/server/pos-offline-card-order.d.ts +64 -0
- package/src/lib/server/pos-offline-card-order.js +102 -0
- package/src/lib/server/pos-offline-card-order.js.map +1 -0
- package/src/lib/server/pos-offline-card-reconcile.d.ts +67 -1
- package/src/lib/server/pos-offline-card-reconcile.js +215 -18
- package/src/lib/server/pos-offline-card-reconcile.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +39 -0
- package/src/lib/server/pos-offline-sync.js +190 -55
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-ops-gate.d.ts +15 -4
- package/src/lib/server/pos-ops-gate.js +42 -9
- package/src/lib/server/pos-ops-gate.js.map +1 -1
- package/src/lib/server/pos-ops-routes.js +24 -0
- package/src/lib/server/pos-ops-routes.js.map +1 -1
- package/src/lib/server/pos-order-refund-ids.d.ts +28 -0
- package/src/lib/server/pos-order-refund-ids.js +31 -0
- package/src/lib/server/pos-order-refund-ids.js.map +1 -0
- package/src/lib/server/pos-order.js +52 -49
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.js +1 -1
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-reader-splash-admin.js +30 -32
- package/src/lib/server/pos-reader-splash-admin.js.map +1 -1
- package/src/lib/server/pos-reader-splash-images-route.d.ts +17 -0
- package/src/lib/server/pos-reader-splash-images-route.js +113 -0
- package/src/lib/server/pos-reader-splash-images-route.js.map +1 -0
- package/src/lib/server/pos-reader-splash-images.d.ts +51 -0
- package/src/lib/server/pos-reader-splash-images.js +123 -0
- package/src/lib/server/pos-reader-splash-images.js.map +1 -0
- package/src/lib/server/pos-reader-splash.d.ts +68 -1
- package/src/lib/server/pos-reader-splash.js +182 -11
- package/src/lib/server/pos-reader-splash.js.map +1 -1
- package/src/lib/server/pos-readers.d.ts +29 -0
- package/src/lib/server/pos-readers.js +134 -35
- package/src/lib/server/pos-readers.js.map +1 -1
- package/src/lib/server/pos-return.d.ts +10 -0
- package/src/lib/server/pos-return.js +26 -1
- package/src/lib/server/pos-return.js.map +1 -1
- package/src/lib/server/pos-sale.js +6 -1
- package/src/lib/server/pos-sale.js.map +1 -1
- package/src/lib/server/pos-shift.js +11 -0
- package/src/lib/server/pos-shift.js.map +1 -1
- package/src/lib/server/pos-staff-pin.js +25 -20
- package/src/lib/server/pos-staff-pin.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +14 -4
- package/src/lib/server/pos-terminal.js +34 -38
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/printers.d.ts +7 -3
- package/src/lib/server/printers.js +18 -12
- package/src/lib/server/printers.js.map +1 -1
- package/src/lib/server/product-drafts.d.ts +11 -1
- package/src/lib/server/product-drafts.js +12 -8
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product.d.ts +15 -1
- package/src/lib/server/product.js +16 -3
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/products-write.d.ts +26 -2
- package/src/lib/server/products-write.js +19 -7
- package/src/lib/server/products-write.js.map +1 -1
- package/src/lib/server/refund.js +34 -11
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reservation-availability-query.d.ts +8 -0
- package/src/lib/server/reservation-availability-query.js +11 -1
- package/src/lib/server/reservation-availability-query.js.map +1 -1
- package/src/lib/server/reservation-availability.d.ts +1 -1
- package/src/lib/server/reservation-availability.js +7 -2
- package/src/lib/server/reservation-availability.js.map +1 -1
- package/src/lib/server/reservation-guests.d.ts +32 -0
- package/src/lib/server/reservation-guests.js +285 -0
- package/src/lib/server/reservation-guests.js.map +1 -0
- package/src/lib/server/reservation-walk-in.d.ts +11 -1
- package/src/lib/server/reservation-walk-in.js +56 -12
- package/src/lib/server/reservation-walk-in.js.map +1 -1
- package/src/lib/server/reserve.js +18 -5
- package/src/lib/server/reserve.js.map +1 -1
- package/src/lib/server/returns.js +9 -6
- package/src/lib/server/returns.js.map +1 -1
- package/src/lib/server/reviews.d.ts +22 -2
- package/src/lib/server/reviews.js +88 -20
- package/src/lib/server/reviews.js.map +1 -1
- package/src/lib/server/shipping-connectors.js +10 -11
- package/src/lib/server/shipping-connectors.js.map +1 -1
- package/src/lib/server/site-page-resolver.js +20 -3
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/store-day.d.ts +33 -0
- package/src/lib/server/store-day.js +46 -0
- package/src/lib/server/store-day.js.map +1 -0
- package/src/lib/server/store-setup-ai-writer.d.ts +2 -1
- package/src/lib/server/store-setup-ai-writer.js +5 -6
- package/src/lib/server/store-setup-ai-writer.js.map +1 -1
- package/src/lib/server/storefront-tax.d.ts +13 -0
- package/src/lib/server/storefront-tax.js +8 -1
- package/src/lib/server/storefront-tax.js.map +1 -1
- package/src/lib/server/tax-return-source.d.ts +32 -3
- package/src/lib/server/tax-return-source.js +99 -20
- package/src/lib/server/tax-return-source.js.map +1 -1
- package/src/lib/server.js +100 -2
- package/src/lib/server.js.map +1 -1
- package/src/lib/testing/fake-firestore.js +58 -16
- package/src/lib/testing/fake-firestore.js.map +1 -1
- package/src/lib/testing/pos-ops-memory-firestore.js +18 -4
- package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -1
- package/src/lib/testing/site-register-permissions.d.ts +29 -0
- package/src/lib/testing/site-register-permissions.js +38 -0
- package/src/lib/testing/site-register-permissions.js.map +1 -0
- package/src/lib/transfer/tracking.server.js +8 -5
- package/src/lib/transfer/tracking.server.js.map +1 -1
- package/src/lib/utils/add-to-cart.d.ts +2 -0
- package/src/lib/utils/add-to-cart.js +6 -3
- package/src/lib/utils/add-to-cart.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/payment-methods-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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n Chip,\n Divider,\n Stack,\n Switch,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n STOREFRONT_PAYMENT_METHODS,\n type StorefrontPaymentMethodId,\n type StorefrontPaymentMethodSettings,\n type StorefrontPaymentMethodSpec,\n} from '../../model/commerce-payment-methods'\nimport { PAYMENTS_SETTINGS_ANCHOR } from './payments-settings-card.component'\n\nexport interface PaymentMethodsCardProps {\n hostId: string\n}\n\n/** One method as the route reports it (`server/payment-methods.ts`). */\nexport interface PaymentMethodRowView {\n id: StorefrontPaymentMethodId\n on: boolean\n platform: 'on' | 'unavailable' | null\n capability: 'active' | 'pending' | 'inactive' | 'unrequested' | null\n}\n\nexport interface PaymentMethodDomainView {\n domain: string\n enabled: boolean\n stripeId: string | null\n status: { applePay: string | null; googlePay: string | null }\n lastError: string | null\n}\n\nexport interface PaymentMethodsView {\n methods: PaymentMethodRowView[]\n domains: PaymentMethodDomainView[]\n accountConnected: boolean\n /** Absent from an older answer: read as allowed, and the route still judges. */\n canEdit?: boolean\n canFinish?: boolean\n warnings: string[]\n}\n\n/**\n * What a method's Stripe state means to the merchant, or null for nothing to\n * say. Only an ON method gets a verdict: an off one is the merchant's choice.\n */\nexport function capabilityVerdict(\n row: PaymentMethodRowView,\n accountConnected: boolean,\n): { label: string; color: 'success' | 'warning' | 'default' } | null {\n if (!row.on) return null\n if (!accountConnected) return { label: 'Connect Stripe first', color: 'default' }\n switch (row.capability) {\n case 'active':\n return { label: 'Ready', color: 'success' }\n case 'pending':\n return { label: 'Stripe is reviewing', color: 'warning' }\n case 'inactive':\n return { label: 'Stripe needs more details', color: 'warning' }\n case 'unrequested':\n return { label: 'Save to request', color: 'default' }\n default:\n return null\n }\n}\n\n/** The domain chip: what Apple Pay can do on this name right now. */\nexport function domainVerdict(domain: PaymentMethodDomainView): {\n label: string\n color: 'success' | 'warning' | 'default'\n} {\n if (domain.enabled && domain.status.applePay === 'active') {\n return { label: 'Apple Pay ready', color: 'success' }\n }\n if (domain.enabled) return { label: 'Registered', color: 'default' }\n if (domain.lastError) return { label: 'Retrying', color: 'warning' }\n return { label: 'Registers on first checkout', color: 'default' }\n}\n\n/**\n * The methods a merchant can see: everything the platform offers, and every\n * method we could not ask Stripe about except crypto, which is shown only once\n * the platform positively offers it (AGL-3629: hidden where unavailable).\n */\nexport function visibleMethods(\n rows: readonly PaymentMethodRowView[],\n): Array<{ row: PaymentMethodRowView; spec: StorefrontPaymentMethodSpec }> {\n return rows\n .map((row) => ({\n row,\n spec: STOREFRONT_PAYMENT_METHODS.find((method) => method.id === row.id),\n }))\n .filter(\n (entry): entry is { row: PaymentMethodRowView; spec: StorefrontPaymentMethodSpec } =>\n Boolean(entry.spec) &&\n entry.row.platform !== 'unavailable' &&\n !(entry.row.platform === null && entry.spec?.kind === 'crypto'),\n )\n}\n\n/**\n * Payment methods (AGL-3629): which wallets, buy-now-pay-later and crypto\n * options the storefront offers, what each needs, and whether Stripe is ready\n * for it. Cards are always on and are not listed.\n *\n * Read and saved through `/api/commerce/payment-methods` rather than a\n * Firestore listen, because two of the three facts per row — what the\n * platform offers and the payout account's capability — live at Stripe, and a\n * save is a Stripe request as well as a settings write.\n */\nexport function PaymentMethodsCard(props: PaymentMethodsCardProps) {\n const { hostId } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [view, setView] = useState<PaymentMethodsView | null>(null)\n const [state, setState] = useState<'loading' | 'loaded' | 'error' | 'unconfigured'>(\n 'loading',\n )\n const [draft, setDraft] = useState<StorefrontPaymentMethodSettings>({})\n const [saving, setSaving] = useState(false)\n const [nonce, setNonce] = useState(0)\n // The load keys on the uid, not the user object: a refreshed token hands\n // back a new object, and reloading on it would throw away unsaved toggles.\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid\n\n useEffect(() => {\n const user = userRef.current\n if (!uid || !user || !hostId) return\n let cancelled = false\n setState('loading')\n void (async () => {\n try {\n const response = await authorizedFetch(\n user,\n `/api/commerce/payment-methods?hostId=${encodeURIComponent(hostId)}`,\n )\n if (cancelled) return\n if (response.status === 501) return void setState('unconfigured')\n if (!response.ok) return void setState('error')\n const payload = (await response.json()) as PaymentMethodsView\n if (cancelled) return\n setView(payload)\n setDraft({})\n setState('loaded')\n } catch {\n if (!cancelled) setState('error')\n }\n })()\n return () => {\n cancelled = true\n }\n }, [uid, hostId, nonce])\n\n const dirty = Object.keys(draft).length > 0\n\n const handleSave = useCallback(async () => {\n if (!dirty) return\n setSaving(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/payment-methods', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, methods: draft }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Payment methods were not saved', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n setView(payload as PaymentMethodsView)\n setDraft({})\n enqueueSnackbar('Payment methods saved', { variant: 'success', persist: false })\n } catch {\n enqueueSnackbar('Payment methods were not saved', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setSaving(false)\n }\n }, [dirty, draft, enqueueSnackbar, hostId, user])\n\n const handleFinish = useCallback(async () => {\n setSaving(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/payment-methods', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, action: 'finish' }),\n })\n const payload = await response.json().catch(() => ({}))\n if (response.ok && typeof payload?.url === 'string') {\n return void window.location.assign(payload.url)\n }\n enqueueSnackbar(payload?.error ?? 'Stripe could not be opened', {\n variant: 'error',\n allowDuplicate: true,\n })\n } catch {\n enqueueSnackbar('Stripe could not be opened', { variant: 'error', allowDuplicate: true })\n } finally {\n setSaving(false)\n }\n }, [enqueueSnackbar, hostId, user])\n\n const rows = view ? visibleMethods(view.methods) : []\n const canEdit = view?.canEdit !== false\n const canFinish = view?.canFinish !== false\n\n return (\n <CardDisplay\n header={'Payment methods'}\n help={pluginDocsHelp('commerce', { anchor: '#payment-methods' })}\n HeaderProps={{\n action:\n state === 'loaded' && canEdit ? (\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={!dirty || saving}\n onClick={handleSave}\n >\n {saving ? 'Saving…' : 'Save'}\n </Button>\n ) : null,\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1.5} data-testid=\"payment-methods-card\">\n {state === 'loading' ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Checking your payment methods…'}\n </Typography>\n ) : null}\n {state === 'unconfigured' ? (\n <Alert severity=\"info\">{'Payments are not configured on this deployment.'}</Alert>\n ) : null}\n {state === 'error' ? (\n <Alert\n severity=\"error\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={() => setNonce((n) => n + 1)}>\n {'Retry'}\n </Button>\n }\n >\n {'We couldn’t load your payment methods. Nothing has changed — ' +\n 'shoppers still see what they saw before.'}\n </Alert>\n ) : null}\n {state === 'loaded' && view ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Cards are always on. Turn off anything you don’t want to offer. ' +\n 'Stripe shows each method only on orders and to shoppers it suits, ' +\n 'using the limits below.'}\n </Typography>\n {canEdit ? null : (\n <Alert severity=\"info\">\n {'Only a site admin can change which payment methods your store offers.'}\n </Alert>\n )}\n {/* What every \"Connect Stripe first\" chip below waits on, and where\n it is done: the Payments card above (AGL-3982). */}\n {view.accountConnected ? null : (\n <PrerequisiteNotice href={`#${PAYMENTS_SETTINGS_ANCHOR}`} actionLabel=\"Connect Stripe\">\n {'Connect Stripe in the Payments card above to offer these methods. ' +\n 'Methods you turn on show at checkout once Stripe is connected and approves them.'}\n </PrerequisiteNotice>\n )}\n {view.warnings.map((warning) => (\n <Alert key={warning} severity=\"warning\">\n {warning}\n </Alert>\n ))}\n {rows.map(({ row, spec }) => {\n const on = draft[row.id] ?? row.on\n const verdict = capabilityVerdict({ ...row, on }, view.accountConnected)\n return (\n <Stack key={row.id} spacing={0.5} data-testid={`payment-method-${row.id}`}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Switch\n checked={on}\n disabled={!canEdit || saving}\n onChange={(event) => {\n const next = event.target.checked\n setDraft((current) => {\n const copy = { ...current }\n if (next === row.on) delete copy[row.id]\n else copy[row.id] = next\n return copy\n })\n }}\n slotProps={{ input: { 'aria-label': spec.label } }}\n />\n <Typography variant=\"subtitle2\" sx={{ flex: 1 }}>\n {spec.label}\n </Typography>\n {spec.capability && verdict ? (\n <Chip size=\"small\" variant=\"outlined\" label={verdict.label} color={verdict.color} />\n ) : null}\n {on && row.capability === 'inactive' && canFinish ? (\n <Button size=\"small\" disabled={saving} onClick={handleFinish}>\n {'Finish in Stripe'}\n </Button>\n ) : null}\n </Stack>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {spec.requirements}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {spec.limits}\n </Typography>\n </Stack>\n )\n })}\n <Divider />\n <Typography variant=\"subtitle2\">{'Wallet domains'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Apple Pay shows only on a domain registered with Stripe. Your ' +\n 'site’s domains are registered for you when you connect them and ' +\n 'on the first in-page checkout.'}\n </Typography>\n {view.domains.map((domain) => {\n const verdict = domainVerdict(domain)\n return (\n <Stack\n key={domain.domain}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n data-testid={`payment-domain-${domain.domain}`}\n >\n <Typography variant=\"body2\" sx={{ flex: 1 }}>\n {domain.domain}\n </Typography>\n <Chip size=\"small\" variant=\"outlined\" label={verdict.label} color={verdict.color} />\n </Stack>\n )\n })}\n </>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n}\nPaymentMethodsCard.displayName = 'PaymentMethodsCard'\n\nexport default PaymentMethodsCard\n"],"names":["pluginDocsHelp","CardDisplay","PrerequisiteNotice","useSnackbar","authorizedFetch","useUser","Alert","Button","Chip","Divider","Stack","Switch","Typography","useCallback","useEffect","useRef","useState","STOREFRONT_PAYMENT_METHODS","PAYMENTS_SETTINGS_ANCHOR","capabilityVerdict","row","accountConnected","on","label","color","capability","domainVerdict","domain","enabled","status","applePay","lastError","visibleMethods","rows","map","spec","find","method","id","filter","entry","Boolean","platform","kind","PaymentMethodsCard","props","hostId","data","user","enqueueSnackbar","view","setView","state","setState","draft","setDraft","saving","setSaving","nonce","setNonce","userRef","current","uid","cancelled","response","encodeURIComponent","ok","payload","json","dirty","Object","keys","length","handleSave","headers","body","JSON","stringify","methods","catch","error","variant","allowDuplicate","persist","handleFinish","action","url","window","location","assign","canEdit","canFinish","header","help","anchor","HeaderProps","size","disabled","onClick","contentGutterX","contentGutterY","spacing","data-testid","severity","n","href","actionLabel","warnings","warning","verdict","direction","sx","alignItems","checked","onChange","event","next","target","copy","slotProps","input","flex","requirements","limits","domains","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SACEC,0BAA0B,QAIrB,0CAAsC;AAC7C,SAASC,wBAAwB,QAAQ,wCAAoC;AAgC7E;;;CAGC,GACD,OAAO,S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AAQtF,KAAK;gDAAEC,OAAOqF,QAAQrF,KAAK;iDAC9E;4CACHF,MAAMF,IAAIK,UAAU,KAAK,cAAckE,0BACtC,KAACpF;gDAAOyF,MAAK;gDAAQC,UAAUzC;gDAAQ0C,SAASd;0DAC7C;iDAED;;;kDAEN,KAACxE;wCAAWqE,SAAQ;wCAAQzD,OAAM;kDAC/BW,KAAKuF,YAAY;;kDAEpB,KAAC9G;wCAAWqE,SAAQ;wCAAUzD,OAAM;kDACjCW,KAAKwF,MAAM;;;+BAhCJvG,IAAIkB,EAAE;wBAoCtB;sCACA,KAAC7B;sCACD,KAACG;4BAAWqE,SAAQ;sCAAa;;sCACjC,KAACrE;4BAAWqE,SAAQ;4BAAQzD,OAAM;sCAC/B,mEACC,qEACA;;wBAEH0B,KAAK0E,OAAO,CAAC1F,GAAG,CAAC,CAACP;4BACjB,MAAMkF,UAAUnF,cAAcC;4BAC9B,qBACE,MAACjB;gCAECoG,WAAU;gCACVT,SAAS;gCACTU,IAAI;oCAAEC,YAAY;gCAAS;gCAC3BV,eAAa,CAAC,eAAe,EAAE3E,OAAOA,MAAM,EAAE;;kDAE9C,KAACf;wCAAWqE,SAAQ;wCAAQ8B,IAAI;4CAAEU,MAAM;wCAAE;kDACvC9F,OAAOA,MAAM;;kDAEhB,KAACnB;wCAAKwF,MAAK;wCAAQf,SAAQ;wCAAW1D,OAAOsF,QAAQtF,KAAK;wCAAEC,OAAOqF,QAAQrF,KAAK;;;+BAT3EG,OAAOA,MAAM;wBAYxB;;qBAEA;;;;AAIZ;AACAiB,mBAAmBiF,WAAW,GAAG;AAEjC,eAAejF,mBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/payment-methods-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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n Chip,\n Divider,\n Stack,\n Switch,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n STOREFRONT_PAYMENT_METHODS,\n type StorefrontPaymentMethodId,\n type StorefrontPaymentMethodSettings,\n type StorefrontPaymentMethodSpec,\n} from '../../model/commerce-payment-methods'\nimport { PAYMENTS_SETTINGS_ANCHOR } from './payments-settings-card.component'\n\nexport interface PaymentMethodsCardProps {\n hostId: string\n}\n\n/** One method as the route reports it (`server/payment-methods.ts`). */\nexport interface PaymentMethodRowView {\n id: StorefrontPaymentMethodId\n on: boolean\n platform: 'on' | 'unavailable' | null\n capability: 'active' | 'pending' | 'inactive' | 'unrequested' | null\n}\n\nexport interface PaymentMethodDomainView {\n domain: string\n enabled: boolean\n stripeId: string | null\n status: { applePay: string | null; googlePay: string | null }\n lastError: string | null\n}\n\nexport interface PaymentMethodsView {\n methods: PaymentMethodRowView[]\n domains: PaymentMethodDomainView[]\n accountConnected: boolean\n /** Absent from an older answer: read as allowed, and the route still judges. */\n canEdit?: boolean\n canFinish?: boolean\n warnings: string[]\n}\n\n/**\n * What a method's Stripe state means to the merchant, or null for nothing to\n * say. Only an ON method gets a verdict: an off one is the merchant's choice.\n */\nexport function capabilityVerdict(\n row: PaymentMethodRowView,\n accountConnected: boolean,\n): { label: string; color: 'success' | 'warning' | 'default' } | null {\n if (!row.on) return null\n if (!accountConnected) return { label: 'Connect Stripe first', color: 'default' }\n switch (row.capability) {\n case 'active':\n return { label: 'Ready', color: 'success' }\n case 'pending':\n return { label: 'Stripe is reviewing', color: 'warning' }\n case 'inactive':\n return { label: 'Stripe needs more details', color: 'warning' }\n case 'unrequested':\n return { label: 'Save to request', color: 'default' }\n default:\n return null\n }\n}\n\n/** The domain chip: what Apple Pay can do on this name right now. */\nexport function domainVerdict(domain: PaymentMethodDomainView): {\n label: string\n color: 'success' | 'warning' | 'default'\n} {\n if (domain.enabled && domain.status.applePay === 'active') {\n return { label: 'Apple Pay ready', color: 'success' }\n }\n if (domain.enabled) return { label: 'Registered', color: 'default' }\n if (domain.lastError) return { label: 'Retrying', color: 'warning' }\n return { label: 'Registers on first checkout', color: 'default' }\n}\n\n/**\n * The methods a merchant can see: everything the platform offers, and every\n * method we could not ask Stripe about except crypto, which is shown only once\n * the platform positively offers it (AGL-3629: hidden where unavailable).\n */\nexport function visibleMethods(\n rows: readonly PaymentMethodRowView[],\n): Array<{ row: PaymentMethodRowView; spec: StorefrontPaymentMethodSpec }> {\n return rows\n .map((row) => ({\n row,\n spec: STOREFRONT_PAYMENT_METHODS.find((method) => method.id === row.id),\n }))\n .filter(\n (entry): entry is { row: PaymentMethodRowView; spec: StorefrontPaymentMethodSpec } =>\n Boolean(entry.spec) &&\n entry.row.platform !== 'unavailable' &&\n !(entry.row.platform === null && entry.spec?.kind === 'crypto'),\n )\n}\n\n/**\n * Payment methods (AGL-3629): which wallets, buy-now-pay-later and crypto\n * options the storefront offers, what each needs, and whether Stripe is ready\n * for it. Cards are always on and are not listed.\n *\n * Read and saved through `/api/commerce/payment-methods` rather than a\n * Firestore listen, because two of the three facts per row — what the\n * platform offers and the payout account's capability — live at Stripe, and a\n * save is a Stripe request as well as a settings write.\n */\nexport function PaymentMethodsCard(props: PaymentMethodsCardProps) {\n const { hostId } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [view, setView] = useState<PaymentMethodsView | null>(null)\n const [state, setState] = useState<'loading' | 'loaded' | 'error' | 'unconfigured'>(\n 'loading',\n )\n const [draft, setDraft] = useState<StorefrontPaymentMethodSettings>({})\n const [saving, setSaving] = useState(false)\n const [nonce, setNonce] = useState(0)\n // The load keys on the uid, not the user object: a refreshed token hands\n // back a new object, and reloading on it would throw away unsaved toggles.\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid\n\n useEffect(() => {\n const user = userRef.current\n if (!uid || !user || !hostId) return\n let cancelled = false\n setState('loading')\n void (async () => {\n try {\n const response = await authorizedFetch(\n user,\n `/api/commerce/payment-methods?hostId=${encodeURIComponent(hostId)}`,\n )\n if (cancelled) return\n if (response.status === 501) return void setState('unconfigured')\n if (!response.ok) return void setState('error')\n const payload = (await response.json()) as PaymentMethodsView\n if (cancelled) return\n setView(payload)\n setDraft({})\n setState('loaded')\n } catch {\n if (!cancelled) setState('error')\n }\n })()\n return () => {\n cancelled = true\n }\n }, [uid, hostId, nonce])\n\n const dirty = Object.keys(draft).length > 0\n\n const handleSave = useCallback(async () => {\n if (!dirty) return\n setSaving(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/payment-methods', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, methods: draft }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Payment methods were not saved', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n setView(payload as PaymentMethodsView)\n setDraft({})\n enqueueSnackbar('Payment methods saved', { variant: 'success', persist: false })\n } catch {\n enqueueSnackbar('Payment methods were not saved', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setSaving(false)\n }\n }, [dirty, draft, enqueueSnackbar, hostId, user])\n\n const handleFinish = useCallback(async () => {\n setSaving(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/payment-methods', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, action: 'finish' }),\n })\n const payload = await response.json().catch(() => ({}))\n if (response.ok && typeof payload?.url === 'string') {\n return void window.location.assign(payload.url)\n }\n enqueueSnackbar(payload?.error ?? 'Stripe could not be opened', {\n variant: 'error',\n allowDuplicate: true,\n })\n } catch {\n enqueueSnackbar('Stripe could not be opened', { variant: 'error', allowDuplicate: true })\n } finally {\n setSaving(false)\n }\n }, [enqueueSnackbar, hostId, user])\n\n const rows = view ? visibleMethods(view.methods) : []\n const canEdit = view?.canEdit !== false\n const canFinish = view?.canFinish !== false\n\n return (\n <CardDisplay\n header={'Payment methods'}\n help={pluginDocsHelp('commerce', { anchor: '#payment-methods' })}\n HeaderProps={{\n action:\n state === 'loaded' && canEdit ? (\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={!dirty || saving}\n onClick={handleSave}\n >\n {saving ? 'Saving…' : 'Save'}\n </Button>\n ) : null,\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1.5} data-testid=\"payment-methods-card\">\n {state === 'loading' ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Checking your payment methods…'}\n </Typography>\n ) : null}\n {state === 'unconfigured' ? (\n <Alert severity=\"info\">{'Payments are not configured on this deployment.'}</Alert>\n ) : null}\n {state === 'error' ? (\n <Alert\n severity=\"error\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={() => setNonce((n) => n + 1)}>\n {'Retry'}\n </Button>\n }\n >\n {'We couldn’t load your payment methods. Nothing has changed — ' +\n 'shoppers still see what they saw before.'}\n </Alert>\n ) : null}\n {state === 'loaded' && view ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Cards are always on. Turn off anything you don’t want to offer. ' +\n 'Stripe shows each method only on orders and to shoppers it suits, ' +\n 'using the limits below.'}\n </Typography>\n {canEdit ? null : (\n <Alert severity=\"info\">\n {'Changing which payment methods your store offers takes the \"Manage payment methods\" permission — ask an organization admin.'}\n </Alert>\n )}\n {/* What every \"Connect Stripe first\" chip below waits on, and where\n it is done: the Payments card above (AGL-3982). */}\n {view.accountConnected ? null : (\n <PrerequisiteNotice href={`#${PAYMENTS_SETTINGS_ANCHOR}`} actionLabel=\"Connect Stripe\">\n {'Connect Stripe in the Payments card above to offer these methods. ' +\n 'Methods you turn on show at checkout once Stripe is connected and approves them.'}\n </PrerequisiteNotice>\n )}\n {view.warnings.map((warning) => (\n <Alert key={warning} severity=\"warning\">\n {warning}\n </Alert>\n ))}\n {rows.map(({ row, spec }) => {\n const on = draft[row.id] ?? row.on\n const verdict = capabilityVerdict({ ...row, on }, view.accountConnected)\n return (\n <Stack key={row.id} spacing={0.5} data-testid={`payment-method-${row.id}`}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Switch\n checked={on}\n disabled={!canEdit || saving}\n onChange={(event) => {\n const next = event.target.checked\n setDraft((current) => {\n const copy = { ...current }\n if (next === row.on) delete copy[row.id]\n else copy[row.id] = next\n return copy\n })\n }}\n slotProps={{ input: { 'aria-label': spec.label } }}\n />\n <Typography variant=\"subtitle2\" sx={{ flex: 1 }}>\n {spec.label}\n </Typography>\n {spec.capability && verdict ? (\n <Chip size=\"small\" variant=\"outlined\" label={verdict.label} color={verdict.color} />\n ) : null}\n {on && row.capability === 'inactive' && canFinish ? (\n <Button size=\"small\" disabled={saving} onClick={handleFinish}>\n {'Finish in Stripe'}\n </Button>\n ) : null}\n </Stack>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {spec.requirements}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {spec.limits}\n </Typography>\n </Stack>\n )\n })}\n <Divider />\n <Typography variant=\"subtitle2\">{'Wallet domains'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Apple Pay shows only on a domain registered with Stripe. Your ' +\n 'site’s domains are registered for you when you connect them and ' +\n 'on the first in-page checkout.'}\n </Typography>\n {view.domains.map((domain) => {\n const verdict = domainVerdict(domain)\n return (\n <Stack\n key={domain.domain}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n data-testid={`payment-domain-${domain.domain}`}\n >\n <Typography variant=\"body2\" sx={{ flex: 1 }}>\n {domain.domain}\n </Typography>\n <Chip size=\"small\" variant=\"outlined\" label={verdict.label} color={verdict.color} />\n </Stack>\n )\n })}\n </>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n}\nPaymentMethodsCard.displayName = 'PaymentMethodsCard'\n\nexport default PaymentMethodsCard\n"],"names":["pluginDocsHelp","CardDisplay","PrerequisiteNotice","useSnackbar","authorizedFetch","useUser","Alert","Button","Chip","Divider","Stack","Switch","Typography","useCallback","useEffect","useRef","useState","STOREFRONT_PAYMENT_METHODS","PAYMENTS_SETTINGS_ANCHOR","capabilityVerdict","row","accountConnected","on","label","color","capability","domainVerdict","domain","enabled","status","applePay","lastError","visibleMethods","rows","map","spec","find","method","id","filter","entry","Boolean","platform","kind","PaymentMethodsCard","props","hostId","data","user","enqueueSnackbar","view","setView","state","setState","draft","setDraft","saving","setSaving","nonce","setNonce","userRef","current","uid","cancelled","response","encodeURIComponent","ok","payload","json","dirty","Object","keys","length","handleSave","headers","body","JSON","stringify","methods","catch","error","variant","allowDuplicate","persist","handleFinish","action","url","window","location","assign","canEdit","canFinish","header","help","anchor","HeaderProps","size","disabled","onClick","contentGutterX","contentGutterY","spacing","data-testid","severity","n","href","actionLabel","warnings","warning","verdict","direction","sx","alignItems","checked","onChange","event","next","target","copy","slotProps","input","flex","requirements","limits","domains","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,MAA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AG;AAEjC,eAAejF,mBAAkB"}
|
|
@@ -24,6 +24,11 @@ export interface PosCartPanelProps {
|
|
|
24
24
|
customer?: ReactNode;
|
|
25
25
|
/** Lines can no longer change: a sale is open against them. */
|
|
26
26
|
locked: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Why this member may not give a discount (AGL-4047): the "Give discounts
|
|
29
|
+
* at the register" key refused. The field stays, disabled with the reason.
|
|
30
|
+
*/
|
|
31
|
+
discountBlocked?: string;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* The basket (AGL-3607): lines with large quantity steppers, the stock
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ 'use client';
|
|
17
17
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
|
|
18
19
|
import { Box, Button, ButtonBase, IconButton, Stack, TextField, Typography } from "@mui/material";
|
|
19
20
|
import { POS_TOUCH_PX } from "./pos-product-grid.component.js";
|
|
20
21
|
import { usd } from "./pos-api.js";
|
|
@@ -23,6 +24,7 @@ import { usd } from "./pos-api.js";
|
|
|
23
24
|
* warning under any line the shelf cannot cover (AGL-2357, said and never
|
|
24
25
|
* enforced), the cashier's discount and the customer the sale is for.
|
|
25
26
|
*/ export function PosCartPanel(props) {
|
|
27
|
+
var _props_discountBlocked;
|
|
26
28
|
const { lines, locked } = props;
|
|
27
29
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
28
30
|
spacing: 1,
|
|
@@ -136,19 +138,23 @@ import { usd } from "./pos-api.js";
|
|
|
136
138
|
/*#__PURE__*/ _jsx(Stack, {
|
|
137
139
|
direction: "row",
|
|
138
140
|
spacing: 1,
|
|
139
|
-
children: /*#__PURE__*/ _jsx(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
141
|
+
children: /*#__PURE__*/ _jsx(BlockedControl, {
|
|
142
|
+
blocked: Boolean(props.discountBlocked),
|
|
143
|
+
reason: (_props_discountBlocked = props.discountBlocked) != null ? _props_discountBlocked : '',
|
|
144
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
145
|
+
label: "Discount %",
|
|
146
|
+
value: props.discountPct || '',
|
|
147
|
+
onChange: (event)=>props.onDiscountPct(Math.min(100, Math.max(0, Number(event.target.value) || 0))),
|
|
148
|
+
disabled: locked,
|
|
149
|
+
sx: {
|
|
150
|
+
width: 120
|
|
151
|
+
},
|
|
152
|
+
slotProps: {
|
|
153
|
+
htmlInput: {
|
|
154
|
+
inputMode: 'numeric'
|
|
155
|
+
}
|
|
150
156
|
}
|
|
151
|
-
}
|
|
157
|
+
})
|
|
152
158
|
})
|
|
153
159
|
}),
|
|
154
160
|
props.customer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-cart-panel.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 type { ReactNode } from 'react'\nimport { Box, Button, ButtonBase, IconButton, Stack, TextField, Typography } from '@mui/material'\nimport type { ModifierSelection, StockShortfall } from '../../../model'\nimport { POS_TOUCH_PX } from './pos-product-grid.component'\nimport { usd } from './pos-api'\n\nexport interface RegisterLine {\n productId: string\n variantId?: string\n name: string\n variantLabel?: string\n /** Per unit, modifiers included: the register's estimate until the server prices it. */\n unitAmountCents: number\n quantity: number\n /** The modifier options picked (AGL-3607); the server prices them. */\n modifiers?: ModifierSelection[]\n}\n\nexport interface PosCartPanelProps {\n lines: RegisterLine[]\n shortfalls: Array<Pick<StockShortfall, 'available'> | null>\n onQuantity: (index: number, quantity: number) => void\n onRemove: (index: number) => void\n /** Opens the line in the item sheet to change its options or quantity. */\n onEdit?: (index: number) => void\n discountPct: number\n onDiscountPct: (value: number) => void\n /** The register's customer lookup (AGL-3609), under the discount. */\n customer?: ReactNode\n /** Lines can no longer change: a sale is open against them. */\n locked: boolean\n}\n\n/**\n * The basket (AGL-3607): lines with large quantity steppers, the stock\n * warning under any line the shelf cannot cover (AGL-2357, said and never\n * enforced), the cashier's discount and the customer the sale is for.\n */\nexport function PosCartPanel(props: PosCartPanelProps) {\n const { lines, locked } = props\n return (\n <Stack spacing={1} sx={{ minHeight: 0 }}>\n <Box sx={{ overflowY: 'auto', flex: 1 }}>\n {lines.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Tap products to add them.'}\n </Typography>\n ) : (\n lines.map((line, index) => (\n <Box key={`${line.productId}:${line.variantId ?? ''}:${index}`} sx={{ py: 0.5 }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <ButtonBase\n disabled={locked || !props.onEdit}\n onClick={() => props.onEdit?.(index)}\n aria-label={locked ? undefined : `Change ${line.name}`}\n sx={{\n flex: 1,\n minWidth: 0,\n minHeight: POS_TOUCH_PX,\n justifyContent: 'flex-start',\n textAlign: 'left',\n borderRadius: 1,\n }}\n >\n <Box sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {`${line.quantity}× ${line.name}`}\n </Typography>\n {line.variantLabel ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" noWrap>\n {line.variantLabel}\n </Typography>\n ) : null}\n </Box>\n </ButtonBase>\n {!locked ? (\n <>\n <IconButton\n aria-label={`One fewer ${line.name}`}\n onClick={() => props.onQuantity(index, line.quantity - 1)}\n sx={{ width: POS_TOUCH_PX, height: POS_TOUCH_PX }}\n >\n {'−'}\n </IconButton>\n <IconButton\n aria-label={`One more ${line.name}`}\n onClick={() => props.onQuantity(index, line.quantity + 1)}\n sx={{ width: POS_TOUCH_PX, height: POS_TOUCH_PX }}\n >\n {'+'}\n </IconButton>\n </>\n ) : null}\n <Typography variant=\"body2\">{usd(line.unitAmountCents * line.quantity)}</Typography>\n {!locked ? (\n <Button\n color=\"error\"\n onClick={() => props.onRemove(index)}\n aria-label={`Remove ${line.name}`}\n sx={{ minWidth: POS_TOUCH_PX, minHeight: POS_TOUCH_PX }}\n >\n {'✕'}\n </Button>\n ) : null}\n </Stack>\n {props.shortfalls[index] ? (\n <Typography variant=\"caption\" color=\"warning.main\">\n {`Only ${props.shortfalls[index]?.available} in stock — selling ${line.quantity}`}\n </Typography>\n ) : null}\n </Box>\n ))\n )}\n </Box>\n <Stack direction=\"row\" spacing={1}>\n <TextField\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-cart-panel.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 { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport type { ReactNode } from 'react'\nimport { Box, Button, ButtonBase, IconButton, Stack, TextField, Typography } from '@mui/material'\nimport type { ModifierSelection, StockShortfall } from '../../../model'\nimport { POS_TOUCH_PX } from './pos-product-grid.component'\nimport { usd } from './pos-api'\n\nexport interface RegisterLine {\n productId: string\n variantId?: string\n name: string\n variantLabel?: string\n /** Per unit, modifiers included: the register's estimate until the server prices it. */\n unitAmountCents: number\n quantity: number\n /** The modifier options picked (AGL-3607); the server prices them. */\n modifiers?: ModifierSelection[]\n}\n\nexport interface PosCartPanelProps {\n lines: RegisterLine[]\n shortfalls: Array<Pick<StockShortfall, 'available'> | null>\n onQuantity: (index: number, quantity: number) => void\n onRemove: (index: number) => void\n /** Opens the line in the item sheet to change its options or quantity. */\n onEdit?: (index: number) => void\n discountPct: number\n onDiscountPct: (value: number) => void\n /** The register's customer lookup (AGL-3609), under the discount. */\n customer?: ReactNode\n /** Lines can no longer change: a sale is open against them. */\n locked: boolean\n /**\n * Why this member may not give a discount (AGL-4047): the \"Give discounts\n * at the register\" key refused. The field stays, disabled with the reason.\n */\n discountBlocked?: string\n}\n\n/**\n * The basket (AGL-3607): lines with large quantity steppers, the stock\n * warning under any line the shelf cannot cover (AGL-2357, said and never\n * enforced), the cashier's discount and the customer the sale is for.\n */\nexport function PosCartPanel(props: PosCartPanelProps) {\n const { lines, locked } = props\n return (\n <Stack spacing={1} sx={{ minHeight: 0 }}>\n <Box sx={{ overflowY: 'auto', flex: 1 }}>\n {lines.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Tap products to add them.'}\n </Typography>\n ) : (\n lines.map((line, index) => (\n <Box key={`${line.productId}:${line.variantId ?? ''}:${index}`} sx={{ py: 0.5 }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <ButtonBase\n disabled={locked || !props.onEdit}\n onClick={() => props.onEdit?.(index)}\n aria-label={locked ? undefined : `Change ${line.name}`}\n sx={{\n flex: 1,\n minWidth: 0,\n minHeight: POS_TOUCH_PX,\n justifyContent: 'flex-start',\n textAlign: 'left',\n borderRadius: 1,\n }}\n >\n <Box sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {`${line.quantity}× ${line.name}`}\n </Typography>\n {line.variantLabel ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" noWrap>\n {line.variantLabel}\n </Typography>\n ) : null}\n </Box>\n </ButtonBase>\n {!locked ? (\n <>\n <IconButton\n aria-label={`One fewer ${line.name}`}\n onClick={() => props.onQuantity(index, line.quantity - 1)}\n sx={{ width: POS_TOUCH_PX, height: POS_TOUCH_PX }}\n >\n {'−'}\n </IconButton>\n <IconButton\n aria-label={`One more ${line.name}`}\n onClick={() => props.onQuantity(index, line.quantity + 1)}\n sx={{ width: POS_TOUCH_PX, height: POS_TOUCH_PX }}\n >\n {'+'}\n </IconButton>\n </>\n ) : null}\n <Typography variant=\"body2\">{usd(line.unitAmountCents * line.quantity)}</Typography>\n {!locked ? (\n <Button\n color=\"error\"\n onClick={() => props.onRemove(index)}\n aria-label={`Remove ${line.name}`}\n sx={{ minWidth: POS_TOUCH_PX, minHeight: POS_TOUCH_PX }}\n >\n {'✕'}\n </Button>\n ) : null}\n </Stack>\n {props.shortfalls[index] ? (\n <Typography variant=\"caption\" color=\"warning.main\">\n {`Only ${props.shortfalls[index]?.available} in stock — selling ${line.quantity}`}\n </Typography>\n ) : null}\n </Box>\n ))\n )}\n </Box>\n <Stack direction=\"row\" spacing={1}>\n <BlockedControl blocked={Boolean(props.discountBlocked)} reason={props.discountBlocked ?? ''}>\n <TextField\n label=\"Discount %\"\n value={props.discountPct || ''}\n onChange={(event) =>\n props.onDiscountPct(Math.min(100, Math.max(0, Number(event.target.value) || 0)))\n }\n disabled={locked}\n sx={{ width: 120 }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n </BlockedControl>\n </Stack>\n {props.customer}\n </Stack>\n )\n}\nPosCartPanel.displayName = 'PosCartPanel'\n"],"names":["BlockedControl","Box","Button","ButtonBase","IconButton","Stack","TextField","Typography","POS_TOUCH_PX","usd","PosCartPanel","props","lines","locked","spacing","sx","minHeight","overflowY","flex","length","variant","color","map","line","index","py","direction","alignItems","disabled","onEdit","onClick","aria-label","undefined","name","minWidth","justifyContent","textAlign","borderRadius","noWrap","quantity","variantLabel","component","onQuantity","width","height","unitAmountCents","onRemove","shortfalls","available","productId","variantId","blocked","Boolean","discountBlocked","reason","label","value","discountPct","onChange","event","onDiscountPct","Math","min","max","Number","target","slotProps","htmlInput","inputMode","customer","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,cAAc,QAAQ,4DAA2D;AAE1F,SAASC,GAAG,EAAEC,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAe;AAEjG,SAASC,YAAY,QAAQ,kCAA8B;AAC3D,SAASC,GAAG,QAAQ,eAAW;AAkC/B;;;;CAIC,GACD,OAAO,SAASC,aAAaC,KAAwB;QA6EoBA;IA5EvE,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAGF;IAC1B,qBACE,MAACN;QAAMS,SAAS;QAAGC,IAAI;YAAEC,WAAW;QAAE;;0BACpC,KAACf;gBAAIc,IAAI;oBAAEE,WAAW;oBAAQC,MAAM;gBAAE;0BACnCN,MAAMO,MAAM,KAAK,kBAChB,KAACZ;oBAAWa,SAAQ;oBAAQC,OAAM;8BAC/B;qBAGHT,MAAMU,GAAG,CAAC,CAACC,MAAMC;wBACgBD;wBA0DhBZ;yCA1Df,MAACV;wBAA+Dc,IAAI;4BAAEU,IAAI;wBAAI;;0CAC5E,MAACpB;gCAAMqB,WAAU;gCAAMZ,SAAS;gCAAGC,IAAI;oCAAEY,YAAY;gCAAS;;kDAC5D,KAACxB;wCACCyB,UAAUf,UAAU,CAACF,MAAMkB,MAAM;wCACjCC,SAAS,IAAMnB,MAAMkB,MAAM,oBAAZlB,MAAMkB,MAAM,MAAZlB,OAAea;wCAC9BO,cAAYlB,SAASmB,YAAY,CAAC,OAAO,EAAET,KAAKU,IAAI,EAAE;wCACtDlB,IAAI;4CACFG,MAAM;4CACNgB,UAAU;4CACVlB,WAAWR;4CACX2B,gBAAgB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AvBb,wBAAyBqC,SAAS,CAAC,oBAAoB,EAAEzB,KAAKgB,QAAQ,EAAE;iCAEjF;;uBA5DI,GAAGhB,KAAK0B,SAAS,CAAC,CAAC,GAAE1B,kBAAAA,KAAK2B,SAAS,YAAd3B,kBAAkB,GAAG,CAAC,EAAEC,OAAO;;;0BAiEpE,KAACnB;gBAAMqB,WAAU;gBAAMZ,SAAS;0BAC9B,cAAA,KAACd;oBAAemD,SAASC,QAAQzC,MAAM0C,eAAe;oBAAGC,MAAM,GAAE3C,yBAAAA,MAAM0C,eAAe,YAArB1C,yBAAyB;8BACxF,cAAA,KAACL;wBACCiD,OAAM;wBACNC,OAAO7C,MAAM8C,WAAW,IAAI;wBAC5BC,UAAU,CAACC,QACThD,MAAMiD,aAAa,CAACC,KAAKC,GAAG,CAAC,KAAKD,KAAKE,GAAG,CAAC,GAAGC,OAAOL,MAAMM,MAAM,CAACT,KAAK,KAAK;wBAE9E5B,UAAUf;wBACVE,IAAI;4BAAE4B,OAAO;wBAAI;wBACjBuB,WAAW;4BAAEC,WAAW;gCAAEC,WAAW;4BAAU;wBAAE;;;;YAItDzD,MAAM0D,QAAQ;;;AAGrB;AACA3D,aAAa4D,WAAW,GAAG"}
|
|
@@ -15,12 +15,22 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { authorizedFetch } from '@aglyn/shared-util-http/authorized-token';
|
|
18
|
-
import type { PosHardwareLine, PosHardwareOffer, PosHardwareOrderStatus, PosHardwareShippingMethod, PosHardwareTracking } from '../../../model/pos-hardware';
|
|
18
|
+
import type { PosHardwareAttachment, PosHardwareLine, PosHardwareOffer, PosHardwareOrderShippingMethod, PosHardwareOrderSource, PosHardwareOrderStatus, PosHardwarePaidTo, PosHardwareRefund, PosHardwareRegisterSale, PosHardwareReturnRequest, PosHardwareShippingMethod, PosHardwareTracking, PosHardwareUnit } from '../../../model/pos-hardware';
|
|
19
19
|
type User = Parameters<typeof authorizedFetch>[0];
|
|
20
20
|
export declare class PosHardwareRequestError extends Error {
|
|
21
21
|
readonly status: number;
|
|
22
|
-
|
|
22
|
+
/** The route's `reason`, when it names a step the caller takes next. */
|
|
23
|
+
readonly reason?: string;
|
|
24
|
+
constructor(message: string, status: number,
|
|
25
|
+
/** The route's `reason`, when it names a step the caller takes next. */
|
|
26
|
+
reason?: string);
|
|
23
27
|
}
|
|
28
|
+
/** One request to a hardware route, refused with the route's own words. */
|
|
29
|
+
export declare function sendPosHardwareRequest<T>(user: User, url: string, init: {
|
|
30
|
+
method: 'GET' | 'POST';
|
|
31
|
+
body?: unknown;
|
|
32
|
+
attemptKey?: string;
|
|
33
|
+
}): Promise<T>;
|
|
24
34
|
export type PosHardwareCatalog = {
|
|
25
35
|
available: false;
|
|
26
36
|
} | {
|
|
@@ -48,6 +58,16 @@ export interface PosHardwareOrderRow {
|
|
|
48
58
|
tracking: PosHardwareTracking | null;
|
|
49
59
|
createdAtMs: number;
|
|
50
60
|
updatedAtMs: number;
|
|
61
|
+
/** Bought in person at the platform's own store (AGL-4038), and its readers still to set up. */
|
|
62
|
+
source?: PosHardwareOrderSource;
|
|
63
|
+
discountCents?: number;
|
|
64
|
+
readersToSetUp?: number;
|
|
65
|
+
refundedCents?: number;
|
|
66
|
+
returnRequest?: {
|
|
67
|
+
state: PosHardwareReturnRequest['state'];
|
|
68
|
+
requestedAtMs: number;
|
|
69
|
+
note: string | null;
|
|
70
|
+
} | null;
|
|
51
71
|
}
|
|
52
72
|
/** Leaves the console for Stripe Checkout, which returns to the card. */
|
|
53
73
|
export declare function openPosHardwareCheckout(url: string): void;
|
|
@@ -66,13 +86,40 @@ export declare function posHardwareCheckout(user: User, attemptKey: string, body
|
|
|
66
86
|
url: string;
|
|
67
87
|
orderId: string;
|
|
68
88
|
}>;
|
|
89
|
+
/** A reader the workspace bought in person, waiting to be set up (AGL-4038). */
|
|
90
|
+
export interface WaitingReaderOrder extends PosHardwareOrderRow {
|
|
91
|
+
/** The store it is for; empty while the buyer has still to choose. */
|
|
92
|
+
hostId: string;
|
|
93
|
+
/** Readers whose serial was taken at the sale: they set themselves up. */
|
|
94
|
+
serialsTaken: number;
|
|
95
|
+
}
|
|
96
|
+
export interface WaitingReaders {
|
|
97
|
+
posPlan: boolean;
|
|
98
|
+
stores: Array<{
|
|
99
|
+
hostId: string;
|
|
100
|
+
name: string;
|
|
101
|
+
hasLocation: boolean;
|
|
102
|
+
setupUrl: string;
|
|
103
|
+
}>;
|
|
104
|
+
orders: WaitingReaderOrder[];
|
|
105
|
+
}
|
|
106
|
+
export declare function posHardwareWaiting(user: User, hostId: string): Promise<WaitingReaders>;
|
|
107
|
+
/** Chooses the store (`hostId`) a reader bought in person is for. */
|
|
108
|
+
export declare function posHardwareChooseStore(user: User, hostId: string, orderId: string): Promise<{
|
|
109
|
+
ok: true;
|
|
110
|
+
order: PosHardwareOrderRow;
|
|
111
|
+
}>;
|
|
112
|
+
export declare function posHardwareMarkSetUp(user: User, hostId: string, orderId: string): Promise<{
|
|
113
|
+
ok: true;
|
|
114
|
+
order: PosHardwareOrderRow;
|
|
115
|
+
}>;
|
|
69
116
|
/** An order as the staff page lists it. */
|
|
70
117
|
export interface StaffHardwareOrderRow extends Omit<PosHardwareOrderRow, 'shippingCents' | 'shippingLabel'> {
|
|
71
118
|
orgId: string;
|
|
72
119
|
hostId: string;
|
|
73
120
|
contactEmail: string | null;
|
|
74
121
|
shipping: {
|
|
75
|
-
method:
|
|
122
|
+
method: PosHardwareOrderShippingMethod;
|
|
76
123
|
label: string;
|
|
77
124
|
cents: number;
|
|
78
125
|
name: string | null;
|
|
@@ -97,15 +144,30 @@ export interface StaffHardwareOrderRow extends Omit<PosHardwareOrderRow, 'shippi
|
|
|
97
144
|
stripeHardwareOrderId: string | null;
|
|
98
145
|
livemode: boolean;
|
|
99
146
|
refundPending: boolean;
|
|
147
|
+
/** Sold in person at the platform's own store (AGL-4038), and what that sale says. */
|
|
148
|
+
source: PosHardwareOrderSource;
|
|
149
|
+
discountCents: number;
|
|
150
|
+
posSale: PosHardwareRegisterSale | null;
|
|
151
|
+
paidTo: PosHardwarePaidTo | null;
|
|
152
|
+
attachment: PosHardwareAttachment | null;
|
|
153
|
+
units: PosHardwareUnit[];
|
|
154
|
+
refundedCents: number;
|
|
155
|
+
refunds: PosHardwareRefund[];
|
|
156
|
+
returnRequest: PosHardwareReturnRequest | null;
|
|
100
157
|
}
|
|
101
|
-
|
|
158
|
+
/** The staff list's filter: one status, every order, or the in-person sales still to attach. */
|
|
159
|
+
export type StaffHardwareFilter = PosHardwareOrderStatus | '' | 'to-attach' | 'returns';
|
|
160
|
+
export declare function staffHardwareOrders(user: User, filter: StaffHardwareFilter, after?: string | null): Promise<{
|
|
102
161
|
orders: StaffHardwareOrderRow[];
|
|
103
162
|
next: string | null;
|
|
104
163
|
pageSize: number;
|
|
105
164
|
canWrite: boolean;
|
|
106
165
|
}>;
|
|
107
166
|
export declare function staffHardwareOrderAction(user: User, body: {
|
|
108
|
-
action: 'update' | 'cancel' | 'refund';
|
|
167
|
+
action: 'update' | 'cancel' | 'refund' | 'refund-return' | 'forget-buyer' | 'decline-return';
|
|
168
|
+
/** An online return's restocking fee, in cents (AGL-4038). */
|
|
169
|
+
restockingFeeCents?: number;
|
|
170
|
+
note?: string;
|
|
109
171
|
orgId: string;
|
|
110
172
|
orderId: string;
|
|
111
173
|
stripeHardwareOrderId?: string | null;
|
|
@@ -115,8 +177,17 @@ export declare function staffHardwareOrderAction(user: User, body: {
|
|
|
115
177
|
url?: string;
|
|
116
178
|
} | null;
|
|
117
179
|
status?: PosHardwareOrderStatus;
|
|
180
|
+
/** A cancel or a refund: email the buyer about it (AGL-4038). */
|
|
181
|
+
notifyBuyer?: boolean;
|
|
118
182
|
}): Promise<{
|
|
119
183
|
ok: true;
|
|
120
184
|
order: StaffHardwareOrderRow;
|
|
185
|
+
/** A cancel or a refund: what became of the buyer's email, `off` when staff chose none. */
|
|
186
|
+
buyerEmail?: "sent" | "already" | "skipped" | "failed" | "off";
|
|
187
|
+
}>;
|
|
188
|
+
/** Asks to return a card reader bought in person, with the reason (AGL-4038). */
|
|
189
|
+
export declare function posHardwareRequestReturn(user: User, hostId: string, orderId: string, reason: string): Promise<{
|
|
190
|
+
ok: true;
|
|
191
|
+
order: PosHardwareOrderRow;
|
|
121
192
|
}>;
|
|
122
193
|
export {};
|
|
@@ -16,11 +16,11 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/ import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
18
18
|
export class PosHardwareRequestError extends Error {
|
|
19
|
-
constructor(message, status){
|
|
20
|
-
super(message), this.status = status;
|
|
19
|
+
constructor(message, status, /** The route's `reason`, when it names a step the caller takes next. */ reason){
|
|
20
|
+
super(message), this.status = status, this.reason = reason;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
async function
|
|
23
|
+
/** One request to a hardware route, refused with the route's own words. */ export async function sendPosHardwareRequest(user, url, init) {
|
|
24
24
|
var _init_body;
|
|
25
25
|
const response = await authorizedFetch(user, url, _extends({
|
|
26
26
|
method: init.method,
|
|
@@ -35,7 +35,7 @@ async function send(user, url, init) {
|
|
|
35
35
|
const payload = await response.json().catch(()=>({}));
|
|
36
36
|
if (!response.ok) {
|
|
37
37
|
var _ref;
|
|
38
|
-
throw new PosHardwareRequestError(String((_ref = payload == null ? void 0 : payload.error) != null ? _ref : 'Something went wrong'), response.status);
|
|
38
|
+
throw new PosHardwareRequestError(String((_ref = payload == null ? void 0 : payload.error) != null ? _ref : 'Something went wrong'), response.status, typeof (payload == null ? void 0 : payload.reason) === 'string' ? payload.reason : undefined);
|
|
39
39
|
}
|
|
40
40
|
return payload;
|
|
41
41
|
}
|
|
@@ -44,7 +44,7 @@ const SHOP = '/api/commerce/pos-hardware';
|
|
|
44
44
|
window.location.assign(url);
|
|
45
45
|
}
|
|
46
46
|
export function posHardwareCatalog(user, hostId) {
|
|
47
|
-
return
|
|
47
|
+
return sendPosHardwareRequest(user, SHOP, {
|
|
48
48
|
method: 'POST',
|
|
49
49
|
body: {
|
|
50
50
|
action: 'catalog',
|
|
@@ -53,7 +53,7 @@ export function posHardwareCatalog(user, hostId) {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
export function posHardwareOrders(user, hostId) {
|
|
56
|
-
return
|
|
56
|
+
return sendPosHardwareRequest(user, SHOP, {
|
|
57
57
|
method: 'POST',
|
|
58
58
|
body: {
|
|
59
59
|
action: 'orders',
|
|
@@ -62,7 +62,7 @@ export function posHardwareOrders(user, hostId) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
export function posHardwareCheckout(user, attemptKey, body) {
|
|
65
|
-
return
|
|
65
|
+
return sendPosHardwareRequest(user, SHOP, {
|
|
66
66
|
method: 'POST',
|
|
67
67
|
body: _extends({}, body, {
|
|
68
68
|
action: 'checkout'
|
|
@@ -70,21 +70,63 @@ export function posHardwareCheckout(user, attemptKey, body) {
|
|
|
70
70
|
attemptKey
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
+
export function posHardwareWaiting(user, hostId) {
|
|
74
|
+
return sendPosHardwareRequest(user, SHOP, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
body: {
|
|
77
|
+
action: 'waiting',
|
|
78
|
+
hostId
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** Chooses the store (`hostId`) a reader bought in person is for. */ export function posHardwareChooseStore(user, hostId, orderId) {
|
|
83
|
+
return sendPosHardwareRequest(user, SHOP, {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
body: {
|
|
86
|
+
action: 'choose-store',
|
|
87
|
+
hostId,
|
|
88
|
+
orderId
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export function posHardwareMarkSetUp(user, hostId, orderId) {
|
|
93
|
+
return sendPosHardwareRequest(user, SHOP, {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
body: {
|
|
96
|
+
action: 'mark-set-up',
|
|
97
|
+
hostId,
|
|
98
|
+
orderId
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
73
102
|
const STAFF = '/api/commerce/admin/hardware-orders';
|
|
74
|
-
export function staffHardwareOrders(user,
|
|
103
|
+
export function staffHardwareOrders(user, filter, after = null) {
|
|
75
104
|
const params = new URLSearchParams();
|
|
76
|
-
if (
|
|
105
|
+
if (filter === 'to-attach') params.set('attach', 'pending');
|
|
106
|
+
else if (filter === 'returns') params.set('returns', 'requested');
|
|
107
|
+
else if (filter) params.set('status', filter);
|
|
77
108
|
if (after) params.set('after', after);
|
|
78
109
|
const search = params.toString();
|
|
79
|
-
return
|
|
110
|
+
return sendPosHardwareRequest(user, search ? `${STAFF}?${search}` : STAFF, {
|
|
80
111
|
method: 'GET'
|
|
81
112
|
});
|
|
82
113
|
}
|
|
83
114
|
export function staffHardwareOrderAction(user, body) {
|
|
84
|
-
return
|
|
115
|
+
return sendPosHardwareRequest(user, STAFF, {
|
|
85
116
|
method: 'POST',
|
|
86
117
|
body
|
|
87
118
|
});
|
|
88
119
|
}
|
|
120
|
+
/** Asks to return a card reader bought in person, with the reason (AGL-4038). */ export function posHardwareRequestReturn(user, hostId, orderId, reason) {
|
|
121
|
+
return sendPosHardwareRequest(user, SHOP, {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
body: {
|
|
124
|
+
action: 'request-return',
|
|
125
|
+
hostId,
|
|
126
|
+
orderId,
|
|
127
|
+
reason
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
89
131
|
|
|
90
132
|
//# sourceMappingURL=pos-hardware-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-hardware-api.ts"],"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\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport type {\n PosHardwareLine,\n PosHardwareOffer,\n PosHardwareOrderStatus,\n PosHardwareShippingMethod,\n PosHardwareTracking,\n} from '../../../model/pos-hardware'\n\n/*\n * The POS hardware shop's client half (AGL-4038): the Hardware card's calls\n * and the staff page's, so neither component builds a request by hand.\n */\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\nexport class PosHardwareRequestError extends Error {\n constructor(\n message: string,\n readonly status: number,\n ) {\n super(message)\n }\n}\n\nasync function send<T>(\n user: User,\n url: string,\n init: { method: 'GET' | 'POST'; body?: unknown; attemptKey?: string },\n): Promise<T> {\n const response = await authorizedFetch(user, url, {\n method: init.method,\n headers: {\n ...(init.method === 'POST' ? { 'Content-Type': 'application/json' } : {}),\n ...(init.attemptKey ? { 'Idempotency-Key': init.attemptKey } : {}),\n },\n ...(init.method === 'POST' ? { body: JSON.stringify(init.body ?? {}) } : {}),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n throw new PosHardwareRequestError(String(payload?.error ?? 'Something went wrong'), response.status)\n }\n return payload as T\n}\n\nexport type PosHardwareCatalog =\n | { available: false }\n | {\n available: true\n offers: PosHardwareOffer[]\n shipping: Array<{ method: PosHardwareShippingMethod; label: string; cents: number }>\n automaticTax: boolean\n shipCountries: string[]\n }\n\n/** An order as the Hardware card lists it. */\nexport interface PosHardwareOrderRow {\n id: string\n number: string\n status: PosHardwareOrderStatus\n lines: PosHardwareLine[]\n subtotalCents: number\n shippingCents: number\n shippingLabel: string\n taxCents: number\n totalCents: number\n tracking: PosHardwareTracking | null\n createdAtMs: number\n updatedAtMs: number\n}\n\nconst SHOP = '/api/commerce/pos-hardware'\n\n/** Leaves the console for Stripe Checkout, which returns to the card. */\nexport function openPosHardwareCheckout(url: string): void {\n window.location.assign(url)\n}\n\nexport function posHardwareCatalog(user: User, hostId: string) {\n return send<PosHardwareCatalog>(user, SHOP, { method: 'POST', body: { action: 'catalog', hostId } })\n}\n\nexport function posHardwareOrders(user: User, hostId: string) {\n return send<{ orders: PosHardwareOrderRow[] }>(user, SHOP, {\n method: 'POST',\n body: { action: 'orders', hostId },\n })\n}\n\nexport function posHardwareCheckout(\n user: User,\n attemptKey: string,\n body: {\n hostId: string\n lines: Array<{ sku: string; quantity: number }>\n shippingMethod: PosHardwareShippingMethod\n },\n) {\n return send<{ url: string; orderId: string }>(user, SHOP, {\n method: 'POST',\n body: { ...body, action: 'checkout' },\n attemptKey,\n })\n}\n\n/** An order as the staff page lists it. */\nexport interface StaffHardwareOrderRow extends Omit<PosHardwareOrderRow, 'shippingCents' | 'shippingLabel'> {\n orgId: string\n hostId: string\n contactEmail: string | null\n shipping: {\n method: PosHardwareShippingMethod\n label: string\n cents: number\n name: string | null\n phone: string | null\n address: {\n line1: string\n line2?: string\n city: string\n state?: string\n postalCode: string\n country: string\n } | null\n /** What an account erasure left of the address: where tax is sourced. */\n taxRegion?: { country: string; state: string | null; postalCode: string | null } | null\n } | null\n stripeCheckoutSessionId: string | null\n stripePaymentIntentId: string | null\n stripeHardwareOrderId: string | null\n livemode: boolean\n refundPending: boolean\n}\n\nconst STAFF = '/api/commerce/admin/hardware-orders'\n\nexport function staffHardwareOrders(user: User, status: PosHardwareOrderStatus | '', after: string | null = null) {\n const params = new URLSearchParams()\n if (status) params.set('status', status)\n if (after) params.set('after', after)\n const search = params.toString()\n return send<{ orders: StaffHardwareOrderRow[]; next: string | null; pageSize: number; canWrite: boolean }>(\n user,\n search ? `${STAFF}?${search}` : STAFF,\n { method: 'GET' },\n )\n}\n\nexport function staffHardwareOrderAction(\n user: User,\n body: {\n action: 'update' | 'cancel' | 'refund'\n orgId: string\n orderId: string\n stripeHardwareOrderId?: string | null\n tracking?: { carrier: string; number: string; url?: string } | null\n status?: PosHardwareOrderStatus\n },\n) {\n return send<{ ok: true; order: StaffHardwareOrderRow }>(user, STAFF, { method: 'POST', body })\n}\n"],"names":["authorizedFetch","PosHardwareRequestError","Error","message","status","send","user","url","init","response","method","headers","attemptKey","body","JSON","stringify","payload","json","catch","ok","String","error","SHOP","openPosHardwareCheckout","window","location","assign","posHardwareCatalog","hostId","action","posHardwareOrders","posHardwareCheckout","STAFF","staffHardwareOrders","after","params","URLSearchParams","set","search","toString","staffHardwareOrderAction"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAAQ,2CAA0C;AAgB1E,OAAO,MAAMC,gCAAgCC;IAC3C,YACEC,OAAe,EACf,AAASC,MAAc,CACvB;QACA,KAAK,CAACD,eAFGC,SAAAA;IAGX;AACF;AAEA,eAAeC,KACbC,IAAU,EACVC,GAAW,EACXC,IAAqE;QAQfA;IANtD,MAAMC,WAAW,MAAMT,gBAAgBM,MAAMC,KAAK;QAChDG,QAAQF,KAAKE,MAAM;QACnBC,SAAS,aACHH,KAAKE,MAAM,KAAK,SAAS;YAAE,gBAAgB;QAAmB,IAAI,CAAC,GACnEF,KAAKI,UAAU,GAAG;YAAE,mBAAmBJ,KAAKI,UAAU;QAAC,IAAI,CAAC;OAE9DJ,KAAKE,MAAM,KAAK,SAAS;QAAEG,MAAMC,KAAKC,SAAS,EAACP,aAAAA,KAAKK,IAAI,YAATL,aAAa,CAAC;IAAG,IAAI,CAAC;IAE5E,MAAMQ,UAAU,MAAMP,SAASQ,IAAI,GAAGC,KAAK,CAAC,IAAO,CAAA,CAAC,CAAA;IACpD,IAAI,CAACT,SAASU,EAAE,EAAE;;QAChB,MAAM,IAAIlB,wBAAwBmB,eAAOJ,2BAAAA,QAASK,KAAK,mBAAI,yBAAyBZ,SAASL,MAAM;IACrG;IACA,OAAOY;AACT;AA4BA,MAAMM,OAAO;AAEb,uEAAuE,GACvE,OAAO,SAASC,wBAAwBhB,GAAW;IACjDiB,OAAOC,QAAQ,CAACC,MAAM,CAACnB;AACzB;AAEA,OAAO,SAASoB,mBAAmBrB,IAAU,EAAEsB,MAAc;IAC3D,OAAOvB,KAAyBC,MAAMgB,MAAM;QAAEZ,QAAQ;QAAQG,MAAM;YAAEgB,QAAQ;YAAWD;QAAO;IAAE;AACpG;AAEA,OAAO,SAASE,kBAAkBxB,IAAU,EAAEsB,MAAc;IAC1D,OAAOvB,KAAwCC,MAAMgB,MAAM;QACzDZ,QAAQ;QACRG,MAAM;YAAEgB,QAAQ;YAAUD;QAAO;IACnC;AACF;AAEA,OAAO,SAASG,oBACdzB,IAAU,EACVM,UAAkB,EAClBC,IAIC;IAED,OAAOR,KAAuCC,MAAMgB,MAAM;QACxDZ,QAAQ;QACRG,MAAM,aAAKA;YAAMgB,QAAQ;;QACzBjB;IACF;AACF;AA+BA,MAAMoB,QAAQ;AAEd,OAAO,SAASC,oBAAoB3B,IAAU,EAAEF,MAAmC,EAAE8B,QAAuB,IAAI;IAC9G,MAAMC,SAAS,IAAIC;IACnB,IAAIhC,QAAQ+B,OAAOE,GAAG,CAAC,UAAUjC;IACjC,IAAI8B,OAAOC,OAAOE,GAAG,CAAC,SAASH;IAC/B,MAAMI,SAASH,OAAOI,QAAQ;IAC9B,OAAOlC,KACLC,MACAgC,SAAS,GAAGN,MAAM,CAAC,EAAEM,QAAQ,GAAGN,OAChC;QAAEtB,QAAQ;IAAM;AAEpB;AAEA,OAAO,SAAS8B,yBACdlC,IAAU,EACVO,IAOC;IAED,OAAOR,KAAiDC,MAAM0B,OAAO;QAAEtB,QAAQ;QAAQG;IAAK;AAC9F"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-hardware-api.ts"],"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\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport type {\n PosHardwareAttachment,\n PosHardwareLine,\n PosHardwareOffer,\n PosHardwareOrderShippingMethod,\n PosHardwareOrderSource,\n PosHardwareOrderStatus,\n PosHardwarePaidTo,\n PosHardwareRefund,\n PosHardwareRegisterSale,\n PosHardwareReturnRequest,\n PosHardwareShippingMethod,\n PosHardwareTracking,\n PosHardwareUnit,\n} from '../../../model/pos-hardware'\n\n/*\n * The POS hardware shop's client half (AGL-4038): the Hardware card's calls\n * and the staff page's, so neither component builds a request by hand.\n */\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\nexport class PosHardwareRequestError extends Error {\n constructor(\n message: string,\n readonly status: number,\n /** The route's `reason`, when it names a step the caller takes next. */\n readonly reason?: string,\n ) {\n super(message)\n }\n}\n\n/** One request to a hardware route, refused with the route's own words. */\nexport async function sendPosHardwareRequest<T>(\n user: User,\n url: string,\n init: { method: 'GET' | 'POST'; body?: unknown; attemptKey?: string },\n): Promise<T> {\n const response = await authorizedFetch(user, url, {\n method: init.method,\n headers: {\n ...(init.method === 'POST' ? { 'Content-Type': 'application/json' } : {}),\n ...(init.attemptKey ? { 'Idempotency-Key': init.attemptKey } : {}),\n },\n ...(init.method === 'POST' ? { body: JSON.stringify(init.body ?? {}) } : {}),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n throw new PosHardwareRequestError(\n String(payload?.error ?? 'Something went wrong'),\n response.status,\n typeof payload?.reason === 'string' ? payload.reason : undefined,\n )\n }\n return payload as T\n}\n\nexport type PosHardwareCatalog =\n | { available: false }\n | {\n available: true\n offers: PosHardwareOffer[]\n shipping: Array<{ method: PosHardwareShippingMethod; label: string; cents: number }>\n automaticTax: boolean\n shipCountries: string[]\n }\n\n/** An order as the Hardware card lists it. */\nexport interface PosHardwareOrderRow {\n id: string\n number: string\n status: PosHardwareOrderStatus\n lines: PosHardwareLine[]\n subtotalCents: number\n shippingCents: number\n shippingLabel: string\n taxCents: number\n totalCents: number\n tracking: PosHardwareTracking | null\n createdAtMs: number\n updatedAtMs: number\n /** Bought in person at the platform's own store (AGL-4038), and its readers still to set up. */\n source?: PosHardwareOrderSource\n discountCents?: number\n readersToSetUp?: number\n refundedCents?: number\n returnRequest?: { state: PosHardwareReturnRequest['state']; requestedAtMs: number; note: string | null } | null\n}\n\nconst SHOP = '/api/commerce/pos-hardware'\n\n/** Leaves the console for Stripe Checkout, which returns to the card. */\nexport function openPosHardwareCheckout(url: string): void {\n window.location.assign(url)\n}\n\nexport function posHardwareCatalog(user: User, hostId: string) {\n return sendPosHardwareRequest<PosHardwareCatalog>(user, SHOP, { method: 'POST', body: { action: 'catalog', hostId } })\n}\n\nexport function posHardwareOrders(user: User, hostId: string) {\n return sendPosHardwareRequest<{ orders: PosHardwareOrderRow[] }>(user, SHOP, {\n method: 'POST',\n body: { action: 'orders', hostId },\n })\n}\n\nexport function posHardwareCheckout(\n user: User,\n attemptKey: string,\n body: {\n hostId: string\n lines: Array<{ sku: string; quantity: number }>\n shippingMethod: PosHardwareShippingMethod\n },\n) {\n return sendPosHardwareRequest<{ url: string; orderId: string }>(user, SHOP, {\n method: 'POST',\n body: { ...body, action: 'checkout' },\n attemptKey,\n })\n}\n\n/** A reader the workspace bought in person, waiting to be set up (AGL-4038). */\nexport interface WaitingReaderOrder extends PosHardwareOrderRow {\n /** The store it is for; empty while the buyer has still to choose. */\n hostId: string\n /** Readers whose serial was taken at the sale: they set themselves up. */\n serialsTaken: number\n}\n\nexport interface WaitingReaders {\n posPlan: boolean\n stores: Array<{ hostId: string; name: string; hasLocation: boolean; setupUrl: string }>\n orders: WaitingReaderOrder[]\n}\n\nexport function posHardwareWaiting(user: User, hostId: string) {\n return sendPosHardwareRequest<WaitingReaders>(user, SHOP, { method: 'POST', body: { action: 'waiting', hostId } })\n}\n\n/** Chooses the store (`hostId`) a reader bought in person is for. */\nexport function posHardwareChooseStore(user: User, hostId: string, orderId: string) {\n return sendPosHardwareRequest<{ ok: true; order: PosHardwareOrderRow }>(user, SHOP, {\n method: 'POST',\n body: { action: 'choose-store', hostId, orderId },\n })\n}\n\nexport function posHardwareMarkSetUp(user: User, hostId: string, orderId: string) {\n return sendPosHardwareRequest<{ ok: true; order: PosHardwareOrderRow }>(user, SHOP, {\n method: 'POST',\n body: { action: 'mark-set-up', hostId, orderId },\n })\n}\n\n/** An order as the staff page lists it. */\nexport interface StaffHardwareOrderRow extends Omit<PosHardwareOrderRow, 'shippingCents' | 'shippingLabel'> {\n orgId: string\n hostId: string\n contactEmail: string | null\n shipping: {\n method: PosHardwareOrderShippingMethod\n label: string\n cents: number\n name: string | null\n phone: string | null\n address: {\n line1: string\n line2?: string\n city: string\n state?: string\n postalCode: string\n country: string\n } | null\n /** What an account erasure left of the address: where tax is sourced. */\n taxRegion?: { country: string; state: string | null; postalCode: string | null } | null\n } | null\n stripeCheckoutSessionId: string | null\n stripePaymentIntentId: string | null\n stripeHardwareOrderId: string | null\n livemode: boolean\n refundPending: boolean\n /** Sold in person at the platform's own store (AGL-4038), and what that sale says. */\n source: PosHardwareOrderSource\n discountCents: number\n posSale: PosHardwareRegisterSale | null\n paidTo: PosHardwarePaidTo | null\n attachment: PosHardwareAttachment | null\n units: PosHardwareUnit[]\n refundedCents: number\n refunds: PosHardwareRefund[]\n returnRequest: PosHardwareReturnRequest | null\n}\n\nconst STAFF = '/api/commerce/admin/hardware-orders'\n\n/** The staff list's filter: one status, every order, or the in-person sales still to attach. */\nexport type StaffHardwareFilter = PosHardwareOrderStatus | '' | 'to-attach' | 'returns'\n\nexport function staffHardwareOrders(user: User, filter: StaffHardwareFilter, after: string | null = null) {\n const params = new URLSearchParams()\n if (filter === 'to-attach') params.set('attach', 'pending')\n else if (filter === 'returns') params.set('returns', 'requested')\n else if (filter) params.set('status', filter)\n if (after) params.set('after', after)\n const search = params.toString()\n return sendPosHardwareRequest<{ orders: StaffHardwareOrderRow[]; next: string | null; pageSize: number; canWrite: boolean }>(\n user,\n search ? `${STAFF}?${search}` : STAFF,\n { method: 'GET' },\n )\n}\n\nexport function staffHardwareOrderAction(\n user: User,\n body: {\n action: 'update' | 'cancel' | 'refund' | 'refund-return' | 'forget-buyer' | 'decline-return'\n /** An online return's restocking fee, in cents (AGL-4038). */\n restockingFeeCents?: number\n note?: string\n orgId: string\n orderId: string\n stripeHardwareOrderId?: string | null\n tracking?: { carrier: string; number: string; url?: string } | null\n status?: PosHardwareOrderStatus\n /** A cancel or a refund: email the buyer about it (AGL-4038). */\n notifyBuyer?: boolean\n },\n) {\n return sendPosHardwareRequest<{\n ok: true\n order: StaffHardwareOrderRow\n /** A cancel or a refund: what became of the buyer's email, `off` when staff chose none. */\n buyerEmail?: 'sent' | 'already' | 'skipped' | 'failed' | 'off'\n }>(user, STAFF, { method: 'POST', body })\n}\n\n/** Asks to return a card reader bought in person, with the reason (AGL-4038). */\nexport function posHardwareRequestReturn(user: User, hostId: string, orderId: string, reason: string) {\n return sendPosHardwareRequest<{ ok: true; order: PosHardwareOrderRow }>(user, SHOP, {\n method: 'POST',\n body: { action: 'request-return', hostId, orderId, reason },\n })\n}\n"],"names":["authorizedFetch","PosHardwareRequestError","Error","message","status","reason","sendPosHardwareRequest","user","url","init","response","method","headers","attemptKey","body","JSON","stringify","payload","json","catch","ok","String","error","undefined","SHOP","openPosHardwareCheckout","window","location","assign","posHardwareCatalog","hostId","action","posHardwareOrders","posHardwareCheckout","posHardwareWaiting","posHardwareChooseStore","orderId","posHardwareMarkSetUp","STAFF","staffHardwareOrders","filter","after","params","URLSearchParams","set","search","toString","staffHardwareOrderAction","posHardwareRequestReturn"],"mappings":";AAAA;;;;;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AS,GAAGP,MAAM,CAAC,EAAEO,QAAQ,GAAGP,OAChC;QAAE3B,QAAQ;IAAM;AAEpB;AAEA,OAAO,SAASoC,yBACdxC,IAAU,EACVO,IAYC;IAED,OAAOR,uBAKJC,MAAM+B,OAAO;QAAE3B,QAAQ;QAAQG;IAAK;AACzC;AAEA,+EAA+E,GAC/E,OAAO,SAASkC,yBAAyBzC,IAAU,EAAEuB,MAAc,EAAEM,OAAe,EAAE/B,MAAc;IAClG,OAAOC,uBAAiEC,MAAMiB,MAAM;QAClFb,QAAQ;QACRG,MAAM;YAAEiB,QAAQ;YAAkBD;YAAQM;YAAS/B;QAAO;IAC5D;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { posHardwareSaleStatus } from './pos-hardware-sale-api';
|
|
2
|
+
type User = Parameters<typeof posHardwareSaleStatus>[0];
|
|
3
|
+
type Notify = (message: string, variant: 'success' | 'info' | 'warning' | 'error') => void;
|
|
4
|
+
export interface PosHardwareBuyerProps {
|
|
5
|
+
user: User;
|
|
6
|
+
hostId: string;
|
|
7
|
+
/** The sale open (or just paid) on this register, when it has a card reader. */
|
|
8
|
+
saleOrderId: string | null;
|
|
9
|
+
notify: Notify;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Selling a card reader at the platform's own store's register (AGL-4038):
|
|
13
|
+
* on a sale that has one, the buyer is attached here, and every reader sold
|
|
14
|
+
* without one waits on the To attach list. Draws nothing on any store but
|
|
15
|
+
* the platform's own hardware seller. Loaded on its own, by the register.
|
|
16
|
+
*/
|
|
17
|
+
declare function PosHardwareBuyer(props: PosHardwareBuyerProps): import("react").JSX.Element;
|
|
18
|
+
export default PosHardwareBuyer;
|