@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,702 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as s, jsx as e, Fragment as Me } from "react/jsx-runtime";
|
|
3
|
+
import q, { useState as A, useRef as Ve, useEffect as k, useCallback as Y } from "react";
|
|
4
|
+
import { zodResolver as De } from "@hookform/resolvers/zod";
|
|
5
|
+
import { AlertCircle as Ae, CheckCircle2 as er, Info as rr } from "lucide-react";
|
|
6
|
+
import { Select as le, SelectTrigger as ne, SelectValue as ce, SelectContent as ue, SelectItem as F, Badge as L, Label as N, Input as P, Button as Te } from "@nextblock-cms/ui";
|
|
7
|
+
import { productSchema as tr } from "../../../../product-schema.es.js";
|
|
8
|
+
import { useForm as sr } from "react-hook-form";
|
|
9
|
+
import { ProductMediaManager as ar } from "./ProductMediaManager.es.js";
|
|
10
|
+
import { SyncFreemiusPricingButton as dr } from "./SyncFreemiusPricingButton.es.js";
|
|
11
|
+
import { VariationsEditor as ir } from "./VariationsEditor.es.js";
|
|
12
|
+
import { CurrencyPriceFields as Ie } from "./CurrencyPriceFields.es.js";
|
|
13
|
+
import { SaleScheduleFields as je } from "./SaleScheduleFields.es.js";
|
|
14
|
+
import { ProductCategorySelector as or } from "./ProductCategorySelector.es.js";
|
|
15
|
+
import { getStoreManagedPriceCurrencyCodes as lr, resolveEditorCurrencyPriceMaps as nr, sanitizeProductFormValuesForStoreManagedCurrencies as Be } from "../product-price-sync.es.js";
|
|
16
|
+
import { derivePaymentProviderFromProductType as cr } from "../../../../types.es.js";
|
|
17
|
+
import { convertMinorUnitAmount as Re } from "../../../../currency.es.js";
|
|
18
|
+
import { majorUnitAmountToMinor as Oe, minorUnitAmountToMajor as qe } from "@nextblock-cms/utils";
|
|
19
|
+
function Q({ title: r, description: a, action: x, children: h, hideHeader: C }) {
|
|
20
|
+
return /* @__PURE__ */ s("section", { className: "rounded-lg border bg-card p-3 shadow-sm space-y-3", children: [
|
|
21
|
+
!C && /* @__PURE__ */ s("div", { className: "flex items-start justify-between gap-4 flex-wrap border-b border-muted/50 pb-2 mb-1", children: [
|
|
22
|
+
/* @__PURE__ */ s("div", { className: "space-y-0.5", children: [
|
|
23
|
+
/* @__PURE__ */ e("h2", { className: "text-sm font-bold tracking-tight", children: r }),
|
|
24
|
+
a ? /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground leading-none", children: a }) : null
|
|
25
|
+
] }),
|
|
26
|
+
x
|
|
27
|
+
] }),
|
|
28
|
+
/* @__PURE__ */ e("div", { className: C ? "" : "pt-1", children: h })
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
function ur(r, a, x) {
|
|
32
|
+
const h = a ? Number.parseInt(a, 10) : void 0;
|
|
33
|
+
return r?.language_id || (Number.isFinite(h) ? h : void 0) || x.find((C) => C.is_default)?.id || x[0]?.id || 1;
|
|
34
|
+
}
|
|
35
|
+
function ze(r, a, x, h, C) {
|
|
36
|
+
const T = (h.find((y) => y.is_default) ?? h[0])?.code || "USD", R = r?.prices && Object.keys(r.prices).length > 0 ? r.prices : {
|
|
37
|
+
[T]: typeof r?.price == "number" ? r.price / 100 : 0
|
|
38
|
+
}, z = r?.sale_prices && Object.keys(r.sale_prices).length > 0 ? r.sale_prices : typeof r?.sale_price == "number" ? {
|
|
39
|
+
[T]: r.sale_price / 100
|
|
40
|
+
} : {}, U = r?.product_type || "", I = r?.payment_provider || (r?.product_type ? cr(r.product_type) : "stripe");
|
|
41
|
+
return {
|
|
42
|
+
...Be({
|
|
43
|
+
product_type: U || "physical",
|
|
44
|
+
payment_provider: I,
|
|
45
|
+
title: r?.title || "",
|
|
46
|
+
slug: r?.slug || "",
|
|
47
|
+
sku: r?.sku || "",
|
|
48
|
+
upc: r?.upc || "",
|
|
49
|
+
is_taxable: r?.is_taxable ?? !0,
|
|
50
|
+
price: typeof r?.price == "number" ? r.price / 100 : 0,
|
|
51
|
+
prices: R,
|
|
52
|
+
sale_price: typeof r?.sale_price == "number" ? r.sale_price / 100 : null,
|
|
53
|
+
sale_prices: z,
|
|
54
|
+
stock: r?.stock || 0,
|
|
55
|
+
meta_title: r?.meta_title || "",
|
|
56
|
+
meta_description: r?.meta_description || "",
|
|
57
|
+
short_description: r?.short_description || "",
|
|
58
|
+
description_json: r?.description_json || {
|
|
59
|
+
type: "doc",
|
|
60
|
+
content: [{ type: "paragraph" }]
|
|
61
|
+
},
|
|
62
|
+
freemius_product_id: r?.freemius_product_id || "",
|
|
63
|
+
freemius_plan_id: r?.freemius_plan_id || "",
|
|
64
|
+
trial_period_days: r?.trial_period_days ?? 0,
|
|
65
|
+
trial_requires_payment_method: r?.trial_requires_payment_method ?? !1,
|
|
66
|
+
status: r?.status || "draft",
|
|
67
|
+
language_id: ur(
|
|
68
|
+
r,
|
|
69
|
+
a,
|
|
70
|
+
x
|
|
71
|
+
),
|
|
72
|
+
translation_group_id: r?.translation_group_id || C || void 0,
|
|
73
|
+
product_media: r?.product_media?.map((y) => ({
|
|
74
|
+
media_id: y.media_id
|
|
75
|
+
})) || [],
|
|
76
|
+
category_ids: r?.category_ids || [],
|
|
77
|
+
variation_attributes: r?.variation_attributes || [],
|
|
78
|
+
variants: r?.variants?.map((y) => ({
|
|
79
|
+
...y,
|
|
80
|
+
prices: y.prices || {},
|
|
81
|
+
sale_prices: y.sale_prices || {}
|
|
82
|
+
})) || []
|
|
83
|
+
}, h),
|
|
84
|
+
product_type: U,
|
|
85
|
+
payment_provider: I
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function Ue(r) {
|
|
89
|
+
return r ? r.map((a) => ({
|
|
90
|
+
id: a.id || a.media_id,
|
|
91
|
+
media_id: a.media_id,
|
|
92
|
+
file_path: a.media?.file_path || a.media?.object_key || "",
|
|
93
|
+
alt: a.media?.alt_text || "",
|
|
94
|
+
sort_order: a.sort_order ?? 0
|
|
95
|
+
})).sort((a, x) => a.sort_order - x.sort_order) : [];
|
|
96
|
+
}
|
|
97
|
+
function mr(r) {
|
|
98
|
+
return r.map((a) => ({ media_id: a.media_id }));
|
|
99
|
+
}
|
|
100
|
+
function pr(r) {
|
|
101
|
+
return r.map((a) => ({
|
|
102
|
+
media_id: a.media_id,
|
|
103
|
+
file_path: a.file_path,
|
|
104
|
+
alt: a.alt
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
const hr = (r) => r.toString().toLowerCase().trim().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
108
|
+
function Tr({
|
|
109
|
+
initialData: r,
|
|
110
|
+
isEdit: a = !1,
|
|
111
|
+
mediaPickerNode: x,
|
|
112
|
+
availableLanguagesProp: h,
|
|
113
|
+
globalAttributesProp: C,
|
|
114
|
+
currenciesProp: W,
|
|
115
|
+
translationGroupId: T,
|
|
116
|
+
targetLanguageId: R,
|
|
117
|
+
freemiusDashboardNode: z,
|
|
118
|
+
enabledProviders: U,
|
|
119
|
+
configStatus: I,
|
|
120
|
+
createAction: Z,
|
|
121
|
+
updateAction: y,
|
|
122
|
+
availableCategoriesProp: Ee = []
|
|
123
|
+
}) {
|
|
124
|
+
const [B, E] = A(!1), [G, D] = A(() => !!r?.variants?.length), c = q.useMemo(
|
|
125
|
+
() => W.filter((t) => t.is_active !== !1).sort((t, i) => t.is_default !== i.is_default ? t.is_default ? -1 : 1 : t.code.localeCompare(i.code)),
|
|
126
|
+
[W]
|
|
127
|
+
), l = q.useMemo(
|
|
128
|
+
() => c.find((t) => t.is_default) ?? c[0],
|
|
129
|
+
[c]
|
|
130
|
+
), K = q.useMemo(
|
|
131
|
+
() => lr(c),
|
|
132
|
+
[c]
|
|
133
|
+
), me = sr({
|
|
134
|
+
resolver: De(tr),
|
|
135
|
+
defaultValues: ze(
|
|
136
|
+
r,
|
|
137
|
+
R,
|
|
138
|
+
h,
|
|
139
|
+
c,
|
|
140
|
+
T
|
|
141
|
+
)
|
|
142
|
+
}), {
|
|
143
|
+
register: n,
|
|
144
|
+
handleSubmit: ee,
|
|
145
|
+
setValue: d,
|
|
146
|
+
reset: pe,
|
|
147
|
+
watch: o,
|
|
148
|
+
setError: $,
|
|
149
|
+
formState: { errors: f, dirtyFields: he }
|
|
150
|
+
} = me, fe = Ve(!0), re = Ve(null), [Ke, H] = A(!1), [ge, J] = A(null), [_e, $e] = A(null), te = o(), xe = me.formState.isDirty;
|
|
151
|
+
k(() => {
|
|
152
|
+
if (!a) return;
|
|
153
|
+
if (fe.current) {
|
|
154
|
+
fe.current = !1, re.current = JSON.stringify(te);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!xe) return;
|
|
158
|
+
const t = JSON.stringify(te);
|
|
159
|
+
if (t === re.current) return;
|
|
160
|
+
const i = setTimeout(() => {
|
|
161
|
+
B || (re.current = t, ee(Fe)());
|
|
162
|
+
}, 1e3);
|
|
163
|
+
return () => clearTimeout(i);
|
|
164
|
+
}, [te, a, xe, B, ee]);
|
|
165
|
+
const ye = o("title"), O = o("product_type"), p = O === "digital" ? "freemius" : O === "physical" ? "stripe" : void 0, b = O === "physical", be = O === "digital", se = p ? U[p] : !1, ae = p ? I[p].hasKeys : !1, He = !!o("freemius_product_id"), ve = Number(o("trial_period_days") || 0), Ne = !!o("trial_requires_payment_method"), Je = o("variants") || [], M = o("price"), j = o("sale_price"), v = o("prices") || {}, V = o("sale_prices") || {}, S = (Je?.length || 0) > 0, Xe = o("language_id"), Ye = h.find((t) => t.id === Xe)?.code || h.find((t) => t.is_default)?.code || h[0]?.code, X = q.useMemo(
|
|
166
|
+
() => nr({
|
|
167
|
+
currencies: c,
|
|
168
|
+
prices: v,
|
|
169
|
+
salePrices: V,
|
|
170
|
+
fallbackPrice: M,
|
|
171
|
+
fallbackSalePrice: j
|
|
172
|
+
}),
|
|
173
|
+
[M, j, c, v, V]
|
|
174
|
+
), Le = q.useMemo(
|
|
175
|
+
() => r?.variants?.map((t) => ({
|
|
176
|
+
...t,
|
|
177
|
+
prices: t.prices || {},
|
|
178
|
+
sale_prices: t.sale_prices || {}
|
|
179
|
+
})),
|
|
180
|
+
[r?.variants]
|
|
181
|
+
);
|
|
182
|
+
k(() => {
|
|
183
|
+
if (he.title && !a) {
|
|
184
|
+
const t = hr(ye);
|
|
185
|
+
d("slug", t, { shouldValidate: !0 });
|
|
186
|
+
}
|
|
187
|
+
}, [ye, he.title, d, a]);
|
|
188
|
+
const [de, Pe] = A(
|
|
189
|
+
() => Ue(r?.product_media)
|
|
190
|
+
), [ie, Se] = A(/* @__PURE__ */ new Set());
|
|
191
|
+
k(() => {
|
|
192
|
+
pe(
|
|
193
|
+
ze(
|
|
194
|
+
r,
|
|
195
|
+
R,
|
|
196
|
+
h,
|
|
197
|
+
c,
|
|
198
|
+
T
|
|
199
|
+
)
|
|
200
|
+
), Pe(Ue(r?.product_media)), Se(/* @__PURE__ */ new Set()), D(!!r?.variants?.length);
|
|
201
|
+
}, [
|
|
202
|
+
h,
|
|
203
|
+
c,
|
|
204
|
+
r,
|
|
205
|
+
pe,
|
|
206
|
+
R,
|
|
207
|
+
T
|
|
208
|
+
]);
|
|
209
|
+
const Qe = (t) => {
|
|
210
|
+
const i = new Set(t.map((m) => m.id)), u = de.filter((m) => !i.has(m.id)), g = new Set(ie);
|
|
211
|
+
u.forEach((m) => {
|
|
212
|
+
m.media_id && g.add(m.media_id);
|
|
213
|
+
}), Se(g), Pe(t), d("product_media", mr(t), { shouldDirty: !0 }), d("explicitly_removed_media_ids", Array.from(g), {
|
|
214
|
+
shouldDirty: !0
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
k(() => {
|
|
218
|
+
d("explicitly_removed_media_ids", Array.from(ie));
|
|
219
|
+
}, [ie, d]), k(() => {
|
|
220
|
+
S && D(!0);
|
|
221
|
+
}, [S]), k(() => {
|
|
222
|
+
n("is_taxable"), n("price"), n("sale_price"), n("payment_provider"), n("trial_requires_payment_method");
|
|
223
|
+
}, [n]), k(() => {
|
|
224
|
+
if (!be) {
|
|
225
|
+
d("trial_period_days", 0, { shouldDirty: !1, shouldValidate: !0 }), d("trial_requires_payment_method", !1, {
|
|
226
|
+
shouldDirty: !1,
|
|
227
|
+
shouldValidate: !0
|
|
228
|
+
});
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
ve <= 0 && d("trial_requires_payment_method", !1, {
|
|
232
|
+
shouldDirty: !1,
|
|
233
|
+
shouldValidate: !0
|
|
234
|
+
});
|
|
235
|
+
}, [be, d, ve]), k(() => {
|
|
236
|
+
p && d("payment_provider", p, {
|
|
237
|
+
shouldDirty: !1,
|
|
238
|
+
shouldValidate: !0
|
|
239
|
+
});
|
|
240
|
+
}, [p, d]), k(() => {
|
|
241
|
+
l && v[l.code] === void 0 && d(
|
|
242
|
+
"prices",
|
|
243
|
+
{
|
|
244
|
+
...v,
|
|
245
|
+
[l.code]: M || 0
|
|
246
|
+
},
|
|
247
|
+
{ shouldDirty: !1 }
|
|
248
|
+
);
|
|
249
|
+
}, [M, l, v, d]);
|
|
250
|
+
const we = Y(
|
|
251
|
+
(t, i) => {
|
|
252
|
+
const u = {
|
|
253
|
+
...v,
|
|
254
|
+
[t]: i
|
|
255
|
+
};
|
|
256
|
+
d("prices", u, { shouldDirty: !0, shouldValidate: !0 }), t === l?.code && d("price", i, { shouldDirty: !0, shouldValidate: !0 });
|
|
257
|
+
},
|
|
258
|
+
[l?.code, v, d]
|
|
259
|
+
), ke = Y(
|
|
260
|
+
(t, i) => {
|
|
261
|
+
const u = {
|
|
262
|
+
...V,
|
|
263
|
+
[t]: i
|
|
264
|
+
};
|
|
265
|
+
d("sale_prices", u, {
|
|
266
|
+
shouldDirty: !0,
|
|
267
|
+
shouldValidate: !0
|
|
268
|
+
}), t === l?.code && d("sale_price", i, { shouldDirty: !0, shouldValidate: !0 });
|
|
269
|
+
},
|
|
270
|
+
[l?.code, V, d]
|
|
271
|
+
), Ce = Y(() => {
|
|
272
|
+
if (!l)
|
|
273
|
+
return;
|
|
274
|
+
const t = new Set(K), i = v[l.code] ?? M ?? 0, u = V[l.code] ?? j ?? null, g = c.reduce((w, _) => {
|
|
275
|
+
if (_.code !== l.code && t.has(_.code))
|
|
276
|
+
return w;
|
|
277
|
+
const oe = Re({
|
|
278
|
+
amount: Oe(i, l.code),
|
|
279
|
+
fromCurrencyCode: l.code,
|
|
280
|
+
toCurrencyCode: _.code,
|
|
281
|
+
currencies: c,
|
|
282
|
+
applyRounding: !0
|
|
283
|
+
});
|
|
284
|
+
return w[_.code] = qe(oe, _.code), w;
|
|
285
|
+
}, {}), m = c.reduce(
|
|
286
|
+
(w, _) => {
|
|
287
|
+
if (_.code !== l.code && t.has(_.code))
|
|
288
|
+
return w;
|
|
289
|
+
if (typeof u != "number")
|
|
290
|
+
return (_.code === l.code || !t.has(_.code)) && (w[_.code] = null), w;
|
|
291
|
+
const oe = Re({
|
|
292
|
+
amount: Oe(u, l.code),
|
|
293
|
+
fromCurrencyCode: l.code,
|
|
294
|
+
toCurrencyCode: _.code,
|
|
295
|
+
currencies: c,
|
|
296
|
+
applyRounding: !0
|
|
297
|
+
});
|
|
298
|
+
return w[_.code] = qe(oe, _.code), w;
|
|
299
|
+
},
|
|
300
|
+
{}
|
|
301
|
+
);
|
|
302
|
+
d("prices", g, { shouldDirty: !0, shouldValidate: !0 }), d("sale_prices", m, {
|
|
303
|
+
shouldDirty: !0,
|
|
304
|
+
shouldValidate: !0
|
|
305
|
+
}), d("price", g[l.code] ?? i, {
|
|
306
|
+
shouldDirty: !0,
|
|
307
|
+
shouldValidate: !0
|
|
308
|
+
}), d("sale_price", m[l.code] ?? null, {
|
|
309
|
+
shouldDirty: !0,
|
|
310
|
+
shouldValidate: !0
|
|
311
|
+
});
|
|
312
|
+
}, [
|
|
313
|
+
c,
|
|
314
|
+
l,
|
|
315
|
+
v,
|
|
316
|
+
V,
|
|
317
|
+
d,
|
|
318
|
+
K,
|
|
319
|
+
M,
|
|
320
|
+
j
|
|
321
|
+
]), We = Y(
|
|
322
|
+
({
|
|
323
|
+
variationAttributes: t,
|
|
324
|
+
variants: i
|
|
325
|
+
}) => {
|
|
326
|
+
d("variation_attributes", t, { shouldDirty: !0 }), d("variants", i, { shouldDirty: !0, shouldValidate: !0 });
|
|
327
|
+
},
|
|
328
|
+
[d]
|
|
329
|
+
), Fe = async (t) => {
|
|
330
|
+
E(!0), H(!0), J(null);
|
|
331
|
+
try {
|
|
332
|
+
if (!p) {
|
|
333
|
+
const m = "Select whether this product is physical or digital before saving.";
|
|
334
|
+
$("product_type", {
|
|
335
|
+
type: "manual",
|
|
336
|
+
message: m
|
|
337
|
+
}), a ? J(m) : alert(m), E(!1), H(!1);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (t.status === "active" && (!se || !ae)) {
|
|
341
|
+
const m = `${p === "stripe" ? "Stripe" : "Freemius"} must be enabled and fully configured before this product can be published.`;
|
|
342
|
+
$("product_type", {
|
|
343
|
+
type: "manual",
|
|
344
|
+
message: m
|
|
345
|
+
}), a ? J(m) : alert(m), E(!1), H(!1);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const i = b ? 0 : Math.max(0, Number(t.trial_period_days || 0)), u = {
|
|
349
|
+
...t,
|
|
350
|
+
product_type: t.product_type,
|
|
351
|
+
payment_provider: p,
|
|
352
|
+
freemius_product_id: b ? "" : t.freemius_product_id,
|
|
353
|
+
freemius_plan_id: b ? "" : t.freemius_plan_id,
|
|
354
|
+
trial_period_days: i,
|
|
355
|
+
trial_requires_payment_method: !b && i > 0 ? t.trial_requires_payment_method : !1,
|
|
356
|
+
upc: b ? t.upc : null,
|
|
357
|
+
is_taxable: b ? t.is_taxable : !1,
|
|
358
|
+
variation_attributes: b ? t.variation_attributes : [],
|
|
359
|
+
variants: b ? t.variants : []
|
|
360
|
+
}, g = Be(
|
|
361
|
+
u,
|
|
362
|
+
c
|
|
363
|
+
);
|
|
364
|
+
if (a && y)
|
|
365
|
+
await y(g), $e(/* @__PURE__ */ new Date());
|
|
366
|
+
else if (Z)
|
|
367
|
+
await Z(g);
|
|
368
|
+
else
|
|
369
|
+
throw new Error("Product form action is not configured.");
|
|
370
|
+
} catch (i) {
|
|
371
|
+
if (console.error(i), i.message === "NEXT_REDIRECT")
|
|
372
|
+
return;
|
|
373
|
+
let u = i.message || "An error occurred while saving.";
|
|
374
|
+
if (i.code === "23505") {
|
|
375
|
+
const g = i.message?.toLowerCase() || "";
|
|
376
|
+
g.includes("products_slug_key") || g.includes("slug") ? (u = "This slug is already in use. Please choose another one.", $("slug", {
|
|
377
|
+
type: "manual",
|
|
378
|
+
message: u
|
|
379
|
+
})) : (g.includes("products_sku_key") || g.includes("sku")) && (u = "This SKU is already in use.", $("sku", {
|
|
380
|
+
type: "manual",
|
|
381
|
+
message: u
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
a ? J(u) : alert(u);
|
|
385
|
+
} finally {
|
|
386
|
+
E(!1), H(!1);
|
|
387
|
+
}
|
|
388
|
+
}, Ze = S ? "bg-muted/60 text-muted-foreground opacity-70" : "", Ge = pr(de);
|
|
389
|
+
return /* @__PURE__ */ s("form", { onSubmit: ee(Fe), className: "space-y-2.5 pb-4", children: [
|
|
390
|
+
/* @__PURE__ */ e("input", { type: "hidden", ...n("translation_group_id") }),
|
|
391
|
+
/* @__PURE__ */ e("input", { type: "hidden", ...n("payment_provider") }),
|
|
392
|
+
/* @__PURE__ */ s("div", { className: "space-y-2.5 w-full", children: [
|
|
393
|
+
/* @__PURE__ */ s("div", { className: "rounded-lg border bg-card p-2.5 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap", children: [
|
|
394
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-6", children: [
|
|
395
|
+
/* @__PURE__ */ s("div", { className: "flex h-9 items-center gap-2", children: [
|
|
396
|
+
/* @__PURE__ */ e("span", { className: "text-sm font-bold whitespace-nowrap leading-none pt-0.5", children: "Product Type" }),
|
|
397
|
+
f.product_type && /* @__PURE__ */ e(Ae, { className: "h-4 w-4 text-destructive" })
|
|
398
|
+
] }),
|
|
399
|
+
/* @__PURE__ */ e("div", { className: "flex h-9 items-center", children: /* @__PURE__ */ s(
|
|
400
|
+
le,
|
|
401
|
+
{
|
|
402
|
+
onValueChange: (t) => d("product_type", t, {
|
|
403
|
+
shouldDirty: !0,
|
|
404
|
+
shouldValidate: !0
|
|
405
|
+
}),
|
|
406
|
+
value: O || void 0,
|
|
407
|
+
children: [
|
|
408
|
+
/* @__PURE__ */ e(ne, { className: "w-[160px] h-9 text-xs", children: /* @__PURE__ */ e(ce, { placeholder: "Select Type" }) }),
|
|
409
|
+
/* @__PURE__ */ s(ue, { children: [
|
|
410
|
+
/* @__PURE__ */ e(F, { value: "physical", children: "Physical Product" }),
|
|
411
|
+
/* @__PURE__ */ e(F, { value: "digital", children: "Digital Product" })
|
|
412
|
+
] })
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
) })
|
|
416
|
+
] }),
|
|
417
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-6", children: [
|
|
418
|
+
/* @__PURE__ */ s("div", { className: "flex h-9 items-center gap-3", children: [
|
|
419
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider leading-none", children: "Payment Provider" }),
|
|
420
|
+
/* @__PURE__ */ e(L, { variant: "outline", className: "text-xs py-1 font-bold bg-muted/30 leading-none", children: p ? p === "stripe" ? "Stripe" : "Freemius" : "—" })
|
|
421
|
+
] }),
|
|
422
|
+
p && /* @__PURE__ */ e("div", { className: "flex h-9 items-center gap-2", children: se && ae ? /* @__PURE__ */ s("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: [
|
|
423
|
+
/* @__PURE__ */ e(er, { className: "h-3 w-3" }),
|
|
424
|
+
"Ready"
|
|
425
|
+
] }) : /* @__PURE__ */ s("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: [
|
|
426
|
+
/* @__PURE__ */ e(Ae, { className: "h-3 w-3" }),
|
|
427
|
+
se ? "Keys Missing" : "Disabled"
|
|
428
|
+
] }) }),
|
|
429
|
+
!ae && p && I[p].missing.length > 0 && /* @__PURE__ */ s("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: [
|
|
430
|
+
/* @__PURE__ */ e(rr, { className: "h-3 w-3" }),
|
|
431
|
+
"Missing: ",
|
|
432
|
+
I[p].missing.join(", ")
|
|
433
|
+
] })
|
|
434
|
+
] })
|
|
435
|
+
] }),
|
|
436
|
+
/* @__PURE__ */ s(
|
|
437
|
+
Q,
|
|
438
|
+
{
|
|
439
|
+
title: "Product Information",
|
|
440
|
+
hideHeader: !0,
|
|
441
|
+
children: [
|
|
442
|
+
a && /* @__PURE__ */ s("div", { className: "flex items-center justify-between text-xs text-muted-foreground pb-2 border-b border-border/40 mb-2.5", children: [
|
|
443
|
+
/* @__PURE__ */ e("span", { className: "font-semibold text-[11px] uppercase tracking-wider text-muted-foreground/80", children: "Product Settings" }),
|
|
444
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 min-h-[16px]", children: Ke ? /* @__PURE__ */ s(Me, { children: [
|
|
445
|
+
/* @__PURE__ */ s("div", { className: "relative flex h-2 w-2", children: [
|
|
446
|
+
/* @__PURE__ */ e("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75" }),
|
|
447
|
+
/* @__PURE__ */ e("span", { className: "relative inline-flex rounded-full h-2 w-2 bg-amber-500" })
|
|
448
|
+
] }),
|
|
449
|
+
/* @__PURE__ */ e("span", { className: "text-amber-600 dark:text-amber-400 font-medium", children: "Autosaving settings..." })
|
|
450
|
+
] }) : ge ? /* @__PURE__ */ s("span", { className: "text-red-500 font-medium", children: [
|
|
451
|
+
"Error saving settings: ",
|
|
452
|
+
ge
|
|
453
|
+
] }) : _e ? /* @__PURE__ */ s("span", { className: "text-emerald-600 dark:text-emerald-400 font-medium", children: [
|
|
454
|
+
"Settings autosaved at ",
|
|
455
|
+
_e.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" })
|
|
456
|
+
] }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground/60", children: "Settings autosave in draft mode" }) })
|
|
457
|
+
] }),
|
|
458
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5", children: [
|
|
459
|
+
/* @__PURE__ */ s("div", { className: "col-span-2 space-y-1", children: [
|
|
460
|
+
/* @__PURE__ */ e(N, { htmlFor: "title", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Title" }),
|
|
461
|
+
/* @__PURE__ */ e(P, { id: "title", placeholder: "Product title", ...n("title"), className: "h-8 text-sm" }),
|
|
462
|
+
f.title && /* @__PURE__ */ e("p", { className: "text-destructive text-[11px] leading-none", children: f.title.message })
|
|
463
|
+
] }),
|
|
464
|
+
/* @__PURE__ */ s("div", { className: "col-span-2 space-y-1", children: [
|
|
465
|
+
/* @__PURE__ */ e(N, { htmlFor: "slug", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Slug" }),
|
|
466
|
+
/* @__PURE__ */ e(P, { id: "slug", placeholder: "product-slug", ...n("slug"), className: "h-8 text-sm" }),
|
|
467
|
+
f.slug && /* @__PURE__ */ e("p", { className: "text-destructive text-[11px] leading-none", children: f.slug.message })
|
|
468
|
+
] }),
|
|
469
|
+
/* @__PURE__ */ s("div", { className: "col-span-1 space-y-1", children: [
|
|
470
|
+
/* @__PURE__ */ e(N, { htmlFor: "sku", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "SKU" }),
|
|
471
|
+
/* @__PURE__ */ e(P, { id: "sku", placeholder: "SKU", ...n("sku"), className: "h-8 text-sm font-mono" }),
|
|
472
|
+
f.sku && /* @__PURE__ */ e("p", { className: "text-destructive text-[11px] leading-none", children: f.sku.message })
|
|
473
|
+
] }),
|
|
474
|
+
/* @__PURE__ */ s("div", { className: "col-span-1 space-y-1", children: [
|
|
475
|
+
/* @__PURE__ */ e(N, { htmlFor: "upc_ean", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "UPC / EAN" }),
|
|
476
|
+
/* @__PURE__ */ e(P, { id: "upc_ean", placeholder: "000000000", ...n("upc"), className: "h-8 text-sm font-mono", readOnly: S })
|
|
477
|
+
] })
|
|
478
|
+
] }),
|
|
479
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5 mt-2", children: [
|
|
480
|
+
/* @__PURE__ */ s("div", { className: "lg:col-span-2 col-span-2 space-y-1", children: [
|
|
481
|
+
/* @__PURE__ */ e(N, { htmlFor: "meta_title", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Meta Title" }),
|
|
482
|
+
/* @__PURE__ */ e(P, { id: "meta_title", ...n("meta_title"), placeholder: "SEO page title (50-60 chars)", className: "h-8 text-sm" })
|
|
483
|
+
] }),
|
|
484
|
+
/* @__PURE__ */ s("div", { className: `lg:col-span-${a ? "3" : "4"} col-span-2 space-y-1`, children: [
|
|
485
|
+
/* @__PURE__ */ e(N, { htmlFor: "meta_description", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Meta Description" }),
|
|
486
|
+
/* @__PURE__ */ e(P, { id: "meta_description", ...n("meta_description"), placeholder: "SEO description (150-160 chars)", className: "h-8 text-sm" })
|
|
487
|
+
] }),
|
|
488
|
+
a && /* @__PURE__ */ s("div", { className: "lg:col-span-1 col-span-2 space-y-1", children: [
|
|
489
|
+
/* @__PURE__ */ e(N, { htmlFor: "status", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Status" }),
|
|
490
|
+
/* @__PURE__ */ s(le, { onValueChange: (t) => d("status", t, { shouldDirty: !0 }), value: o("status"), children: [
|
|
491
|
+
/* @__PURE__ */ e(ne, { className: "h-8 text-xs", children: /* @__PURE__ */ e(ce, { placeholder: "Status" }) }),
|
|
492
|
+
/* @__PURE__ */ s(ue, { children: [
|
|
493
|
+
/* @__PURE__ */ e(F, { value: "draft", children: "Draft" }),
|
|
494
|
+
/* @__PURE__ */ e(F, { value: "active", children: "Active" }),
|
|
495
|
+
/* @__PURE__ */ e(F, { value: "archived", children: "Archived" })
|
|
496
|
+
] })
|
|
497
|
+
] })
|
|
498
|
+
] })
|
|
499
|
+
] })
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
/* @__PURE__ */ e(
|
|
504
|
+
Q,
|
|
505
|
+
{
|
|
506
|
+
title: "Product Categories",
|
|
507
|
+
description: "Assign this product to one or more categories.",
|
|
508
|
+
children: /* @__PURE__ */ e(
|
|
509
|
+
or,
|
|
510
|
+
{
|
|
511
|
+
categories: Ee,
|
|
512
|
+
selectedIds: o("category_ids") || [],
|
|
513
|
+
onChange: (t) => d("category_ids", t, { shouldDirty: !0, shouldValidate: !0 })
|
|
514
|
+
}
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
/* @__PURE__ */ s("section", { className: "rounded-lg border bg-card p-3 shadow-sm space-y-3", children: [
|
|
519
|
+
b && /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-4 flex-wrap border-b border-muted/50 pb-2", children: [
|
|
520
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ s("div", { className: "space-y-0.5", children: [
|
|
521
|
+
/* @__PURE__ */ e("h2", { className: "text-sm font-bold tracking-tight", children: "Pricing & Inventory" }),
|
|
522
|
+
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground leading-none", children: "Manage simple or variant pricing." })
|
|
523
|
+
] }) }),
|
|
524
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
|
|
525
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2 bg-muted/40 rounded-md px-2.5 py-1.5", children: [
|
|
526
|
+
/* @__PURE__ */ e("span", { className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Stock" }),
|
|
527
|
+
/* @__PURE__ */ e(
|
|
528
|
+
P,
|
|
529
|
+
{
|
|
530
|
+
id: "stock",
|
|
531
|
+
type: "number",
|
|
532
|
+
min: "0",
|
|
533
|
+
...n("stock", { valueAsNumber: !0 }),
|
|
534
|
+
placeholder: "0",
|
|
535
|
+
readOnly: S,
|
|
536
|
+
className: `${Ze} h-8 w-20 text-sm text-center font-mono bg-background`
|
|
537
|
+
}
|
|
538
|
+
)
|
|
539
|
+
] }),
|
|
540
|
+
S ? /* @__PURE__ */ e(L, { variant: "secondary", className: "text-[11px] py-0 px-2 h-5", children: "Variant pricing" }) : null
|
|
541
|
+
] })
|
|
542
|
+
] }),
|
|
543
|
+
b ? /* @__PURE__ */ s("div", { className: "space-y-3", children: [
|
|
544
|
+
/* @__PURE__ */ s("div", { className: "w-full", children: [
|
|
545
|
+
/* @__PURE__ */ e(
|
|
546
|
+
Ie,
|
|
547
|
+
{
|
|
548
|
+
idPrefix: "product",
|
|
549
|
+
currencies: c,
|
|
550
|
+
prices: X.prices,
|
|
551
|
+
salePrices: X.salePrices,
|
|
552
|
+
managedCurrencyCodes: K,
|
|
553
|
+
onPriceChange: we,
|
|
554
|
+
onSalePriceChange: ke,
|
|
555
|
+
onAutoFill: Ce,
|
|
556
|
+
readOnly: S,
|
|
557
|
+
helperText: S ? "Parent prices stay as a fallback, but active variants define the live shopper price." : void 0,
|
|
558
|
+
trailing: /* @__PURE__ */ e(
|
|
559
|
+
je,
|
|
560
|
+
{
|
|
561
|
+
idPrefix: "product",
|
|
562
|
+
startAt: o("sale_start_at"),
|
|
563
|
+
endAt: o("sale_end_at"),
|
|
564
|
+
onChange: (t, i) => d(t, i, { shouldDirty: !0, shouldValidate: !0 }),
|
|
565
|
+
error: f.sale_end_at?.message,
|
|
566
|
+
bare: !0
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
}
|
|
570
|
+
),
|
|
571
|
+
f.price && /* @__PURE__ */ e("p", { className: "text-destructive text-sm mt-1", children: f.price.message }),
|
|
572
|
+
f.sale_price && /* @__PURE__ */ e("p", { className: "text-destructive text-sm mt-1", children: f.sale_price.message }),
|
|
573
|
+
f.stock && /* @__PURE__ */ e("p", { className: "text-destructive text-[10px] font-medium leading-none mt-1", children: f.stock.message })
|
|
574
|
+
] }),
|
|
575
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3 rounded border border-dashed p-2.5 bg-muted/5", children: [
|
|
576
|
+
/* @__PURE__ */ e("span", { className: "text-xs font-bold uppercase tracking-wider text-muted-foreground", children: S ? "Variations Active" : "Variations" }),
|
|
577
|
+
/* @__PURE__ */ e(
|
|
578
|
+
Te,
|
|
579
|
+
{
|
|
580
|
+
type: "button",
|
|
581
|
+
variant: G ? "outline" : "default",
|
|
582
|
+
onClick: () => D((t) => !t),
|
|
583
|
+
size: "sm",
|
|
584
|
+
className: "h-7 text-xs px-3",
|
|
585
|
+
children: G ? "Hide" : "Manage"
|
|
586
|
+
}
|
|
587
|
+
)
|
|
588
|
+
] }),
|
|
589
|
+
G && /* @__PURE__ */ e("div", { className: "border-t pt-3", children: /* @__PURE__ */ e(
|
|
590
|
+
ir,
|
|
591
|
+
{
|
|
592
|
+
globalAttributes: C,
|
|
593
|
+
currentLanguageCode: Ye,
|
|
594
|
+
baseSku: o("sku") || "",
|
|
595
|
+
basePrice: M || 0,
|
|
596
|
+
basePrices: v,
|
|
597
|
+
baseSalePrice: typeof j == "number" ? j : null,
|
|
598
|
+
baseSalePrices: V,
|
|
599
|
+
currencies: c,
|
|
600
|
+
availableVariantImages: Ge,
|
|
601
|
+
initialVariationAttributes: r?.variation_attributes,
|
|
602
|
+
initialVariants: Le,
|
|
603
|
+
onChange: We
|
|
604
|
+
}
|
|
605
|
+
) })
|
|
606
|
+
] }) : /* @__PURE__ */ s(Me, { children: [
|
|
607
|
+
/* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
608
|
+
/* @__PURE__ */ s("div", { className: "flex items-end gap-4 w-full", children: [
|
|
609
|
+
/* @__PURE__ */ s("div", { className: "flex-1", children: [
|
|
610
|
+
/* @__PURE__ */ e(N, { htmlFor: "freemius_product_id", className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block", children: "Freemius Product ID" }),
|
|
611
|
+
/* @__PURE__ */ e(P, { id: "freemius_product_id", ...n("freemius_product_id"), className: "h-9" })
|
|
612
|
+
] }),
|
|
613
|
+
/* @__PURE__ */ s("div", { className: "flex-1", children: [
|
|
614
|
+
/* @__PURE__ */ e(N, { htmlFor: "freemius_plan_id", className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block", children: "Freemius Plan ID" }),
|
|
615
|
+
/* @__PURE__ */ e(P, { id: "freemius_plan_id", ...n("freemius_plan_id"), className: "h-9" })
|
|
616
|
+
] }),
|
|
617
|
+
He ? /* @__PURE__ */ e(dr, { productId: o("freemius_product_id") }) : null
|
|
618
|
+
] }),
|
|
619
|
+
/* @__PURE__ */ s("div", { className: "bg-muted/10 border rounded-md overflow-hidden", children: [
|
|
620
|
+
/* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-6 bg-muted/20 border-b p-2.5 px-4", children: [
|
|
621
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
622
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground", children: "Free Trial" }),
|
|
623
|
+
/* @__PURE__ */ s(L, { variant: "outline", className: "font-mono text-xs shadow-sm bg-background", children: [
|
|
624
|
+
String(o("trial_period_days") || 0),
|
|
625
|
+
" Days"
|
|
626
|
+
] })
|
|
627
|
+
] }),
|
|
628
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
629
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground", children: "Card Required" }),
|
|
630
|
+
/* @__PURE__ */ e(L, { variant: Ne ? "default" : "secondary", className: "text-xs shadow-sm", children: Ne ? "Yes" : "No" })
|
|
631
|
+
] }),
|
|
632
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground ml-auto", children: "Managed in Freemius dashboard" }),
|
|
633
|
+
/* @__PURE__ */ e("input", { type: "hidden", ...n("trial_period_days", { valueAsNumber: !0 }) })
|
|
634
|
+
] }),
|
|
635
|
+
/* @__PURE__ */ s("div", { className: "w-full p-4 pt-3 space-y-2", children: [
|
|
636
|
+
/* @__PURE__ */ e(
|
|
637
|
+
Ie,
|
|
638
|
+
{
|
|
639
|
+
idPrefix: "product",
|
|
640
|
+
currencies: c,
|
|
641
|
+
prices: X.prices,
|
|
642
|
+
salePrices: X.salePrices,
|
|
643
|
+
managedCurrencyCodes: K,
|
|
644
|
+
onPriceChange: we,
|
|
645
|
+
onSalePriceChange: ke,
|
|
646
|
+
onAutoFill: Ce,
|
|
647
|
+
readOnly: !0,
|
|
648
|
+
trailing: /* @__PURE__ */ e(
|
|
649
|
+
je,
|
|
650
|
+
{
|
|
651
|
+
idPrefix: "product",
|
|
652
|
+
startAt: o("sale_start_at"),
|
|
653
|
+
endAt: o("sale_end_at"),
|
|
654
|
+
onChange: (t, i) => d(t, i, { shouldDirty: !0, shouldValidate: !0 }),
|
|
655
|
+
error: f.sale_end_at?.message,
|
|
656
|
+
bare: !0
|
|
657
|
+
}
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
),
|
|
661
|
+
/* @__PURE__ */ e("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." })
|
|
662
|
+
] })
|
|
663
|
+
] })
|
|
664
|
+
] }),
|
|
665
|
+
z && /* @__PURE__ */ e("div", { className: "pt-2 border-t", children: z })
|
|
666
|
+
] })
|
|
667
|
+
] }),
|
|
668
|
+
/* @__PURE__ */ e(Q, { title: "Product Description", hideHeader: !0, children: /* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
669
|
+
/* @__PURE__ */ e(N, { htmlFor: "short_description", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Short Description" }),
|
|
670
|
+
/* @__PURE__ */ e(P, { id: "short_description", ...n("short_description"), placeholder: "Brief summary for product cards...", className: "h-8 text-sm" })
|
|
671
|
+
] }) }) }),
|
|
672
|
+
/* @__PURE__ */ s(Q, { title: "Media Gallery", description: "Drag to reorder. First image is the hero.", children: [
|
|
673
|
+
/* @__PURE__ */ e(
|
|
674
|
+
ar,
|
|
675
|
+
{
|
|
676
|
+
initialMedia: de,
|
|
677
|
+
onUpdate: Qe,
|
|
678
|
+
mediaPickerNode: x
|
|
679
|
+
}
|
|
680
|
+
),
|
|
681
|
+
/* @__PURE__ */ e("input", { type: "hidden", ...n("product_media") })
|
|
682
|
+
] }),
|
|
683
|
+
!a && /* @__PURE__ */ s("div", { className: "rounded-lg border bg-card p-3 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap", children: [
|
|
684
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
685
|
+
/* @__PURE__ */ e("span", { className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Status" }),
|
|
686
|
+
/* @__PURE__ */ s(le, { onValueChange: (t) => d("status", t), value: o("status"), children: [
|
|
687
|
+
/* @__PURE__ */ e(ne, { className: "h-8 w-[110px] text-sm", children: /* @__PURE__ */ e(ce, { placeholder: "Status" }) }),
|
|
688
|
+
/* @__PURE__ */ s(ue, { children: [
|
|
689
|
+
/* @__PURE__ */ e(F, { value: "draft", children: "Draft" }),
|
|
690
|
+
/* @__PURE__ */ e(F, { value: "active", children: "Active" }),
|
|
691
|
+
/* @__PURE__ */ e(F, { value: "archived", children: "Archived" })
|
|
692
|
+
] })
|
|
693
|
+
] })
|
|
694
|
+
] }),
|
|
695
|
+
/* @__PURE__ */ e(Te, { disabled: B, type: "submit", size: "sm", className: "h-8 text-sm px-5", children: B ? "Saving..." : "Save Changes" })
|
|
696
|
+
] })
|
|
697
|
+
] })
|
|
698
|
+
] });
|
|
699
|
+
}
|
|
700
|
+
export {
|
|
701
|
+
Tr as ProductForm
|
|
702
|
+
};
|