@nextblock-cms/ecom 0.20.1 → 0.21.0
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/_virtual/_rolldown/runtime.cjs.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs.js +1 -1
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs.js +1 -1
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs.js +1 -1
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs.js +1 -1
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs.js +1 -1
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs.js +1 -1
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs.js +1 -1
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs.js +1 -1
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs.js +1 -1
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs.js +1 -1
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs.js +1 -1
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs.js +1 -1
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs.js +1 -1
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs.js +1 -1
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs.js +1 -1
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs.js +1 -1
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs.js +1 -1
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs.js +1 -1
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs.js +25 -25
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs.js +1 -1
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs.js +1 -1
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs.js +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs.js +3 -3
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs.js +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs.js +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs.js +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs.js +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs.js +1 -1
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs.js +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs.js +1 -1
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs.js +1 -5
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs.js +1 -1
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs.js +1 -1
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs.js +1 -1
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs.js +1 -1
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs.js +2 -2
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs.js +2 -2
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs.js +1 -1
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs.js +1 -1
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs.js +1 -1
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs.js +1 -1
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs.js +1 -1
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs.js +1 -1
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +16 -16
- package/server.cjs.js +1 -1
- package/server.es.js +56 -211
|
@@ -1,700 +1,879 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { derivePaymentProviderFromProductType as e } from "../../../../types.es.js";
|
|
3
|
+
import { convertMinorUnitAmount as t } from "../../../../currency.es.js";
|
|
4
|
+
import { productSchema as n } from "../../../../product-schema.es.js";
|
|
5
|
+
import { ProductMediaManager as r } from "./ProductMediaManager.es.js";
|
|
6
|
+
import { SyncFreemiusPricingButton as i } from "./SyncFreemiusPricingButton.es.js";
|
|
7
|
+
import { CurrencyPriceFields as a } from "./CurrencyPriceFields.es.js";
|
|
8
|
+
import { SaleScheduleFields as o } from "./SaleScheduleFields.es.js";
|
|
9
|
+
import { getStoreManagedPriceCurrencyCodes as ee, resolveEditorCurrencyPriceMaps as te, sanitizeProductFormValuesForStoreManagedCurrencies as ne } from "../product-price-sync.es.js";
|
|
10
|
+
import { VariationsEditor as s } from "./VariationsEditor.es.js";
|
|
11
|
+
import { ProductCategorySelector as c } from "./ProductCategorySelector.es.js";
|
|
12
|
+
import l, { useCallback as u, useEffect as d, useRef as re, useState as f } from "react";
|
|
13
|
+
import { AlertCircle as ie, CheckCircle2 as ae, Info as oe } from "lucide-react";
|
|
14
|
+
import { majorUnitAmountToMinor as se, minorUnitAmountToMajor as ce } from "@nextblock-cms/utils";
|
|
15
|
+
import { Fragment as le, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
16
|
+
import { useForm as ue } from "react-hook-form";
|
|
17
|
+
import { zodResolver as de } from "@hookform/resolvers/zod";
|
|
18
|
+
import { Badge as h, Button as fe, Input as g, Label as _, Select as pe, SelectContent as me, SelectItem as he, SelectTrigger as ge, SelectValue as _e } from "@nextblock-cms/ui";
|
|
19
|
+
//#region libs/ecommerce/src/lib/pages/cms/products/components/ProductForm.tsx
|
|
20
|
+
function v({ title: e, description: t, action: n, children: r, hideHeader: i }) {
|
|
21
|
+
return /* @__PURE__ */ m("section", {
|
|
22
|
+
className: "rounded-lg border bg-card p-3 shadow-sm space-y-3",
|
|
23
|
+
children: [!i && /* @__PURE__ */ m("div", {
|
|
24
|
+
className: "flex items-start justify-between gap-4 flex-wrap border-b border-muted/50 pb-2 mb-1",
|
|
25
|
+
children: [/* @__PURE__ */ m("div", {
|
|
26
|
+
className: "space-y-0.5",
|
|
27
|
+
children: [/* @__PURE__ */ p("h2", {
|
|
28
|
+
className: "text-sm font-bold tracking-tight",
|
|
29
|
+
children: e
|
|
30
|
+
}), t ? /* @__PURE__ */ p("p", {
|
|
31
|
+
className: "text-[11px] text-muted-foreground leading-none",
|
|
32
|
+
children: t
|
|
33
|
+
}) : null]
|
|
34
|
+
}), n]
|
|
35
|
+
}), /* @__PURE__ */ p("div", {
|
|
36
|
+
className: i ? "" : "pt-1",
|
|
37
|
+
children: r
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
30
40
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
function y(e, t, n) {
|
|
42
|
+
let r = t ? Number.parseInt(t, 10) : void 0;
|
|
43
|
+
return e?.language_id || (Number.isFinite(r) ? r : void 0) || n.find((e) => e.is_default)?.id || n[0]?.id || 1;
|
|
34
44
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
variation_attributes: r?.variation_attributes || [],
|
|
79
|
-
variants: r?.variants?.map((b) => ({
|
|
80
|
-
...b,
|
|
81
|
-
prices: b.prices || {},
|
|
82
|
-
sale_prices: b.sale_prices || {}
|
|
83
|
-
})) || []
|
|
84
|
-
}, m),
|
|
85
|
-
product_type: z,
|
|
86
|
-
payment_provider: A
|
|
87
|
-
};
|
|
45
|
+
function ve(t, n, r, i, a) {
|
|
46
|
+
let o = (i.find((e) => e.is_default) ?? i[0])?.code || "USD", ee = t?.prices && Object.keys(t.prices).length > 0 ? t.prices : { [o]: typeof t?.price == "number" ? t.price / 100 : 0 }, te = t?.sale_prices && Object.keys(t.sale_prices).length > 0 ? t.sale_prices : typeof t?.sale_price == "number" ? { [o]: t.sale_price / 100 } : {}, s = t?.product_type || "", c = t?.payment_provider || (t?.product_type ? e(t.product_type) : "stripe");
|
|
47
|
+
return {
|
|
48
|
+
...ne({
|
|
49
|
+
product_type: s || "physical",
|
|
50
|
+
payment_provider: c,
|
|
51
|
+
title: t?.title || "",
|
|
52
|
+
slug: t?.slug || "",
|
|
53
|
+
sku: t?.sku || "",
|
|
54
|
+
upc: t?.upc || "",
|
|
55
|
+
is_taxable: t?.is_taxable ?? !0,
|
|
56
|
+
price: typeof t?.price == "number" ? t.price / 100 : 0,
|
|
57
|
+
prices: ee,
|
|
58
|
+
sale_price: typeof t?.sale_price == "number" ? t.sale_price / 100 : null,
|
|
59
|
+
sale_prices: te,
|
|
60
|
+
stock: t?.stock || 0,
|
|
61
|
+
meta_title: t?.meta_title || "",
|
|
62
|
+
meta_description: t?.meta_description || "",
|
|
63
|
+
custom_canonical: t?.custom_canonical || "",
|
|
64
|
+
short_description: t?.short_description || "",
|
|
65
|
+
description_json: t?.description_json || {
|
|
66
|
+
type: "doc",
|
|
67
|
+
content: [{ type: "paragraph" }]
|
|
68
|
+
},
|
|
69
|
+
freemius_product_id: t?.freemius_product_id || "",
|
|
70
|
+
freemius_plan_id: t?.freemius_plan_id || "",
|
|
71
|
+
trial_period_days: t?.trial_period_days ?? 0,
|
|
72
|
+
trial_requires_payment_method: t?.trial_requires_payment_method ?? !1,
|
|
73
|
+
status: t?.status || "draft",
|
|
74
|
+
language_id: y(t, n, r),
|
|
75
|
+
translation_group_id: t?.translation_group_id || a || void 0,
|
|
76
|
+
product_media: t?.product_media?.map((e) => ({ media_id: e.media_id })) || [],
|
|
77
|
+
category_ids: t?.category_ids || [],
|
|
78
|
+
variation_attributes: t?.variation_attributes || [],
|
|
79
|
+
variants: t?.variants?.map((e) => ({
|
|
80
|
+
...e,
|
|
81
|
+
prices: e.prices || {},
|
|
82
|
+
sale_prices: e.sale_prices || {}
|
|
83
|
+
})) || []
|
|
84
|
+
}, i),
|
|
85
|
+
product_type: s,
|
|
86
|
+
payment_provider: c
|
|
87
|
+
};
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
function ye(e) {
|
|
90
|
+
return e ? e.map((e) => ({
|
|
91
|
+
id: e.id || e.media_id,
|
|
92
|
+
media_id: e.media_id,
|
|
93
|
+
file_path: e.media?.file_path || e.media?.object_key || "",
|
|
94
|
+
alt: e.media?.alt_text || "",
|
|
95
|
+
sort_order: e.sort_order ?? 0
|
|
96
|
+
})).sort((e, t) => e.sort_order - t.sort_order) : [];
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
98
|
+
function be(e) {
|
|
99
|
+
return e.map((e) => ({ media_id: e.media_id }));
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
function xe(e) {
|
|
102
|
+
return e.map((e) => ({
|
|
103
|
+
media_id: e.media_id,
|
|
104
|
+
file_path: e.file_path,
|
|
105
|
+
alt: e.alt
|
|
106
|
+
}));
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
108
|
+
var Se = (e) => e.toString().toLowerCase().trim().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
109
|
+
function Ce({ initialData: e, isEdit: y = !1, mediaPickerNode: Ce, availableLanguagesProp: b, globalAttributesProp: we, currenciesProp: Te, translationGroupId: x, targetLanguageId: S, freemiusDashboardNode: Ee, enabledProviders: De, configStatus: C, createAction: Oe, updateAction: ke, availableCategoriesProp: Ae = [], hasOpenDraft: je = !1, onSeoChange: Me }) {
|
|
110
|
+
let [w, T] = f(!1), [E, D] = f(() => !!e?.variants?.length), O = l.useMemo(() => Te.filter((e) => e.is_active !== !1).sort((e, t) => e.is_default === t.is_default ? e.code.localeCompare(t.code) : e.is_default ? -1 : 1), [Te]), k = l.useMemo(() => O.find((e) => e.is_default) ?? O[0], [O]), A = l.useMemo(() => ee(O), [O]), Ne = ue({
|
|
111
|
+
resolver: de(n),
|
|
112
|
+
defaultValues: ve(e, S, b, O, x)
|
|
113
|
+
}), { register: j, handleSubmit: M, setValue: N, reset: Pe, watch: P, setError: F, formState: { errors: I, dirtyFields: Fe } } = Ne, Ie = re(!0), L = re(null), [Le, R] = f(!1), [Re, z] = f(null), [ze, Be] = f(null), B = P(), Ve = Ne.formState.isDirty, He = B.title, Ue = B.meta_title, V = B.meta_description;
|
|
114
|
+
d(() => {
|
|
115
|
+
Me?.({
|
|
116
|
+
title: He,
|
|
117
|
+
meta_title: Ue,
|
|
118
|
+
meta_description: V
|
|
119
|
+
});
|
|
120
|
+
}, [
|
|
121
|
+
He,
|
|
122
|
+
Ue,
|
|
123
|
+
V,
|
|
124
|
+
Me
|
|
125
|
+
]), d(() => {
|
|
126
|
+
if (!y) return;
|
|
127
|
+
if (Ie.current) {
|
|
128
|
+
Ie.current = !1, L.current = JSON.stringify(B);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!Ve) return;
|
|
132
|
+
let e = JSON.stringify(B);
|
|
133
|
+
if (e === L.current) return;
|
|
134
|
+
let t = setTimeout(() => {
|
|
135
|
+
w || (L.current = e, M($)());
|
|
136
|
+
}, 400);
|
|
137
|
+
return () => clearTimeout(t);
|
|
138
|
+
}, [
|
|
139
|
+
B,
|
|
140
|
+
y,
|
|
141
|
+
Ve,
|
|
142
|
+
w,
|
|
143
|
+
M
|
|
144
|
+
]);
|
|
145
|
+
let We = P("title"), H = P("product_type"), U = H === "digital" ? "freemius" : H === "physical" ? "stripe" : void 0, W = H === "physical", Ge = H === "digital", Ke = U ? De[U] : !1, qe = U ? C[U].hasKeys : !1, Je = !!P("freemius_product_id"), Ye = Number(P("trial_period_days") || 0), Xe = !!P("trial_requires_payment_method"), Ze = P("variants") || [], G = P("price"), K = P("sale_price"), q = P("prices") || {}, J = P("sale_prices") || {}, Y = (Ze?.length || 0) > 0, Qe = P("language_id"), $e = b.find((e) => e.id === Qe)?.code || b.find((e) => e.is_default)?.code || b[0]?.code, X = l.useMemo(() => te({
|
|
146
|
+
currencies: O,
|
|
147
|
+
prices: q,
|
|
148
|
+
salePrices: J,
|
|
149
|
+
fallbackPrice: G,
|
|
150
|
+
fallbackSalePrice: K
|
|
151
|
+
}), [
|
|
152
|
+
G,
|
|
153
|
+
K,
|
|
154
|
+
O,
|
|
155
|
+
q,
|
|
156
|
+
J
|
|
157
|
+
]), et = l.useMemo(() => e?.variants?.map((e) => ({
|
|
158
|
+
...e,
|
|
159
|
+
prices: e.prices || {},
|
|
160
|
+
sale_prices: e.sale_prices || {}
|
|
161
|
+
})), [e?.variants]);
|
|
162
|
+
d(() => {
|
|
163
|
+
if (Fe.title && !y) {
|
|
164
|
+
let e = Se(We);
|
|
165
|
+
N("slug", e, { shouldValidate: !0 });
|
|
166
|
+
}
|
|
167
|
+
}, [
|
|
168
|
+
We,
|
|
169
|
+
Fe.title,
|
|
170
|
+
N,
|
|
171
|
+
y
|
|
172
|
+
]);
|
|
173
|
+
let [Z, tt] = f(() => ye(e?.product_media)), [Q, nt] = f(/* @__PURE__ */ new Set());
|
|
174
|
+
d(() => {
|
|
175
|
+
Pe(ve(e, S, b, O, x)), tt(ye(e?.product_media)), nt(/* @__PURE__ */ new Set()), D(!!e?.variants?.length);
|
|
176
|
+
}, [
|
|
177
|
+
b,
|
|
178
|
+
O,
|
|
179
|
+
e,
|
|
180
|
+
Pe,
|
|
181
|
+
S,
|
|
182
|
+
x
|
|
183
|
+
]);
|
|
184
|
+
let rt = (e) => {
|
|
185
|
+
let t = new Set(e.map((e) => e.id)), n = Z.filter((e) => !t.has(e.id)), r = new Set(Q);
|
|
186
|
+
n.forEach((e) => {
|
|
187
|
+
e.media_id && r.add(e.media_id);
|
|
188
|
+
}), nt(r), tt(e), N("product_media", be(e), { shouldDirty: !0 }), N("explicitly_removed_media_ids", Array.from(r), { shouldDirty: !0 });
|
|
189
|
+
};
|
|
190
|
+
d(() => {
|
|
191
|
+
N("explicitly_removed_media_ids", Array.from(Q));
|
|
192
|
+
}, [Q, N]), d(() => {
|
|
193
|
+
Y && D(!0);
|
|
194
|
+
}, [Y]), d(() => {
|
|
195
|
+
j("is_taxable"), j("price"), j("sale_price"), j("payment_provider"), j("trial_requires_payment_method");
|
|
196
|
+
}, [j]), d(() => {
|
|
197
|
+
if (!Ge) {
|
|
198
|
+
N("trial_period_days", 0, {
|
|
199
|
+
shouldDirty: !1,
|
|
200
|
+
shouldValidate: !0
|
|
201
|
+
}), N("trial_requires_payment_method", !1, {
|
|
202
|
+
shouldDirty: !1,
|
|
203
|
+
shouldValidate: !0
|
|
204
|
+
});
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
Ye <= 0 && N("trial_requires_payment_method", !1, {
|
|
208
|
+
shouldDirty: !1,
|
|
209
|
+
shouldValidate: !0
|
|
210
|
+
});
|
|
211
|
+
}, [
|
|
212
|
+
Ge,
|
|
213
|
+
N,
|
|
214
|
+
Ye
|
|
215
|
+
]), d(() => {
|
|
216
|
+
U && N("payment_provider", U, {
|
|
217
|
+
shouldDirty: !1,
|
|
218
|
+
shouldValidate: !0
|
|
219
|
+
});
|
|
220
|
+
}, [U, N]), d(() => {
|
|
221
|
+
k && q[k.code] === void 0 && N("prices", {
|
|
222
|
+
...q,
|
|
223
|
+
[k.code]: G || 0
|
|
224
|
+
}, { shouldDirty: !1 });
|
|
225
|
+
}, [
|
|
226
|
+
G,
|
|
227
|
+
k,
|
|
228
|
+
q,
|
|
229
|
+
N
|
|
230
|
+
]);
|
|
231
|
+
let it = u((e, t) => {
|
|
232
|
+
let n = {
|
|
233
|
+
...q,
|
|
234
|
+
[e]: t
|
|
235
|
+
};
|
|
236
|
+
N("prices", n, {
|
|
237
|
+
shouldDirty: !0,
|
|
238
|
+
shouldValidate: !0
|
|
239
|
+
}), e === k?.code && N("price", t, {
|
|
240
|
+
shouldDirty: !0,
|
|
241
|
+
shouldValidate: !0
|
|
242
|
+
});
|
|
243
|
+
}, [
|
|
244
|
+
k?.code,
|
|
245
|
+
q,
|
|
246
|
+
N
|
|
247
|
+
]), at = u((e, t) => {
|
|
248
|
+
let n = {
|
|
249
|
+
...J,
|
|
250
|
+
[e]: t
|
|
251
|
+
};
|
|
252
|
+
N("sale_prices", n, {
|
|
253
|
+
shouldDirty: !0,
|
|
254
|
+
shouldValidate: !0
|
|
255
|
+
}), e === k?.code && N("sale_price", t, {
|
|
256
|
+
shouldDirty: !0,
|
|
257
|
+
shouldValidate: !0
|
|
258
|
+
});
|
|
259
|
+
}, [
|
|
260
|
+
k?.code,
|
|
261
|
+
J,
|
|
262
|
+
N
|
|
263
|
+
]), ot = u(() => {
|
|
264
|
+
if (!k) return;
|
|
265
|
+
let e = new Set(A), n = q[k.code] ?? G ?? 0, r = J[k.code] ?? K ?? null, i = O.reduce((r, i) => {
|
|
266
|
+
if (i.code !== k.code && e.has(i.code)) return r;
|
|
267
|
+
let a = t({
|
|
268
|
+
amount: se(n, k.code),
|
|
269
|
+
fromCurrencyCode: k.code,
|
|
270
|
+
toCurrencyCode: i.code,
|
|
271
|
+
currencies: O,
|
|
272
|
+
applyRounding: !0
|
|
273
|
+
});
|
|
274
|
+
return r[i.code] = ce(a, i.code), r;
|
|
275
|
+
}, {}), a = O.reduce((n, i) => {
|
|
276
|
+
if (i.code !== k.code && e.has(i.code)) return n;
|
|
277
|
+
if (typeof r != "number") return (i.code === k.code || !e.has(i.code)) && (n[i.code] = null), n;
|
|
278
|
+
let a = t({
|
|
279
|
+
amount: se(r, k.code),
|
|
280
|
+
fromCurrencyCode: k.code,
|
|
281
|
+
toCurrencyCode: i.code,
|
|
282
|
+
currencies: O,
|
|
283
|
+
applyRounding: !0
|
|
284
|
+
});
|
|
285
|
+
return n[i.code] = ce(a, i.code), n;
|
|
286
|
+
}, {});
|
|
287
|
+
N("prices", i, {
|
|
288
|
+
shouldDirty: !0,
|
|
289
|
+
shouldValidate: !0
|
|
290
|
+
}), N("sale_prices", a, {
|
|
291
|
+
shouldDirty: !0,
|
|
292
|
+
shouldValidate: !0
|
|
293
|
+
}), N("price", i[k.code] ?? n, {
|
|
294
|
+
shouldDirty: !0,
|
|
295
|
+
shouldValidate: !0
|
|
296
|
+
}), N("sale_price", a[k.code] ?? null, {
|
|
297
|
+
shouldDirty: !0,
|
|
298
|
+
shouldValidate: !0
|
|
299
|
+
});
|
|
300
|
+
}, [
|
|
301
|
+
O,
|
|
302
|
+
k,
|
|
303
|
+
q,
|
|
304
|
+
J,
|
|
305
|
+
N,
|
|
306
|
+
A,
|
|
307
|
+
G,
|
|
308
|
+
K
|
|
309
|
+
]), st = u(({ variationAttributes: e, variants: t }) => {
|
|
310
|
+
N("variation_attributes", e, { shouldDirty: !0 }), N("variants", t, {
|
|
311
|
+
shouldDirty: !0,
|
|
312
|
+
shouldValidate: !0
|
|
313
|
+
});
|
|
314
|
+
}, [N]), $ = async (e) => {
|
|
315
|
+
T(!0), R(!0), z(null);
|
|
316
|
+
try {
|
|
317
|
+
if (!U) {
|
|
318
|
+
let e = "Select whether this product is physical or digital before saving.";
|
|
319
|
+
F("product_type", {
|
|
320
|
+
type: "manual",
|
|
321
|
+
message: e
|
|
322
|
+
}), y ? z(e) : alert(e), T(!1), R(!1);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
let t = W ? 0 : Math.max(0, Number(e.trial_period_days || 0)), n = {
|
|
326
|
+
...e,
|
|
327
|
+
product_type: e.product_type,
|
|
328
|
+
payment_provider: U,
|
|
329
|
+
freemius_product_id: W ? "" : e.freemius_product_id,
|
|
330
|
+
freemius_plan_id: W ? "" : e.freemius_plan_id,
|
|
331
|
+
trial_period_days: t,
|
|
332
|
+
trial_requires_payment_method: !W && t > 0 && e.trial_requires_payment_method,
|
|
333
|
+
upc: W ? e.upc : null,
|
|
334
|
+
is_taxable: W ? e.is_taxable : !1,
|
|
335
|
+
variation_attributes: W ? e.variation_attributes : [],
|
|
336
|
+
variants: W ? e.variants : []
|
|
337
|
+
}, r = ne(n, O);
|
|
338
|
+
if (y && ke) await ke(r), Be(/* @__PURE__ */ new Date());
|
|
339
|
+
else if (Oe) await Oe(r);
|
|
340
|
+
else throw Error("Product form action is not configured.");
|
|
341
|
+
} catch (e) {
|
|
342
|
+
if (console.error(e), e.message === "NEXT_REDIRECT") return;
|
|
343
|
+
let t = e.message || "An error occurred while saving.";
|
|
344
|
+
if (e.code === "23505") {
|
|
345
|
+
let n = e.message?.toLowerCase() || "";
|
|
346
|
+
n.includes("products_slug_key") || n.includes("slug") ? (t = "This slug is already in use. Please choose another one.", F("slug", {
|
|
347
|
+
type: "manual",
|
|
348
|
+
message: t
|
|
349
|
+
})) : (n.includes("products_sku_key") || n.includes("sku")) && (t = "This SKU is already in use.", F("sku", {
|
|
350
|
+
type: "manual",
|
|
351
|
+
message: t
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
y ? z(t) : alert(t);
|
|
355
|
+
} finally {
|
|
356
|
+
T(!1), R(!1);
|
|
357
|
+
}
|
|
358
|
+
}, ct = Y ? "bg-muted/60 text-muted-foreground opacity-70" : "", lt = xe(Z);
|
|
359
|
+
return /* @__PURE__ */ m("form", {
|
|
360
|
+
onSubmit: M($),
|
|
361
|
+
className: "space-y-2.5 pb-4",
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ p("input", {
|
|
364
|
+
type: "hidden",
|
|
365
|
+
...j("translation_group_id")
|
|
366
|
+
}),
|
|
367
|
+
/* @__PURE__ */ p("input", {
|
|
368
|
+
type: "hidden",
|
|
369
|
+
...j("payment_provider")
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ m("div", {
|
|
372
|
+
className: "space-y-2.5 w-full",
|
|
373
|
+
children: [
|
|
374
|
+
/* @__PURE__ */ m("div", {
|
|
375
|
+
className: "rounded-lg border bg-card p-2.5 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",
|
|
376
|
+
children: [/* @__PURE__ */ m("div", {
|
|
377
|
+
className: "flex items-center gap-6",
|
|
378
|
+
children: [/* @__PURE__ */ m("div", {
|
|
379
|
+
className: "flex h-9 items-center gap-2",
|
|
380
|
+
children: [/* @__PURE__ */ p("span", {
|
|
381
|
+
className: "text-sm font-bold whitespace-nowrap leading-none pt-0.5",
|
|
382
|
+
children: "Product Type"
|
|
383
|
+
}), I.product_type && /* @__PURE__ */ p(ie, { className: "h-4 w-4 text-destructive" })]
|
|
384
|
+
}), /* @__PURE__ */ p("div", {
|
|
385
|
+
className: "flex h-9 items-center",
|
|
386
|
+
children: /* @__PURE__ */ m(pe, {
|
|
387
|
+
onValueChange: (e) => N("product_type", e, {
|
|
388
|
+
shouldDirty: !0,
|
|
389
|
+
shouldValidate: !0
|
|
390
|
+
}),
|
|
391
|
+
value: H || void 0,
|
|
392
|
+
children: [/* @__PURE__ */ p(ge, {
|
|
393
|
+
className: "w-[160px] h-9 text-xs",
|
|
394
|
+
children: /* @__PURE__ */ p(_e, { placeholder: "Select Type" })
|
|
395
|
+
}), /* @__PURE__ */ m(me, { children: [/* @__PURE__ */ p(he, {
|
|
396
|
+
value: "physical",
|
|
397
|
+
children: "Physical Product"
|
|
398
|
+
}), /* @__PURE__ */ p(he, {
|
|
399
|
+
value: "digital",
|
|
400
|
+
children: "Digital Product"
|
|
401
|
+
})] })]
|
|
402
|
+
})
|
|
403
|
+
})]
|
|
404
|
+
}), /* @__PURE__ */ m("div", {
|
|
405
|
+
className: "flex items-center gap-6",
|
|
406
|
+
children: [
|
|
407
|
+
/* @__PURE__ */ m("div", {
|
|
408
|
+
className: "flex h-9 items-center gap-3",
|
|
409
|
+
children: [/* @__PURE__ */ p("span", {
|
|
410
|
+
className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider leading-none",
|
|
411
|
+
children: "Payment Provider"
|
|
412
|
+
}), /* @__PURE__ */ p(h, {
|
|
413
|
+
variant: "outline",
|
|
414
|
+
className: "text-xs py-1 font-bold bg-muted/30 leading-none",
|
|
415
|
+
children: U ? U === "stripe" ? "Stripe" : "Freemius" : "—"
|
|
416
|
+
})]
|
|
417
|
+
}),
|
|
418
|
+
U && /* @__PURE__ */ p("div", {
|
|
419
|
+
className: "flex h-9 items-center gap-2",
|
|
420
|
+
children: Ke && qe ? /* @__PURE__ */ m("span", {
|
|
421
|
+
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",
|
|
422
|
+
children: [/* @__PURE__ */ p(ae, { className: "h-3 w-3" }), "Ready"]
|
|
423
|
+
}) : /* @__PURE__ */ m("span", {
|
|
424
|
+
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",
|
|
425
|
+
children: [/* @__PURE__ */ p(ie, { className: "h-3 w-3" }), Ke ? "Keys Missing" : "Disabled"]
|
|
426
|
+
})
|
|
427
|
+
}),
|
|
428
|
+
!qe && U && C[U].missing.length > 0 && /* @__PURE__ */ m("a", {
|
|
429
|
+
href: "/cms/payments",
|
|
430
|
+
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 hover:text-foreground hover:border-solid",
|
|
431
|
+
children: [
|
|
432
|
+
/* @__PURE__ */ p(oe, { className: "h-3 w-3" }),
|
|
433
|
+
"Missing: ",
|
|
434
|
+
C[U].missing.join(", "),
|
|
435
|
+
" — set up payments"
|
|
436
|
+
]
|
|
437
|
+
})
|
|
438
|
+
]
|
|
439
|
+
})]
|
|
440
|
+
}),
|
|
441
|
+
/* @__PURE__ */ m(v, {
|
|
442
|
+
title: "Product Information",
|
|
443
|
+
hideHeader: !0,
|
|
444
|
+
children: [
|
|
445
|
+
y && /* @__PURE__ */ m("div", {
|
|
446
|
+
className: "flex items-center justify-between text-xs text-muted-foreground pb-2 border-b border-border/40 mb-2.5",
|
|
447
|
+
children: [/* @__PURE__ */ p("span", {
|
|
448
|
+
className: "font-semibold text-[11px] uppercase tracking-wider text-muted-foreground/80",
|
|
449
|
+
children: "Product Settings"
|
|
450
|
+
}), /* @__PURE__ */ p("div", {
|
|
451
|
+
className: "flex items-center gap-1.5 min-h-[16px]",
|
|
452
|
+
children: Le ? /* @__PURE__ */ m(le, { children: [/* @__PURE__ */ m("div", {
|
|
453
|
+
className: "relative flex h-2 w-2",
|
|
454
|
+
children: [/* @__PURE__ */ p("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75" }), /* @__PURE__ */ p("span", { className: "relative inline-flex rounded-full h-2 w-2 bg-amber-500" })]
|
|
455
|
+
}), /* @__PURE__ */ p("span", {
|
|
456
|
+
className: "text-amber-600 dark:text-amber-400 font-medium",
|
|
457
|
+
children: "Autosaving settings..."
|
|
458
|
+
})] }) : Re ? /* @__PURE__ */ m("span", {
|
|
459
|
+
className: "text-red-500 font-medium",
|
|
460
|
+
children: ["Error saving settings: ", Re]
|
|
461
|
+
}) : ze ? /* @__PURE__ */ m("span", {
|
|
462
|
+
className: "text-emerald-600 dark:text-emerald-400 font-medium",
|
|
463
|
+
children: ["Settings autosaved at ", ze.toLocaleTimeString([], {
|
|
464
|
+
hour: "2-digit",
|
|
465
|
+
minute: "2-digit",
|
|
466
|
+
second: "2-digit"
|
|
467
|
+
})]
|
|
468
|
+
}) : /* @__PURE__ */ p("span", {
|
|
469
|
+
className: "text-muted-foreground/60",
|
|
470
|
+
children: "Settings autosave in draft mode"
|
|
471
|
+
})
|
|
472
|
+
})]
|
|
473
|
+
}),
|
|
474
|
+
/* @__PURE__ */ m("div", {
|
|
475
|
+
className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5",
|
|
476
|
+
children: [
|
|
477
|
+
/* @__PURE__ */ m("div", {
|
|
478
|
+
className: "col-span-2 space-y-1",
|
|
479
|
+
children: [
|
|
480
|
+
/* @__PURE__ */ p(_, {
|
|
481
|
+
htmlFor: "title",
|
|
482
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
483
|
+
children: "Title"
|
|
484
|
+
}),
|
|
485
|
+
/* @__PURE__ */ p(g, {
|
|
486
|
+
id: "title",
|
|
487
|
+
placeholder: "Product title",
|
|
488
|
+
...j("title"),
|
|
489
|
+
className: "h-8 text-sm"
|
|
490
|
+
}),
|
|
491
|
+
I.title && /* @__PURE__ */ p("p", {
|
|
492
|
+
className: "text-destructive text-[11px] leading-none",
|
|
493
|
+
children: I.title.message
|
|
494
|
+
})
|
|
495
|
+
]
|
|
496
|
+
}),
|
|
497
|
+
/* @__PURE__ */ m("div", {
|
|
498
|
+
className: "col-span-2 space-y-1",
|
|
499
|
+
children: [
|
|
500
|
+
/* @__PURE__ */ p(_, {
|
|
501
|
+
htmlFor: "slug",
|
|
502
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
503
|
+
children: "Slug"
|
|
504
|
+
}),
|
|
505
|
+
/* @__PURE__ */ p(g, {
|
|
506
|
+
id: "slug",
|
|
507
|
+
placeholder: "product-slug",
|
|
508
|
+
...j("slug"),
|
|
509
|
+
className: "h-8 text-sm"
|
|
510
|
+
}),
|
|
511
|
+
I.slug && /* @__PURE__ */ p("p", {
|
|
512
|
+
className: "text-destructive text-[11px] leading-none",
|
|
513
|
+
children: I.slug.message
|
|
514
|
+
})
|
|
515
|
+
]
|
|
516
|
+
}),
|
|
517
|
+
/* @__PURE__ */ m("div", {
|
|
518
|
+
className: "col-span-1 space-y-1",
|
|
519
|
+
children: [
|
|
520
|
+
/* @__PURE__ */ p(_, {
|
|
521
|
+
htmlFor: "sku",
|
|
522
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
523
|
+
children: "SKU"
|
|
524
|
+
}),
|
|
525
|
+
/* @__PURE__ */ p(g, {
|
|
526
|
+
id: "sku",
|
|
527
|
+
placeholder: "SKU",
|
|
528
|
+
...j("sku"),
|
|
529
|
+
className: "h-8 text-sm font-mono"
|
|
530
|
+
}),
|
|
531
|
+
I.sku && /* @__PURE__ */ p("p", {
|
|
532
|
+
className: "text-destructive text-[11px] leading-none",
|
|
533
|
+
children: I.sku.message
|
|
534
|
+
})
|
|
535
|
+
]
|
|
536
|
+
}),
|
|
537
|
+
/* @__PURE__ */ m("div", {
|
|
538
|
+
className: "col-span-1 space-y-1",
|
|
539
|
+
children: [/* @__PURE__ */ p(_, {
|
|
540
|
+
htmlFor: "upc_ean",
|
|
541
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
542
|
+
children: "UPC / EAN"
|
|
543
|
+
}), /* @__PURE__ */ p(g, {
|
|
544
|
+
id: "upc_ean",
|
|
545
|
+
placeholder: "000000000",
|
|
546
|
+
...j("upc"),
|
|
547
|
+
className: "h-8 text-sm font-mono",
|
|
548
|
+
readOnly: Y
|
|
549
|
+
})]
|
|
550
|
+
})
|
|
551
|
+
]
|
|
552
|
+
}),
|
|
553
|
+
/* @__PURE__ */ m("div", {
|
|
554
|
+
className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-12 gap-2.5 mt-2",
|
|
555
|
+
children: [
|
|
556
|
+
/* @__PURE__ */ m("div", {
|
|
557
|
+
className: `${y ? "lg:col-span-3" : "lg:col-span-4"} col-span-2 space-y-1`,
|
|
558
|
+
children: [/* @__PURE__ */ p(_, {
|
|
559
|
+
htmlFor: "meta_title",
|
|
560
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
561
|
+
children: "Meta Title"
|
|
562
|
+
}), /* @__PURE__ */ p(g, {
|
|
563
|
+
id: "meta_title",
|
|
564
|
+
...j("meta_title"),
|
|
565
|
+
placeholder: "SEO page title (50-60 chars)",
|
|
566
|
+
className: "h-8 text-sm"
|
|
567
|
+
})]
|
|
568
|
+
}),
|
|
569
|
+
/* @__PURE__ */ m("div", {
|
|
570
|
+
className: "lg:col-span-4 col-span-2 space-y-1",
|
|
571
|
+
children: [/* @__PURE__ */ p(_, {
|
|
572
|
+
htmlFor: "meta_description",
|
|
573
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
574
|
+
children: "Meta Description"
|
|
575
|
+
}), /* @__PURE__ */ p(g, {
|
|
576
|
+
id: "meta_description",
|
|
577
|
+
...j("meta_description"),
|
|
578
|
+
placeholder: "SEO description (150-160 chars)",
|
|
579
|
+
className: "h-8 text-sm"
|
|
580
|
+
})]
|
|
581
|
+
}),
|
|
582
|
+
/* @__PURE__ */ m("div", {
|
|
583
|
+
className: `${y ? "lg:col-span-3" : "lg:col-span-4"} col-span-2 space-y-1`,
|
|
584
|
+
children: [/* @__PURE__ */ p(_, {
|
|
585
|
+
htmlFor: "custom_canonical",
|
|
586
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
587
|
+
children: "Canonical URL (optional)"
|
|
588
|
+
}), /* @__PURE__ */ p(g, {
|
|
589
|
+
id: "custom_canonical",
|
|
590
|
+
...j("custom_canonical"),
|
|
591
|
+
placeholder: "Blank = self-referencing. Absolute https://… URL or /relative path to override.",
|
|
592
|
+
className: "h-8 text-sm"
|
|
593
|
+
})]
|
|
594
|
+
})
|
|
595
|
+
]
|
|
596
|
+
})
|
|
597
|
+
]
|
|
598
|
+
}),
|
|
599
|
+
/* @__PURE__ */ p(v, {
|
|
600
|
+
title: "Product Categories",
|
|
601
|
+
description: "Assign this product to one or more categories.",
|
|
602
|
+
children: /* @__PURE__ */ p(c, {
|
|
603
|
+
categories: Ae,
|
|
604
|
+
selectedIds: P("category_ids") || [],
|
|
605
|
+
onChange: (e) => N("category_ids", e, {
|
|
606
|
+
shouldDirty: !0,
|
|
607
|
+
shouldValidate: !0
|
|
608
|
+
})
|
|
609
|
+
})
|
|
610
|
+
}),
|
|
611
|
+
/* @__PURE__ */ m("section", {
|
|
612
|
+
className: "rounded-lg border bg-card p-3 shadow-sm space-y-3",
|
|
613
|
+
children: [W && /* @__PURE__ */ m("div", {
|
|
614
|
+
className: "flex items-center justify-between gap-4 flex-wrap border-b border-muted/50 pb-2",
|
|
615
|
+
children: [/* @__PURE__ */ p("div", {
|
|
616
|
+
className: "flex items-center gap-4",
|
|
617
|
+
children: /* @__PURE__ */ m("div", {
|
|
618
|
+
className: "space-y-0.5",
|
|
619
|
+
children: [/* @__PURE__ */ p("h2", {
|
|
620
|
+
className: "text-sm font-bold tracking-tight",
|
|
621
|
+
children: "Pricing & Inventory"
|
|
622
|
+
}), /* @__PURE__ */ p("p", {
|
|
623
|
+
className: "text-[11px] text-muted-foreground leading-none",
|
|
624
|
+
children: "Manage simple or variant pricing."
|
|
625
|
+
})]
|
|
626
|
+
})
|
|
627
|
+
}), /* @__PURE__ */ m("div", {
|
|
628
|
+
className: "flex items-center gap-3",
|
|
629
|
+
children: [/* @__PURE__ */ m("div", {
|
|
630
|
+
className: "flex items-center gap-2 bg-muted/40 rounded-md px-2.5 py-1.5",
|
|
631
|
+
children: [/* @__PURE__ */ p("span", {
|
|
632
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
633
|
+
children: "Stock"
|
|
634
|
+
}), /* @__PURE__ */ p(g, {
|
|
635
|
+
id: "stock",
|
|
636
|
+
type: "number",
|
|
637
|
+
min: "0",
|
|
638
|
+
...j("stock", { valueAsNumber: !0 }),
|
|
639
|
+
placeholder: "0",
|
|
640
|
+
readOnly: Y,
|
|
641
|
+
className: `${ct} h-8 w-20 text-sm text-center font-mono bg-background`
|
|
642
|
+
})]
|
|
643
|
+
}), Y ? /* @__PURE__ */ p(h, {
|
|
644
|
+
variant: "secondary",
|
|
645
|
+
className: "text-[11px] py-0 px-2 h-5",
|
|
646
|
+
children: "Variant pricing"
|
|
647
|
+
}) : null]
|
|
648
|
+
})]
|
|
649
|
+
}), W ? /* @__PURE__ */ m("div", {
|
|
650
|
+
className: "space-y-3",
|
|
651
|
+
children: [
|
|
652
|
+
/* @__PURE__ */ m("div", {
|
|
653
|
+
className: "w-full",
|
|
654
|
+
children: [
|
|
655
|
+
/* @__PURE__ */ p(a, {
|
|
656
|
+
idPrefix: "product",
|
|
657
|
+
currencies: O,
|
|
658
|
+
prices: X.prices,
|
|
659
|
+
salePrices: X.salePrices,
|
|
660
|
+
managedCurrencyCodes: A,
|
|
661
|
+
onPriceChange: it,
|
|
662
|
+
onSalePriceChange: at,
|
|
663
|
+
onAutoFill: ot,
|
|
664
|
+
readOnly: Y,
|
|
665
|
+
helperText: Y ? "Parent prices stay as a fallback, but active variants define the live shopper price." : void 0,
|
|
666
|
+
trailing: /* @__PURE__ */ p(o, {
|
|
667
|
+
idPrefix: "product",
|
|
668
|
+
startAt: P("sale_start_at"),
|
|
669
|
+
endAt: P("sale_end_at"),
|
|
670
|
+
onChange: (e, t) => N(e, t, {
|
|
671
|
+
shouldDirty: !0,
|
|
672
|
+
shouldValidate: !0
|
|
673
|
+
}),
|
|
674
|
+
error: I.sale_end_at?.message,
|
|
675
|
+
bare: !0
|
|
676
|
+
})
|
|
677
|
+
}),
|
|
678
|
+
I.price && /* @__PURE__ */ p("p", {
|
|
679
|
+
className: "text-destructive text-sm mt-1",
|
|
680
|
+
children: I.price.message
|
|
681
|
+
}),
|
|
682
|
+
I.sale_price && /* @__PURE__ */ p("p", {
|
|
683
|
+
className: "text-destructive text-sm mt-1",
|
|
684
|
+
children: I.sale_price.message
|
|
685
|
+
}),
|
|
686
|
+
I.stock && /* @__PURE__ */ p("p", {
|
|
687
|
+
className: "text-destructive text-[10px] font-medium leading-none mt-1",
|
|
688
|
+
children: I.stock.message
|
|
689
|
+
})
|
|
690
|
+
]
|
|
691
|
+
}),
|
|
692
|
+
/* @__PURE__ */ m("div", {
|
|
693
|
+
className: "flex items-center justify-between gap-3 rounded border border-dashed p-2.5 bg-muted/5",
|
|
694
|
+
children: [/* @__PURE__ */ p("span", {
|
|
695
|
+
className: "text-xs font-bold uppercase tracking-wider text-muted-foreground",
|
|
696
|
+
children: Y ? "Variations Active" : "Variations"
|
|
697
|
+
}), /* @__PURE__ */ p(fe, {
|
|
698
|
+
type: "button",
|
|
699
|
+
variant: E ? "outline" : "default",
|
|
700
|
+
onClick: () => D((e) => !e),
|
|
701
|
+
size: "sm",
|
|
702
|
+
className: "h-7 text-xs px-3",
|
|
703
|
+
children: E ? "Hide" : "Manage"
|
|
704
|
+
})]
|
|
705
|
+
}),
|
|
706
|
+
E && /* @__PURE__ */ p("div", {
|
|
707
|
+
className: "border-t pt-3",
|
|
708
|
+
children: /* @__PURE__ */ p(s, {
|
|
709
|
+
globalAttributes: we,
|
|
710
|
+
currentLanguageCode: $e,
|
|
711
|
+
baseSku: P("sku") || "",
|
|
712
|
+
basePrice: G || 0,
|
|
713
|
+
basePrices: q,
|
|
714
|
+
baseSalePrice: typeof K == "number" ? K : null,
|
|
715
|
+
baseSalePrices: J,
|
|
716
|
+
currencies: O,
|
|
717
|
+
availableVariantImages: lt,
|
|
718
|
+
initialVariationAttributes: e?.variation_attributes,
|
|
719
|
+
initialVariants: et,
|
|
720
|
+
onChange: st
|
|
721
|
+
})
|
|
722
|
+
})
|
|
723
|
+
]
|
|
724
|
+
}) : /* @__PURE__ */ m(le, { children: [/* @__PURE__ */ m("div", {
|
|
725
|
+
className: "space-y-4",
|
|
726
|
+
children: [/* @__PURE__ */ m("div", {
|
|
727
|
+
className: "flex items-end gap-4 w-full",
|
|
728
|
+
children: [
|
|
729
|
+
/* @__PURE__ */ m("div", {
|
|
730
|
+
className: "flex-1",
|
|
731
|
+
children: [/* @__PURE__ */ p(_, {
|
|
732
|
+
htmlFor: "freemius_product_id",
|
|
733
|
+
className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",
|
|
734
|
+
children: "Freemius Product ID"
|
|
735
|
+
}), /* @__PURE__ */ p(g, {
|
|
736
|
+
id: "freemius_product_id",
|
|
737
|
+
...j("freemius_product_id"),
|
|
738
|
+
className: "h-9"
|
|
739
|
+
})]
|
|
740
|
+
}),
|
|
741
|
+
/* @__PURE__ */ m("div", {
|
|
742
|
+
className: "flex-1",
|
|
743
|
+
children: [/* @__PURE__ */ p(_, {
|
|
744
|
+
htmlFor: "freemius_plan_id",
|
|
745
|
+
className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",
|
|
746
|
+
children: "Freemius Plan ID"
|
|
747
|
+
}), /* @__PURE__ */ p(g, {
|
|
748
|
+
id: "freemius_plan_id",
|
|
749
|
+
...j("freemius_plan_id"),
|
|
750
|
+
className: "h-9"
|
|
751
|
+
})]
|
|
752
|
+
}),
|
|
753
|
+
Je ? /* @__PURE__ */ p(i, {
|
|
754
|
+
productId: P("freemius_product_id"),
|
|
755
|
+
hasOpenDraft: je
|
|
756
|
+
}) : null
|
|
757
|
+
]
|
|
758
|
+
}), /* @__PURE__ */ m("div", {
|
|
759
|
+
className: "bg-muted/10 border rounded-md overflow-hidden",
|
|
760
|
+
children: [/* @__PURE__ */ m("div", {
|
|
761
|
+
className: "flex flex-wrap items-center gap-6 bg-muted/20 border-b p-2.5 px-4",
|
|
762
|
+
children: [
|
|
763
|
+
/* @__PURE__ */ m("div", {
|
|
764
|
+
className: "flex items-center gap-2",
|
|
765
|
+
children: [/* @__PURE__ */ p("span", {
|
|
766
|
+
className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground",
|
|
767
|
+
children: "Free Trial"
|
|
768
|
+
}), /* @__PURE__ */ m(h, {
|
|
769
|
+
variant: "outline",
|
|
770
|
+
className: "font-mono text-xs shadow-sm bg-background",
|
|
771
|
+
children: [String(P("trial_period_days") || 0), " Days"]
|
|
772
|
+
})]
|
|
773
|
+
}),
|
|
774
|
+
/* @__PURE__ */ m("div", {
|
|
775
|
+
className: "flex items-center gap-2",
|
|
776
|
+
children: [/* @__PURE__ */ p("span", {
|
|
777
|
+
className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground",
|
|
778
|
+
children: "Card Required"
|
|
779
|
+
}), /* @__PURE__ */ p(h, {
|
|
780
|
+
variant: Xe ? "default" : "secondary",
|
|
781
|
+
className: "text-xs shadow-sm",
|
|
782
|
+
children: Xe ? "Yes" : "No"
|
|
783
|
+
})]
|
|
784
|
+
}),
|
|
785
|
+
/* @__PURE__ */ p("span", {
|
|
786
|
+
className: "text-[10px] text-muted-foreground ml-auto",
|
|
787
|
+
children: "Managed in Freemius dashboard"
|
|
788
|
+
}),
|
|
789
|
+
/* @__PURE__ */ p("input", {
|
|
790
|
+
type: "hidden",
|
|
791
|
+
...j("trial_period_days", { valueAsNumber: !0 })
|
|
792
|
+
})
|
|
793
|
+
]
|
|
794
|
+
}), /* @__PURE__ */ m("div", {
|
|
795
|
+
className: "w-full p-4 pt-3 space-y-2",
|
|
796
|
+
children: [/* @__PURE__ */ p(a, {
|
|
797
|
+
idPrefix: "product",
|
|
798
|
+
currencies: O,
|
|
799
|
+
prices: X.prices,
|
|
800
|
+
salePrices: X.salePrices,
|
|
801
|
+
managedCurrencyCodes: A,
|
|
802
|
+
onPriceChange: it,
|
|
803
|
+
onSalePriceChange: at,
|
|
804
|
+
onAutoFill: ot,
|
|
805
|
+
readOnly: !0,
|
|
806
|
+
trailing: /* @__PURE__ */ p(o, {
|
|
807
|
+
idPrefix: "product",
|
|
808
|
+
startAt: P("sale_start_at"),
|
|
809
|
+
endAt: P("sale_end_at"),
|
|
810
|
+
onChange: (e, t) => N(e, t, {
|
|
811
|
+
shouldDirty: !0,
|
|
812
|
+
shouldValidate: !0
|
|
813
|
+
}),
|
|
814
|
+
error: I.sale_end_at?.message,
|
|
815
|
+
bare: !0
|
|
816
|
+
})
|
|
817
|
+
}), /* @__PURE__ */ p("p", {
|
|
818
|
+
className: "text-[10px] leading-snug text-muted-foreground",
|
|
819
|
+
children: "Scheduling a sale on a Freemius product generates a time-bounded Freemius coupon so the discount is enforced at Freemius checkout."
|
|
820
|
+
})]
|
|
821
|
+
})]
|
|
822
|
+
})]
|
|
823
|
+
}), Ee && /* @__PURE__ */ p("div", {
|
|
824
|
+
className: "pt-2 border-t",
|
|
825
|
+
children: Ee
|
|
826
|
+
})] })]
|
|
827
|
+
}),
|
|
828
|
+
/* @__PURE__ */ p(v, {
|
|
829
|
+
title: "Product Description",
|
|
830
|
+
hideHeader: !0,
|
|
831
|
+
children: /* @__PURE__ */ p("div", {
|
|
832
|
+
className: "space-y-2",
|
|
833
|
+
children: /* @__PURE__ */ m("div", {
|
|
834
|
+
className: "space-y-1",
|
|
835
|
+
children: [/* @__PURE__ */ p(_, {
|
|
836
|
+
htmlFor: "short_description",
|
|
837
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
838
|
+
children: "Short Description"
|
|
839
|
+
}), /* @__PURE__ */ p(g, {
|
|
840
|
+
id: "short_description",
|
|
841
|
+
...j("short_description"),
|
|
842
|
+
placeholder: "Brief summary for product cards...",
|
|
843
|
+
className: "h-8 text-sm"
|
|
844
|
+
})]
|
|
845
|
+
})
|
|
846
|
+
})
|
|
847
|
+
}),
|
|
848
|
+
/* @__PURE__ */ m(v, {
|
|
849
|
+
title: "Media Gallery",
|
|
850
|
+
description: "Drag to reorder. First image is the hero.",
|
|
851
|
+
children: [/* @__PURE__ */ p(r, {
|
|
852
|
+
initialMedia: Z,
|
|
853
|
+
onUpdate: rt,
|
|
854
|
+
mediaPickerNode: Ce
|
|
855
|
+
}), /* @__PURE__ */ p("input", {
|
|
856
|
+
type: "hidden",
|
|
857
|
+
...j("product_media")
|
|
858
|
+
})]
|
|
859
|
+
}),
|
|
860
|
+
!y && /* @__PURE__ */ m("div", {
|
|
861
|
+
className: "rounded-lg border bg-card p-3 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",
|
|
862
|
+
children: [/* @__PURE__ */ p("p", {
|
|
863
|
+
className: "text-xs text-muted-foreground",
|
|
864
|
+
children: "New products start as a draft. Publish it from the top bar once it's ready."
|
|
865
|
+
}), /* @__PURE__ */ p(fe, {
|
|
866
|
+
disabled: w,
|
|
867
|
+
type: "submit",
|
|
868
|
+
size: "sm",
|
|
869
|
+
className: "h-8 text-sm px-5",
|
|
870
|
+
children: w ? "Saving..." : "Save Changes"
|
|
871
|
+
})]
|
|
872
|
+
})
|
|
873
|
+
]
|
|
874
|
+
})
|
|
875
|
+
]
|
|
876
|
+
});
|
|
697
877
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
};
|
|
878
|
+
//#endregion
|
|
879
|
+
export { Ce as ProductForm };
|