@nextblock-cms/ecom 0.8.6 → 0.8.7
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 +4 -4
- 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,114 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { useState as o, useTransition as k, useEffect as N } from "react";
|
|
4
|
+
import { Dialog as F, DialogTrigger as A, Button as h, DialogContent as M, DialogHeader as O, DialogTitle as V, DialogDescription as j, Label as E, Select as R, SelectTrigger as B, SelectValue as H, SelectContent as I, SelectItem as S, DialogFooter as U, DialogClose as _ } from "@nextblock-cms/ui";
|
|
5
|
+
import { getProductTranslations as $, copyProductFromLanguageAction as q } from "../actions.es.js";
|
|
6
|
+
import { useRouter as z } from "next/navigation";
|
|
7
|
+
import { Copy as J, CheckCircle2 as K, AlertCircle as Q } from "lucide-react";
|
|
8
|
+
function te({
|
|
9
|
+
productId: i,
|
|
10
|
+
currentLanguageId: v,
|
|
11
|
+
translationGroupId: l,
|
|
12
|
+
allSiteLanguages: p
|
|
13
|
+
}) {
|
|
14
|
+
const [d, m] = o(!1), [n, x] = o(null), [f, b] = o([]), [y, C] = o(!1), [s, c] = o(null), [u, T] = k(), w = z();
|
|
15
|
+
N(() => {
|
|
16
|
+
d && l && (async () => {
|
|
17
|
+
C(!0);
|
|
18
|
+
try {
|
|
19
|
+
const g = (await $(l)).filter((L) => L.id !== i);
|
|
20
|
+
b(g);
|
|
21
|
+
} catch (a) {
|
|
22
|
+
console.error("Error fetching translations:", a);
|
|
23
|
+
} finally {
|
|
24
|
+
C(!1);
|
|
25
|
+
}
|
|
26
|
+
})();
|
|
27
|
+
}, [d, l, i]);
|
|
28
|
+
const D = async () => {
|
|
29
|
+
if (!n) {
|
|
30
|
+
c({
|
|
31
|
+
type: "error",
|
|
32
|
+
text: "Please select a source version to copy from."
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
c(null), T(async () => {
|
|
37
|
+
const t = await q(i, n);
|
|
38
|
+
t.success ? (c({
|
|
39
|
+
type: "success",
|
|
40
|
+
text: "Content copied successfully. The page will now refresh."
|
|
41
|
+
}), setTimeout(() => {
|
|
42
|
+
m(!1), w.refresh();
|
|
43
|
+
}, 1500)) : c({
|
|
44
|
+
type: "error",
|
|
45
|
+
text: t.error || "Failed to copy content."
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}, P = p.find((t) => t.id === v);
|
|
49
|
+
return /* @__PURE__ */ r(F, { open: d, onOpenChange: m, children: [
|
|
50
|
+
/* @__PURE__ */ e(A, { asChild: !0, children: /* @__PURE__ */ r(h, { variant: "outline", title: "Copy content from another language", children: [
|
|
51
|
+
/* @__PURE__ */ e(J, { className: "h-4 w-4 mr-2" }),
|
|
52
|
+
"Copy Content..."
|
|
53
|
+
] }) }),
|
|
54
|
+
/* @__PURE__ */ r(M, { children: [
|
|
55
|
+
/* @__PURE__ */ r(O, { children: [
|
|
56
|
+
/* @__PURE__ */ e(V, { children: "Copy Content from Another Language" }),
|
|
57
|
+
/* @__PURE__ */ r(j, { children: [
|
|
58
|
+
"Select a source version to copy from. This will replace the title, description, and media of the current product (",
|
|
59
|
+
P?.name,
|
|
60
|
+
"). This action cannot be undone."
|
|
61
|
+
] })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ r("div", { className: "space-y-4 py-4", children: [
|
|
64
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
65
|
+
/* @__PURE__ */ e(E, { htmlFor: "sourceProduct", children: "Select Source Version" }),
|
|
66
|
+
/* @__PURE__ */ r(
|
|
67
|
+
R,
|
|
68
|
+
{
|
|
69
|
+
onValueChange: (t) => x(t),
|
|
70
|
+
disabled: u || y,
|
|
71
|
+
value: n || void 0,
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ e(B, { id: "sourceProduct", children: /* @__PURE__ */ e(H, { placeholder: y ? "Loading versions..." : "Select a version..." }) }),
|
|
74
|
+
/* @__PURE__ */ e(I, { children: f.length > 0 ? f.map((t) => {
|
|
75
|
+
const a = p.find((g) => g.id === t.language_id);
|
|
76
|
+
return /* @__PURE__ */ r(S, { value: t.id, children: [
|
|
77
|
+
t.title,
|
|
78
|
+
" (",
|
|
79
|
+
a?.name || "Unknown Language",
|
|
80
|
+
")"
|
|
81
|
+
] }, t.id);
|
|
82
|
+
}) : /* @__PURE__ */ e(S, { value: "none", disabled: !0, children: "No other versions available" }) })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
] }),
|
|
87
|
+
s && /* @__PURE__ */ r(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
className: `p-3 rounded-md text-sm flex items-center gap-2 ${s.type === "success" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" : "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,
|
|
91
|
+
children: [
|
|
92
|
+
s.type === "success" ? /* @__PURE__ */ e(K, { className: "h-5 w-5" }) : /* @__PURE__ */ e(Q, { className: "h-5 w-5" }),
|
|
93
|
+
s.text
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ r(U, { children: [
|
|
99
|
+
/* @__PURE__ */ e(_, { asChild: !0, children: /* @__PURE__ */ e(h, { variant: "outline", children: "Cancel" }) }),
|
|
100
|
+
/* @__PURE__ */ e(
|
|
101
|
+
h,
|
|
102
|
+
{
|
|
103
|
+
onClick: D,
|
|
104
|
+
disabled: u || !n || n === "none",
|
|
105
|
+
children: u ? "Copying..." : "Copy Content & Replace"
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] })
|
|
109
|
+
] })
|
|
110
|
+
] });
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
te as CopyProductFromLanguage
|
|
114
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@nextblock-cms/ui"),y=require("../../../../currency.cjs.js");function j({idPrefix:s="currency",currencies:l,prices:u,salePrices:m,managedCurrencyCodes:p=[],onPriceChange:x,onSalePriceChange:f,readOnly:g=!1,helperText:c,trailing:o}){const b=l.find(n=>n.is_default)??l[0],h=new Set(p);return b?e.jsxs("div",{className:"flex flex-col gap-2",children:[c&&e.jsx("p",{className:"text-xs text-muted-foreground bg-muted/20 p-2 rounded-md border",children:c}),e.jsx("div",{className:"divide-y divide-muted/50",children:l.map(n=>{const t=y.normalizeCurrencyRecord(n),d=t.is_default!==!0&&h.has(t.code),i=g||d;return e.jsxs("div",{className:"flex flex-wrap items-stretch gap-4 py-3 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"flex items-center gap-2 w-[160px] shrink-0 self-stretch border-r border-border/50 pr-4",children:[e.jsx("span",{className:"text-sm font-black tracking-tighter text-foreground",children:t.code}),e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:t.symbol}),t.is_default?e.jsx("span",{className:"text-[9px] uppercase font-bold bg-primary/10 text-primary px-1.5 py-0.5 rounded tracking-widest leading-none",children:"Default"}):d?e.jsx("span",{className:"text-[9px] uppercase font-bold bg-muted text-muted-foreground px-1.5 py-0.5 rounded tracking-widest leading-none",children:"Auto"}):null,!t.is_default&&e.jsxs("span",{className:"text-[9px] text-muted-foreground/80 font-medium tracking-wide leading-none ml-auto",children:["x",t.exchange_rate]})]}),e.jsxs("div",{className:"grid flex-1 grid-cols-2 items-end gap-3 sm:grid-cols-4",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(a.Label,{htmlFor:`${s}-price-${t.code}`,className:"block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",children:"Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none",children:t.symbol}),e.jsx(a.Input,{id:`${s}-price-${t.code}`,type:"number",step:"0.01",min:"0",value:u[t.code]??"",disabled:i,className:"h-8 w-full text-sm pl-6",onChange:r=>x(t.code,Number(r.target.value||0))})]})]}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(a.Label,{htmlFor:`${s}-sale-price-${t.code}`,className:"block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",children:"Sale"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none",children:t.symbol}),e.jsx(a.Input,{id:`${s}-sale-price-${t.code}`,type:"number",step:"0.01",min:"0",value:m[t.code]??"",disabled:i,placeholder:d?"Auto":"—",className:"h-8 w-full text-sm pl-6",onChange:r=>f(t.code,r.target.value===""?null:Number(r.target.value))})]})]}),o&&t.is_default?o:null]})]},t.code)})})]}):null}exports.CurrencyPriceFields=j;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Label as m, Input as u } from "@nextblock-cms/ui";
|
|
4
|
+
import { normalizeCurrencyRecord as v } from "../../../../currency.es.js";
|
|
5
|
+
function $({
|
|
6
|
+
idPrefix: a = "currency",
|
|
7
|
+
currencies: d,
|
|
8
|
+
prices: p,
|
|
9
|
+
salePrices: f,
|
|
10
|
+
managedCurrencyCodes: x = [],
|
|
11
|
+
onPriceChange: g,
|
|
12
|
+
onSalePriceChange: h,
|
|
13
|
+
readOnly: b = !1,
|
|
14
|
+
helperText: o,
|
|
15
|
+
trailing: c
|
|
16
|
+
}) {
|
|
17
|
+
const N = d.find((n) => n.is_default) ?? d[0], y = new Set(x);
|
|
18
|
+
return N ? /* @__PURE__ */ r("div", { className: "flex flex-col gap-2", children: [
|
|
19
|
+
o && /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground bg-muted/20 p-2 rounded-md border", children: o }),
|
|
20
|
+
/* @__PURE__ */ t("div", { className: "divide-y divide-muted/50", children: d.map((n) => {
|
|
21
|
+
const e = v(n), s = e.is_default !== !0 && y.has(e.code), i = b || s;
|
|
22
|
+
return /* @__PURE__ */ r(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
className: "flex flex-wrap items-stretch gap-4 py-3 first:pt-0 last:pb-0",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 w-[160px] shrink-0 self-stretch border-r border-border/50 pr-4", children: [
|
|
28
|
+
/* @__PURE__ */ t("span", { className: "text-sm font-black tracking-tighter text-foreground", children: e.code }),
|
|
29
|
+
/* @__PURE__ */ t("span", { className: "text-[11px] text-muted-foreground font-medium", children: e.symbol }),
|
|
30
|
+
e.is_default ? /* @__PURE__ */ t("span", { className: "text-[9px] uppercase font-bold bg-primary/10 text-primary px-1.5 py-0.5 rounded tracking-widest leading-none", children: "Default" }) : s ? /* @__PURE__ */ t("span", { className: "text-[9px] uppercase font-bold bg-muted text-muted-foreground px-1.5 py-0.5 rounded tracking-widest leading-none", children: "Auto" }) : null,
|
|
31
|
+
!e.is_default && /* @__PURE__ */ r("span", { className: "text-[9px] text-muted-foreground/80 font-medium tracking-wide leading-none ml-auto", children: [
|
|
32
|
+
"x",
|
|
33
|
+
e.exchange_rate
|
|
34
|
+
] })
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ r("div", { className: "grid flex-1 grid-cols-2 items-end gap-3 sm:grid-cols-4", children: [
|
|
37
|
+
/* @__PURE__ */ r("div", { className: "min-w-0 space-y-1", children: [
|
|
38
|
+
/* @__PURE__ */ t(
|
|
39
|
+
m,
|
|
40
|
+
{
|
|
41
|
+
htmlFor: `${a}-price-${e.code}`,
|
|
42
|
+
className: "block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",
|
|
43
|
+
children: "Price"
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ r("div", { className: "relative", children: [
|
|
47
|
+
/* @__PURE__ */ t("span", { className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none", children: e.symbol }),
|
|
48
|
+
/* @__PURE__ */ t(
|
|
49
|
+
u,
|
|
50
|
+
{
|
|
51
|
+
id: `${a}-price-${e.code}`,
|
|
52
|
+
type: "number",
|
|
53
|
+
step: "0.01",
|
|
54
|
+
min: "0",
|
|
55
|
+
value: p[e.code] ?? "",
|
|
56
|
+
disabled: i,
|
|
57
|
+
className: "h-8 w-full text-sm pl-6",
|
|
58
|
+
onChange: (l) => g(
|
|
59
|
+
e.code,
|
|
60
|
+
Number(l.target.value || 0)
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] })
|
|
65
|
+
] }),
|
|
66
|
+
/* @__PURE__ */ r("div", { className: "min-w-0 space-y-1", children: [
|
|
67
|
+
/* @__PURE__ */ t(
|
|
68
|
+
m,
|
|
69
|
+
{
|
|
70
|
+
htmlFor: `${a}-sale-price-${e.code}`,
|
|
71
|
+
className: "block text-[10px] uppercase font-bold text-muted-foreground tracking-widest",
|
|
72
|
+
children: "Sale"
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ r("div", { className: "relative", children: [
|
|
76
|
+
/* @__PURE__ */ t("span", { className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-xs text-muted-foreground font-bold pointer-events-none", children: e.symbol }),
|
|
77
|
+
/* @__PURE__ */ t(
|
|
78
|
+
u,
|
|
79
|
+
{
|
|
80
|
+
id: `${a}-sale-price-${e.code}`,
|
|
81
|
+
type: "number",
|
|
82
|
+
step: "0.01",
|
|
83
|
+
min: "0",
|
|
84
|
+
value: f[e.code] ?? "",
|
|
85
|
+
disabled: i,
|
|
86
|
+
placeholder: s ? "Auto" : "—",
|
|
87
|
+
className: "h-8 w-full text-sm pl-6",
|
|
88
|
+
onChange: (l) => h(
|
|
89
|
+
e.code,
|
|
90
|
+
l.target.value === "" ? null : Number(l.target.value)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
] })
|
|
95
|
+
] }),
|
|
96
|
+
c && e.is_default ? c : null
|
|
97
|
+
] })
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
e.code
|
|
101
|
+
);
|
|
102
|
+
}) })
|
|
103
|
+
] }) : null;
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
$ as CurrencyPriceFields
|
|
107
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("@nextblock-cms/ui"),f=require("react"),g=require("lucide-react"),y=require("next/navigation");function p({productName:u,isIcon:c=!1,className:r,redirectTo:n,deleteAction:l}){const[e,d]=f.useTransition(),o=y.useRouter(),i=async s=>{s.preventDefault(),s.stopPropagation(),window.confirm(`Are you sure you want to delete "${u}"? This action cannot be undone.`)&&d(async()=>{try{await l(),n?o.push(n):o.refresh()}catch(h){console.error("Failed to delete product:",h),alert("Failed to delete product. Please try again.")}})};return c?t.jsx(a.Button,{variant:"ghost",size:"icon",onClick:i,disabled:e,className:`text-red-500 hover:text-red-600 hover:bg-red-50 ${r}`,title:"Delete Product",children:t.jsx(g.Trash2,{className:"h-4 w-4"})}):t.jsx(a.Button,{variant:"destructive",onClick:i,disabled:e,className:r,type:"button",children:e?"Deleting...":"Delete Product"})}exports.DeleteProductButton=p;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Button as s } from "@nextblock-cms/ui";
|
|
4
|
+
import { useTransition as p } from "react";
|
|
5
|
+
import { Trash2 as h } from "lucide-react";
|
|
6
|
+
import { useRouter as m } from "next/navigation";
|
|
7
|
+
function b({
|
|
8
|
+
productName: l,
|
|
9
|
+
isIcon: c = !1,
|
|
10
|
+
className: r,
|
|
11
|
+
redirectTo: o,
|
|
12
|
+
deleteAction: d
|
|
13
|
+
}) {
|
|
14
|
+
const [e, u] = p(), n = m(), i = async (a) => {
|
|
15
|
+
a.preventDefault(), a.stopPropagation(), window.confirm(`Are you sure you want to delete "${l}"? This action cannot be undone.`) && u(async () => {
|
|
16
|
+
try {
|
|
17
|
+
await d(), o ? n.push(o) : n.refresh();
|
|
18
|
+
} catch (f) {
|
|
19
|
+
console.error("Failed to delete product:", f), alert("Failed to delete product. Please try again.");
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
return c ? /* @__PURE__ */ t(
|
|
24
|
+
s,
|
|
25
|
+
{
|
|
26
|
+
variant: "ghost",
|
|
27
|
+
size: "icon",
|
|
28
|
+
onClick: i,
|
|
29
|
+
disabled: e,
|
|
30
|
+
className: `text-red-500 hover:text-red-600 hover:bg-red-50 ${r}`,
|
|
31
|
+
title: "Delete Product",
|
|
32
|
+
children: /* @__PURE__ */ t(h, { className: "h-4 w-4" })
|
|
33
|
+
}
|
|
34
|
+
) : /* @__PURE__ */ t(
|
|
35
|
+
s,
|
|
36
|
+
{
|
|
37
|
+
variant: "destructive",
|
|
38
|
+
onClick: i,
|
|
39
|
+
disabled: e,
|
|
40
|
+
className: r,
|
|
41
|
+
type: "button",
|
|
42
|
+
children: e ? "Deleting..." : "Delete Product"
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
b as DeleteProductButton
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("react"),r=require("@nextblock-cms/ui"),o=require("sonner"),m=require("../actions.cjs.js");function b({plans:l}){return e.jsx("div",{className:"w-full",children:l&&l.length>0?e.jsx("div",{className:"space-y-8",children:l.map(a=>e.jsxs("div",{className:"w-full",children:[l.length>1&&e.jsx("h3",{className:"font-semibold text-lg text-slate-700 dark:text-slate-300 border-b pb-2 mb-4 mt-6",children:a.title||a.name}),e.jsx("div",{className:`${l.length>1?"rounded-lg border":"rounded-b-lg border-x border-b"} overflow-x-auto dark:border-slate-700 bg-card`,children:e.jsxs(r.Table,{children:[e.jsx(r.TableHeader,{children:e.jsxs(r.TableRow,{children:[e.jsx(r.TableHead,{children:"Licenses"}),e.jsx(r.TableHead,{children:"API Monthly"}),e.jsx(r.TableHead,{children:"Override Monthly"}),e.jsx(r.TableHead,{children:"API Annual"}),e.jsx(r.TableHead,{children:"Override Annual"}),e.jsx(r.TableHead,{children:"API Lifetime"}),e.jsx(r.TableHead,{children:"Override Lifetime"})]})}),e.jsx(r.TableBody,{children:a.freemius_pricing&&a.freemius_pricing.length>0?a.freemius_pricing.map(s=>e.jsx(x,{pricing:s},s.id)):e.jsx(r.TableRow,{children:e.jsx(r.TableCell,{colSpan:7,className:"text-center text-slate-500 py-4",children:"No pricing configurations found for this plan."})})})]})})]},a.id))}):e.jsxs("div",{className:"text-center py-10 bg-slate-50 dark:bg-slate-800/50 rounded border border-dashed border-slate-300 dark:border-slate-700",children:[e.jsx("p",{className:"text-slate-500",children:"No Freemius plans synchronized yet."}),e.jsx("p",{className:"text-xs mt-2 text-slate-400",children:"Click the full synchronization button to import from Freemius."})]})})}function x({pricing:l}){const[a,s]=h.useTransition(),i=(t,d)=>{const n=d===""?null:parseFloat(d);d!==""&&Number.isNaN(n)||s(async()=>{const{success:c,error:u}=await m.updateFreemiusOverride(l.id,{[t]:n});c?o.toast.success("Pricing override saved"):o.toast.error(u||"Failed to update pricing")})};return e.jsxs(r.TableRow,{children:[e.jsx(r.TableCell,{className:"font-medium",children:l.license_quota||"Unlimited"}),e.jsx(r.TableCell,{className:"text-slate-500",children:l.api_monthly_price?`$${l.api_monthly_price}`:"-"}),e.jsx(r.TableCell,{children:e.jsx(r.Input,{type:"number",step:"0.01",placeholder:"Override...",defaultValue:l.override_monthly_price||"",onBlur:t=>{t.target.value!==(l.override_monthly_price?.toString()||"")&&i("override_monthly_price",t.target.value)},className:"w-24 h-8",disabled:a})}),e.jsx(r.TableCell,{className:"text-slate-500",children:l.api_annual_price?`$${l.api_annual_price}`:"-"}),e.jsx(r.TableCell,{children:e.jsx(r.Input,{type:"number",step:"0.01",placeholder:"Override...",defaultValue:l.override_annual_price||"",onBlur:t=>{t.target.value!==(l.override_annual_price?.toString()||"")&&i("override_annual_price",t.target.value)},className:"w-24 h-8",disabled:a})}),e.jsx(r.TableCell,{className:"text-slate-500",children:l.api_lifetime_price?`$${l.api_lifetime_price}`:"-"}),e.jsx(r.TableCell,{children:e.jsx(r.Input,{type:"number",step:"0.01",placeholder:"Override...",defaultValue:l.override_lifetime_price||"",onBlur:t=>{t.target.value!==(l.override_lifetime_price?.toString()||"")&&i("override_lifetime_price",t.target.value)},className:"w-24 h-8",disabled:a})})]})}exports.FreemiusPricingDashboard=b;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
3
|
+
import { useTransition as _ } from "react";
|
|
4
|
+
import { Table as b, TableHeader as v, TableRow as m, TableHead as a, TableBody as N, TableCell as l, Input as c } from "@nextblock-cms/ui";
|
|
5
|
+
import { toast as h } from "sonner";
|
|
6
|
+
import { updateFreemiusOverride as x } from "../actions.es.js";
|
|
7
|
+
function $({ plans: r }) {
|
|
8
|
+
return /* @__PURE__ */ e("div", { className: "w-full", children: r && r.length > 0 ? /* @__PURE__ */ e("div", { className: "space-y-8", children: r.map((t) => /* @__PURE__ */ d("div", { className: "w-full", children: [
|
|
9
|
+
r.length > 1 && /* @__PURE__ */ e("h3", { className: "font-semibold text-lg text-slate-700 dark:text-slate-300 border-b pb-2 mb-4 mt-6", children: t.title || t.name }),
|
|
10
|
+
/* @__PURE__ */ e("div", { className: `${r.length > 1 ? "rounded-lg border" : "rounded-b-lg border-x border-b"} overflow-x-auto dark:border-slate-700 bg-card`, children: /* @__PURE__ */ d(b, { children: [
|
|
11
|
+
/* @__PURE__ */ e(v, { children: /* @__PURE__ */ d(m, { children: [
|
|
12
|
+
/* @__PURE__ */ e(a, { children: "Licenses" }),
|
|
13
|
+
/* @__PURE__ */ e(a, { children: "API Monthly" }),
|
|
14
|
+
/* @__PURE__ */ e(a, { children: "Override Monthly" }),
|
|
15
|
+
/* @__PURE__ */ e(a, { children: "API Annual" }),
|
|
16
|
+
/* @__PURE__ */ e(a, { children: "Override Annual" }),
|
|
17
|
+
/* @__PURE__ */ e(a, { children: "API Lifetime" }),
|
|
18
|
+
/* @__PURE__ */ e(a, { children: "Override Lifetime" })
|
|
19
|
+
] }) }),
|
|
20
|
+
/* @__PURE__ */ e(N, { children: t.freemius_pricing && t.freemius_pricing.length > 0 ? t.freemius_pricing.map((n) => /* @__PURE__ */ e(y, { pricing: n }, n.id)) : /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(l, { colSpan: 7, className: "text-center text-slate-500 py-4", children: "No pricing configurations found for this plan." }) }) })
|
|
21
|
+
] }) })
|
|
22
|
+
] }, t.id)) }) : /* @__PURE__ */ d("div", { className: "text-center py-10 bg-slate-50 dark:bg-slate-800/50 rounded border border-dashed border-slate-300 dark:border-slate-700", children: [
|
|
23
|
+
/* @__PURE__ */ e("p", { className: "text-slate-500", children: "No Freemius plans synchronized yet." }),
|
|
24
|
+
/* @__PURE__ */ e("p", { className: "text-xs mt-2 text-slate-400", children: "Click the full synchronization button to import from Freemius." })
|
|
25
|
+
] }) });
|
|
26
|
+
}
|
|
27
|
+
function y({ pricing: r }) {
|
|
28
|
+
const [t, n] = _(), s = (i, o) => {
|
|
29
|
+
const u = o === "" ? null : parseFloat(o);
|
|
30
|
+
o !== "" && Number.isNaN(u) || n(async () => {
|
|
31
|
+
const { success: f, error: p } = await x(r.id, { [i]: u });
|
|
32
|
+
f ? h.success("Pricing override saved") : h.error(p || "Failed to update pricing");
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
return /* @__PURE__ */ d(m, { children: [
|
|
36
|
+
/* @__PURE__ */ e(l, { className: "font-medium", children: r.license_quota || "Unlimited" }),
|
|
37
|
+
/* @__PURE__ */ e(l, { className: "text-slate-500", children: r.api_monthly_price ? `$${r.api_monthly_price}` : "-" }),
|
|
38
|
+
/* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(
|
|
39
|
+
c,
|
|
40
|
+
{
|
|
41
|
+
type: "number",
|
|
42
|
+
step: "0.01",
|
|
43
|
+
placeholder: "Override...",
|
|
44
|
+
defaultValue: r.override_monthly_price || "",
|
|
45
|
+
onBlur: (i) => {
|
|
46
|
+
i.target.value !== (r.override_monthly_price?.toString() || "") && s("override_monthly_price", i.target.value);
|
|
47
|
+
},
|
|
48
|
+
className: "w-24 h-8",
|
|
49
|
+
disabled: t
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ e(l, { className: "text-slate-500", children: r.api_annual_price ? `$${r.api_annual_price}` : "-" }),
|
|
53
|
+
/* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(
|
|
54
|
+
c,
|
|
55
|
+
{
|
|
56
|
+
type: "number",
|
|
57
|
+
step: "0.01",
|
|
58
|
+
placeholder: "Override...",
|
|
59
|
+
defaultValue: r.override_annual_price || "",
|
|
60
|
+
onBlur: (i) => {
|
|
61
|
+
i.target.value !== (r.override_annual_price?.toString() || "") && s("override_annual_price", i.target.value);
|
|
62
|
+
},
|
|
63
|
+
className: "w-24 h-8",
|
|
64
|
+
disabled: t
|
|
65
|
+
}
|
|
66
|
+
) }),
|
|
67
|
+
/* @__PURE__ */ e(l, { className: "text-slate-500", children: r.api_lifetime_price ? `$${r.api_lifetime_price}` : "-" }),
|
|
68
|
+
/* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(
|
|
69
|
+
c,
|
|
70
|
+
{
|
|
71
|
+
type: "number",
|
|
72
|
+
step: "0.01",
|
|
73
|
+
placeholder: "Override...",
|
|
74
|
+
defaultValue: r.override_lifetime_price || "",
|
|
75
|
+
onBlur: (i) => {
|
|
76
|
+
i.target.value !== (r.override_lifetime_price?.toString() || "") && s("override_lifetime_price", i.target.value);
|
|
77
|
+
},
|
|
78
|
+
className: "w-24 h-8",
|
|
79
|
+
disabled: t
|
|
80
|
+
}
|
|
81
|
+
) })
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
$ as FreemiusPricingDashboard
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react"),u=require("lucide-react"),q=require("@nextblock-cms/utils"),a=require("@nextblock-cms/ui"),L=require("../server-actions.cjs.js"),x=require("sonner");function P({categories:d=[],selectedIds:s=[],onChange:m,placeholder:v="Select categories..."}){const[h,w]=n.useState(!1),[l,g]=n.useState(""),[o,f]=n.useState(d),[p,b]=n.useState(!1);n.useEffect(()=>{f(d)},[d]);const y=n.useMemo(()=>o.filter(e=>s.includes(e.id)),[o,s]),j=n.useMemo(()=>{if(!l)return o;const e=l.toLowerCase();return o.filter(t=>t.name.toLowerCase().includes(e)||t.slug.toLowerCase().includes(e))},[o,l]),i=l.trim(),C=n.useMemo(()=>{if(!i)return!1;const e=i.toLowerCase();return!o.some(t=>t.name.toLowerCase()===e)},[o,i]),N=async()=>{if(i){b(!0);try{const e=await L.createCategoryAction({name:i});if(e.success&&e.category){const t={id:e.category.id,name:e.category.name,slug:e.category.slug};f(c=>[...c,t]),m([...s,t.id]),g(""),x.toast.success(`Category "${t.name}" created successfully.`)}else x.toast.error(e.error||"Failed to create category.")}catch(e){x.toast.error(e.message||"An error occurred while creating category.")}finally{b(!1)}}},k=e=>{const t=s.includes(e)?s.filter(c=>c!==e):[...s,e];m(t)},S=(e,t)=>{t.stopPropagation(),m(s.filter(c=>c!==e))};return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5 min-h-[32px] p-1 border rounded-md bg-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",children:y.length===0?r.jsx("span",{className:"text-xs text-muted-foreground self-center px-2 py-1 select-none",children:"No categories selected."}):y.map(e=>r.jsxs(a.Badge,{variant:"secondary",className:"pl-2 pr-1.5 py-0.5 text-xs flex items-center gap-1 bg-amber-500/10 text-amber-800 dark:text-amber-300 border border-amber-500/20 rounded-full",children:[e.name,r.jsx("button",{type:"button",onClick:t=>S(e.id,t),className:"rounded-full p-0.5 text-muted-foreground hover:bg-amber-500/20 hover:text-amber-950 dark:hover:text-amber-50 transition-colors cursor-pointer","aria-label":`Remove ${e.name}`,children:r.jsx(u.X,{className:"h-3 w-3"})})]},e.id))}),r.jsxs(a.Popover,{open:h,onOpenChange:w,children:[r.jsx(a.PopoverTrigger,{asChild:!0,children:r.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":h,className:"w-full justify-between h-8 text-xs font-normal",children:[r.jsx("span",{className:"truncate",children:s.length>0?`${s.length} categor${s.length===1?"y":"ies"} selected`:v}),r.jsx(u.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),r.jsxs(a.PopoverContent,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:[r.jsxs("div",{className:"flex items-center border-b px-3",children:[r.jsx(u.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx(a.Input,{className:"flex h-9 w-full rounded-md bg-transparent py-2 text-xs outline-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"Search categories...",value:l,onChange:e=>g(e.target.value)})]}),C&&r.jsx("div",{className:"border-b border-border/50 p-1",children:r.jsxs(a.Button,{type:"button",variant:"ghost",size:"sm",className:"w-full justify-start text-xs h-8 text-amber-600 dark:text-amber-400 hover:text-amber-700 hover:bg-amber-500/10 cursor-pointer",onClick:N,disabled:p,children:[p?r.jsx(u.Loader2,{className:"mr-2 h-3 w-3 animate-spin"}):r.jsx("span",{className:"font-bold mr-1.5",children:"+"}),'Create category "',i,'"']})}),r.jsx("div",{className:"max-h-60 overflow-y-auto p-1",children:j.length===0?r.jsx("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No categories found."}):r.jsx("div",{className:"flex flex-col gap-0.5",children:j.map(e=>{const t=s.includes(e.id);return r.jsxs("div",{onClick:()=>k(e.id),className:q.cn("relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-xs outline-none hover:bg-accent hover:text-accent-foreground text-left transition-colors",t&&"bg-accent/40 font-medium"),children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center pointer-events-none",children:r.jsx(a.Checkbox,{checked:t,tabIndex:-1,"aria-label":`Toggle ${e.name}`,className:"h-3.5 w-3.5"})}),r.jsxs("span",{className:"flex flex-col",children:[r.jsx("span",{children:e.name}),r.jsxs("span",{className:"font-mono text-[9px] text-muted-foreground leading-none",children:["/",e.slug]})]}),t&&r.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(u.Check,{className:"h-3.5 w-3.5 text-primary"})})]},e.id)})})})]})]})]})}exports.ProductCategorySelector=P;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useState as c, useEffect as P, useMemo as u } from "react";
|
|
4
|
+
import { X as $, ChevronsUpDown as O, Search as Q, Loader2 as T, Check as q } from "lucide-react";
|
|
5
|
+
import { cn as A } from "@nextblock-cms/utils";
|
|
6
|
+
import { Badge as B, Popover as R, PopoverTrigger as z, Button as w, PopoverContent as D, Input as E, Checkbox as F } from "@nextblock-cms/ui";
|
|
7
|
+
import { createCategoryAction as M } from "../server-actions.es.js";
|
|
8
|
+
import { toast as h } from "sonner";
|
|
9
|
+
function W({
|
|
10
|
+
categories: m = [],
|
|
11
|
+
selectedIds: o = [],
|
|
12
|
+
onChange: d,
|
|
13
|
+
placeholder: N = "Select categories..."
|
|
14
|
+
}) {
|
|
15
|
+
const [f, C] = c(!1), [l, p] = c(""), [n, g] = c(m), [x, b] = c(!1);
|
|
16
|
+
P(() => {
|
|
17
|
+
g(m);
|
|
18
|
+
}, [m]);
|
|
19
|
+
const y = u(() => n.filter((e) => o.includes(e.id)), [n, o]), v = u(() => {
|
|
20
|
+
if (!l) return n;
|
|
21
|
+
const e = l.toLowerCase();
|
|
22
|
+
return n.filter(
|
|
23
|
+
(t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e)
|
|
24
|
+
);
|
|
25
|
+
}, [n, l]), s = l.trim(), k = u(() => {
|
|
26
|
+
if (!s) return !1;
|
|
27
|
+
const e = s.toLowerCase();
|
|
28
|
+
return !n.some((t) => t.name.toLowerCase() === e);
|
|
29
|
+
}, [n, s]), L = async () => {
|
|
30
|
+
if (s) {
|
|
31
|
+
b(!0);
|
|
32
|
+
try {
|
|
33
|
+
const e = await M({ name: s });
|
|
34
|
+
if (e.success && e.category) {
|
|
35
|
+
const t = {
|
|
36
|
+
id: e.category.id,
|
|
37
|
+
name: e.category.name,
|
|
38
|
+
slug: e.category.slug
|
|
39
|
+
};
|
|
40
|
+
g((i) => [...i, t]), d([...o, t.id]), p(""), h.success(`Category "${t.name}" created successfully.`);
|
|
41
|
+
} else
|
|
42
|
+
h.error(e.error || "Failed to create category.");
|
|
43
|
+
} catch (e) {
|
|
44
|
+
h.error(e.message || "An error occurred while creating category.");
|
|
45
|
+
} finally {
|
|
46
|
+
b(!1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, j = (e) => {
|
|
50
|
+
const t = o.includes(e) ? o.filter((i) => i !== e) : [...o, e];
|
|
51
|
+
d(t);
|
|
52
|
+
}, S = (e, t) => {
|
|
53
|
+
t.stopPropagation(), d(o.filter((i) => i !== e));
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
56
|
+
/* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1.5 min-h-[32px] p-1 border rounded-md bg-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2", children: y.length === 0 ? /* @__PURE__ */ r("span", { className: "text-xs text-muted-foreground self-center px-2 py-1 select-none", children: "No categories selected." }) : y.map((e) => /* @__PURE__ */ a(
|
|
57
|
+
B,
|
|
58
|
+
{
|
|
59
|
+
variant: "secondary",
|
|
60
|
+
className: "pl-2 pr-1.5 py-0.5 text-xs flex items-center gap-1 bg-amber-500/10 text-amber-800 dark:text-amber-300 border border-amber-500/20 rounded-full",
|
|
61
|
+
children: [
|
|
62
|
+
e.name,
|
|
63
|
+
/* @__PURE__ */ r(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
type: "button",
|
|
67
|
+
onClick: (t) => S(e.id, t),
|
|
68
|
+
className: "rounded-full p-0.5 text-muted-foreground hover:bg-amber-500/20 hover:text-amber-950 dark:hover:text-amber-50 transition-colors cursor-pointer",
|
|
69
|
+
"aria-label": `Remove ${e.name}`,
|
|
70
|
+
children: /* @__PURE__ */ r($, { className: "h-3 w-3" })
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
e.id
|
|
76
|
+
)) }),
|
|
77
|
+
/* @__PURE__ */ a(R, { open: f, onOpenChange: C, children: [
|
|
78
|
+
/* @__PURE__ */ r(z, { asChild: !0, children: /* @__PURE__ */ a(
|
|
79
|
+
w,
|
|
80
|
+
{
|
|
81
|
+
variant: "outline",
|
|
82
|
+
role: "combobox",
|
|
83
|
+
"aria-expanded": f,
|
|
84
|
+
className: "w-full justify-between h-8 text-xs font-normal",
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ r("span", { className: "truncate", children: o.length > 0 ? `${o.length} categor${o.length === 1 ? "y" : "ies"} selected` : N }),
|
|
87
|
+
/* @__PURE__ */ r(O, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
) }),
|
|
91
|
+
/* @__PURE__ */ a(D, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: [
|
|
92
|
+
/* @__PURE__ */ a("div", { className: "flex items-center border-b px-3", children: [
|
|
93
|
+
/* @__PURE__ */ r(Q, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
94
|
+
/* @__PURE__ */ r(
|
|
95
|
+
E,
|
|
96
|
+
{
|
|
97
|
+
className: "flex h-9 w-full rounded-md bg-transparent py-2 text-xs outline-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",
|
|
98
|
+
placeholder: "Search categories...",
|
|
99
|
+
value: l,
|
|
100
|
+
onChange: (e) => p(e.target.value)
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
] }),
|
|
104
|
+
k && /* @__PURE__ */ r("div", { className: "border-b border-border/50 p-1", children: /* @__PURE__ */ a(
|
|
105
|
+
w,
|
|
106
|
+
{
|
|
107
|
+
type: "button",
|
|
108
|
+
variant: "ghost",
|
|
109
|
+
size: "sm",
|
|
110
|
+
className: "w-full justify-start text-xs h-8 text-amber-600 dark:text-amber-400 hover:text-amber-700 hover:bg-amber-500/10 cursor-pointer",
|
|
111
|
+
onClick: L,
|
|
112
|
+
disabled: x,
|
|
113
|
+
children: [
|
|
114
|
+
x ? /* @__PURE__ */ r(T, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ r("span", { className: "font-bold mr-1.5", children: "+" }),
|
|
115
|
+
'Create category "',
|
|
116
|
+
s,
|
|
117
|
+
'"'
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
) }),
|
|
121
|
+
/* @__PURE__ */ r("div", { className: "max-h-60 overflow-y-auto p-1", children: v.length === 0 ? /* @__PURE__ */ r("p", { className: "py-4 text-center text-xs text-muted-foreground", children: "No categories found." }) : /* @__PURE__ */ r("div", { className: "flex flex-col gap-0.5", children: v.map((e) => {
|
|
122
|
+
const t = o.includes(e.id);
|
|
123
|
+
return /* @__PURE__ */ a(
|
|
124
|
+
"div",
|
|
125
|
+
{
|
|
126
|
+
onClick: () => j(e.id),
|
|
127
|
+
className: A(
|
|
128
|
+
"relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-xs outline-none hover:bg-accent hover:text-accent-foreground text-left transition-colors",
|
|
129
|
+
t && "bg-accent/40 font-medium"
|
|
130
|
+
),
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ r("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center pointer-events-none", children: /* @__PURE__ */ r(
|
|
133
|
+
F,
|
|
134
|
+
{
|
|
135
|
+
checked: t,
|
|
136
|
+
tabIndex: -1,
|
|
137
|
+
"aria-label": `Toggle ${e.name}`,
|
|
138
|
+
className: "h-3.5 w-3.5"
|
|
139
|
+
}
|
|
140
|
+
) }),
|
|
141
|
+
/* @__PURE__ */ a("span", { className: "flex flex-col", children: [
|
|
142
|
+
/* @__PURE__ */ r("span", { children: e.name }),
|
|
143
|
+
/* @__PURE__ */ a("span", { className: "font-mono text-[9px] text-muted-foreground leading-none", children: [
|
|
144
|
+
"/",
|
|
145
|
+
e.slug
|
|
146
|
+
] })
|
|
147
|
+
] }),
|
|
148
|
+
t && /* @__PURE__ */ r("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ r(q, { className: "h-3.5 w-3.5 text-primary" }) })
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
e.id
|
|
152
|
+
);
|
|
153
|
+
}) }) })
|
|
154
|
+
] })
|
|
155
|
+
] })
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
W as ProductCategorySelector
|
|
160
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),Be=require("@hookform/resolvers/zod"),L=require("lucide-react"),t=require("@nextblock-cms/ui"),Oe=require("../../../../product-schema.cjs.js"),Ue=require("react-hook-form"),ze=require("./ProductMediaManager.cjs.js"),Le=require("./SyncFreemiusPricingButton.cjs.js"),Ke=require("./VariationsEditor.cjs.js"),je=require("./CurrencyPriceFields.cjs.js"),ve=require("./SaleScheduleFields.cjs.js"),$e=require("./ProductCategorySelector.cjs.js"),H=require("../product-price-sync.cjs.js"),He=require("../../../../types.cjs.js"),Ne=require("../../../../currency.cjs.js"),K=require("@nextblock-cms/utils");function $({title:s,description:a,action:y,children:h,hideHeader:P}){return e.jsxs("section",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-3",children:[!P&&e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap border-b border-muted/50 pb-2 mb-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h2",{className:"text-sm font-bold tracking-tight",children:s}),a?e.jsx("p",{className:"text-[11px] text-muted-foreground leading-none",children:a}):null]}),y]}),e.jsx("div",{className:P?"":"pt-1",children:h})]})}function Je(s,a,y){const h=a?Number.parseInt(a,10):void 0;return s?.language_id||(Number.isFinite(h)?h:void 0)||y.find(P=>P.is_default)?.id||y[0]?.id||1}function Se(s,a,y,h,P){const k=(h.find(b=>b.is_default)??h[0])?.code||"USD",V=s?.prices&&Object.keys(s.prices).length>0?s.prices:{[k]:typeof s?.price=="number"?s.price/100:0},A=s?.sale_prices&&Object.keys(s.sale_prices).length>0?s.sale_prices:typeof s?.sale_price=="number"?{[k]:s.sale_price/100}:{},q=s?.product_type||"",F=s?.payment_provider||(s?.product_type?He.derivePaymentProviderFromProductType(s.product_type):"stripe");return{...H.sanitizeProductFormValuesForStoreManagedCurrencies({product_type:q||"physical",payment_provider:F,title:s?.title||"",slug:s?.slug||"",sku:s?.sku||"",upc:s?.upc||"",is_taxable:s?.is_taxable??!0,price:typeof s?.price=="number"?s.price/100:0,prices:V,sale_price:typeof s?.sale_price=="number"?s.sale_price/100:null,sale_prices:A,stock:s?.stock||0,meta_title:s?.meta_title||"",meta_description:s?.meta_description||"",short_description:s?.short_description||"",description_json:s?.description_json||{type:"doc",content:[{type:"paragraph"}]},freemius_product_id:s?.freemius_product_id||"",freemius_plan_id:s?.freemius_plan_id||"",trial_period_days:s?.trial_period_days??0,trial_requires_payment_method:s?.trial_requires_payment_method??!1,status:s?.status||"draft",language_id:Je(s,a,y),translation_group_id:s?.translation_group_id||P||void 0,product_media:s?.product_media?.map(b=>({media_id:b.media_id}))||[],category_ids:s?.category_ids||[],variation_attributes:s?.variation_attributes||[],variants:s?.variants?.map(b=>({...b,prices:b.prices||{},sale_prices:b.sale_prices||{}}))||[]},h),product_type:q,payment_provider:F}}function Pe(s){return s?s.map(a=>({id:a.id||a.media_id,media_id:a.media_id,file_path:a.media?.file_path||a.media?.object_key||"",alt:a.media?.alt_text||"",sort_order:a.sort_order??0})).sort((a,y)=>a.sort_order-y.sort_order):[]}function Xe(s){return s.map(a=>({media_id:a.media_id}))}function Ye(s){return s.map(a=>({media_id:a.media_id,file_path:a.file_path,alt:a.alt}))}const Qe=s=>s.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,"");function We({initialData:s,isEdit:a=!1,mediaPickerNode:y,availableLanguagesProp:h,globalAttributesProp:P,currenciesProp:J,translationGroupId:k,targetLanguageId:V,freemiusDashboardNode:A,enabledProviders:q,configStatus:F,createAction:X,updateAction:b,availableCategoriesProp:we=[]}){const[T,R]=l.useState(!1),[Y,Q]=l.useState(()=>!!s?.variants?.length),u=l.useMemo(()=>J.filter(r=>r.is_active!==!1).sort((r,d)=>r.is_default!==d.is_default?r.is_default?-1:1:r.code.localeCompare(d.code)),[J]),c=l.useMemo(()=>u.find(r=>r.is_default)??u[0],[u]),E=l.useMemo(()=>H.getStoreManagedPriceCurrencyCodes(u),[u]),ae=Ue.useForm({resolver:Be.zodResolver(Oe.productSchema),defaultValues:Se(s,V,h,u,k)}),{register:o,handleSubmit:W,setValue:i,reset:ie,watch:n,setError:B,formState:{errors:g,dirtyFields:de}}=ae,le=l.useRef(!0),Z=l.useRef(null),[Ce,O]=l.useState(!1),[ne,U]=l.useState(null),[ce,ke]=l.useState(null),G=n(),oe=ae.formState.isDirty;l.useEffect(()=>{if(!a)return;if(le.current){le.current=!1,Z.current=JSON.stringify(G);return}if(!oe)return;const r=JSON.stringify(G);if(r===Z.current)return;const d=setTimeout(()=>{T||(Z.current=r,W(be)())},1e3);return()=>clearTimeout(d)},[G,a,oe,T,W]);const ue=n("title"),I=n("product_type"),x=I==="digital"?"freemius":I==="physical"?"stripe":void 0,j=I==="physical",pe=I==="digital",D=x?q[x]:!1,ee=x?F[x].hasKeys:!1,Fe=!!n("freemius_product_id"),me=Number(n("trial_period_days")||0),xe=!!n("trial_requires_payment_method"),Me=n("variants")||[],w=n("price"),M=n("sale_price"),v=n("prices")||{},C=n("sale_prices")||{},N=(Me?.length||0)>0,Ve=n("language_id"),Ie=h.find(r=>r.id===Ve)?.code||h.find(r=>r.is_default)?.code||h[0]?.code,z=l.useMemo(()=>H.resolveEditorCurrencyPriceMaps({currencies:u,prices:v,salePrices:C,fallbackPrice:w,fallbackSalePrice:M}),[w,M,u,v,C]),Ae=l.useMemo(()=>s?.variants?.map(r=>({...r,prices:r.prices||{},sale_prices:r.sale_prices||{}})),[s?.variants]);l.useEffect(()=>{if(de.title&&!a){const r=Qe(ue);i("slug",r,{shouldValidate:!0})}},[ue,de.title,i,a]);const[se,he]=l.useState(()=>Pe(s?.product_media)),[re,ge]=l.useState(new Set);l.useEffect(()=>{ie(Se(s,V,h,u,k)),he(Pe(s?.product_media)),ge(new Set),Q(!!s?.variants?.length)},[h,u,s,ie,V,k]);const qe=r=>{const d=new Set(r.map(m=>m.id)),p=se.filter(m=>!d.has(m.id)),f=new Set(re);p.forEach(m=>{m.media_id&&f.add(m.media_id)}),ge(f),he(r),i("product_media",Xe(r),{shouldDirty:!0}),i("explicitly_removed_media_ids",Array.from(f),{shouldDirty:!0})};l.useEffect(()=>{i("explicitly_removed_media_ids",Array.from(re))},[re,i]),l.useEffect(()=>{N&&Q(!0)},[N]),l.useEffect(()=>{o("is_taxable"),o("price"),o("sale_price"),o("payment_provider"),o("trial_requires_payment_method")},[o]),l.useEffect(()=>{if(!pe){i("trial_period_days",0,{shouldDirty:!1,shouldValidate:!0}),i("trial_requires_payment_method",!1,{shouldDirty:!1,shouldValidate:!0});return}me<=0&&i("trial_requires_payment_method",!1,{shouldDirty:!1,shouldValidate:!0})},[pe,i,me]),l.useEffect(()=>{x&&i("payment_provider",x,{shouldDirty:!1,shouldValidate:!0})},[x,i]),l.useEffect(()=>{c&&v[c.code]===void 0&&i("prices",{...v,[c.code]:w||0},{shouldDirty:!1})},[w,c,v,i]);const fe=l.useCallback((r,d)=>{const p={...v,[r]:d};i("prices",p,{shouldDirty:!0,shouldValidate:!0}),r===c?.code&&i("price",d,{shouldDirty:!0,shouldValidate:!0})},[c?.code,v,i]),_e=l.useCallback((r,d)=>{const p={...C,[r]:d};i("sale_prices",p,{shouldDirty:!0,shouldValidate:!0}),r===c?.code&&i("sale_price",d,{shouldDirty:!0,shouldValidate:!0})},[c?.code,C,i]),ye=l.useCallback(()=>{if(!c)return;const r=new Set(E),d=v[c.code]??w??0,p=C[c.code]??M??null,f=u.reduce((S,_)=>{if(_.code!==c.code&&r.has(_.code))return S;const te=Ne.convertMinorUnitAmount({amount:K.majorUnitAmountToMinor(d,c.code),fromCurrencyCode:c.code,toCurrencyCode:_.code,currencies:u,applyRounding:!0});return S[_.code]=K.minorUnitAmountToMajor(te,_.code),S},{}),m=u.reduce((S,_)=>{if(_.code!==c.code&&r.has(_.code))return S;if(typeof p!="number")return(_.code===c.code||!r.has(_.code))&&(S[_.code]=null),S;const te=Ne.convertMinorUnitAmount({amount:K.majorUnitAmountToMinor(p,c.code),fromCurrencyCode:c.code,toCurrencyCode:_.code,currencies:u,applyRounding:!0});return S[_.code]=K.minorUnitAmountToMajor(te,_.code),S},{});i("prices",f,{shouldDirty:!0,shouldValidate:!0}),i("sale_prices",m,{shouldDirty:!0,shouldValidate:!0}),i("price",f[c.code]??d,{shouldDirty:!0,shouldValidate:!0}),i("sale_price",m[c.code]??null,{shouldDirty:!0,shouldValidate:!0})},[u,c,v,C,i,E,w,M]),Te=l.useCallback(({variationAttributes:r,variants:d})=>{i("variation_attributes",r,{shouldDirty:!0}),i("variants",d,{shouldDirty:!0,shouldValidate:!0})},[i]),be=async r=>{R(!0),O(!0),U(null);try{if(!x){const m="Select whether this product is physical or digital before saving.";B("product_type",{type:"manual",message:m}),a?U(m):alert(m),R(!1),O(!1);return}if(r.status==="active"&&(!D||!ee)){const m=`${x==="stripe"?"Stripe":"Freemius"} must be enabled and fully configured before this product can be published.`;B("product_type",{type:"manual",message:m}),a?U(m):alert(m),R(!1),O(!1);return}const d=j?0:Math.max(0,Number(r.trial_period_days||0)),p={...r,product_type:r.product_type,payment_provider:x,freemius_product_id:j?"":r.freemius_product_id,freemius_plan_id:j?"":r.freemius_plan_id,trial_period_days:d,trial_requires_payment_method:!j&&d>0?r.trial_requires_payment_method:!1,upc:j?r.upc:null,is_taxable:j?r.is_taxable:!1,variation_attributes:j?r.variation_attributes:[],variants:j?r.variants:[]},f=H.sanitizeProductFormValuesForStoreManagedCurrencies(p,u);if(a&&b)await b(f),ke(new Date);else if(X)await X(f);else throw new Error("Product form action is not configured.")}catch(d){if(console.error(d),d.message==="NEXT_REDIRECT")return;let p=d.message||"An error occurred while saving.";if(d.code==="23505"){const f=d.message?.toLowerCase()||"";f.includes("products_slug_key")||f.includes("slug")?(p="This slug is already in use. Please choose another one.",B("slug",{type:"manual",message:p})):(f.includes("products_sku_key")||f.includes("sku"))&&(p="This SKU is already in use.",B("sku",{type:"manual",message:p}))}a?U(p):alert(p)}finally{R(!1),O(!1)}},Re=N?"bg-muted/60 text-muted-foreground opacity-70":"",Ee=Ye(se);return e.jsxs("form",{onSubmit:W(be),className:"space-y-2.5 pb-4",children:[e.jsx("input",{type:"hidden",...o("translation_group_id")}),e.jsx("input",{type:"hidden",...o("payment_provider")}),e.jsxs("div",{className:"space-y-2.5 w-full",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-2.5 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex h-9 items-center gap-2",children:[e.jsx("span",{className:"text-sm font-bold whitespace-nowrap leading-none pt-0.5",children:"Product Type"}),g.product_type&&e.jsx(L.AlertCircle,{className:"h-4 w-4 text-destructive"})]}),e.jsx("div",{className:"flex h-9 items-center",children:e.jsxs(t.Select,{onValueChange:r=>i("product_type",r,{shouldDirty:!0,shouldValidate:!0}),value:I||void 0,children:[e.jsx(t.SelectTrigger,{className:"w-[160px] h-9 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select Type"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"physical",children:"Physical Product"}),e.jsx(t.SelectItem,{value:"digital",children:"Digital Product"})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex h-9 items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider leading-none",children:"Payment Provider"}),e.jsx(t.Badge,{variant:"outline",className:"text-xs py-1 font-bold bg-muted/30 leading-none",children:x?x==="stripe"?"Stripe":"Freemius":"—"})]}),x&&e.jsx("div",{className:"flex h-9 items-center gap-2",children:D&&ee?e.jsxs("span",{className:"flex items-center gap-1.5 text-emerald-600 text-[10px] font-bold bg-emerald-50 px-2 py-1 rounded-full border border-emerald-100 uppercase leading-none",children:[e.jsx(L.CheckCircle2,{className:"h-3 w-3"}),"Ready"]}):e.jsxs("span",{className:"flex items-center gap-1.5 text-amber-600 text-[10px] font-bold bg-amber-50 px-2 py-1 rounded-full border border-amber-100 uppercase leading-none",children:[e.jsx(L.AlertCircle,{className:"h-3 w-3"}),D?"Keys Missing":"Disabled"]})}),!ee&&x&&F[x].missing.length>0&&e.jsxs("div",{className:"hidden xl:flex h-9 items-center gap-1 text-[10px] text-muted-foreground bg-muted/50 px-2 py-1 rounded border border-dashed leading-none",children:[e.jsx(L.Info,{className:"h-3 w-3"}),"Missing: ",F[x].missing.join(", ")]})]})]}),e.jsxs($,{title:"Product Information",hideHeader:!0,children:[a&&e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground pb-2 border-b border-border/40 mb-2.5",children:[e.jsx("span",{className:"font-semibold text-[11px] uppercase tracking-wider text-muted-foreground/80",children:"Product Settings"}),e.jsx("div",{className:"flex items-center gap-1.5 min-h-[16px]",children:Ce?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-amber-500"})]}),e.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Autosaving settings..."})]}):ne?e.jsxs("span",{className:"text-red-500 font-medium",children:["Error saving settings: ",ne]}):ce?e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400 font-medium",children:["Settings autosaved at ",ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})]}):e.jsx("span",{className:"text-muted-foreground/60",children:"Settings autosave in draft mode"})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5",children:[e.jsxs("div",{className:"col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"title",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Title"}),e.jsx(t.Input,{id:"title",placeholder:"Product title",...o("title"),className:"h-8 text-sm"}),g.title&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.title.message})]}),e.jsxs("div",{className:"col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"slug",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Slug"}),e.jsx(t.Input,{id:"slug",placeholder:"product-slug",...o("slug"),className:"h-8 text-sm"}),g.slug&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.slug.message})]}),e.jsxs("div",{className:"col-span-1 space-y-1",children:[e.jsx(t.Label,{htmlFor:"sku",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"SKU"}),e.jsx(t.Input,{id:"sku",placeholder:"SKU",...o("sku"),className:"h-8 text-sm font-mono"}),g.sku&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.sku.message})]}),e.jsxs("div",{className:"col-span-1 space-y-1",children:[e.jsx(t.Label,{htmlFor:"upc_ean",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"UPC / EAN"}),e.jsx(t.Input,{id:"upc_ean",placeholder:"000000000",...o("upc"),className:"h-8 text-sm font-mono",readOnly:N})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5 mt-2",children:[e.jsxs("div",{className:"lg:col-span-2 col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"meta_title",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Meta Title"}),e.jsx(t.Input,{id:"meta_title",...o("meta_title"),placeholder:"SEO page title (50-60 chars)",className:"h-8 text-sm"})]}),e.jsxs("div",{className:`lg:col-span-${a?"3":"4"} col-span-2 space-y-1`,children:[e.jsx(t.Label,{htmlFor:"meta_description",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Meta Description"}),e.jsx(t.Input,{id:"meta_description",...o("meta_description"),placeholder:"SEO description (150-160 chars)",className:"h-8 text-sm"})]}),a&&e.jsxs("div",{className:"lg:col-span-1 col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"status",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Status"}),e.jsxs(t.Select,{onValueChange:r=>i("status",r,{shouldDirty:!0}),value:n("status"),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Status"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"draft",children:"Draft"}),e.jsx(t.SelectItem,{value:"active",children:"Active"}),e.jsx(t.SelectItem,{value:"archived",children:"Archived"})]})]})]})]})]}),e.jsx($,{title:"Product Categories",description:"Assign this product to one or more categories.",children:e.jsx($e.ProductCategorySelector,{categories:we,selectedIds:n("category_ids")||[],onChange:r=>i("category_ids",r,{shouldDirty:!0,shouldValidate:!0})})}),e.jsxs("section",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-3",children:[j&&e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap border-b border-muted/50 pb-2",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h2",{className:"text-sm font-bold tracking-tight",children:"Pricing & Inventory"}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-none",children:"Manage simple or variant pricing."})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/40 rounded-md px-2.5 py-1.5",children:[e.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Stock"}),e.jsx(t.Input,{id:"stock",type:"number",min:"0",...o("stock",{valueAsNumber:!0}),placeholder:"0",readOnly:N,className:`${Re} h-8 w-20 text-sm text-center font-mono bg-background`})]}),N?e.jsx(t.Badge,{variant:"secondary",className:"text-[11px] py-0 px-2 h-5",children:"Variant pricing"}):null]})]}),j?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"w-full",children:[e.jsx(je.CurrencyPriceFields,{idPrefix:"product",currencies:u,prices:z.prices,salePrices:z.salePrices,managedCurrencyCodes:E,onPriceChange:fe,onSalePriceChange:_e,onAutoFill:ye,readOnly:N,helperText:N?"Parent prices stay as a fallback, but active variants define the live shopper price.":void 0,trailing:e.jsx(ve.SaleScheduleFields,{idPrefix:"product",startAt:n("sale_start_at"),endAt:n("sale_end_at"),onChange:(r,d)=>i(r,d,{shouldDirty:!0,shouldValidate:!0}),error:g.sale_end_at?.message,bare:!0})}),g.price&&e.jsx("p",{className:"text-destructive text-sm mt-1",children:g.price.message}),g.sale_price&&e.jsx("p",{className:"text-destructive text-sm mt-1",children:g.sale_price.message}),g.stock&&e.jsx("p",{className:"text-destructive text-[10px] font-medium leading-none mt-1",children:g.stock.message})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded border border-dashed p-2.5 bg-muted/5",children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:N?"Variations Active":"Variations"}),e.jsx(t.Button,{type:"button",variant:Y?"outline":"default",onClick:()=>Q(r=>!r),size:"sm",className:"h-7 text-xs px-3",children:Y?"Hide":"Manage"})]}),Y&&e.jsx("div",{className:"border-t pt-3",children:e.jsx(Ke.VariationsEditor,{globalAttributes:P,currentLanguageCode:Ie,baseSku:n("sku")||"",basePrice:w||0,basePrices:v,baseSalePrice:typeof M=="number"?M:null,baseSalePrices:C,currencies:u,availableVariantImages:Ee,initialVariationAttributes:s?.variation_attributes,initialVariants:Ae,onChange:Te})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-4 w-full",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(t.Label,{htmlFor:"freemius_product_id",className:"text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",children:"Freemius Product ID"}),e.jsx(t.Input,{id:"freemius_product_id",...o("freemius_product_id"),className:"h-9"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(t.Label,{htmlFor:"freemius_plan_id",className:"text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",children:"Freemius Plan ID"}),e.jsx(t.Input,{id:"freemius_plan_id",...o("freemius_plan_id"),className:"h-9"})]}),Fe?e.jsx(Le.SyncFreemiusPricingButton,{productId:n("freemius_product_id")}):null]}),e.jsxs("div",{className:"bg-muted/10 border rounded-md overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-6 bg-muted/20 border-b p-2.5 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Free Trial"}),e.jsxs(t.Badge,{variant:"outline",className:"font-mono text-xs shadow-sm bg-background",children:[String(n("trial_period_days")||0)," Days"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Card Required"}),e.jsx(t.Badge,{variant:xe?"default":"secondary",className:"text-xs shadow-sm",children:xe?"Yes":"No"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto",children:"Managed in Freemius dashboard"}),e.jsx("input",{type:"hidden",...o("trial_period_days",{valueAsNumber:!0})})]}),e.jsxs("div",{className:"w-full p-4 pt-3 space-y-2",children:[e.jsx(je.CurrencyPriceFields,{idPrefix:"product",currencies:u,prices:z.prices,salePrices:z.salePrices,managedCurrencyCodes:E,onPriceChange:fe,onSalePriceChange:_e,onAutoFill:ye,readOnly:!0,trailing:e.jsx(ve.SaleScheduleFields,{idPrefix:"product",startAt:n("sale_start_at"),endAt:n("sale_end_at"),onChange:(r,d)=>i(r,d,{shouldDirty:!0,shouldValidate:!0}),error:g.sale_end_at?.message,bare:!0})}),e.jsx("p",{className:"text-[10px] leading-snug text-muted-foreground",children:"Scheduling a sale on a Freemius product generates a time-bounded Freemius coupon so the discount is enforced at Freemius checkout."})]})]})]}),A&&e.jsx("div",{className:"pt-2 border-t",children:A})]})]}),e.jsx($,{title:"Product Description",hideHeader:!0,children:e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{htmlFor:"short_description",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Short Description"}),e.jsx(t.Input,{id:"short_description",...o("short_description"),placeholder:"Brief summary for product cards...",className:"h-8 text-sm"})]})})}),e.jsxs($,{title:"Media Gallery",description:"Drag to reorder. First image is the hero.",children:[e.jsx(ze.ProductMediaManager,{initialMedia:se,onUpdate:qe,mediaPickerNode:y}),e.jsx("input",{type:"hidden",...o("product_media")})]}),!a&&e.jsxs("div",{className:"rounded-lg border bg-card p-3 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Status"}),e.jsxs(t.Select,{onValueChange:r=>i("status",r),value:n("status"),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-[110px] text-sm",children:e.jsx(t.SelectValue,{placeholder:"Status"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"draft",children:"Draft"}),e.jsx(t.SelectItem,{value:"active",children:"Active"}),e.jsx(t.SelectItem,{value:"archived",children:"Archived"})]})]})]}),e.jsx(t.Button,{disabled:T,type:"submit",size:"sm",className:"h-8 text-sm px-5",children:T?"Saving...":"Save Changes"})]})]})]})}exports.ProductForm=We;
|