@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
|
@@ -1,172 +1,214 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { resolveSubdivisionName as e } from "../../../states.es.js";
|
|
2
|
+
import { getEcommerceInventorySettings as t } from "../../../inventory-settings.es.js";
|
|
3
|
+
import { getEnabledPaymentProviders as n } from "../payments/queries.es.js";
|
|
4
|
+
import { deleteTaxRateAction as r, updateTaxSettingsAction as i } from "./actions.es.js";
|
|
5
|
+
import { TaxRateForm as a } from "./components/TaxRateForm.es.js";
|
|
6
|
+
import o from "next/link";
|
|
7
|
+
import { ArrowLeft as s, Settings2 as c, ShieldCheck as l, Trash2 as u } from "lucide-react";
|
|
8
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
|
+
import { createClient as m, getServiceRoleSupabaseClient as h } from "@nextblock-cms/db/server";
|
|
10
|
+
import { Badge as g, Button as _, Card as v, CardContent as y, CardDescription as b, CardHeader as x, CardTitle as S } from "@nextblock-cms/ui";
|
|
11
|
+
//#region src/lib/pages/cms/taxes/TaxesPage.tsx
|
|
12
|
+
function C(e) {
|
|
13
|
+
return `${e.toFixed(4).replace(/\.?0+$/, "")}%`;
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
15
|
+
function w(t) {
|
|
16
|
+
return t.state_code ? `${t.country_code} - ${e(t.country_code, t.state_code)}` : `${t.country_code} - Country-wide`;
|
|
16
17
|
}
|
|
17
|
-
async function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
18
|
+
async function T({ searchParams: e }) {
|
|
19
|
+
let T = m(), E = h(), [D, O, k] = await Promise.all([
|
|
20
|
+
t(T),
|
|
21
|
+
n(),
|
|
22
|
+
E.from("tax_rates").select("id, country_code, state_code, tax_name, tax_rate, created_at, updated_at").order("country_code").order("state_code").order("tax_name")
|
|
23
|
+
]), A = k.data || [], j = k.error, M = O.stripe;
|
|
24
|
+
return /* @__PURE__ */ p("div", {
|
|
25
|
+
className: "mx-auto w-full max-w-6xl space-y-6 px-6 py-8",
|
|
26
|
+
children: [
|
|
27
|
+
e?.success ? /* @__PURE__ */ f("div", {
|
|
28
|
+
className: "rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-700",
|
|
29
|
+
children: e.success
|
|
30
|
+
}) : null,
|
|
31
|
+
/* @__PURE__ */ p("div", {
|
|
32
|
+
className: "flex items-center justify-between gap-4",
|
|
33
|
+
children: [/* @__PURE__ */ p("div", {
|
|
34
|
+
className: "flex items-center gap-3",
|
|
35
|
+
children: [/* @__PURE__ */ f(_, {
|
|
36
|
+
asChild: !0,
|
|
37
|
+
variant: "outline",
|
|
38
|
+
size: "icon",
|
|
39
|
+
"aria-label": "Back to shipping",
|
|
40
|
+
children: /* @__PURE__ */ f(o, {
|
|
41
|
+
href: "/cms/shipping",
|
|
42
|
+
children: /* @__PURE__ */ f(s, { className: "h-4 w-4" })
|
|
43
|
+
})
|
|
44
|
+
}), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", {
|
|
45
|
+
className: "text-2xl font-bold",
|
|
46
|
+
children: "Tax Settings"
|
|
47
|
+
}), /* @__PURE__ */ f("p", {
|
|
48
|
+
className: "text-sm text-muted-foreground",
|
|
49
|
+
children: "Configure Stripe tax behavior globally and maintain manual country or state/province tax rates for physical goods."
|
|
50
|
+
})] })]
|
|
51
|
+
}), /* @__PURE__ */ p("div", {
|
|
52
|
+
className: "flex items-center gap-2",
|
|
53
|
+
children: [/* @__PURE__ */ p(g, {
|
|
54
|
+
variant: M ? "default" : "outline",
|
|
55
|
+
className: "uppercase",
|
|
56
|
+
children: ["Stripe ", M ? "Enabled" : "Disabled"]
|
|
57
|
+
}), /* @__PURE__ */ f("div", {
|
|
58
|
+
className: "rounded-full border bg-muted/30 p-3 text-muted-foreground",
|
|
59
|
+
children: /* @__PURE__ */ f(c, { className: "h-5 w-5" })
|
|
60
|
+
})]
|
|
61
|
+
})]
|
|
62
|
+
}),
|
|
63
|
+
M ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p(v, { children: [/* @__PURE__ */ p(x, { children: [/* @__PURE__ */ f(S, { children: "Global Tax Controls" }), /* @__PURE__ */ f(b, { children: "Manual mode uses the tax rates below. Automatic mode uses Stripe Tax during Stripe Checkout instead of a free third-party tax API." })] }), /* @__PURE__ */ f(y, { children: /* @__PURE__ */ p("form", {
|
|
64
|
+
action: i,
|
|
65
|
+
className: "space-y-6",
|
|
66
|
+
children: [/* @__PURE__ */ p("div", {
|
|
67
|
+
className: "rounded-lg border bg-muted/20 p-4",
|
|
68
|
+
children: [/* @__PURE__ */ f("input", {
|
|
69
|
+
type: "hidden",
|
|
70
|
+
name: "enableTaxes",
|
|
71
|
+
value: "false"
|
|
72
|
+
}), /* @__PURE__ */ p("label", {
|
|
73
|
+
htmlFor: "enable-taxes",
|
|
74
|
+
className: "flex cursor-pointer items-start gap-3",
|
|
75
|
+
children: [/* @__PURE__ */ f("input", {
|
|
76
|
+
id: "enable-taxes",
|
|
77
|
+
name: "enableTaxes",
|
|
78
|
+
type: "checkbox",
|
|
79
|
+
value: "true",
|
|
80
|
+
defaultChecked: D.enableTaxes,
|
|
81
|
+
className: "mt-1 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
|
|
82
|
+
}), /* @__PURE__ */ p("span", {
|
|
83
|
+
className: "space-y-1",
|
|
84
|
+
children: [/* @__PURE__ */ f("span", {
|
|
85
|
+
className: "block font-medium",
|
|
86
|
+
children: "Enable taxes"
|
|
87
|
+
}), /* @__PURE__ */ f("span", {
|
|
88
|
+
className: "block text-sm text-muted-foreground",
|
|
89
|
+
children: "When disabled, tax totals resolve to zero even if product or jurisdiction records exist."
|
|
90
|
+
})]
|
|
91
|
+
})]
|
|
92
|
+
})]
|
|
93
|
+
}), /* @__PURE__ */ p("div", {
|
|
94
|
+
className: "grid gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-end",
|
|
95
|
+
children: [/* @__PURE__ */ p("div", {
|
|
96
|
+
className: "space-y-2",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ f("label", {
|
|
99
|
+
htmlFor: "tax-calculation-mode",
|
|
100
|
+
className: "text-sm font-medium text-foreground",
|
|
101
|
+
children: "Tax calculation mode"
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ p("select", {
|
|
104
|
+
id: "tax-calculation-mode",
|
|
105
|
+
name: "taxCalculationMode",
|
|
106
|
+
defaultValue: D.taxCalculationMode,
|
|
107
|
+
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
108
|
+
children: [/* @__PURE__ */ f("option", {
|
|
109
|
+
value: "manual",
|
|
110
|
+
children: "Manual tax rates"
|
|
111
|
+
}), /* @__PURE__ */ f("option", {
|
|
112
|
+
value: "automatic",
|
|
113
|
+
children: "Automatic via Stripe Tax"
|
|
114
|
+
})]
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ f("p", {
|
|
117
|
+
className: "text-sm text-muted-foreground",
|
|
118
|
+
children: "Automatic mode depends on your Stripe Tax setup. Manual rates stay saved and can be used again if you switch back later."
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}), /* @__PURE__ */ f("div", {
|
|
122
|
+
className: "flex justify-end",
|
|
123
|
+
children: /* @__PURE__ */ f(_, {
|
|
124
|
+
type: "submit",
|
|
125
|
+
children: "Save Tax Settings"
|
|
126
|
+
})
|
|
127
|
+
})]
|
|
128
|
+
})]
|
|
129
|
+
}) })] }), /* @__PURE__ */ p(v, { children: [/* @__PURE__ */ f(x, { children: /* @__PURE__ */ p("div", {
|
|
130
|
+
className: "flex items-center justify-between gap-4",
|
|
131
|
+
children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f(S, { children: "Manual Tax Rates" }), /* @__PURE__ */ f(b, { children: "Add combined taxes as separate rows. For example, create both GST and PST for the same province if they should stack." })] }), /* @__PURE__ */ f(g, {
|
|
132
|
+
variant: D.taxCalculationMode === "manual" ? "default" : "outline",
|
|
133
|
+
children: D.taxCalculationMode === "manual" ? "Active Mode" : "Stored for Manual Mode"
|
|
134
|
+
})]
|
|
135
|
+
}) }), /* @__PURE__ */ p(y, {
|
|
136
|
+
className: "space-y-6",
|
|
137
|
+
children: [j ? /* @__PURE__ */ f("div", {
|
|
138
|
+
className: "rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",
|
|
139
|
+
children: "Tax rates couldn't be loaded yet. This usually means the new tax migration hasn't been applied to the current database."
|
|
140
|
+
}) : null, j ? null : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("div", {
|
|
141
|
+
className: "rounded-xl border bg-card p-4",
|
|
142
|
+
children: [/* @__PURE__ */ p("div", {
|
|
143
|
+
className: "mb-4 flex items-center gap-2",
|
|
144
|
+
children: [/* @__PURE__ */ f(l, { className: "h-4 w-4 text-primary" }), /* @__PURE__ */ f("h2", {
|
|
145
|
+
className: "font-semibold",
|
|
146
|
+
children: "Create a Tax Rate"
|
|
147
|
+
})]
|
|
148
|
+
}), /* @__PURE__ */ f(a, {})]
|
|
149
|
+
}), /* @__PURE__ */ f("div", {
|
|
150
|
+
className: "space-y-4",
|
|
151
|
+
children: A.length === 0 ? /* @__PURE__ */ p("div", {
|
|
152
|
+
className: "rounded-xl border border-dashed bg-muted/10 px-4 py-8 text-center",
|
|
153
|
+
children: [/* @__PURE__ */ f("p", {
|
|
154
|
+
className: "font-medium",
|
|
155
|
+
children: "No manual tax rates yet"
|
|
156
|
+
}), /* @__PURE__ */ f("p", {
|
|
157
|
+
className: "mt-1 text-sm text-muted-foreground",
|
|
158
|
+
children: "Add country-wide or state/province-specific rows to start calculating manual taxes."
|
|
159
|
+
})]
|
|
160
|
+
}) : A.map((e) => /* @__PURE__ */ p(v, {
|
|
161
|
+
className: "border-muted",
|
|
162
|
+
children: [/* @__PURE__ */ f(x, {
|
|
163
|
+
className: "pb-4",
|
|
164
|
+
children: /* @__PURE__ */ p("div", {
|
|
165
|
+
className: "flex items-start justify-between gap-4",
|
|
166
|
+
children: [/* @__PURE__ */ p("div", {
|
|
167
|
+
className: "space-y-1",
|
|
168
|
+
children: [/* @__PURE__ */ f(S, {
|
|
169
|
+
className: "text-base",
|
|
170
|
+
children: e.tax_name
|
|
171
|
+
}), /* @__PURE__ */ f(b, { children: w(e) })]
|
|
172
|
+
}), /* @__PURE__ */ p("div", {
|
|
173
|
+
className: "flex items-center gap-2",
|
|
174
|
+
children: [/* @__PURE__ */ f(g, {
|
|
175
|
+
variant: "outline",
|
|
176
|
+
children: C(Number(e.tax_rate))
|
|
177
|
+
}), /* @__PURE__ */ f("form", {
|
|
178
|
+
action: async () => {
|
|
179
|
+
"use server";
|
|
180
|
+
await r(e.id);
|
|
181
|
+
},
|
|
182
|
+
children: /* @__PURE__ */ f(_, {
|
|
183
|
+
type: "submit",
|
|
184
|
+
variant: "ghost",
|
|
185
|
+
size: "icon",
|
|
186
|
+
"aria-label": "Delete tax rate",
|
|
187
|
+
children: /* @__PURE__ */ f(u, { className: "h-4 w-4" })
|
|
188
|
+
})
|
|
189
|
+
})]
|
|
190
|
+
})]
|
|
191
|
+
})
|
|
192
|
+
}), /* @__PURE__ */ f(y, { children: /* @__PURE__ */ f(a, {
|
|
193
|
+
initialData: e,
|
|
194
|
+
submitLabel: "Update tax rate",
|
|
195
|
+
compact: !0
|
|
196
|
+
}) })]
|
|
197
|
+
}, e.id))
|
|
198
|
+
})] })]
|
|
199
|
+
})] })] }) : /* @__PURE__ */ p(v, {
|
|
200
|
+
className: "border-dashed",
|
|
201
|
+
children: [/* @__PURE__ */ p(x, { children: [/* @__PURE__ */ f(S, { children: "Enable Stripe to configure physical-product taxes" }), /* @__PURE__ */ f(b, { children: "Stripe tax settings apply whenever Stripe is enabled for physical products. Freemius still handles taxes on its own digital checkout flow." })] }), /* @__PURE__ */ f(y, { children: /* @__PURE__ */ f(_, {
|
|
202
|
+
asChild: !0,
|
|
203
|
+
variant: "outline",
|
|
204
|
+
children: /* @__PURE__ */ f(o, {
|
|
205
|
+
href: "/cms/payments",
|
|
206
|
+
children: "Open Payment Settings"
|
|
207
|
+
})
|
|
208
|
+
}) })]
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
});
|
|
169
212
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
213
|
+
//#endregion
|
|
214
|
+
export { T as TaxesPage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use server";const e=require("../../../countries.cjs"),t=require("../../../states.cjs"),n=require("../../../inventory-settings.cjs");let 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||n.role!==`ADMIN`)throw Error(`Forbidden`);return e}async function s(e){let t=await o(),r=await n.getEcommerceInventorySettings(t),s=e.getAll(`enableTaxes`).includes(`true`),c=e.get(`taxCalculationMode`)===`automatic`?`automatic`:`manual`,{error:l}=await n.upsertEcommerceInventorySettings(t,{trackQuantities:r.trackQuantities,enableTaxes:s,taxCalculationMode:c});if(l)throw Error(l.message);(0,a.revalidatePath)(`/cms/shipping`),(0,a.revalidatePath)(`/cms/settings/taxes`),(0,i.redirect)(`/cms/settings/taxes?success=Tax settings updated`)}async function c(n){let r=await o(),i=String(n.get(`id`)||``).trim(),s=e.normalizeCountryCode(String(n.get(`country_code`)||``).trim()),c=String(n.get(`state_code`)||``).trim(),l=String(n.get(`tax_name`)||``).trim(),u=Number(n.get(`tax_rate`));if(!s)throw Error(`Country code is required.`);if(!l)throw Error(`Tax name is required.`);if(!Number.isFinite(u)||u<0||u>100)throw Error(`Tax rate must be between 0 and 100.`);let d={country_code:s,state_code:t.normalizeSubdivisionCode(s,c)||null,tax_name:l,tax_rate:u},{error:f}=await(i?r.from(`tax_rates`).update(d).eq(`id`,i):r.from(`tax_rates`).insert(d));if(f)throw Error(f.message);(0,a.revalidatePath)(`/cms/settings/taxes`)}async function l(e){let{error:t}=await(await o()).from(`tax_rates`).delete().eq(`id`,e);if(t)throw Error(t.message);(0,a.revalidatePath)(`/cms/settings/taxes`)}exports.deleteTaxRateAction=l,exports.saveTaxRateAction=c,exports.updateTaxSettingsAction=s;
|
|
@@ -1,57 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!r || r.role !== "ADMIN")
|
|
16
|
-
throw new Error("Forbidden");
|
|
17
|
-
return t;
|
|
1
|
+
"use server";
|
|
2
|
+
import { normalizeCountryCode as e } from "../../../countries.es.js";
|
|
3
|
+
import { normalizeSubdivisionCode as t } from "../../../states.es.js";
|
|
4
|
+
import { getEcommerceInventorySettings as n, upsertEcommerceInventorySettings as r } from "../../../inventory-settings.es.js";
|
|
5
|
+
import { createClient as i } from "@nextblock-cms/db/server";
|
|
6
|
+
import { redirect as a } from "next/navigation";
|
|
7
|
+
import { revalidatePath as o } from "next/cache";
|
|
8
|
+
//#region src/lib/pages/cms/taxes/actions.ts
|
|
9
|
+
async function s() {
|
|
10
|
+
let e = i(), { 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 || n.role !== "ADMIN") throw Error("Forbidden");
|
|
14
|
+
return e;
|
|
18
15
|
}
|
|
19
|
-
async function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
s("/cms/shipping"), s("/cms/settings/taxes"), w("/cms/settings/taxes?success=Tax settings updated");
|
|
16
|
+
async function c(e) {
|
|
17
|
+
let t = await s(), i = await n(t), c = e.getAll("enableTaxes").includes("true"), l = e.get("taxCalculationMode") === "automatic" ? "automatic" : "manual", { error: u } = await r(t, {
|
|
18
|
+
trackQuantities: i.trackQuantities,
|
|
19
|
+
enableTaxes: c,
|
|
20
|
+
taxCalculationMode: l
|
|
21
|
+
});
|
|
22
|
+
if (u) throw Error(u.message);
|
|
23
|
+
o("/cms/shipping"), o("/cms/settings/taxes"), a("/cms/settings/taxes?success=Tax settings updated");
|
|
28
24
|
}
|
|
29
|
-
async function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, d = r ? e.from("tax_rates").update(m).eq("id", r) : e.from("tax_rates").insert(m), { error: u } = await d;
|
|
43
|
-
if (u)
|
|
44
|
-
throw new Error(u.message);
|
|
45
|
-
s("/cms/settings/taxes");
|
|
25
|
+
async function l(n) {
|
|
26
|
+
let r = await s(), i = String(n.get("id") || "").trim(), a = e(String(n.get("country_code") || "").trim()), c = String(n.get("state_code") || "").trim(), l = String(n.get("tax_name") || "").trim(), u = Number(n.get("tax_rate"));
|
|
27
|
+
if (!a) throw Error("Country code is required.");
|
|
28
|
+
if (!l) throw Error("Tax name is required.");
|
|
29
|
+
if (!Number.isFinite(u) || u < 0 || u > 100) throw Error("Tax rate must be between 0 and 100.");
|
|
30
|
+
let d = {
|
|
31
|
+
country_code: a,
|
|
32
|
+
state_code: t(a, c) || null,
|
|
33
|
+
tax_name: l,
|
|
34
|
+
tax_rate: u
|
|
35
|
+
}, { error: f } = await (i ? r.from("tax_rates").update(d).eq("id", i) : r.from("tax_rates").insert(d));
|
|
36
|
+
if (f) throw Error(f.message);
|
|
37
|
+
o("/cms/settings/taxes");
|
|
46
38
|
}
|
|
47
|
-
async function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
s("/cms/settings/taxes");
|
|
39
|
+
async function u(e) {
|
|
40
|
+
let { error: t } = await (await s()).from("tax_rates").delete().eq("id", e);
|
|
41
|
+
if (t) throw Error(t.message);
|
|
42
|
+
o("/cms/settings/taxes");
|
|
52
43
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
T as saveTaxRateAction,
|
|
56
|
-
C as updateTaxSettingsAction
|
|
57
|
-
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { u as deleteTaxRateAction, l as saveTaxRateAction, c as updateTaxSettingsAction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../../countries.cjs"),t=require("../../../../states.cjs"),n=require("../actions.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("@nextblock-cms/ui");function o({initialData:o,submitLabel:s=`Save tax rate`,compact:c=!1}){let l=e.normalizeCountryCode(o?.country_code)||`US`,[u,d]=(0,r.useState)(l),[f,p]=(0,r.useState)(t.normalizeSubdivisionCode(l,o?.state_code)||o?.state_code||``),m=(0,r.useMemo)(()=>t.getStatesForCountry(u),[u]),h=t.countryUsesStructuredStates(u);return(0,i.jsxs)(`form`,{action:n.saveTaxRateAction,className:`space-y-4`,children:[o?.id?(0,i.jsx)(`input`,{type:`hidden`,name:`id`,value:o.id}):null,(0,i.jsxs)(`div`,{className:c?`grid gap-4 md:grid-cols-4`:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(a.Label,{htmlFor:o?.id?`country-${o.id}`:`tax-rate-country`,children:`Country`}),(0,i.jsx)(`select`,{id:o?.id?`country-${o.id}`:`tax-rate-country`,name:`country_code`,value:u,onChange:e=>{let n=e.target.value,r=t.getStatesForCountry(n);d(n),p(r.some(e=>e.code===f)?f:``)},className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:e.countries.map(e=>(0,i.jsx)(`option`,{value:e.code,children:e.name},e.code))})]}),(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(a.Label,{htmlFor:o?.id?`state-${o.id}`:`tax-rate-state`,children:`State / Province`}),h?(0,i.jsxs)(`select`,{id:o?.id?`state-${o.id}`:`tax-rate-state`,name:`state_code`,value:f,onChange:e=>p(e.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,i.jsx)(`option`,{value:``,children:`Country-wide / federal`}),m.map(e=>(0,i.jsx)(`option`,{value:e.code,children:e.name},e.code))]}):(0,i.jsx)(a.Input,{id:o?.id?`state-${o.id}`:`tax-rate-state`,name:`state_code`,value:f,onChange:e=>p(e.target.value),placeholder:`Optional`})]}),(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(a.Label,{htmlFor:o?.id?`name-${o.id}`:`tax-rate-name`,children:`Tax name`}),(0,i.jsx)(a.Input,{id:o?.id?`name-${o.id}`:`tax-rate-name`,name:`tax_name`,defaultValue:o?.tax_name||``,placeholder:`GST, PST, State Sales Tax`,required:!0})]}),(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(a.Label,{htmlFor:o?.id?`rate-${o.id}`:`tax-rate-rate`,children:`Rate (%)`}),(0,i.jsx)(a.Input,{id:o?.id?`rate-${o.id}`:`tax-rate-rate`,name:`tax_rate`,type:`number`,min:`0`,max:`100`,step:`0.0001`,defaultValue:typeof o?.tax_rate==`number`?o.tax_rate.toString():``,placeholder:`5.0000`,required:!0})]})]}),(0,i.jsx)(`div`,{className:`flex justify-end`,children:(0,i.jsx)(a.Button,{type:`submit`,size:c?`sm`:`default`,children:s})})]})}exports.TaxRateForm=o;
|
|
@@ -4,5 +4,5 @@ interface TaxRateFormProps {
|
|
|
4
4
|
submitLabel?: string;
|
|
5
5
|
compact?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function TaxRateForm({ initialData, submitLabel, compact, }: TaxRateFormProps): import(
|
|
7
|
+
export declare function TaxRateForm({ initialData, submitLabel, compact, }: TaxRateFormProps): import('react').JSX.Element;
|
|
8
8
|
export {};
|