@nextblock-cms/ecom 0.8.6 → 0.8.11
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/index.cjs.js +1 -1
- package/index.es.js +136 -533
- package/lib/CurrencyProvider.cjs.js +1 -0
- package/lib/CurrencyProvider.es.js +99 -0
- package/lib/cart-store.cjs.js +1 -0
- package/{cart-store.es.js → lib/cart-store.es.js} +13 -13
- package/lib/components/AccountNavigationMenu.cjs.js +1 -0
- package/lib/components/AccountNavigationMenu.es.js +44 -0
- package/lib/components/AddToCartButton.cjs.js +1 -0
- package/{AddToCartButton-ffE0DhHu.js → lib/components/AddToCartButton.es.js} +14 -13
- package/lib/components/Cart.cjs.js +1 -0
- package/lib/components/Cart.es.js +148 -0
- package/lib/components/CartDrawer.cjs.js +1 -0
- package/{components → lib/components}/CartDrawer.es.js +15 -14
- package/{components → lib/components}/CartIcon.cjs.js +1 -1
- package/{components → lib/components}/CartIcon.es.js +1 -0
- package/lib/components/Checkout.cjs.js +1 -0
- package/{components → lib/components}/Checkout.es.js +330 -363
- package/lib/components/CouponForm.cjs.js +1 -0
- package/lib/components/CouponForm.es.js +136 -0
- package/lib/components/CurrencySwitcher.cjs.js +1 -0
- package/{components → lib/components}/CurrencySwitcher.es.js +5 -4
- package/lib/components/CustomerProfileForm.cjs.js +1 -0
- package/lib/components/CustomerProfileForm.es.js +355 -0
- package/lib/components/FeaturedProduct.cjs.js +1 -0
- package/{components → lib/components}/FeaturedProduct.es.js +9 -8
- package/lib/components/InvoiceDocument.cjs.js +1 -0
- package/lib/components/InvoiceDocument.es.js +196 -0
- package/lib/components/InvoiceViewerShell.cjs.js +29 -0
- package/lib/components/InvoiceViewerShell.es.js +100 -0
- package/lib/components/ProductCard.cjs.js +1 -0
- package/lib/components/ProductCard.es.js +119 -0
- package/lib/components/ProductDetailsLayout.cjs.js +1 -0
- package/lib/components/ProductDetailsLayout.es.js +361 -0
- package/lib/components/ProductGallery.cjs.js +1 -0
- package/lib/components/ProductGallery.es.js +41 -0
- package/lib/components/ProductGrid.cjs.js +1 -0
- package/lib/components/ProductGrid.es.js +19 -0
- package/lib/components/ShippingEstimator.cjs.js +1 -0
- package/lib/components/ShippingEstimator.es.js +125 -0
- package/lib/components/SubscriptionSelector.cjs.js +1 -0
- package/lib/components/SubscriptionSelector.es.js +140 -0
- package/lib/countries.cjs.js +1 -0
- package/lib/countries.es.js +77 -0
- package/lib/coupon-server.cjs.js +1 -0
- package/{coupon-server-DUKVtyYs.js → lib/coupon-server.es.js} +68 -82
- package/lib/coupons.cjs.js +1 -0
- package/lib/coupons.es.js +17 -0
- package/lib/currency-store.cjs.js +1 -0
- package/lib/currency-store.es.js +27 -0
- package/lib/currency-sync.cjs.js +1 -0
- package/lib/currency-sync.es.js +180 -0
- package/lib/customer-addresses.cjs.js +1 -0
- package/lib/customer-addresses.es.js +116 -0
- package/lib/customer-orders.cjs.js +1 -0
- package/lib/customer-orders.es.js +45 -0
- package/lib/customer.cjs.js +1 -0
- package/{customer-C3xccjUg.js → lib/customer.es.js} +15 -14
- package/lib/export-helpers.cjs.js +1 -0
- package/lib/export-helpers.es.js +56 -0
- package/lib/factory.cjs.js +1 -0
- package/lib/factory.es.js +8 -0
- package/lib/freemius-coupons.cjs.js +1 -0
- package/lib/freemius-coupons.es.js +272 -0
- package/lib/freemius-order-sync.cjs.js +1 -0
- package/lib/freemius-order-sync.es.js +284 -0
- package/lib/inventory-settings.cjs.js +1 -0
- package/lib/inventory-settings.es.js +86 -0
- package/lib/invoice-server.cjs.js +33 -0
- package/lib/invoice-server.es.js +141 -0
- package/lib/invoice-ui.cjs.js +1 -0
- package/lib/invoice-ui.es.js +71 -0
- package/lib/invoice.cjs.js +1 -0
- package/lib/invoice.es.js +102 -0
- package/lib/order-inventory.cjs.js +61 -0
- package/lib/order-inventory.es.js +128 -0
- package/lib/order-tax-details.cjs.js +1 -0
- package/lib/order-tax-details.es.js +164 -0
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +189 -0
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +5 -0
- package/lib/pages/cms/coupons/CouponsPage.es.js +171 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -0
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.es.js +48 -0
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +120 -0
- package/lib/pages/cms/coupons/actions.cjs.js +1 -0
- package/lib/pages/cms/coupons/actions.es.js +128 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +27 -0
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +130 -0
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.es.js +137 -0
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.es.js +22 -0
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.es.js +71 -0
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -0
- package/lib/pages/cms/orders/OrdersPage.es.js +104 -0
- package/lib/pages/cms/orders/actions.cjs.js +7 -0
- package/lib/pages/cms/orders/actions.es.js +71 -0
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +27 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +55 -0
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -0
- package/lib/pages/cms/payments/PaymentsClient.es.js +188 -0
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -0
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -0
- package/lib/pages/cms/payments/actions.cjs.js +1 -0
- package/lib/pages/cms/payments/actions.es.js +23 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -0
- package/lib/pages/cms/payments/queries.es.js +30 -0
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -0
- package/lib/pages/cms/products/ProductsPage.es.js +46 -0
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -0
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +156 -0
- package/lib/pages/cms/products/actions.cjs.js +44 -0
- package/lib/pages/cms/products/actions.es.js +175 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +48 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +291 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +36 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +263 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +114 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +107 -0
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +48 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +86 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +160 -0
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +702 -0
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +104 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +228 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +137 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +36 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +40 -0
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.es.js +408 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +16 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +214 -0
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +95 -0
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -0
- package/lib/pages/cms/products/new/NewProductPage.es.js +76 -0
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +98 -0
- package/lib/pages/cms/products/server-actions.cjs.js +1 -0
- package/lib/pages/cms/products/server-actions.es.js +193 -0
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +211 -0
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -0
- package/lib/pages/cms/shipping/components/RateForm.es.js +441 -0
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +228 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +159 -0
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -0
- package/lib/pages/cms/taxes/TaxesPage.es.js +172 -0
- package/lib/pages/cms/taxes/actions.cjs.js +1 -0
- package/lib/pages/cms/taxes/actions.es.js +57 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +100 -0
- package/lib/product-actions.cjs.js +237 -0
- package/lib/product-actions.es.js +524 -0
- package/lib/product-context.cjs.js +1 -0
- package/lib/product-context.es.js +16 -0
- package/lib/product-schema.cjs.js +1 -0
- package/lib/product-schema.es.js +134 -0
- package/lib/providers/freemius.cjs.js +5 -0
- package/lib/providers/freemius.es.js +538 -0
- package/lib/providers/stripe.cjs.js +1 -0
- package/lib/providers/stripe.es.js +473 -0
- package/lib/server-actions/coupon-actions.cjs.js +1 -0
- package/lib/server-actions/coupon-actions.es.js +23 -0
- package/lib/server-actions/customer-actions.cjs.js +1 -0
- package/lib/server-actions/customer-actions.es.js +30 -0
- package/lib/server-actions/product-actions.cjs.js +1 -0
- package/{server-actions → lib/server-actions}/product-actions.es.js +5 -4
- package/lib/server-actions/shipping-actions.cjs.js +1 -0
- package/{shipping-actions-BnHjlo2q.js → lib/server-actions/shipping-actions.es.js} +9 -7
- package/lib/server-actions/tax-actions.cjs.js +1 -0
- package/lib/server-actions/tax-actions.es.js +40 -0
- package/lib/shared-inventory.cjs.js +15 -0
- package/lib/shared-inventory.es.js +171 -0
- package/lib/shipping/resolver.cjs.js +7 -0
- package/lib/shipping/resolver.es.js +62 -0
- package/lib/shipping-rate-currency.cjs.js +1 -0
- package/lib/shipping-rate-currency.es.js +72 -0
- package/lib/states.cjs.js +1 -0
- package/{states-DlHJezQ1.js → lib/states.es.js} +27 -100
- package/lib/stripe/checkout.cjs.js +1 -0
- package/lib/stripe/checkout.es.js +182 -0
- package/lib/stripe/client.cjs.js +1 -0
- package/lib/stripe/client.es.js +7 -0
- package/lib/stripe/order-sync.cjs.js +1 -0
- package/lib/stripe/order-sync.es.js +130 -0
- package/lib/stripe/webhooks.cjs.js +1 -0
- package/lib/stripe/webhooks.es.js +30 -0
- package/lib/tax-calculation.cjs.js +1 -0
- package/lib/tax-calculation.es.js +101 -0
- package/lib/trials.cjs.js +1 -0
- package/{trials-RDcRAZKx.js → lib/trials.es.js} +9 -9
- package/{use-cart.es.js → lib/use-cart.es.js} +1 -0
- package/lib/zod-config.cjs.js +1 -0
- package/lib/zod-config.es.js +6 -0
- package/package.json +6 -6
- package/server.cjs.js +1 -110
- package/server.es.js +178 -6052
- package/AddToCartButton-DsSEH9yp.cjs +0 -1
- package/CouponForm-BI_5SBHQ.js +0 -152
- package/CouponForm-D_uu2bLP.cjs +0 -1
- package/CurrencyProvider-Cg-Q6ucj.cjs +0 -1
- package/CurrencyProvider-OzlRN96V.js +0 -120
- package/CurrencyProvider.cjs.js +0 -1
- package/CurrencyProvider.es.js +0 -10
- package/ProductDetailsLayout-BxJH_BxR.cjs +0 -1
- package/ProductDetailsLayout-Dg8dRTYp.js +0 -530
- package/ProductGrid-BdL7iglO.cjs +0 -1
- package/ProductGrid-D3AWM8sr.js +0 -130
- package/actions-AHmBrS5e.cjs +0 -48
- package/actions-j5fuSZX-.js +0 -820
- package/cart-store.cjs.js +0 -1
- package/components/Cart.cjs.js +0 -1
- package/components/Cart.es.js +0 -259
- package/components/CartDrawer.cjs.js +0 -1
- package/components/Checkout.cjs.js +0 -1
- package/components/CurrencySwitcher.cjs.js +0 -1
- package/components/FeaturedProduct.cjs.js +0 -1
- package/components/ProductDetailsLayout.cjs.js +0 -1
- package/components/ProductDetailsLayout.es.js +0 -19
- package/components/ProductGrid.cjs.js +0 -1
- package/components/ProductGrid.es.js +0 -6
- package/coupon-server-C9ySm3I5.cjs +0 -1
- package/customer-C-UPvrYN.cjs +0 -1
- package/invoice-ui-CAnJPu6n.cjs +0 -29
- package/invoice-ui-DtpbTJE1.js +0 -2886
- package/product-actions-CONBF8i6.cjs +0 -251
- package/product-actions-DjlIWCMH.js +0 -691
- package/resolver-Fz_FKsfX.cjs +0 -7
- package/resolver-cfrCaHpE.js +0 -128
- package/server-actions/product-actions.cjs.js +0 -1
- package/shipping-actions-D6zt20gg.cjs +0 -1
- package/states-CWYRxV4B.cjs +0 -1
- package/tax-calculation-Dab89aHd.js +0 -181
- package/tax-calculation-MkDKOEkL.cjs +0 -1
- package/trials-DvZaOtNy.cjs +0 -1
- /package/{components → lib/components}/SimpleTiptapRenderer.cjs.js +0 -0
- /package/{components → lib/components}/SimpleTiptapRenderer.es.js +0 -0
- /package/{currency-constants.cjs.js → lib/currency-constants.cjs.js} +0 -0
- /package/{currency-constants.es.js → lib/currency-constants.es.js} +0 -0
- /package/{currency-rest-client-uolJxUkL.cjs → lib/currency-rest-client.cjs.js} +0 -0
- /package/{currency-rest-client-CwoqdgAP.js → lib/currency-rest-client.es.js} +0 -0
- /package/{currency.cjs.js → lib/currency.cjs.js} +0 -0
- /package/{currency.es.js → lib/currency.es.js} +0 -0
- /package/{types.cjs.js → lib/types.cjs.js} +0 -0
- /package/{types.es.js → lib/types.es.js} +0 -0
- /package/{use-cart.cjs.js → lib/use-cart.cjs.js} +0 -0
- /package/{variation-utils.cjs.js → lib/variation-utils.cjs.js} +0 -0
- /package/{variation-utils.es.js → lib/variation-utils.es.js} +0 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useState as h, useEffect as O, useMemo as z } from "react";
|
|
4
|
+
import { Dialog as T, DialogTrigger as U, Button as u, DialogContent as q, DialogHeader as Q, DialogTitle as W, DialogDescription as A, Label as f, Input as w, Card as C, Checkbox as E, DialogFooter as H } from "@nextblock-cms/ui";
|
|
5
|
+
import { Edit2 as G, Plus as J, Search as K, MapPin as R } from "lucide-react";
|
|
6
|
+
import { countries as k } from "../../../../countries.es.js";
|
|
7
|
+
import { getStatesForCountry as V } from "../../../../states.es.js";
|
|
8
|
+
import { updateShippingZone as X, createShippingZone as Y } from "../server-actions.es.js";
|
|
9
|
+
function P(d = []) {
|
|
10
|
+
return [...new Set(d.map((o) => o.country_code))];
|
|
11
|
+
}
|
|
12
|
+
function j(d = []) {
|
|
13
|
+
return d.reduce((o, a) => {
|
|
14
|
+
if (!a.state_code)
|
|
15
|
+
return o;
|
|
16
|
+
const c = new Set(o[a.country_code] || []);
|
|
17
|
+
return c.add(a.state_code), o[a.country_code] = [...c], o;
|
|
18
|
+
}, {});
|
|
19
|
+
}
|
|
20
|
+
function D(d, o) {
|
|
21
|
+
return d.flatMap((a) => {
|
|
22
|
+
const c = o[a] || [];
|
|
23
|
+
return c.length === 0 ? [{ country_code: a, state_code: null }] : c.map((i) => ({
|
|
24
|
+
country_code: a,
|
|
25
|
+
state_code: i
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function ce({ mode: d = "create", initialData: o }) {
|
|
30
|
+
const [a, c] = h(!1), i = d === "edit", [p, x] = h(o?.name || ""), [v, N] = h(o?.priority_order || 0), [m, b] = h(
|
|
31
|
+
P(o?.locations)
|
|
32
|
+
), [_, g] = h(
|
|
33
|
+
j(o?.locations)
|
|
34
|
+
), [y, S] = h(""), [$, L] = h(!1);
|
|
35
|
+
O(() => {
|
|
36
|
+
a && (x(o?.name || ""), N(o?.priority_order || 0), b(P(o?.locations)), g(j(o?.locations)), S(""));
|
|
37
|
+
}, [o, a]);
|
|
38
|
+
const B = z(() => {
|
|
39
|
+
const e = y.trim().toLowerCase();
|
|
40
|
+
return e ? k.filter(
|
|
41
|
+
(t) => t.name.toLowerCase().includes(e) || t.code.toLowerCase().includes(e)
|
|
42
|
+
) : k;
|
|
43
|
+
}, [y]), Z = z(() => k.filter((e) => m.includes(e.code)), [m]), I = (e) => {
|
|
44
|
+
b(
|
|
45
|
+
(t) => t.includes(e) ? t.filter((l) => l !== e) : [...t, e]
|
|
46
|
+
), g((t) => {
|
|
47
|
+
if (t[e]) {
|
|
48
|
+
const l = { ...t };
|
|
49
|
+
return delete l[e], l;
|
|
50
|
+
}
|
|
51
|
+
return t;
|
|
52
|
+
});
|
|
53
|
+
}, M = (e, t) => {
|
|
54
|
+
g((l) => {
|
|
55
|
+
const n = new Set(l[e] || []);
|
|
56
|
+
return n.has(t) ? n.delete(t) : n.add(t), {
|
|
57
|
+
...l,
|
|
58
|
+
[e]: [...n]
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return /* @__PURE__ */ s(T, { open: a, onOpenChange: c, children: [
|
|
63
|
+
/* @__PURE__ */ r(U, { asChild: !0, children: i ? /* @__PURE__ */ r(u, { variant: "ghost", size: "icon", className: "h-8 w-8 text-slate-400 hover:text-primary", children: /* @__PURE__ */ r(G, { className: "h-4 w-4" }) }) : /* @__PURE__ */ s(u, { className: "gap-2 shadow-sm", children: [
|
|
64
|
+
/* @__PURE__ */ r(J, { className: "h-4 w-4" }),
|
|
65
|
+
"New Zone"
|
|
66
|
+
] }) }),
|
|
67
|
+
/* @__PURE__ */ r(q, { className: "max-w-4xl max-h-[90vh] flex flex-col overflow-hidden", children: /* @__PURE__ */ s("form", { onSubmit: async (e) => {
|
|
68
|
+
if (e.preventDefault(), !p || m.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
L(!0);
|
|
71
|
+
const t = D(m, _), l = i && o?.id ? await X(o.id, p, v, t) : await Y(p, v, t);
|
|
72
|
+
L(!1), l.success ? (c(!1), i || (x(""), N(0), b([]), g({}), S(""))) : l.error && alert(l.error);
|
|
73
|
+
}, className: "flex h-full flex-col overflow-hidden", children: [
|
|
74
|
+
/* @__PURE__ */ s(Q, { children: [
|
|
75
|
+
/* @__PURE__ */ r(W, { children: i ? "Edit Shipping Zone" : "Create Shipping Zone" }),
|
|
76
|
+
/* @__PURE__ */ r(A, { children: "Select countries first, then optionally limit a zone to specific states or provinces. Leaving state selections empty keeps the whole country in the zone." })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ s("div", { className: "grid gap-6 overflow-y-auto py-6 pr-2", children: [
|
|
79
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-4 items-center gap-4", children: [
|
|
80
|
+
/* @__PURE__ */ r(f, { htmlFor: "name", className: "text-right", children: "Zone Name" }),
|
|
81
|
+
/* @__PURE__ */ r(
|
|
82
|
+
w,
|
|
83
|
+
{
|
|
84
|
+
id: "name",
|
|
85
|
+
value: p,
|
|
86
|
+
onChange: (e) => x(e.target.value),
|
|
87
|
+
placeholder: "e.g. North America, Canada East, US West",
|
|
88
|
+
className: "col-span-3",
|
|
89
|
+
required: !0
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] }),
|
|
93
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-4 items-center gap-4", children: [
|
|
94
|
+
/* @__PURE__ */ r(f, { htmlFor: "priority", className: "text-right", children: "Priority Order" }),
|
|
95
|
+
/* @__PURE__ */ r(
|
|
96
|
+
w,
|
|
97
|
+
{
|
|
98
|
+
id: "priority",
|
|
99
|
+
type: "number",
|
|
100
|
+
value: v,
|
|
101
|
+
onChange: (e) => N(Number(e.target.value)),
|
|
102
|
+
className: "col-span-3"
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }),
|
|
106
|
+
/* @__PURE__ */ s("div", { className: "grid gap-6 lg:grid-cols-[1.2fr_1fr]", children: [
|
|
107
|
+
/* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
108
|
+
/* @__PURE__ */ s("div", { className: "flex items-end justify-between gap-3", children: [
|
|
109
|
+
/* @__PURE__ */ s(f, { className: "text-sm font-semibold", children: [
|
|
110
|
+
"Countries (",
|
|
111
|
+
m.length,
|
|
112
|
+
")"
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ s("div", { className: "relative w-full max-w-xs", children: [
|
|
115
|
+
/* @__PURE__ */ r(K, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-slate-400" }),
|
|
116
|
+
/* @__PURE__ */ r(
|
|
117
|
+
w,
|
|
118
|
+
{
|
|
119
|
+
placeholder: "Search countries...",
|
|
120
|
+
className: "pl-9 h-9",
|
|
121
|
+
value: y,
|
|
122
|
+
onChange: (e) => S(e.target.value)
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] })
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ r(C, { className: "border-slate-200 bg-slate-50/30 p-4 dark:border-slate-800 dark:bg-slate-900/30", children: /* @__PURE__ */ r("div", { className: "grid max-h-[360px] grid-cols-1 gap-3 overflow-y-auto pr-1 sm:grid-cols-2", children: B.map((e) => {
|
|
128
|
+
const t = m.includes(e.code);
|
|
129
|
+
return /* @__PURE__ */ s(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${t ? "border-primary/30 bg-primary/5 text-primary" : "border-transparent hover:bg-slate-100 dark:hover:bg-slate-800/60"}`,
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ r(
|
|
135
|
+
E,
|
|
136
|
+
{
|
|
137
|
+
id: `country-${e.code}`,
|
|
138
|
+
checked: t,
|
|
139
|
+
onCheckedChange: () => I(e.code)
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ s(
|
|
143
|
+
"label",
|
|
144
|
+
{
|
|
145
|
+
htmlFor: `country-${e.code}`,
|
|
146
|
+
className: "flex-1 cursor-pointer text-xs py-1",
|
|
147
|
+
children: [
|
|
148
|
+
e.name,
|
|
149
|
+
" (",
|
|
150
|
+
e.code,
|
|
151
|
+
")"
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
e.code
|
|
158
|
+
);
|
|
159
|
+
}) }) })
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
162
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
163
|
+
/* @__PURE__ */ r(R, { className: "h-4 w-4 text-slate-500" }),
|
|
164
|
+
/* @__PURE__ */ r(f, { className: "text-sm font-semibold", children: "States / Provinces" })
|
|
165
|
+
] }),
|
|
166
|
+
Z.length === 0 ? /* @__PURE__ */ r(C, { className: "border-dashed p-4 text-sm text-muted-foreground", children: "Select one or more countries to optionally narrow the zone to specific states or provinces." }) : /* @__PURE__ */ r("div", { className: "space-y-4", children: Z.map((e) => {
|
|
167
|
+
const t = V(e.code), l = _[e.code] || [];
|
|
168
|
+
return /* @__PURE__ */ r(C, { className: "p-4", children: /* @__PURE__ */ s("div", { className: "space-y-3", children: [
|
|
169
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3", children: [
|
|
170
|
+
/* @__PURE__ */ s("div", { children: [
|
|
171
|
+
/* @__PURE__ */ s("p", { className: "font-medium", children: [
|
|
172
|
+
e.name,
|
|
173
|
+
" (",
|
|
174
|
+
e.code,
|
|
175
|
+
")"
|
|
176
|
+
] }),
|
|
177
|
+
/* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground", children: t.length > 0 ? "Leave all unchecked to apply this zone to the whole country." : "This country uses a country-level zone in the current UI." })
|
|
178
|
+
] }),
|
|
179
|
+
/* @__PURE__ */ r("span", { className: "text-xs text-muted-foreground", children: l.length > 0 ? `${l.length} selected` : "Whole country" })
|
|
180
|
+
] }),
|
|
181
|
+
t.length > 0 ? /* @__PURE__ */ r("div", { className: "grid max-h-[220px] grid-cols-1 gap-2 overflow-y-auto pr-1 sm:grid-cols-2", children: t.map((n) => {
|
|
182
|
+
const F = l.includes(n.code);
|
|
183
|
+
return /* @__PURE__ */ s(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${F ? "border-primary/30 bg-primary/5 text-primary" : "border-transparent hover:bg-slate-50 dark:hover:bg-slate-800/60"}`,
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ r(
|
|
189
|
+
E,
|
|
190
|
+
{
|
|
191
|
+
id: `${e.code}-${n.code}`,
|
|
192
|
+
checked: F,
|
|
193
|
+
onCheckedChange: () => M(e.code, n.code)
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
/* @__PURE__ */ s(
|
|
197
|
+
"label",
|
|
198
|
+
{
|
|
199
|
+
htmlFor: `${e.code}-${n.code}`,
|
|
200
|
+
className: "flex-1 cursor-pointer text-xs py-1",
|
|
201
|
+
children: [
|
|
202
|
+
n.name,
|
|
203
|
+
" (",
|
|
204
|
+
n.code,
|
|
205
|
+
")"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
`${e.code}-${n.code}`
|
|
212
|
+
);
|
|
213
|
+
}) }) : null
|
|
214
|
+
] }) }, e.code);
|
|
215
|
+
}) })
|
|
216
|
+
] })
|
|
217
|
+
] })
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ s(H, { className: "mt-auto border-t pt-4", children: [
|
|
220
|
+
/* @__PURE__ */ r(u, { type: "button", variant: "ghost", onClick: () => c(!1), children: "Cancel" }),
|
|
221
|
+
/* @__PURE__ */ r(u, { type: "submit", disabled: $ || !p || m.length === 0, children: $ ? i ? "Updating..." : "Creating..." : i ? "Save Changes" : "Create Zone" })
|
|
222
|
+
] })
|
|
223
|
+
] }) })
|
|
224
|
+
] });
|
|
225
|
+
}
|
|
226
|
+
export {
|
|
227
|
+
ce as ZoneForm
|
|
228
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nextblock-cms/db/server"),a=require("next/cache"),C=require("next/navigation"),S=require("../../../countries.cjs.js"),g=require("../../../currency.cjs.js"),l=require("../../../inventory-settings.cjs.js"),_=require("../../../shipping-rate-currency.cjs.js"),z=require("../../../states.cjs.js");function h(o){return Object.entries(o||{}).reduce((e,[n,t])=>{const r=n.trim().toLowerCase(),s=t.trim();return r&&s&&(e[r]=s),e},{})}async function A(o){const e=c.createClient(),{data:{user:n}}=await e.auth.getUser();if(!n)throw new Error("Unauthorized");const{data:t}=await e.from("profiles").select("role").eq("id",n.id).single();if(!t||t.role!=="ADMIN")throw new Error("Forbidden");const r=o.getAll("trackQuantities").includes("true"),s=await l.getEcommerceInventorySettings(e),{error:i}=await l.upsertEcommerceInventorySettings(e,{trackQuantities:r,enableTaxes:s.enableTaxes,taxCalculationMode:s.taxCalculationMode});if(i)throw new Error(i.message);a.revalidatePath("/cms/shipping"),C.redirect("/cms/shipping?success=Inventory settings updated")}function f(o){const e=new Map;for(const n of o){const t=S.normalizeCountryCode(n.country_code);if(!t)continue;const r=z.normalizeSubdivisionCode(t,n.state_code)||null,s=`${t}:${r??"*"}`;e.set(s,{country_code:t,state_code:r})}return[...e.values()]}async function y(o){const{data:e,error:n}=await o.from("currencies").select("code, is_default").eq("is_active",!0).order("is_default",{ascending:!1}).order("code",{ascending:!0});return n?{error:n.message}:{currencies:e||[]}}async function v(o,e,n){const t=c.getServiceRoleSupabaseClient(),r=f(n),{data:s,error:i}=await t.from("shipping_zones").insert({name:o,priority_order:e}).select().single();if(i||!s)return{error:i?.message||"Failed to create zone"};if(r.length>0){const m=r.map(u=>({zone_id:s.id,country_code:u.country_code,state_code:u.state_code??null})),{error:d}=await t.from("shipping_zone_locations").insert(m);if(d)return{error:d.message}}return a.revalidatePath("/cms/shipping"),{success:!0}}async function w(o,e,n,t){const r=c.getServiceRoleSupabaseClient(),s=f(t),{error:i}=await r.from("shipping_zones").update({name:e,priority_order:n,updated_at:new Date().toISOString()}).eq("id",o);if(i)return{error:i.message||"Failed to update zone"};const{error:m}=await r.from("shipping_zone_locations").delete().eq("zone_id",o);if(m)return{error:"Failed to refresh locations"};if(s.length>0){const d=s.map(p=>({zone_id:o,country_code:p.country_code,state_code:p.state_code??null})),{error:u}=await r.from("shipping_zone_locations").insert(d);if(u)return{error:u.message}}return a.revalidatePath("/cms/shipping"),{success:!0}}async function b(o){const e=c.getServiceRoleSupabaseClient(),{error:n}=await e.from("shipping_zones").delete().eq("id",o);return n?{error:n.message}:(a.revalidatePath("/cms/shipping"),{success:!0})}async function R(o,e){const n=c.getServiceRoleSupabaseClient(),t=await y(n);if("error"in t)return{error:t.error};const r=_.sanitizeShippingRateAmountMaps({currencies:t.currencies.map(i=>g.normalizeCurrencyRecord(i)),mode:e.currencyPricingMode,sourceCurrencyCode:e.sourceCurrencyCode,costAmounts:e.costAmounts,minOrderAmounts:e.minOrderAmounts,fallbackCostAmount:e.cost,fallbackMinOrderAmount:e.minOrderAmount}),{error:s}=await n.from("shipping_zone_methods").insert({zone_id:o,name:e.name.trim(),name_translations:h(e.nameTranslations),method_type:e.type,currency_pricing_mode:r.mode,cost_amount:r.costAmounts[r.sourceCurrencyCode],cost_amounts:r.costAmounts,cost_currency:r.sourceCurrencyCode,min_order_amount:r.minOrderAmounts[r.sourceCurrencyCode],min_order_amounts:r.minOrderAmounts});return s?{error:s.message}:(a.revalidatePath("/cms/shipping"),{success:!0})}async function O(o,e){const n=c.getServiceRoleSupabaseClient(),t=await y(n);if("error"in t)return{error:t.error};const r=_.sanitizeShippingRateAmountMaps({currencies:t.currencies.map(i=>g.normalizeCurrencyRecord(i)),mode:e.currencyPricingMode,sourceCurrencyCode:e.sourceCurrencyCode,costAmounts:e.costAmounts,minOrderAmounts:e.minOrderAmounts,fallbackCostAmount:e.cost,fallbackMinOrderAmount:e.minOrderAmount}),{error:s}=await n.from("shipping_zone_methods").update({name:e.name.trim(),name_translations:h(e.nameTranslations),method_type:e.type,currency_pricing_mode:r.mode,cost_amount:r.costAmounts[r.sourceCurrencyCode],cost_amounts:r.costAmounts,cost_currency:r.sourceCurrencyCode,min_order_amount:r.minOrderAmounts[r.sourceCurrencyCode],min_order_amounts:r.minOrderAmounts,updated_at:new Date().toISOString()}).eq("id",o);return s?{error:s.message}:(a.revalidatePath("/cms/shipping"),{success:!0})}async function q(o){const e=c.getServiceRoleSupabaseClient(),{error:n}=await e.from("shipping_zone_methods").delete().eq("id",o);return n?{error:n.message}:(a.revalidatePath("/cms/shipping"),{success:!0})}exports.createShippingRate=R;exports.createShippingZone=v;exports.deleteShippingRate=q;exports.deleteShippingZone=b;exports.updateInventoryTrackingAction=A;exports.updateShippingRate=O;exports.updateShippingZone=w;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { getServiceRoleSupabaseClient as u, createClient as h } from "@nextblock-cms/db/server";
|
|
3
|
+
import { revalidatePath as c } from "next/cache";
|
|
4
|
+
import { redirect as C } from "next/navigation";
|
|
5
|
+
import { normalizeCountryCode as z } from "../../../countries.es.js";
|
|
6
|
+
import { normalizeCurrencyRecord as l } from "../../../currency.es.js";
|
|
7
|
+
import { getEcommerceInventorySettings as A, upsertEcommerceInventorySettings as w } from "../../../inventory-settings.es.js";
|
|
8
|
+
import { sanitizeShippingRateAmountMaps as f } from "../../../shipping-rate-currency.es.js";
|
|
9
|
+
import { normalizeSubdivisionCode as S } from "../../../states.es.js";
|
|
10
|
+
function _(t) {
|
|
11
|
+
return Object.entries(t || {}).reduce((e, [o, n]) => {
|
|
12
|
+
const r = o.trim().toLowerCase(), s = n.trim();
|
|
13
|
+
return r && s && (e[r] = s), e;
|
|
14
|
+
}, {});
|
|
15
|
+
}
|
|
16
|
+
async function I(t) {
|
|
17
|
+
const e = h(), {
|
|
18
|
+
data: { user: o }
|
|
19
|
+
} = await e.auth.getUser();
|
|
20
|
+
if (!o)
|
|
21
|
+
throw new Error("Unauthorized");
|
|
22
|
+
const { data: n } = await e.from("profiles").select("role").eq("id", o.id).single();
|
|
23
|
+
if (!n || n.role !== "ADMIN")
|
|
24
|
+
throw new Error("Forbidden");
|
|
25
|
+
const r = t.getAll("trackQuantities").includes("true"), s = await A(e), { error: i } = await w(e, {
|
|
26
|
+
trackQuantities: r,
|
|
27
|
+
enableTaxes: s.enableTaxes,
|
|
28
|
+
taxCalculationMode: s.taxCalculationMode
|
|
29
|
+
});
|
|
30
|
+
if (i)
|
|
31
|
+
throw new Error(i.message);
|
|
32
|
+
c("/cms/shipping"), C("/cms/shipping?success=Inventory settings updated");
|
|
33
|
+
}
|
|
34
|
+
function g(t) {
|
|
35
|
+
const e = /* @__PURE__ */ new Map();
|
|
36
|
+
for (const o of t) {
|
|
37
|
+
const n = z(o.country_code);
|
|
38
|
+
if (!n)
|
|
39
|
+
continue;
|
|
40
|
+
const r = S(n, o.state_code) || null, s = `${n}:${r ?? "*"}`;
|
|
41
|
+
e.set(s, {
|
|
42
|
+
country_code: n,
|
|
43
|
+
state_code: r
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return [...e.values()];
|
|
47
|
+
}
|
|
48
|
+
async function y(t) {
|
|
49
|
+
const { data: e, error: o } = await t.from("currencies").select("code, is_default").eq("is_active", !0).order("is_default", { ascending: !1 }).order("code", { ascending: !0 });
|
|
50
|
+
return o ? { error: o.message } : {
|
|
51
|
+
currencies: e || []
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function T(t, e, o) {
|
|
55
|
+
const n = u(), r = g(o), { data: s, error: i } = await n.from("shipping_zones").insert({ name: t, priority_order: e }).select().single();
|
|
56
|
+
if (i || !s)
|
|
57
|
+
return { error: i?.message || "Failed to create zone" };
|
|
58
|
+
if (r.length > 0) {
|
|
59
|
+
const d = r.map((a) => ({
|
|
60
|
+
zone_id: s.id,
|
|
61
|
+
country_code: a.country_code,
|
|
62
|
+
state_code: a.state_code ?? null
|
|
63
|
+
})), { error: m } = await n.from("shipping_zone_locations").insert(d);
|
|
64
|
+
if (m)
|
|
65
|
+
return { error: m.message };
|
|
66
|
+
}
|
|
67
|
+
return c("/cms/shipping"), { success: !0 };
|
|
68
|
+
}
|
|
69
|
+
async function x(t, e, o, n) {
|
|
70
|
+
const r = u(), s = g(n), { error: i } = await r.from("shipping_zones").update({ name: e, priority_order: o, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", t);
|
|
71
|
+
if (i)
|
|
72
|
+
return { error: i.message || "Failed to update zone" };
|
|
73
|
+
const { error: d } = await r.from("shipping_zone_locations").delete().eq("zone_id", t);
|
|
74
|
+
if (d)
|
|
75
|
+
return { error: "Failed to refresh locations" };
|
|
76
|
+
if (s.length > 0) {
|
|
77
|
+
const m = s.map((p) => ({
|
|
78
|
+
zone_id: t,
|
|
79
|
+
country_code: p.country_code,
|
|
80
|
+
state_code: p.state_code ?? null
|
|
81
|
+
})), { error: a } = await r.from("shipping_zone_locations").insert(m);
|
|
82
|
+
if (a)
|
|
83
|
+
return { error: a.message };
|
|
84
|
+
}
|
|
85
|
+
return c("/cms/shipping"), { success: !0 };
|
|
86
|
+
}
|
|
87
|
+
async function F(t) {
|
|
88
|
+
const e = u(), { error: o } = await e.from("shipping_zones").delete().eq("id", t);
|
|
89
|
+
return o ? { error: o.message } : (c("/cms/shipping"), { success: !0 });
|
|
90
|
+
}
|
|
91
|
+
async function L(t, e) {
|
|
92
|
+
const o = u(), n = await y(o);
|
|
93
|
+
if ("error" in n)
|
|
94
|
+
return { error: n.error };
|
|
95
|
+
const r = f({
|
|
96
|
+
currencies: n.currencies.map(
|
|
97
|
+
(i) => l(i)
|
|
98
|
+
),
|
|
99
|
+
mode: e.currencyPricingMode,
|
|
100
|
+
sourceCurrencyCode: e.sourceCurrencyCode,
|
|
101
|
+
costAmounts: e.costAmounts,
|
|
102
|
+
minOrderAmounts: e.minOrderAmounts,
|
|
103
|
+
fallbackCostAmount: e.cost,
|
|
104
|
+
fallbackMinOrderAmount: e.minOrderAmount
|
|
105
|
+
}), { error: s } = await o.from("shipping_zone_methods").insert({
|
|
106
|
+
zone_id: t,
|
|
107
|
+
name: e.name.trim(),
|
|
108
|
+
name_translations: _(e.nameTranslations),
|
|
109
|
+
method_type: e.type,
|
|
110
|
+
currency_pricing_mode: r.mode,
|
|
111
|
+
cost_amount: r.costAmounts[r.sourceCurrencyCode],
|
|
112
|
+
cost_amounts: r.costAmounts,
|
|
113
|
+
cost_currency: r.sourceCurrencyCode,
|
|
114
|
+
min_order_amount: r.minOrderAmounts[r.sourceCurrencyCode],
|
|
115
|
+
min_order_amounts: r.minOrderAmounts
|
|
116
|
+
});
|
|
117
|
+
return s ? { error: s.message } : (c("/cms/shipping"), { success: !0 });
|
|
118
|
+
}
|
|
119
|
+
async function Z(t, e) {
|
|
120
|
+
const o = u(), n = await y(o);
|
|
121
|
+
if ("error" in n)
|
|
122
|
+
return { error: n.error };
|
|
123
|
+
const r = f({
|
|
124
|
+
currencies: n.currencies.map(
|
|
125
|
+
(i) => l(i)
|
|
126
|
+
),
|
|
127
|
+
mode: e.currencyPricingMode,
|
|
128
|
+
sourceCurrencyCode: e.sourceCurrencyCode,
|
|
129
|
+
costAmounts: e.costAmounts,
|
|
130
|
+
minOrderAmounts: e.minOrderAmounts,
|
|
131
|
+
fallbackCostAmount: e.cost,
|
|
132
|
+
fallbackMinOrderAmount: e.minOrderAmount
|
|
133
|
+
}), { error: s } = await o.from("shipping_zone_methods").update({
|
|
134
|
+
name: e.name.trim(),
|
|
135
|
+
name_translations: _(e.nameTranslations),
|
|
136
|
+
method_type: e.type,
|
|
137
|
+
currency_pricing_mode: r.mode,
|
|
138
|
+
cost_amount: r.costAmounts[r.sourceCurrencyCode],
|
|
139
|
+
cost_amounts: r.costAmounts,
|
|
140
|
+
cost_currency: r.sourceCurrencyCode,
|
|
141
|
+
min_order_amount: r.minOrderAmounts[r.sourceCurrencyCode],
|
|
142
|
+
min_order_amounts: r.minOrderAmounts,
|
|
143
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
144
|
+
}).eq("id", t);
|
|
145
|
+
return s ? { error: s.message } : (c("/cms/shipping"), { success: !0 });
|
|
146
|
+
}
|
|
147
|
+
async function D(t) {
|
|
148
|
+
const e = u(), { error: o } = await e.from("shipping_zone_methods").delete().eq("id", t);
|
|
149
|
+
return o ? { error: o.message } : (c("/cms/shipping"), { success: !0 });
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
L as createShippingRate,
|
|
153
|
+
T as createShippingZone,
|
|
154
|
+
D as deleteShippingRate,
|
|
155
|
+
F as deleteShippingZone,
|
|
156
|
+
I as updateInventoryTrackingAction,
|
|
157
|
+
Z as updateShippingRate,
|
|
158
|
+
x as updateShippingZone
|
|
159
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("@nextblock-cms/db/server"),a=require("@nextblock-cms/ui"),n=require("lucide-react"),x=require("next/link"),b=require("../../../inventory-settings.cjs.js"),g=require("../../../states.cjs.js"),f=require("../payments/queries.cjs.js"),u=require("./actions.cjs.js"),m=require("./components/TaxRateForm.cjs.js");function y(s){return`${s.toFixed(4).replace(/\.?0+$/,"")}%`}function v(s){return s.state_code?`${s.country_code} - ${g.resolveSubdivisionName(s.country_code,s.state_code)}`:`${s.country_code} - Country-wide`}async function N({searchParams:s}){const h=o.createClient(),p=o.getServiceRoleSupabaseClient(),[r,j,d]=await Promise.all([b.getEcommerceInventorySettings(h),f.getEnabledPaymentProviders(),p.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")]),l=d.data||[],c=d.error,i=j.stripe;return e.jsxs("div",{className:"mx-auto w-full max-w-6xl space-y-6 px-6 py-8",children:[s?.success?e.jsx("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-700",children:s.success}):null,e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(a.Button,{asChild:!0,variant:"outline",size:"icon","aria-label":"Back to shipping",children:e.jsx(x,{href:"/cms/shipping",children:e.jsx(n.ArrowLeft,{className:"h-4 w-4"})})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Tax Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Stripe tax behavior globally and maintain manual country or state/province tax rates for physical goods."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Badge,{variant:i?"default":"outline",className:"uppercase",children:["Stripe ",i?"Enabled":"Disabled"]}),e.jsx("div",{className:"rounded-full border bg-muted/30 p-3 text-muted-foreground",children:e.jsx(n.Settings2,{className:"h-5 w-5"})})]})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs(a.Card,{children:[e.jsxs(a.CardHeader,{children:[e.jsx(a.CardTitle,{children:"Global Tax Controls"}),e.jsx(a.CardDescription,{children:"Manual mode uses the tax rates below. Automatic mode uses Stripe Tax during Stripe Checkout instead of a free third-party tax API."})]}),e.jsx(a.CardContent,{children:e.jsxs("form",{action:u.updateTaxSettingsAction,className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("input",{type:"hidden",name:"enableTaxes",value:"false"}),e.jsxs("label",{htmlFor:"enable-taxes",className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{id:"enable-taxes",name:"enableTaxes",type:"checkbox",value:"true",defaultChecked:r.enableTaxes,className:"mt-1 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block font-medium",children:"Enable taxes"}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:"When disabled, tax totals resolve to zero even if product or jurisdiction records exist."})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"tax-calculation-mode",className:"text-sm font-medium text-foreground",children:"Tax calculation mode"}),e.jsxs("select",{id:"tax-calculation-mode",name:"taxCalculationMode",defaultValue:r.taxCalculationMode,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"manual",children:"Manual tax rates"}),e.jsx("option",{value:"automatic",children:"Automatic via Stripe Tax"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatic mode depends on your Stripe Tax setup. Manual rates stay saved and can be used again if you switch back later."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(a.Button,{type:"submit",children:"Save Tax Settings"})})]})]})})]}),e.jsxs(a.Card,{children:[e.jsx(a.CardHeader,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(a.CardTitle,{children:"Manual Tax Rates"}),e.jsx(a.CardDescription,{children:"Add combined taxes as separate rows. For example, create both GST and PST for the same province if they should stack."})]}),e.jsx(a.Badge,{variant:r.taxCalculationMode==="manual"?"default":"outline",children:r.taxCalculationMode==="manual"?"Active Mode":"Stored for Manual Mode"})]})}),e.jsxs(a.CardContent,{className:"space-y-6",children:[c?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:"Tax rates couldn't be loaded yet. This usually means the new tax migration hasn't been applied to the current database."}):null,c?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border bg-card p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx(n.ShieldCheck,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"Create a Tax Rate"})]}),e.jsx(m.TaxRateForm,{})]}),e.jsx("div",{className:"space-y-4",children:l.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed bg-muted/10 px-4 py-8 text-center",children:[e.jsx("p",{className:"font-medium",children:"No manual tax rates yet"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Add country-wide or state/province-specific rows to start calculating manual taxes."})]}):l.map(t=>e.jsxs(a.Card,{className:"border-muted",children:[e.jsx(a.CardHeader,{className:"pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.CardTitle,{className:"text-base",children:t.tax_name}),e.jsx(a.CardDescription,{children:v(t)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Badge,{variant:"outline",children:y(Number(t.tax_rate))}),e.jsx("form",{action:async()=>{"use server";await u.deleteTaxRateAction(t.id)},children:e.jsx(a.Button,{type:"submit",variant:"ghost",size:"icon","aria-label":"Delete tax rate",children:e.jsx(n.Trash2,{className:"h-4 w-4"})})})]})]})}),e.jsx(a.CardContent,{children:e.jsx(m.TaxRateForm,{initialData:t,submitLabel:"Update tax rate",compact:!0})})]},t.id))})]})]})]})]}):e.jsxs(a.Card,{className:"border-dashed",children:[e.jsxs(a.CardHeader,{children:[e.jsx(a.CardTitle,{children:"Enable Stripe to configure physical-product taxes"}),e.jsx(a.CardDescription,{children:"Stripe tax settings apply whenever Stripe is enabled for physical products. Freemius still handles taxes on its own digital checkout flow."})]}),e.jsx(a.CardContent,{children:e.jsx(a.Button,{asChild:!0,variant:"outline",children:e.jsx(x,{href:"/cms/payments",children:"Open Payment Settings"})})})]})]})}exports.TaxesPage=N;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e, Fragment as b } from "react/jsx-runtime";
|
|
2
|
+
import { createClient as S, getServiceRoleSupabaseClient as w } from "@nextblock-cms/db/server";
|
|
3
|
+
import { Button as l, Badge as u, Card as n, CardHeader as s, CardTitle as d, CardDescription as c, CardContent as o } from "@nextblock-cms/ui";
|
|
4
|
+
import { ArrowLeft as T, Settings2 as C, ShieldCheck as _, Trash2 as k } from "lucide-react";
|
|
5
|
+
import f from "next/link";
|
|
6
|
+
import { getEcommerceInventorySettings as M } from "../../../inventory-settings.es.js";
|
|
7
|
+
import { resolveSubdivisionName as A } from "../../../states.es.js";
|
|
8
|
+
import { getEnabledPaymentProviders as R } from "../payments/queries.es.js";
|
|
9
|
+
import { updateTaxSettingsAction as P, deleteTaxRateAction as j } from "./actions.es.js";
|
|
10
|
+
import { TaxRateForm as g } from "./components/TaxRateForm.es.js";
|
|
11
|
+
function E(t) {
|
|
12
|
+
return `${t.toFixed(4).replace(/\.?0+$/, "")}%`;
|
|
13
|
+
}
|
|
14
|
+
function F(t) {
|
|
15
|
+
return t.state_code ? `${t.country_code} - ${A(t.country_code, t.state_code)}` : `${t.country_code} - Country-wide`;
|
|
16
|
+
}
|
|
17
|
+
async function U({
|
|
18
|
+
searchParams: t
|
|
19
|
+
}) {
|
|
20
|
+
const y = S(), v = w(), [i, N, h] = await Promise.all([
|
|
21
|
+
M(y),
|
|
22
|
+
R(),
|
|
23
|
+
v.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")
|
|
24
|
+
]), p = h.data || [], x = h.error, m = N.stripe;
|
|
25
|
+
return /* @__PURE__ */ a("div", { className: "mx-auto w-full max-w-6xl space-y-6 px-6 py-8", children: [
|
|
26
|
+
t?.success ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-700", children: t.success }) : null,
|
|
27
|
+
/* @__PURE__ */ a("div", { className: "flex items-center justify-between gap-4", children: [
|
|
28
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-3", children: [
|
|
29
|
+
/* @__PURE__ */ e(l, { asChild: !0, variant: "outline", size: "icon", "aria-label": "Back to shipping", children: /* @__PURE__ */ e(f, { href: "/cms/shipping", children: /* @__PURE__ */ e(T, { className: "h-4 w-4" }) }) }),
|
|
30
|
+
/* @__PURE__ */ a("div", { children: [
|
|
31
|
+
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: "Tax Settings" }),
|
|
32
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Configure Stripe tax behavior globally and maintain manual country or state/province tax rates for physical goods." })
|
|
33
|
+
] })
|
|
34
|
+
] }),
|
|
35
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
36
|
+
/* @__PURE__ */ a(u, { variant: m ? "default" : "outline", className: "uppercase", children: [
|
|
37
|
+
"Stripe ",
|
|
38
|
+
m ? "Enabled" : "Disabled"
|
|
39
|
+
] }),
|
|
40
|
+
/* @__PURE__ */ e("div", { className: "rounded-full border bg-muted/30 p-3 text-muted-foreground", children: /* @__PURE__ */ e(C, { className: "h-5 w-5" }) })
|
|
41
|
+
] })
|
|
42
|
+
] }),
|
|
43
|
+
m ? /* @__PURE__ */ a(b, { children: [
|
|
44
|
+
/* @__PURE__ */ a(n, { children: [
|
|
45
|
+
/* @__PURE__ */ a(s, { children: [
|
|
46
|
+
/* @__PURE__ */ e(d, { children: "Global Tax Controls" }),
|
|
47
|
+
/* @__PURE__ */ e(c, { children: "Manual mode uses the tax rates below. Automatic mode uses Stripe Tax during Stripe Checkout instead of a free third-party tax API." })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ a("form", { action: P, className: "space-y-6", children: [
|
|
50
|
+
/* @__PURE__ */ a("div", { className: "rounded-lg border bg-muted/20 p-4", children: [
|
|
51
|
+
/* @__PURE__ */ e("input", { type: "hidden", name: "enableTaxes", value: "false" }),
|
|
52
|
+
/* @__PURE__ */ a("label", { htmlFor: "enable-taxes", className: "flex cursor-pointer items-start gap-3", children: [
|
|
53
|
+
/* @__PURE__ */ e(
|
|
54
|
+
"input",
|
|
55
|
+
{
|
|
56
|
+
id: "enable-taxes",
|
|
57
|
+
name: "enableTaxes",
|
|
58
|
+
type: "checkbox",
|
|
59
|
+
value: "true",
|
|
60
|
+
defaultChecked: i.enableTaxes,
|
|
61
|
+
className: "mt-1 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ a("span", { className: "space-y-1", children: [
|
|
65
|
+
/* @__PURE__ */ e("span", { className: "block font-medium", children: "Enable taxes" }),
|
|
66
|
+
/* @__PURE__ */ e("span", { className: "block text-sm text-muted-foreground", children: "When disabled, tax totals resolve to zero even if product or jurisdiction records exist." })
|
|
67
|
+
] })
|
|
68
|
+
] })
|
|
69
|
+
] }),
|
|
70
|
+
/* @__PURE__ */ a("div", { className: "grid gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-end", children: [
|
|
71
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
72
|
+
/* @__PURE__ */ e(
|
|
73
|
+
"label",
|
|
74
|
+
{
|
|
75
|
+
htmlFor: "tax-calculation-mode",
|
|
76
|
+
className: "text-sm font-medium text-foreground",
|
|
77
|
+
children: "Tax calculation mode"
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ a(
|
|
81
|
+
"select",
|
|
82
|
+
{
|
|
83
|
+
id: "tax-calculation-mode",
|
|
84
|
+
name: "taxCalculationMode",
|
|
85
|
+
defaultValue: i.taxCalculationMode,
|
|
86
|
+
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ e("option", { value: "manual", children: "Manual tax rates" }),
|
|
89
|
+
/* @__PURE__ */ e("option", { value: "automatic", children: "Automatic via Stripe Tax" })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Automatic mode depends on your Stripe Tax setup. Manual rates stay saved and can be used again if you switch back later." })
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ e("div", { className: "flex justify-end", children: /* @__PURE__ */ e(l, { type: "submit", children: "Save Tax Settings" }) })
|
|
96
|
+
] })
|
|
97
|
+
] }) })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ a(n, { children: [
|
|
100
|
+
/* @__PURE__ */ e(s, { children: /* @__PURE__ */ a("div", { className: "flex items-center justify-between gap-4", children: [
|
|
101
|
+
/* @__PURE__ */ a("div", { children: [
|
|
102
|
+
/* @__PURE__ */ e(d, { children: "Manual Tax Rates" }),
|
|
103
|
+
/* @__PURE__ */ e(c, { children: "Add combined taxes as separate rows. For example, create both GST and PST for the same province if they should stack." })
|
|
104
|
+
] }),
|
|
105
|
+
/* @__PURE__ */ e(u, { variant: i.taxCalculationMode === "manual" ? "default" : "outline", children: i.taxCalculationMode === "manual" ? "Active Mode" : "Stored for Manual Mode" })
|
|
106
|
+
] }) }),
|
|
107
|
+
/* @__PURE__ */ a(o, { className: "space-y-6", children: [
|
|
108
|
+
x ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800", children: "Tax rates couldn't be loaded yet. This usually means the new tax migration hasn't been applied to the current database." }) : null,
|
|
109
|
+
x ? null : /* @__PURE__ */ a(b, { children: [
|
|
110
|
+
/* @__PURE__ */ a("div", { className: "rounded-xl border bg-card p-4", children: [
|
|
111
|
+
/* @__PURE__ */ a("div", { className: "mb-4 flex items-center gap-2", children: [
|
|
112
|
+
/* @__PURE__ */ e(_, { className: "h-4 w-4 text-primary" }),
|
|
113
|
+
/* @__PURE__ */ e("h2", { className: "font-semibold", children: "Create a Tax Rate" })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ e(g, {})
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ e("div", { className: "space-y-4", children: p.length === 0 ? /* @__PURE__ */ a("div", { className: "rounded-xl border border-dashed bg-muted/10 px-4 py-8 text-center", children: [
|
|
118
|
+
/* @__PURE__ */ e("p", { className: "font-medium", children: "No manual tax rates yet" }),
|
|
119
|
+
/* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: "Add country-wide or state/province-specific rows to start calculating manual taxes." })
|
|
120
|
+
] }) : p.map((r) => /* @__PURE__ */ a(n, { className: "border-muted", children: [
|
|
121
|
+
/* @__PURE__ */ e(s, { className: "pb-4", children: /* @__PURE__ */ a("div", { className: "flex items-start justify-between gap-4", children: [
|
|
122
|
+
/* @__PURE__ */ a("div", { className: "space-y-1", children: [
|
|
123
|
+
/* @__PURE__ */ e(d, { className: "text-base", children: r.tax_name }),
|
|
124
|
+
/* @__PURE__ */ e(c, { children: F(r) })
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
127
|
+
/* @__PURE__ */ e(u, { variant: "outline", children: E(Number(r.tax_rate)) }),
|
|
128
|
+
/* @__PURE__ */ e(
|
|
129
|
+
"form",
|
|
130
|
+
{
|
|
131
|
+
action: async () => {
|
|
132
|
+
"use server";
|
|
133
|
+
await j(r.id);
|
|
134
|
+
},
|
|
135
|
+
children: /* @__PURE__ */ e(
|
|
136
|
+
l,
|
|
137
|
+
{
|
|
138
|
+
type: "submit",
|
|
139
|
+
variant: "ghost",
|
|
140
|
+
size: "icon",
|
|
141
|
+
"aria-label": "Delete tax rate",
|
|
142
|
+
children: /* @__PURE__ */ e(k, { className: "h-4 w-4" })
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] })
|
|
148
|
+
] }) }),
|
|
149
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(
|
|
150
|
+
g,
|
|
151
|
+
{
|
|
152
|
+
initialData: r,
|
|
153
|
+
submitLabel: "Update tax rate",
|
|
154
|
+
compact: !0
|
|
155
|
+
}
|
|
156
|
+
) })
|
|
157
|
+
] }, r.id)) })
|
|
158
|
+
] })
|
|
159
|
+
] })
|
|
160
|
+
] })
|
|
161
|
+
] }) : /* @__PURE__ */ a(n, { className: "border-dashed", children: [
|
|
162
|
+
/* @__PURE__ */ a(s, { children: [
|
|
163
|
+
/* @__PURE__ */ e(d, { children: "Enable Stripe to configure physical-product taxes" }),
|
|
164
|
+
/* @__PURE__ */ e(c, { children: "Stripe tax settings apply whenever Stripe is enabled for physical products. Freemius still handles taxes on its own digital checkout flow." })
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(l, { asChild: !0, variant: "outline", children: /* @__PURE__ */ e(f, { href: "/cms/payments", children: "Open Payment Settings" }) }) })
|
|
167
|
+
] })
|
|
168
|
+
] });
|
|
169
|
+
}
|
|
170
|
+
export {
|
|
171
|
+
U as TaxesPage
|
|
172
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@nextblock-cms/db/server"),i=require("next/cache"),w=require("next/navigation"),x=require("../../../countries.cjs.js"),g=require("../../../inventory-settings.cjs.js"),h=require("../../../states.cjs.js");async function c(){const t=m.createClient(),{data:{user:e}}=await t.auth.getUser();if(!e)throw new Error("Unauthorized");const{data:a}=await t.from("profiles").select("role").eq("id",e.id).single();if(!a||a.role!=="ADMIN")throw new Error("Forbidden");return t}async function y(t){const e=await c(),a=await g.getEcommerceInventorySettings(e),r=t.getAll("enableTaxes").includes("true"),o=t.get("taxCalculationMode")==="automatic"?"automatic":"manual",{error:n}=await g.upsertEcommerceInventorySettings(e,{trackQuantities:a.trackQuantities,enableTaxes:r,taxCalculationMode:o});if(n)throw new Error(n.message);i.revalidatePath("/cms/shipping"),i.revalidatePath("/cms/settings/taxes"),w.redirect("/cms/settings/taxes?success=Tax settings updated")}async function p(t){const e=await c(),a=String(t.get("id")||"").trim(),r=x.normalizeCountryCode(String(t.get("country_code")||"").trim()),o=String(t.get("state_code")||"").trim(),n=String(t.get("tax_name")||"").trim(),s=Number(t.get("tax_rate"));if(!r)throw new Error("Country code is required.");if(!n)throw new Error("Tax name is required.");if(!Number.isFinite(s)||s<0||s>100)throw new Error("Tax rate must be between 0 and 100.");const u={country_code:r,state_code:h.normalizeSubdivisionCode(r,o)||null,tax_name:n,tax_rate:s},l=a?e.from("tax_rates").update(u).eq("id",a):e.from("tax_rates").insert(u),{error:d}=await l;if(d)throw new Error(d.message);i.revalidatePath("/cms/settings/taxes")}async function b(t){const e=await c(),{error:a}=await e.from("tax_rates").delete().eq("id",t);if(a)throw new Error(a.message);i.revalidatePath("/cms/settings/taxes")}exports.deleteTaxRateAction=b;exports.saveTaxRateAction=p;exports.updateTaxSettingsAction=y;
|