@nextblock-cms/ecom 0.20.3 → 0.21.1
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 +43 -0
- package/_virtual/_rolldown/runtime.cjs +1 -0
- package/index.cjs +1 -0
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs +1 -0
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs +1 -0
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs +1 -0
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs +1 -0
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs +1 -0
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs +1 -0
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs +1 -0
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs +1 -0
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs +1 -0
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs +1 -0
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs +1 -0
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs +1 -0
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs +1 -0
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs +1 -0
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs +1 -0
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs +29 -0
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs +1 -0
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs +1 -0
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs +1 -0
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs +1 -0
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs +1 -0
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs +1 -0
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs +1 -0
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs +1 -0
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs +1 -0
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs +1 -0
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs +1 -0
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs +1 -0
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs +1 -0
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs +1 -0
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs +1 -0
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs +1 -0
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs +1 -0
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs +1 -0
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs +1 -0
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs +1 -0
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs +1 -0
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs +1 -0
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs +1 -0
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs +1 -0
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs +1 -0
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs +1 -0
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs +1 -0
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs +33 -0
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs +1 -0
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs +1 -0
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs +61 -0
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs +1 -0
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs +1 -0
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs +7 -0
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs +1 -0
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs +1 -0
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs +1 -0
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
- package/lib/pages/cms/products/actions.cjs +44 -0
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs +1 -0
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs +1 -0
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs +1 -0
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs +238 -0
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs +1 -0
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs +1 -0
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs +1 -0
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs +1 -0
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs +1 -0
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs +1 -0
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs +1 -0
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs +1 -0
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs +1 -0
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs +15 -0
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs +7 -0
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs +1 -0
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs +1 -0
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs +1 -0
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs +1 -0
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs +1 -0
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs +1 -0
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs +1 -0
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs +1 -0
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs +1 -0
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs +1 -0
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs +1 -0
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs +1 -0
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs +1 -0
- package/lib/zod-config.es.js +5 -6
- package/package.json +22 -21
- package/server.cjs +1 -0
- package/server.es.js +56 -211
- package/index.cjs.js +0 -1
- package/lib/CurrencyProvider.cjs.js +0 -1
- package/lib/PaymentReadinessProvider.cjs.js +0 -1
- package/lib/cart-store.cjs.js +0 -1
- package/lib/components/AccountNavigationMenu.cjs.js +0 -1
- package/lib/components/AddToCartButton.cjs.js +0 -1
- package/lib/components/Cart.cjs.js +0 -1
- package/lib/components/CartDrawer.cjs.js +0 -1
- package/lib/components/CartIcon.cjs.js +0 -1
- package/lib/components/Checkout.cjs.js +0 -1
- package/lib/components/CouponForm.cjs.js +0 -1
- package/lib/components/CurrencySwitcher.cjs.js +0 -1
- package/lib/components/CustomerProfileForm.cjs.js +0 -1
- package/lib/components/FeaturedProduct.cjs.js +0 -1
- package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
- package/lib/components/InvoiceDocument.cjs.js +0 -1
- package/lib/components/InvoiceViewerShell.cjs.js +0 -29
- package/lib/components/ProductCard.cjs.js +0 -1
- package/lib/components/ProductDetailsLayout.cjs.js +0 -1
- package/lib/components/ProductGallery.cjs.js +0 -1
- package/lib/components/ProductGrid.cjs.js +0 -1
- package/lib/components/ShippingEstimator.cjs.js +0 -1
- package/lib/components/ShortDescription.cjs.js +0 -1
- package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
- package/lib/components/SubscriptionSelector.cjs.js +0 -1
- package/lib/countries.cjs.js +0 -1
- package/lib/coupon-server.cjs.js +0 -1
- package/lib/coupons.cjs.js +0 -1
- package/lib/currency-constants.cjs.js +0 -1
- package/lib/currency-rest-client.cjs.js +0 -1
- package/lib/currency-store.cjs.js +0 -1
- package/lib/currency-sync.cjs.js +0 -1
- package/lib/currency.cjs.js +0 -1
- package/lib/customer-addresses.cjs.js +0 -1
- package/lib/customer-orders.cjs.js +0 -1
- package/lib/customer.cjs.js +0 -1
- package/lib/export-helpers.cjs.js +0 -1
- package/lib/factory.cjs.js +0 -1
- package/lib/freemius-coupons.cjs.js +0 -1
- package/lib/freemius-license-claim.cjs.js +0 -1
- package/lib/freemius-license.cjs.js +0 -1
- package/lib/freemius-order-sync.cjs.js +0 -1
- package/lib/freemius-trial-provision.cjs.js +0 -1
- package/lib/inventory-settings.cjs.js +0 -1
- package/lib/invoice-server.cjs.js +0 -33
- package/lib/invoice-ui.cjs.js +0 -1
- package/lib/invoice.cjs.js +0 -1
- package/lib/order-inventory.cjs.js +0 -61
- package/lib/order-tax-details.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
- package/lib/pages/cms/coupons/actions.cjs.js +0 -1
- package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
- package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
- package/lib/pages/cms/orders/actions.cjs.js +0 -7
- package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
- package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
- package/lib/pages/cms/payments/actions.cjs.js +0 -1
- package/lib/pages/cms/payments/queries.cjs.js +0 -1
- package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
- package/lib/pages/cms/products/actions.cjs.js +0 -44
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
- package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
- package/lib/pages/cms/products/server-actions.cjs.js +0 -1
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
- package/lib/pages/cms/taxes/actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
- package/lib/payment-config.cjs.js +0 -1
- package/lib/product-actions.cjs.js +0 -238
- package/lib/product-context.cjs.js +0 -1
- package/lib/product-schema.cjs.js +0 -1
- package/lib/providers/freemius.cjs.js +0 -5
- package/lib/providers/stripe.cjs.js +0 -1
- package/lib/server-actions/coupon-actions.cjs.js +0 -1
- package/lib/server-actions/customer-actions.cjs.js +0 -1
- package/lib/server-actions/product-actions.cjs.js +0 -1
- package/lib/server-actions/shipping-actions.cjs.js +0 -1
- package/lib/server-actions/tax-actions.cjs.js +0 -1
- package/lib/shared-inventory.cjs.js +0 -15
- package/lib/shipping/resolver.cjs.js +0 -7
- package/lib/shipping-rate-currency.cjs.js +0 -1
- package/lib/states.cjs.js +0 -1
- package/lib/stripe/checkout.cjs.js +0 -1
- package/lib/stripe/client.cjs.js +0 -1
- package/lib/stripe/order-sync.cjs.js +0 -1
- package/lib/stripe/webhooks.cjs.js +0 -1
- package/lib/tax-calculation.cjs.js +0 -1
- package/lib/trials.cjs.js +0 -1
- package/lib/types.cjs.js +0 -1
- package/lib/use-cart.cjs.js +0 -1
- package/lib/use-price-formatter.cjs.js +0 -1
- package/lib/variation-utils.cjs.js +0 -1
- package/lib/zod-config.cjs.js +0 -1
- package/server.cjs.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";let e=require("@nextblock-cms/ui/button"),t=require("react"),n=require("lucide-react"),r=require("react/jsx-runtime"),i=require("@nextblock-cms/ui/input");function a(e){let t=e.sku?.trim();return t?t.toUpperCase():`PRODUCT:${e.id}`}function o(e){let t=new Map;for(let n of e){let e=a(n),r=t.get(e);if(r){r.productIds.push(n.id);continue}t.set(e,{key:e,title:n.title,sku:n.sku?.trim()||`No SKU`,thumbnailUrl:n.thumbnailUrl??null,productIds:[n.id]})}return[...t.values()]}function s({products:a,selectedProductIds:s=[]}){let c=(0,t.useMemo)(()=>new Set(s),[s]),[l,u]=(0,t.useState)(c),[d,f]=(0,t.useState)(``),p=(0,t.useMemo)(()=>o(a),[a]),m=(0,t.useMemo)(()=>{let e=d.trim().toLowerCase();return e?p.filter(t=>[t.title,t.sku].some(t=>t.toLowerCase().includes(e))):p},[p,d]),h=e=>{u(new Set(a.filter(t=>t.payment_provider===e).map(e=>e.id)))};return(0,r.jsxs)(`div`,{className:`space-y-3`,children:[(0,r.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,r.jsx)(e.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(new Set(a.map(e=>e.id))),children:`Select All`}),(0,r.jsx)(e.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(`stripe`),children:`Stripe`}),(0,r.jsx)(e.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(`freemius`),children:`Freemius`})]}),(0,r.jsxs)(`div`,{className:`relative`,children:[(0,r.jsx)(n.Search,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,r.jsx)(i.Input,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search products by title or SKU`,className:`pl-9`})]}),(0,r.jsxs)(`div`,{className:`grid max-h-[420px] gap-2 overflow-y-auto rounded-lg border p-3 md:grid-cols-2`,children:[m.map(e=>{let t=e.productIds.some(e=>l.has(e));return(0,r.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 hover:bg-muted/40`,children:[(0,r.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>{let n=new Set(l);for(let r of e.productIds)t.target.checked?n.add(r):n.delete(r);u(n)},className:`mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary`}),t?e.productIds.map(e=>(0,r.jsx)(`input`,{type:`hidden`,name:`product_ids`,value:e},e)):null,(0,r.jsx)(`span`,{className:`flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-md border bg-muted`,children:e.thumbnailUrl?(0,r.jsx)(`img`,{src:e.thumbnailUrl,alt:``,loading:`lazy`,className:`h-full w-full object-cover`}):(0,r.jsx)(n.ImageIcon,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`})}),(0,r.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,r.jsx)(`span`,{className:`block whitespace-normal break-words text-sm font-medium`,children:e.title}),(0,r.jsx)(`span`,{className:`block font-mono text-xs text-muted-foreground`,children:e.sku})]})]},e.key)}),m.length===0?(0,r.jsx)(`div`,{className:`px-2 py-8 text-center text-sm text-muted-foreground md:col-span-2`,children:`No matching products.`}):null]})]})}exports.ProductScopePicker=s;
|
|
@@ -1,120 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button as e } from "@nextblock-cms/ui/button";
|
|
3
|
+
import { useMemo as t, useState as n } from "react";
|
|
4
|
+
import { ImageIcon as r, Search as i } from "lucide-react";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { Input as s } from "@nextblock-cms/ui/input";
|
|
7
|
+
//#region src/lib/pages/cms/coupons/ProductScopePicker.tsx
|
|
8
|
+
function c(e) {
|
|
9
|
+
let t = e.sku?.trim();
|
|
10
|
+
return t ? t.toUpperCase() : `PRODUCT:${e.id}`;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
function l(e) {
|
|
13
|
+
let t = /* @__PURE__ */ new Map();
|
|
14
|
+
for (let n of e) {
|
|
15
|
+
let e = c(n), r = t.get(e);
|
|
16
|
+
if (r) {
|
|
17
|
+
r.productIds.push(n.id);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
t.set(e, {
|
|
21
|
+
key: e,
|
|
22
|
+
title: n.title,
|
|
23
|
+
sku: n.sku?.trim() || "No SKU",
|
|
24
|
+
thumbnailUrl: n.thumbnailUrl ?? null,
|
|
25
|
+
productIds: [n.id]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return [...t.values()];
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
30
|
+
function u({ products: c, selectedProductIds: u = [] }) {
|
|
31
|
+
let d = t(() => new Set(u), [u]), [f, p] = n(d), [m, h] = n(""), g = t(() => l(c), [c]), _ = t(() => {
|
|
32
|
+
let e = m.trim().toLowerCase();
|
|
33
|
+
return e ? g.filter((t) => [t.title, t.sku].some((t) => t.toLowerCase().includes(e))) : g;
|
|
34
|
+
}, [g, m]), v = (e) => {
|
|
35
|
+
p(new Set(c.filter((t) => t.payment_provider === e).map((e) => e.id)));
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ o("div", {
|
|
38
|
+
className: "space-y-3",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ o("div", {
|
|
41
|
+
className: "flex flex-wrap items-center gap-2",
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ a(e, {
|
|
44
|
+
type: "button",
|
|
45
|
+
variant: "outline",
|
|
46
|
+
size: "sm",
|
|
47
|
+
onClick: () => p(new Set(c.map((e) => e.id))),
|
|
48
|
+
children: "Select All"
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ a(e, {
|
|
51
|
+
type: "button",
|
|
52
|
+
variant: "outline",
|
|
53
|
+
size: "sm",
|
|
54
|
+
onClick: () => v("stripe"),
|
|
55
|
+
children: "Stripe"
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ a(e, {
|
|
58
|
+
type: "button",
|
|
59
|
+
variant: "outline",
|
|
60
|
+
size: "sm",
|
|
61
|
+
onClick: () => v("freemius"),
|
|
62
|
+
children: "Freemius"
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ o("div", {
|
|
67
|
+
className: "relative",
|
|
68
|
+
children: [/* @__PURE__ */ a(i, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }), /* @__PURE__ */ a(s, {
|
|
69
|
+
type: "search",
|
|
70
|
+
value: m,
|
|
71
|
+
onChange: (e) => h(e.target.value),
|
|
72
|
+
placeholder: "Search products by title or SKU",
|
|
73
|
+
className: "pl-9"
|
|
74
|
+
})]
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ o("div", {
|
|
77
|
+
className: "grid max-h-[420px] gap-2 overflow-y-auto rounded-lg border p-3 md:grid-cols-2",
|
|
78
|
+
children: [_.map((e) => {
|
|
79
|
+
let t = e.productIds.some((e) => f.has(e));
|
|
80
|
+
return /* @__PURE__ */ o("label", {
|
|
81
|
+
className: "flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 hover:bg-muted/40",
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ a("input", {
|
|
84
|
+
type: "checkbox",
|
|
85
|
+
checked: t,
|
|
86
|
+
onChange: (t) => {
|
|
87
|
+
let n = new Set(f);
|
|
88
|
+
for (let r of e.productIds) t.target.checked ? n.add(r) : n.delete(r);
|
|
89
|
+
p(n);
|
|
90
|
+
},
|
|
91
|
+
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
|
|
92
|
+
}),
|
|
93
|
+
t ? e.productIds.map((e) => /* @__PURE__ */ a("input", {
|
|
94
|
+
type: "hidden",
|
|
95
|
+
name: "product_ids",
|
|
96
|
+
value: e
|
|
97
|
+
}, e)) : null,
|
|
98
|
+
/* @__PURE__ */ a("span", {
|
|
99
|
+
className: "flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-md border bg-muted",
|
|
100
|
+
children: e.thumbnailUrl ? /* @__PURE__ */ a("img", {
|
|
101
|
+
src: e.thumbnailUrl,
|
|
102
|
+
alt: "",
|
|
103
|
+
loading: "lazy",
|
|
104
|
+
className: "h-full w-full object-cover"
|
|
105
|
+
}) : /* @__PURE__ */ a(r, {
|
|
106
|
+
className: "h-5 w-5 text-muted-foreground",
|
|
107
|
+
"aria-hidden": "true"
|
|
108
|
+
})
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ o("span", {
|
|
111
|
+
className: "min-w-0 flex-1",
|
|
112
|
+
children: [/* @__PURE__ */ a("span", {
|
|
113
|
+
className: "block whitespace-normal break-words text-sm font-medium",
|
|
114
|
+
children: e.title
|
|
115
|
+
}), /* @__PURE__ */ a("span", {
|
|
116
|
+
className: "block font-mono text-xs text-muted-foreground",
|
|
117
|
+
children: e.sku
|
|
118
|
+
})]
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}, e.key);
|
|
122
|
+
}), _.length === 0 ? /* @__PURE__ */ a("div", {
|
|
123
|
+
className: "px-2 py-8 text-center text-sm text-muted-foreground md:col-span-2",
|
|
124
|
+
children: "No matching products."
|
|
125
|
+
}) : null]
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
});
|
|
117
129
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { u as ProductScopePicker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use server";const e=require("../../../coupons.cjs"),t=require("../../../freemius-coupons.cjs");let n=require("@nextblock-cms/utils"),r=require("@nextblock-cms/db/server"),i=require("next/navigation"),a=require("next/cache");async function o(){let e=(0,r.createClient)(),{data:{user:t}}=await e.auth.getUser();if(!t)throw Error(`Unauthorized`);let{data:n}=await e.from(`profiles`).select(`role`).eq(`id`,t.id).single();if(n?.role!==`ADMIN`)throw Error(`Forbidden`);return(0,r.getServiceRoleSupabaseClient)()}function s(e){return(typeof e==`string`?e.trim():``)||null}function c(e){let t=s(e);if(!t)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n.toISOString()}function l(e){let t=s(e.value),r=t?Number.parseFloat(t):NaN;if(!Number.isFinite(r)||r<=0)throw Error(`Discount amount must be greater than zero.`);return e.discountType===`fixed`?(0,n.majorUnitAmountToMinor)(r,e.currencyCode):Math.round(r)}function u(e,t){return e.getAll(t).some(e=>e===`true`)}function d(t){let r=e.normalizeCouponCode(s(t.get(`code`))),i=s(t.get(`name`)),a=s(t.get(`provider_scope`))||`all`,o=s(t.get(`discount_type`))||`percent`,d=(0,n.normalizeCurrencyCode)(s(t.get(`currency_code`))),f=l({value:t.get(`discount_amount`),discountType:o,currencyCode:d}),p=s(t.get(`redemption_limit`));if(!r)throw Error(`Coupon code is required.`);if(!i)throw Error(`Coupon name is required.`);if(o===`percent`&&f>100)throw Error(`Percent discounts cannot exceed 100.`);return{coupon:{code:r,name:i,internal_note:s(t.get(`internal_note`)),provider_scope:a,discount_type:o,discount_amount:f,is_active:u(t,`is_active`),starts_at:c(t.get(`starts_at`)),ends_at:c(t.get(`ends_at`)),redemption_limit:p?Number.parseInt(p,10):null,freemius_sync_status:a===`stripe`?`not_required`:`pending`,freemius_sync_error:null},productIds:t.getAll(`product_ids`).map(e=>typeof e==`string`?e.trim():``).filter(Boolean)}}async function f(e){if(await e.client.from(`coupon_products`).delete().eq(`coupon_id`,e.couponId),e.productIds.length===0)return;let{error:t}=await e.client.from(`coupon_products`).insert(e.productIds.map(t=>({coupon_id:e.couponId,product_id:t})));if(t)throw Error(t.message)}async function p(e){let n=await o(),r=d(e),{data:s,error:c}=await n.from(`coupons`).insert(r.coupon).select(`id`).single();if(c||!s)throw Error(c?.message||`Failed to create coupon.`);await f({client:n,couponId:s.id,productIds:r.productIds}),await t.syncCouponToFreemius({couponId:s.id,client:n}),(0,a.revalidatePath)(`/cms/coupons`),(0,i.redirect)(`/cms/coupons`)}async function m(e,n){let r=await o(),s=d(n),{error:c}=await r.from(`coupons`).update(s.coupon).eq(`id`,e);if(c)throw Error(c.message);await f({client:r,couponId:e,productIds:s.productIds}),s.coupon.provider_scope===`stripe`?await t.deleteCouponFromFreemius({couponId:e,client:r}):await t.syncCouponToFreemius({couponId:e,client:r}),(0,a.revalidatePath)(`/cms/coupons`),(0,a.revalidatePath)(`/cms/coupons/${e}/edit`),(0,i.redirect)(`/cms/coupons`)}async function h(e,n){let r=await o(),{error:i}=await r.from(`coupons`).update({is_active:n,freemius_sync_status:`pending`,updated_at:new Date().toISOString()}).eq(`id`,e);if(i)throw Error(i.message);await t.syncCouponToFreemius({couponId:e,client:r}),(0,a.revalidatePath)(`/cms/coupons`)}async function g(e){let n=await o();await t.syncCouponToFreemius({couponId:e,client:n}),(0,a.revalidatePath)(`/cms/coupons`),(0,a.revalidatePath)(`/cms/coupons/${e}/edit`)}async function _(e){let n=await o();await t.deleteCouponFromFreemius({couponId:e,client:n});let{error:r}=await n.from(`coupons`).delete().eq(`id`,e);if(r)throw Error(r.message);(0,a.revalidatePath)(`/cms/coupons`)}exports.createCouponAction=p,exports.deleteCouponAction=_,exports.syncCouponAction=g,exports.toggleCouponActiveAction=h,exports.updateCouponAction=m;
|
|
@@ -1,128 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
"use server";
|
|
2
|
+
import { normalizeCouponCode as e } from "../../../coupons.es.js";
|
|
3
|
+
import { deleteCouponFromFreemius as t, syncCouponToFreemius as n } from "../../../freemius-coupons.es.js";
|
|
4
|
+
import { majorUnitAmountToMinor as r, normalizeCurrencyCode as i } from "@nextblock-cms/utils";
|
|
5
|
+
import { createClient as a, getServiceRoleSupabaseClient as o } from "@nextblock-cms/db/server";
|
|
6
|
+
import { redirect as s } from "next/navigation";
|
|
4
7
|
import { revalidatePath as c } from "next/cache";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!o)
|
|
13
|
-
throw new Error("Unauthorized");
|
|
14
|
-
const { data: t } = await e.from("profiles").select("role").eq("id", o.id).single();
|
|
15
|
-
if (t?.role !== "ADMIN")
|
|
16
|
-
throw new Error("Forbidden");
|
|
17
|
-
return C();
|
|
8
|
+
//#region src/lib/pages/cms/coupons/actions.ts
|
|
9
|
+
async function l() {
|
|
10
|
+
let e = a(), { data: { user: t } } = await e.auth.getUser();
|
|
11
|
+
if (!t) throw Error("Unauthorized");
|
|
12
|
+
let { data: n } = await e.from("profiles").select("role").eq("id", t.id).single();
|
|
13
|
+
if (n?.role !== "ADMIN") throw Error("Forbidden");
|
|
14
|
+
return o();
|
|
18
15
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
16
|
+
function u(e) {
|
|
17
|
+
return (typeof e == "string" ? e.trim() : "") || null;
|
|
21
18
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return Number.isNaN(t.getTime()) ? null : t.toISOString();
|
|
19
|
+
function d(e) {
|
|
20
|
+
let t = u(e);
|
|
21
|
+
if (!t) return null;
|
|
22
|
+
let n = new Date(t);
|
|
23
|
+
return Number.isNaN(n.getTime()) ? null : n.toISOString();
|
|
28
24
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return e.discountType === "fixed" ? A(t, e.currencyCode) : Math.round(t);
|
|
25
|
+
function f(e) {
|
|
26
|
+
let t = u(e.value), n = t ? Number.parseFloat(t) : NaN;
|
|
27
|
+
if (!Number.isFinite(n) || n <= 0) throw Error("Discount amount must be greater than zero.");
|
|
28
|
+
return e.discountType === "fixed" ? r(n, e.currencyCode) : Math.round(n);
|
|
34
29
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
30
|
+
function p(e, t) {
|
|
31
|
+
return e.getAll(t).some((e) => e === "true");
|
|
37
32
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
productIds: e.getAll("product_ids").map((p) => typeof p == "string" ? p.trim() : "").filter(Boolean)
|
|
66
|
-
};
|
|
33
|
+
function m(t) {
|
|
34
|
+
let n = e(u(t.get("code"))), r = u(t.get("name")), a = u(t.get("provider_scope")) || "all", o = u(t.get("discount_type")) || "percent", s = i(u(t.get("currency_code"))), c = f({
|
|
35
|
+
value: t.get("discount_amount"),
|
|
36
|
+
discountType: o,
|
|
37
|
+
currencyCode: s
|
|
38
|
+
}), l = u(t.get("redemption_limit"));
|
|
39
|
+
if (!n) throw Error("Coupon code is required.");
|
|
40
|
+
if (!r) throw Error("Coupon name is required.");
|
|
41
|
+
if (o === "percent" && c > 100) throw Error("Percent discounts cannot exceed 100.");
|
|
42
|
+
return {
|
|
43
|
+
coupon: {
|
|
44
|
+
code: n,
|
|
45
|
+
name: r,
|
|
46
|
+
internal_note: u(t.get("internal_note")),
|
|
47
|
+
provider_scope: a,
|
|
48
|
+
discount_type: o,
|
|
49
|
+
discount_amount: c,
|
|
50
|
+
is_active: p(t, "is_active"),
|
|
51
|
+
starts_at: d(t.get("starts_at")),
|
|
52
|
+
ends_at: d(t.get("ends_at")),
|
|
53
|
+
redemption_limit: l ? Number.parseInt(l, 10) : null,
|
|
54
|
+
freemius_sync_status: a === "stripe" ? "not_required" : "pending",
|
|
55
|
+
freemius_sync_error: null
|
|
56
|
+
},
|
|
57
|
+
productIds: t.getAll("product_ids").map((e) => typeof e == "string" ? e.trim() : "").filter(Boolean)
|
|
58
|
+
};
|
|
67
59
|
}
|
|
68
|
-
async function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}))
|
|
76
|
-
);
|
|
77
|
-
if (o)
|
|
78
|
-
throw new Error(o.message);
|
|
60
|
+
async function h(e) {
|
|
61
|
+
if (await e.client.from("coupon_products").delete().eq("coupon_id", e.couponId), e.productIds.length === 0) return;
|
|
62
|
+
let { error: t } = await e.client.from("coupon_products").insert(e.productIds.map((t) => ({
|
|
63
|
+
coupon_id: e.couponId,
|
|
64
|
+
product_id: t
|
|
65
|
+
})));
|
|
66
|
+
if (t) throw Error(t.message);
|
|
79
67
|
}
|
|
80
|
-
async function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
async function g(e) {
|
|
69
|
+
let t = await l(), r = m(e), { data: i, error: a } = await t.from("coupons").insert(r.coupon).select("id").single();
|
|
70
|
+
if (a || !i) throw Error(a?.message || "Failed to create coupon.");
|
|
71
|
+
await h({
|
|
72
|
+
client: t,
|
|
73
|
+
couponId: i.id,
|
|
74
|
+
productIds: r.productIds
|
|
75
|
+
}), await n({
|
|
76
|
+
couponId: i.id,
|
|
77
|
+
client: t
|
|
78
|
+
}), c("/cms/coupons"), s("/cms/coupons");
|
|
89
79
|
}
|
|
90
|
-
async function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
async function _(e, r) {
|
|
81
|
+
let i = await l(), a = m(r), { error: o } = await i.from("coupons").update(a.coupon).eq("id", e);
|
|
82
|
+
if (o) throw Error(o.message);
|
|
83
|
+
await h({
|
|
84
|
+
client: i,
|
|
85
|
+
couponId: e,
|
|
86
|
+
productIds: a.productIds
|
|
87
|
+
}), a.coupon.provider_scope === "stripe" ? await t({
|
|
88
|
+
couponId: e,
|
|
89
|
+
client: i
|
|
90
|
+
}) : await n({
|
|
91
|
+
couponId: e,
|
|
92
|
+
client: i
|
|
93
|
+
}), c("/cms/coupons"), c(`/cms/coupons/${e}/edit`), s("/cms/coupons");
|
|
99
94
|
}
|
|
100
|
-
async function
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
95
|
+
async function v(e, t) {
|
|
96
|
+
let r = await l(), { error: i } = await r.from("coupons").update({
|
|
97
|
+
is_active: t,
|
|
98
|
+
freemius_sync_status: "pending",
|
|
99
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
100
|
+
}).eq("id", e);
|
|
101
|
+
if (i) throw Error(i.message);
|
|
102
|
+
await n({
|
|
103
|
+
couponId: e,
|
|
104
|
+
client: r
|
|
105
|
+
}), c("/cms/coupons");
|
|
109
106
|
}
|
|
110
|
-
async function
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
async function y(e) {
|
|
108
|
+
let t = await l();
|
|
109
|
+
await n({
|
|
110
|
+
couponId: e,
|
|
111
|
+
client: t
|
|
112
|
+
}), c("/cms/coupons"), c(`/cms/coupons/${e}/edit`);
|
|
113
113
|
}
|
|
114
|
-
async function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
async function b(e) {
|
|
115
|
+
let n = await l();
|
|
116
|
+
await t({
|
|
117
|
+
couponId: e,
|
|
118
|
+
client: n
|
|
119
|
+
});
|
|
120
|
+
let { error: r } = await n.from("coupons").delete().eq("id", e);
|
|
121
|
+
if (r) throw Error(r.message);
|
|
122
|
+
c("/cms/coupons");
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
U as deleteCouponAction,
|
|
125
|
-
M as syncCouponAction,
|
|
126
|
-
P as toggleCouponActiveAction,
|
|
127
|
-
z as updateCouponAction
|
|
128
|
-
};
|
|
124
|
+
//#endregion
|
|
125
|
+
export { g as createCouponAction, b as deleteCouponAction, y as syncCouponAction, v as toggleCouponActiveAction, _ as updateCouponAction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./CouponsPage.cjs"),t=require("./EditCouponPage.cjs");exports.CouponsPage=e.CouponsPage,exports.EditCouponPage=t.EditCouponPage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return Array.isArray(e)?e[0]??null:e??null}var t=process.env.NEXT_PUBLIC_R2_BASE_URL||``;function n(e){return e?e.startsWith(`http`)||!t?e:`${t.replace(/\/+$/,``)}/${e.replace(/^\/+/,``)}`:null}function r(e){let t=Array.isArray(e.product_media)?[...e.product_media].sort((e,t)=>(e.sort_order??0)-(t.sort_order??0)):[];return n(t[0]?.media?.file_path||t[0]?.media?.object_key||null)}function i(t){return(t||[]).map(t=>({id:t.id,title:t.title,sku:t.sku??null,payment_provider:t.payment_provider||`stripe`,freemius_product_id:t.freemius_product_id??null,thumbnailUrl:r(t),language:e(t.language)}))}exports.normalizeCouponProductOptions=i;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/lib/pages/cms/coupons/product-options.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return Array.isArray(e) ? e[0] ?? null : e ?? null;
|
|
3
4
|
}
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
var t = process.env.NEXT_PUBLIC_R2_BASE_URL || "";
|
|
6
|
+
function n(e) {
|
|
7
|
+
return e ? e.startsWith("http") || !t ? e : `${t.replace(/\/+$/, "")}/${e.replace(/^\/+/, "")}` : null;
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
) : [], n = e[0]?.media?.file_path || e[0]?.media?.object_key || null;
|
|
12
|
-
return o(n);
|
|
9
|
+
function r(e) {
|
|
10
|
+
let t = Array.isArray(e.product_media) ? [...e.product_media].sort((e, t) => (e.sort_order ?? 0) - (t.sort_order ?? 0)) : [];
|
|
11
|
+
return n(t[0]?.media?.file_path || t[0]?.media?.object_key || null);
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
function i(t) {
|
|
14
|
+
return (t || []).map((t) => ({
|
|
15
|
+
id: t.id,
|
|
16
|
+
title: t.title,
|
|
17
|
+
sku: t.sku ?? null,
|
|
18
|
+
payment_provider: t.payment_provider || "stripe",
|
|
19
|
+
freemius_product_id: t.freemius_product_id ?? null,
|
|
20
|
+
thumbnailUrl: r(t),
|
|
21
|
+
language: e(t.language)
|
|
22
|
+
}));
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { i as normalizeCouponProductOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../../_virtual/_rolldown/runtime.cjs"),t=require("./export-actions.cjs"),n=require("../../../export-helpers.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime"),o=require("sonner"),s=require("@nextblock-cms/ui");function c(){let[e,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(`general_ledger`);return(0,a.jsxs)(s.Dialog,{open:e,onOpenChange:c,children:[(0,a.jsx)(s.DialogTrigger,{asChild:!0,children:(0,a.jsxs)(s.Button,{variant:`outline`,className:`flex items-center gap-2`,children:[(0,a.jsx)(i.Download,{className:`h-4 w-4`}),`Export Reports`]})}),(0,a.jsxs)(s.DialogContent,{className:`sm:max-w-[425px]`,children:[(0,a.jsxs)(s.DialogHeader,{children:[(0,a.jsxs)(s.DialogTitle,{className:`flex items-center gap-2`,children:[(0,a.jsx)(i.FileDown,{className:`h-5 w-5 text-blue-600`}),`Accounting Reports`]}),(0,a.jsx)(s.DialogDescription,{children:`Generate and download accountant-friendly order reports.`})]}),(0,a.jsxs)(`div`,{className:`grid gap-6 py-4`,children:[(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,a.jsxs)(`div`,{className:`grid gap-2`,children:[(0,a.jsx)(s.Label,{htmlFor:`start-date`,className:`text-xs font-semibold uppercase text-gray-500 tracking-wider`,children:`Start Date`}),(0,a.jsxs)(`div`,{className:`relative`,children:[(0,a.jsx)(s.Input,{id:`start-date`,type:`date`,value:d,onChange:e=>f(e.target.value),className:`pl-8`}),(0,a.jsx)(i.Calendar,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`})]})]}),(0,a.jsxs)(`div`,{className:`grid gap-2`,children:[(0,a.jsx)(s.Label,{htmlFor:`end-date`,className:`text-xs font-semibold uppercase text-gray-500 tracking-wider`,children:`End Date`}),(0,a.jsxs)(`div`,{className:`relative`,children:[(0,a.jsx)(s.Input,{id:`end-date`,type:`date`,value:p,onChange:e=>m(e.target.value),className:`pl-8`}),(0,a.jsx)(i.Calendar,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`})]})]})]}),(0,a.jsxs)(`div`,{className:`grid gap-2`,children:[(0,a.jsx)(s.Label,{htmlFor:`report-type`,className:`text-xs font-semibold uppercase text-gray-500 tracking-wider`,children:`Report Type`}),(0,a.jsxs)(s.Select,{value:h,onValueChange:e=>g(e),children:[(0,a.jsx)(s.SelectTrigger,{id:`report-type`,className:`w-full`,children:(0,a.jsx)(s.SelectValue,{placeholder:`Select report type`})}),(0,a.jsxs)(s.SelectContent,{children:[(0,a.jsx)(s.SelectItem,{value:`general_ledger`,children:`General Sales Ledger`}),(0,a.jsx)(s.SelectItem,{value:`tax_liability`,children:`Tax Liability Summary`}),(0,a.jsx)(s.SelectItem,{value:`currency_summary`,children:`Multi-Currency Revenue Summary`})]})]})]})]}),(0,a.jsx)(s.DialogFooter,{children:(0,a.jsx)(s.Button,{onClick:async()=>{if(!d||!p){o.toast.error(`Please select both start and end dates`);return}u(!0);try{o.toast.info(`Generating report...`);let e=await t.fetchOrderReportData(d,p);if(!e||e.length===0){o.toast.error(`No orders found for the selected date range`),u(!1);return}let r=[],i=`report_${h}_${d}_to_${p}`;switch(h){case`general_ledger`:r=n.mapGeneralSalesLedger(e);break;case`tax_liability`:r=n.mapTaxLiabilitySummary(e);break;case`currency_summary`:r=n.mapMultiCurrencyRevenue(e)}n.generateCSV(r,`${i}.csv`),o.toast.success(`Download complete!`),c(!1)}catch(e){console.error(`Export error:`,e),o.toast.error(`Failed to generate report`)}finally{u(!1)}},disabled:l,className:`w-full bg-blue-600 hover:bg-blue-700 text-white`,children:l?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),`Generating...`]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Download,{className:`mr-2 h-4 w-4`}),`Download Report`]})})})]})]})}exports.ExportReportsDialog=c;
|