@nextblock-cms/ecom 0.8.1 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1 -1
- package/index.es.js +136 -3224
- package/lib/CurrencyProvider.cjs.js +1 -0
- package/lib/CurrencyProvider.es.js +99 -0
- package/lib/cart-store.cjs.js +1 -0
- package/lib/cart-store.es.js +116 -0
- 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/lib/components/AddToCartButton.es.js +60 -0
- 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/lib/components/CartDrawer.es.js +119 -0
- package/lib/components/CartIcon.cjs.js +1 -0
- package/lib/components/CartIcon.es.js +34 -0
- package/lib/components/Checkout.cjs.js +1 -0
- package/lib/components/Checkout.es.js +987 -0
- 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/lib/components/CurrencySwitcher.es.js +18 -0
- 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/lib/components/FeaturedProduct.es.js +72 -0
- 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/SimpleTiptapRenderer.cjs.js +1 -0
- package/lib/components/SimpleTiptapRenderer.es.js +187 -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/lib/coupon-server.es.js +234 -0
- package/lib/coupons.cjs.js +1 -0
- package/lib/coupons.es.js +17 -0
- package/lib/currency-constants.cjs.js +1 -0
- package/lib/currency-constants.es.js +4 -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/currency.cjs.js +1 -0
- package/lib/currency.es.js +312 -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/lib/customer.es.js +58 -0
- 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/lib/server-actions/product-actions.es.js +16 -0
- package/lib/server-actions/shipping-actions.cjs.js +1 -0
- package/lib/server-actions/shipping-actions.es.js +27 -0
- 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/lib/states.es.js +127 -0
- 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/lib/trials.es.js +29 -0
- package/lib/types.cjs.js +1 -0
- package/lib/types.es.js +33 -0
- package/lib/use-cart.cjs.js +1 -0
- package/lib/use-cart.es.js +44 -0
- package/lib/variation-utils.cjs.js +1 -0
- package/lib/variation-utils.es.js +246 -0
- package/lib/zod-config.cjs.js +1 -0
- package/lib/zod-config.es.js +6 -0
- package/package.json +10 -5
- package/server.cjs.js +1 -110
- package/server.es.js +178 -6037
- package/invoice-ui-BJZfedDd.cjs +0 -332
- package/invoice-ui-GJ1ADAjn.js +0 -5759
- /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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),d=require("lucide-react"),I=require("next/image"),f=process.env.NEXT_PUBLIC_R2_BASE_URL||"",h=o=>o?o.startsWith("http")||!f?o:`${f.replace(/\/+$/,"")}/${o.replace(/^\/+/,"")}`:"",_=({initialMedia:o,onUpdate:g,mediaPickerNode:p})=>{const[n,u]=i.useState(o),c=i.useRef(null),m=i.useRef(null);i.useEffect(()=>{u(o)},[o]);const x=(e,r)=>{c.current=r,e.dataTransfer.effectAllowed="move"},v=(e,r)=>{m.current=r,e.preventDefault()},b=e=>{e.preventDefault()},j=e=>{if(e.preventDefault(),c.current===null||m.current===null)return;const r=[...n],s=r[c.current];r.splice(c.current,1),r.splice(m.current,0,s),c.current=null,m.current=null;const a=r.map((l,N)=>({...l,sort_order:N}));u(a),g(a)},y=e=>{if(!e||n.some(a=>a.media_id===e.id))return;const r={id:`temp-${Date.now()}`,media_id:e.id,file_path:e.file_path||e.object_key,alt:e.description||e.file_name||"",sort_order:n.length,isNew:!0},s=[...n,r];u(s),g(s)},w=e=>{const s=n.filter((a,l)=>l!==e).map((a,l)=>({...a,sort_order:l}));u(s),g(s)};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-4",children:[n.map((e,r)=>t.jsxs("div",{className:"group relative aspect-square bg-muted/40 rounded-lg border overflow-hidden cursor-move transition-all hover:shadow-md",draggable:!0,onDragStart:s=>x(s,r),onDragEnter:s=>v(s,r),onDragOver:b,onDrop:j,children:[r===0&&t.jsx("div",{className:"absolute top-2 left-2 z-10 bg-primary text-primary-foreground text-[10px] font-bold px-2 py-0.5 rounded shadow-sm",children:"MAIN"}),t.jsx("button",{type:"button",onClick:()=>w(r),className:"absolute top-1 right-1 z-20 p-1 bg-destructive/90 text-destructive-foreground rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:t.jsx(d.X,{className:"w-3 h-3"})}),t.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/5 transition-colors pointer-events-none"}),t.jsx("div",{className:"absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:t.jsx(d.GripVertical,{className:"w-4 h-4 text-white drop-shadow-md"})}),h(e.file_path)?t.jsx(I,{src:h(e.file_path),alt:e.alt,fill:!0,className:"object-cover",sizes:"(max-width: 768px) 50vw, 33vw"}):t.jsx("div",{className:"flex h-full w-full items-center justify-center text-muted-foreground",children:t.jsx(d.Image,{className:"w-8 h-8 opacity-30"})})]},e.id)),p?i.cloneElement(p,{onSelect:y,children:t.jsxs("button",{type:"button",className:"group relative aspect-square flex flex-col items-center justify-center border-2 border-dashed rounded-lg bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:border-muted-foreground/50 transition-all focus:outline-none focus:ring-2 focus:ring-primary",children:[t.jsx(d.Image,{className:"w-8 h-8 mb-2 opacity-50 group-hover:opacity-75 transition-opacity"}),t.jsx("span",{className:"text-sm font-medium",children:"Add Image"})]})}):t.jsxs("div",{className:"relative aspect-square flex flex-col items-center justify-center border-2 border-dashed rounded-lg bg-muted/10 text-muted-foreground",children:[t.jsx(d.Image,{className:"w-8 h-8 mb-2 opacity-30"}),t.jsx("span",{className:"text-xs text-center px-2",children:"Media Picker not injected"})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag and drop images to reorder. The first image will be used as the main product image."})]})};exports.ProductMediaManager=_;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import D, { useState as j, useRef as f, useEffect as E } from "react";
|
|
4
|
+
import { X as R, GripVertical as S, Image as p } from "lucide-react";
|
|
5
|
+
import A from "next/image";
|
|
6
|
+
const h = process.env.NEXT_PUBLIC_R2_BASE_URL || "", v = (s) => s ? s.startsWith("http") || !h ? s : `${h.replace(/\/+$/, "")}/${s.replace(/^\/+/, "")}` : "", z = ({ initialMedia: s, onUpdate: m, mediaPickerNode: g }) => {
|
|
7
|
+
const [n, d] = j(s), c = f(null), u = f(null);
|
|
8
|
+
E(() => {
|
|
9
|
+
d(s);
|
|
10
|
+
}, [s]);
|
|
11
|
+
const b = (e, r) => {
|
|
12
|
+
c.current = r, e.dataTransfer.effectAllowed = "move";
|
|
13
|
+
}, x = (e, r) => {
|
|
14
|
+
u.current = r, e.preventDefault();
|
|
15
|
+
}, y = (e) => {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
}, w = (e) => {
|
|
18
|
+
if (e.preventDefault(), c.current === null || u.current === null) return;
|
|
19
|
+
const r = [...n], o = r[c.current];
|
|
20
|
+
r.splice(c.current, 1), r.splice(u.current, 0, o), c.current = null, u.current = null;
|
|
21
|
+
const a = r.map((l, I) => ({
|
|
22
|
+
...l,
|
|
23
|
+
sort_order: I
|
|
24
|
+
}));
|
|
25
|
+
d(a), m(a);
|
|
26
|
+
}, N = (e) => {
|
|
27
|
+
if (!e || n.some((a) => a.media_id === e.id))
|
|
28
|
+
return;
|
|
29
|
+
const r = {
|
|
30
|
+
id: `temp-${Date.now()}`,
|
|
31
|
+
// Temp ID
|
|
32
|
+
media_id: e.id,
|
|
33
|
+
file_path: e.file_path || e.object_key,
|
|
34
|
+
alt: e.description || e.file_name || "",
|
|
35
|
+
sort_order: n.length,
|
|
36
|
+
isNew: !0
|
|
37
|
+
}, o = [...n, r];
|
|
38
|
+
d(o), m(o);
|
|
39
|
+
}, _ = (e) => {
|
|
40
|
+
const o = n.filter((a, l) => l !== e).map((a, l) => ({ ...a, sort_order: l }));
|
|
41
|
+
d(o), m(o);
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
|
|
44
|
+
/* @__PURE__ */ i("div", { className: "grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-4", children: [
|
|
45
|
+
n.map((e, r) => /* @__PURE__ */ i(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: "group relative aspect-square bg-muted/40 rounded-lg border overflow-hidden cursor-move transition-all hover:shadow-md",
|
|
49
|
+
draggable: !0,
|
|
50
|
+
onDragStart: (o) => b(o, r),
|
|
51
|
+
onDragEnter: (o) => x(o, r),
|
|
52
|
+
onDragOver: y,
|
|
53
|
+
onDrop: w,
|
|
54
|
+
children: [
|
|
55
|
+
r === 0 && /* @__PURE__ */ t("div", { className: "absolute top-2 left-2 z-10 bg-primary text-primary-foreground text-[10px] font-bold px-2 py-0.5 rounded shadow-sm", children: "MAIN" }),
|
|
56
|
+
/* @__PURE__ */ t(
|
|
57
|
+
"button",
|
|
58
|
+
{
|
|
59
|
+
type: "button",
|
|
60
|
+
onClick: () => _(r),
|
|
61
|
+
className: "absolute top-1 right-1 z-20 p-1 bg-destructive/90 text-destructive-foreground rounded-full opacity-0 group-hover:opacity-100 transition-opacity",
|
|
62
|
+
children: /* @__PURE__ */ t(R, { className: "w-3 h-3" })
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ t("div", { className: "absolute inset-0 bg-black/0 group-hover:bg-black/5 transition-colors pointer-events-none" }),
|
|
66
|
+
/* @__PURE__ */ t("div", { className: "absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ t(S, { className: "w-4 h-4 text-white drop-shadow-md" }) }),
|
|
67
|
+
v(e.file_path) ? /* @__PURE__ */ t(
|
|
68
|
+
A,
|
|
69
|
+
{
|
|
70
|
+
src: v(e.file_path),
|
|
71
|
+
alt: e.alt,
|
|
72
|
+
fill: !0,
|
|
73
|
+
className: "object-cover",
|
|
74
|
+
sizes: "(max-width: 768px) 50vw, 33vw"
|
|
75
|
+
}
|
|
76
|
+
) : /* @__PURE__ */ t("div", { className: "flex h-full w-full items-center justify-center text-muted-foreground", children: /* @__PURE__ */ t(p, { className: "w-8 h-8 opacity-30" }) })
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
e.id
|
|
80
|
+
)),
|
|
81
|
+
g ? D.cloneElement(g, {
|
|
82
|
+
onSelect: N,
|
|
83
|
+
children: /* @__PURE__ */ i(
|
|
84
|
+
"button",
|
|
85
|
+
{
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "group relative aspect-square flex flex-col items-center justify-center border-2 border-dashed rounded-lg bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:border-muted-foreground/50 transition-all focus:outline-none focus:ring-2 focus:ring-primary",
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ t(p, { className: "w-8 h-8 mb-2 opacity-50 group-hover:opacity-75 transition-opacity" }),
|
|
90
|
+
/* @__PURE__ */ t("span", { className: "text-sm font-medium", children: "Add Image" })
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}) : /* @__PURE__ */ i("div", { className: "relative aspect-square flex flex-col items-center justify-center border-2 border-dashed rounded-lg bg-muted/10 text-muted-foreground", children: [
|
|
95
|
+
/* @__PURE__ */ t(p, { className: "w-8 h-8 mb-2 opacity-30" }),
|
|
96
|
+
/* @__PURE__ */ t("span", { className: "text-xs text-center px-2", children: "Media Picker not injected" })
|
|
97
|
+
] })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Drag and drop images to reorder. The first image will be used as the main product image." })
|
|
100
|
+
] });
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
z as ProductMediaManager
|
|
104
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),L=require("next/image"),g=require("next/link"),z=require("next/navigation"),i=require("react"),v=require("lucide-react"),t=require("@nextblock-cms/ui"),C=require("@nextblock-cms/utils"),D=require("./DeleteProductButton.cjs.js"),B=process.env.NEXT_PUBLIC_R2_BASE_URL||"";function U(r){return r?r.startsWith("http")||!B?r:`${B.replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`:null}function V({products:r,languageLabels:f,defaultCurrencyCode:T,deleteProductAction:P,bulkDeleteProductsAction:p,bulkDraftProductsAction:_}){const A=z.useRouter(),[c,u]=i.useState(()=>new Set),[b,R]=i.useState(""),[w,h]=i.useState(null),[x,j]=i.useState(null),[S,H]=i.useTransition(),m=i.useMemo(()=>{const e=b.trim().toLowerCase();return e?r.filter(l=>{const n=f[String(l.language_id)]||"";return[l.title,l.sku,l.slug,l.status,n].filter(Boolean).join(" ").toLowerCase().includes(e)}):r},[f,r,b]),y=i.useMemo(()=>r.map(e=>e.id),[r]),d=i.useMemo(()=>m.map(e=>e.id),[m]),o=i.useMemo(()=>r.filter(e=>c.has(e.id)),[r,c]).length,I=o>1,$=d.filter(e=>c.has(e)).length,N=d.length>0&&d.every(e=>c.has(e)),q=$>0&&!N;i.useEffect(()=>{const e=new Set(y);u(l=>{const n=new Set(Array.from(l).filter(a=>e.has(a)));return n.size===l.size?l:n})},[y]);const E=e=>{u(l=>{const n=new Set(l);return e?d.forEach(a=>n.add(a)):d.forEach(a=>n.delete(a)),n})},M=(e,l)=>{u(n=>{const a=new Set(n);return l?a.add(e):a.delete(e),a})},k=(e,l,n)=>{if(o===0){h("Select at least one product first.");return}window.confirm(l)&&(h(null),j(e),H(async()=>{try{const a=await n(Array.from(c));if(!a.success){h(a.error||"Bulk action failed. Please try again."),j(null);return}u(new Set),A.refresh()}catch(a){console.error("Bulk product action failed:",a),h("Bulk action failed. Please try again.")}finally{j(null)}}))};return s.jsxs("div",{className:"rounded-lg border overflow-hidden dark:border-slate-700",children:[s.jsxs("div",{className:"flex min-h-14 flex-wrap items-center justify-between gap-3 border-b bg-muted/20 px-4 py-3",children:[s.jsxs("div",{className:"flex min-w-[260px] flex-1 flex-wrap items-center gap-3",children:[s.jsxs("div",{className:"relative w-full max-w-sm",children:[s.jsx(v.Search,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx(t.Input,{value:b,onChange:e=>R(e.target.value),placeholder:"Search products...",className:"h-9 pl-9","aria-label":"Search products"})]}),o>0?s.jsxs("span",{className:"text-sm font-medium text-foreground",children:[o," selected"]}):null,w?s.jsx("span",{className:"text-sm text-destructive",children:w}):null]}),I?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(t.Button,{variant:"outline",size:"sm",disabled:S,onClick:()=>k("Moving to draft...",`Move ${o} selected products to draft?`,_),children:[s.jsx(v.Archive,{className:"mr-2 h-4 w-4"}),x==="Moving to draft..."?x:"Set Draft"]}),s.jsxs(t.Button,{variant:"destructive",size:"sm",disabled:S,onClick:()=>k("Deleting...",`Delete ${o} selected products? This action cannot be undone.`,p),children:[s.jsx(v.Trash2,{className:"mr-2 h-4 w-4"}),x==="Deleting..."?x:"Delete"]})]}):null]}),s.jsxs(t.Table,{children:[s.jsx(t.TableHeader,{children:s.jsxs(t.TableRow,{children:[s.jsx(t.TableHead,{className:"w-12",children:s.jsx(t.Checkbox,{checked:N?!0:q?"indeterminate":!1,onCheckedChange:e=>E(e===!0),"aria-label":"Select all products on this page"})}),s.jsx(t.TableHead,{children:"Image"}),s.jsx(t.TableHead,{children:"Title"}),s.jsx(t.TableHead,{children:"SKU"}),s.jsx(t.TableHead,{children:"Price"}),s.jsx(t.TableHead,{children:"Language"}),s.jsx(t.TableHead,{children:"Stock"}),s.jsx(t.TableHead,{children:"Status"}),s.jsx(t.TableHead,{className:"text-right",children:"Actions"})]})}),s.jsx(t.TableBody,{children:m.length>0?m.map(e=>{const l=U(e.product_media?.[0]?.media?.file_path||e.product_media?.[0]?.media?.object_key);return s.jsxs(t.TableRow,{"data-state":c.has(e.id)?"selected":void 0,children:[s.jsx(t.TableCell,{children:s.jsx(t.Checkbox,{checked:c.has(e.id),onCheckedChange:n=>M(e.id,n===!0),"aria-label":`Select ${e.title}`})}),s.jsx(t.TableCell,{children:l?s.jsx(L,{src:l,alt:e.title,width:40,height:40,className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-gray-200 rounded flex items-center justify-center text-xs text-gray-500",children:"No Img"})}),s.jsx(t.TableCell,{className:"font-medium",children:s.jsx(g,{href:`/cms/products/${e.id}/edit`,className:"hover:underline",children:e.title})}),s.jsx(t.TableCell,{children:e.sku}),s.jsx(t.TableCell,{children:s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("span",{className:e.sale_price?"font-semibold text-primary":"",children:typeof(e.sale_price??e.price)=="number"?C.formatPrice(e.sale_price??e.price??0,T):"N/A"}),e.sale_price?s.jsx("span",{className:"text-sm text-muted-foreground line-through",children:C.formatPrice(e.price??0,T)}):null]})}),s.jsx(t.TableCell,{children:s.jsx(t.Badge,{variant:"outline",children:f[String(e.language_id)]||"N/A"})}),s.jsx(t.TableCell,{children:e.stock}),s.jsx(t.TableCell,{children:s.jsx("span",{className:`px-2 py-1 rounded text-xs ${e.status==="active"?"bg-green-100 text-green-800":e.status==="archived"?"bg-gray-100 text-gray-800":"bg-yellow-100 text-yellow-800"}`,children:e.status})}),s.jsxs(t.TableCell,{className:"text-right flex justify-end gap-2 items-center",children:[e.slug?s.jsx(g,{href:`/product/${e.slug}`,target:"_blank",rel:"noopener noreferrer",children:s.jsx(t.Button,{variant:"outline",size:"sm",children:"View Product"})}):null,s.jsx(g,{href:`/cms/products/${e.id}/edit`,children:s.jsx(t.Button,{variant:"ghost",size:"sm",children:"Edit"})}),s.jsx(D.DeleteProductButton,{productName:e.title,isIcon:!0,deleteAction:()=>P(e.id)})]})]},e.id)}):s.jsx(t.TableRow,{children:s.jsx(t.TableCell,{colSpan:9,className:"text-center py-10",children:r.length===0?"No products found.":"No products match your search."})})})]})]})}exports.ProductsBulkTable=V;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import K from "next/image";
|
|
4
|
+
import S from "next/link";
|
|
5
|
+
import { useRouter as W } from "next/navigation";
|
|
6
|
+
import { useState as b, useTransition as X, useMemo as x, useEffect as q } from "react";
|
|
7
|
+
import { Search as F, Archive as G, Trash2 as J } from "lucide-react";
|
|
8
|
+
import { Input as O, Button as v, Table as Y, TableHeader as Z, TableRow as p, TableHead as c, Checkbox as C, TableBody as ee, TableCell as a, Badge as te } from "@nextblock-cms/ui";
|
|
9
|
+
import { formatPrice as I } from "@nextblock-cms/utils";
|
|
10
|
+
import { DeleteProductButton as le } from "./DeleteProductButton.es.js";
|
|
11
|
+
const $ = process.env.NEXT_PUBLIC_R2_BASE_URL || "";
|
|
12
|
+
function re(n) {
|
|
13
|
+
return n ? n.startsWith("http") || !$ ? n : `${$.replace(/\/+$/, "")}/${n.replace(/^\/+/, "")}` : null;
|
|
14
|
+
}
|
|
15
|
+
function fe({
|
|
16
|
+
products: n,
|
|
17
|
+
languageLabels: w,
|
|
18
|
+
defaultCurrencyCode: k,
|
|
19
|
+
deleteProductAction: E,
|
|
20
|
+
bulkDeleteProductsAction: j,
|
|
21
|
+
bulkDraftProductsAction: L
|
|
22
|
+
}) {
|
|
23
|
+
const z = W(), [o, m] = b(() => /* @__PURE__ */ new Set()), [N, D] = b(""), [_, u] = b(null), [f, y] = b(null), [B, R] = X(), g = x(() => {
|
|
24
|
+
const e = N.trim().toLowerCase();
|
|
25
|
+
return e ? n.filter((l) => {
|
|
26
|
+
const i = w[String(l.language_id)] || "";
|
|
27
|
+
return [
|
|
28
|
+
l.title,
|
|
29
|
+
l.sku,
|
|
30
|
+
l.slug,
|
|
31
|
+
l.status,
|
|
32
|
+
i
|
|
33
|
+
].filter(Boolean).join(" ").toLowerCase().includes(e);
|
|
34
|
+
}) : n;
|
|
35
|
+
}, [w, n, N]), P = x(() => n.map((e) => e.id), [n]), h = x(
|
|
36
|
+
() => g.map((e) => e.id),
|
|
37
|
+
[g]
|
|
38
|
+
), d = x(
|
|
39
|
+
() => n.filter((e) => o.has(e.id)),
|
|
40
|
+
[n, o]
|
|
41
|
+
).length, U = d > 1, V = h.filter(
|
|
42
|
+
(e) => o.has(e)
|
|
43
|
+
).length, A = h.length > 0 && h.every((e) => o.has(e)), M = V > 0 && !A;
|
|
44
|
+
q(() => {
|
|
45
|
+
const e = new Set(P);
|
|
46
|
+
m((l) => {
|
|
47
|
+
const i = new Set(
|
|
48
|
+
Array.from(l).filter((r) => e.has(r))
|
|
49
|
+
);
|
|
50
|
+
return i.size === l.size ? l : i;
|
|
51
|
+
});
|
|
52
|
+
}, [P]);
|
|
53
|
+
const Q = (e) => {
|
|
54
|
+
m((l) => {
|
|
55
|
+
const i = new Set(l);
|
|
56
|
+
return e ? h.forEach((r) => i.add(r)) : h.forEach((r) => i.delete(r)), i;
|
|
57
|
+
});
|
|
58
|
+
}, H = (e, l) => {
|
|
59
|
+
m((i) => {
|
|
60
|
+
const r = new Set(i);
|
|
61
|
+
return l ? r.add(e) : r.delete(e), r;
|
|
62
|
+
});
|
|
63
|
+
}, T = (e, l, i) => {
|
|
64
|
+
if (d === 0) {
|
|
65
|
+
u("Select at least one product first.");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
window.confirm(l) && (u(null), y(e), R(async () => {
|
|
69
|
+
try {
|
|
70
|
+
const r = await i(Array.from(o));
|
|
71
|
+
if (!r.success) {
|
|
72
|
+
u(r.error || "Bulk action failed. Please try again."), y(null);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
m(/* @__PURE__ */ new Set()), z.refresh();
|
|
76
|
+
} catch (r) {
|
|
77
|
+
console.error("Bulk product action failed:", r), u("Bulk action failed. Please try again.");
|
|
78
|
+
} finally {
|
|
79
|
+
y(null);
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
82
|
+
};
|
|
83
|
+
return /* @__PURE__ */ s("div", { className: "rounded-lg border overflow-hidden dark:border-slate-700", children: [
|
|
84
|
+
/* @__PURE__ */ s("div", { className: "flex min-h-14 flex-wrap items-center justify-between gap-3 border-b bg-muted/20 px-4 py-3", children: [
|
|
85
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-[260px] flex-1 flex-wrap items-center gap-3", children: [
|
|
86
|
+
/* @__PURE__ */ s("div", { className: "relative w-full max-w-sm", children: [
|
|
87
|
+
/* @__PURE__ */ t(F, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
88
|
+
/* @__PURE__ */ t(
|
|
89
|
+
O,
|
|
90
|
+
{
|
|
91
|
+
value: N,
|
|
92
|
+
onChange: (e) => D(e.target.value),
|
|
93
|
+
placeholder: "Search products...",
|
|
94
|
+
className: "h-9 pl-9",
|
|
95
|
+
"aria-label": "Search products"
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] }),
|
|
99
|
+
d > 0 ? /* @__PURE__ */ s("span", { className: "text-sm font-medium text-foreground", children: [
|
|
100
|
+
d,
|
|
101
|
+
" selected"
|
|
102
|
+
] }) : null,
|
|
103
|
+
_ ? /* @__PURE__ */ t("span", { className: "text-sm text-destructive", children: _ }) : null
|
|
104
|
+
] }),
|
|
105
|
+
U ? /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
106
|
+
/* @__PURE__ */ s(
|
|
107
|
+
v,
|
|
108
|
+
{
|
|
109
|
+
variant: "outline",
|
|
110
|
+
size: "sm",
|
|
111
|
+
disabled: B,
|
|
112
|
+
onClick: () => T(
|
|
113
|
+
"Moving to draft...",
|
|
114
|
+
`Move ${d} selected products to draft?`,
|
|
115
|
+
L
|
|
116
|
+
),
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ t(G, { className: "mr-2 h-4 w-4" }),
|
|
119
|
+
f === "Moving to draft..." ? f : "Set Draft"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ s(
|
|
124
|
+
v,
|
|
125
|
+
{
|
|
126
|
+
variant: "destructive",
|
|
127
|
+
size: "sm",
|
|
128
|
+
disabled: B,
|
|
129
|
+
onClick: () => T(
|
|
130
|
+
"Deleting...",
|
|
131
|
+
`Delete ${d} selected products? This action cannot be undone.`,
|
|
132
|
+
j
|
|
133
|
+
),
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ t(J, { className: "mr-2 h-4 w-4" }),
|
|
136
|
+
f === "Deleting..." ? f : "Delete"
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] }) : null
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ s(Y, { children: [
|
|
143
|
+
/* @__PURE__ */ t(Z, { children: /* @__PURE__ */ s(p, { children: [
|
|
144
|
+
/* @__PURE__ */ t(c, { className: "w-12", children: /* @__PURE__ */ t(
|
|
145
|
+
C,
|
|
146
|
+
{
|
|
147
|
+
checked: A ? !0 : M ? "indeterminate" : !1,
|
|
148
|
+
onCheckedChange: (e) => Q(e === !0),
|
|
149
|
+
"aria-label": "Select all products on this page"
|
|
150
|
+
}
|
|
151
|
+
) }),
|
|
152
|
+
/* @__PURE__ */ t(c, { children: "Image" }),
|
|
153
|
+
/* @__PURE__ */ t(c, { children: "Title" }),
|
|
154
|
+
/* @__PURE__ */ t(c, { children: "SKU" }),
|
|
155
|
+
/* @__PURE__ */ t(c, { children: "Price" }),
|
|
156
|
+
/* @__PURE__ */ t(c, { children: "Language" }),
|
|
157
|
+
/* @__PURE__ */ t(c, { children: "Stock" }),
|
|
158
|
+
/* @__PURE__ */ t(c, { children: "Status" }),
|
|
159
|
+
/* @__PURE__ */ t(c, { className: "text-right", children: "Actions" })
|
|
160
|
+
] }) }),
|
|
161
|
+
/* @__PURE__ */ t(ee, { children: g.length > 0 ? g.map((e) => {
|
|
162
|
+
const l = re(
|
|
163
|
+
e.product_media?.[0]?.media?.file_path || e.product_media?.[0]?.media?.object_key
|
|
164
|
+
);
|
|
165
|
+
return /* @__PURE__ */ s(
|
|
166
|
+
p,
|
|
167
|
+
{
|
|
168
|
+
"data-state": o.has(e.id) ? "selected" : void 0,
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(
|
|
171
|
+
C,
|
|
172
|
+
{
|
|
173
|
+
checked: o.has(e.id),
|
|
174
|
+
onCheckedChange: (i) => H(e.id, i === !0),
|
|
175
|
+
"aria-label": `Select ${e.title}`
|
|
176
|
+
}
|
|
177
|
+
) }),
|
|
178
|
+
/* @__PURE__ */ t(a, { children: l ? /* @__PURE__ */ t(
|
|
179
|
+
K,
|
|
180
|
+
{
|
|
181
|
+
src: l,
|
|
182
|
+
alt: e.title,
|
|
183
|
+
width: 40,
|
|
184
|
+
height: 40,
|
|
185
|
+
className: "w-10 h-10 object-cover rounded"
|
|
186
|
+
}
|
|
187
|
+
) : /* @__PURE__ */ t("div", { className: "w-10 h-10 bg-gray-200 rounded flex items-center justify-center text-xs text-gray-500", children: "No Img" }) }),
|
|
188
|
+
/* @__PURE__ */ t(a, { className: "font-medium", children: /* @__PURE__ */ t(S, { href: `/cms/products/${e.id}/edit`, className: "hover:underline", children: e.title }) }),
|
|
189
|
+
/* @__PURE__ */ t(a, { children: e.sku }),
|
|
190
|
+
/* @__PURE__ */ t(a, { children: /* @__PURE__ */ s("div", { className: "flex items-baseline gap-2", children: [
|
|
191
|
+
/* @__PURE__ */ t("span", { className: e.sale_price ? "font-semibold text-primary" : "", children: typeof (e.sale_price ?? e.price) == "number" ? I(
|
|
192
|
+
e.sale_price ?? e.price ?? 0,
|
|
193
|
+
k
|
|
194
|
+
) : "N/A" }),
|
|
195
|
+
e.sale_price ? /* @__PURE__ */ t("span", { className: "text-sm text-muted-foreground line-through", children: I(e.price ?? 0, k) }) : null
|
|
196
|
+
] }) }),
|
|
197
|
+
/* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(te, { variant: "outline", children: w[String(e.language_id)] || "N/A" }) }),
|
|
198
|
+
/* @__PURE__ */ t(a, { children: e.stock }),
|
|
199
|
+
/* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(
|
|
200
|
+
"span",
|
|
201
|
+
{
|
|
202
|
+
className: `px-2 py-1 rounded text-xs ${e.status === "active" ? "bg-green-100 text-green-800" : e.status === "archived" ? "bg-gray-100 text-gray-800" : "bg-yellow-100 text-yellow-800"}`,
|
|
203
|
+
children: e.status
|
|
204
|
+
}
|
|
205
|
+
) }),
|
|
206
|
+
/* @__PURE__ */ s(a, { className: "text-right flex justify-end gap-2 items-center", children: [
|
|
207
|
+
e.slug ? /* @__PURE__ */ t(S, { href: `/product/${e.slug}`, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ t(v, { variant: "outline", size: "sm", children: "View Product" }) }) : null,
|
|
208
|
+
/* @__PURE__ */ t(S, { href: `/cms/products/${e.id}/edit`, children: /* @__PURE__ */ t(v, { variant: "ghost", size: "sm", children: "Edit" }) }),
|
|
209
|
+
/* @__PURE__ */ t(
|
|
210
|
+
le,
|
|
211
|
+
{
|
|
212
|
+
productName: e.title,
|
|
213
|
+
isIcon: !0,
|
|
214
|
+
deleteAction: () => E(e.id)
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
] })
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
e.id
|
|
221
|
+
);
|
|
222
|
+
}) : /* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(a, { colSpan: 9, className: "text-center py-10", children: n.length === 0 ? "No products found." : "No products match your search." }) }) })
|
|
223
|
+
] })
|
|
224
|
+
] });
|
|
225
|
+
}
|
|
226
|
+
export {
|
|
227
|
+
fe as ProductsBulkTable
|
|
228
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@nextblock-cms/ui"),h=require("@nextblock-cms/utils"),c=t=>String(t).padStart(2,"0");function d(t){if(!t)return"";const a=new Date(t);return Number.isNaN(a.getTime())?"":`${a.getFullYear()}-${c(a.getMonth()+1)}-${c(a.getDate())}T${c(a.getHours())}:${c(a.getMinutes())}`}function o(t){if(!t)return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:a.toISOString()}function f({idPrefix:t="product",startAt:a,endAt:x,onChange:n,error:r,disabled:u,description:m,dense:i,bare:p}){const N=Intl.DateTimeFormat().resolvedOptions().timeZone,g=h.cn("h-7 text-xs",i||p?"w-[150px]":"w-[160px] sm:w-[180px]"),j=e.jsxs(e.Fragment,{children:[e.jsx(s.Label,{htmlFor:`${t}-sale-start-at`,className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Starts"}),e.jsx(s.Input,{id:`${t}-sale-start-at`,type:"datetime-local",value:d(a),disabled:u,onChange:l=>n("sale_start_at",o(l.target.value)),className:g}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"→"}),e.jsx(s.Label,{htmlFor:`${t}-sale-end-at`,className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Ends"}),e.jsx(s.Input,{id:`${t}-sale-end-at`,type:"datetime-local",value:d(x),disabled:u,onChange:l=>n("sale_end_at",o(l.target.value)),className:g})]});return p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(s.Label,{htmlFor:`${t}-sale-start-at`,className:"block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",children:"Starts"}),e.jsx(s.Input,{id:`${t}-sale-start-at`,type:"datetime-local",value:d(a),disabled:u,onChange:l=>n("sale_start_at",o(l.target.value)),className:"h-8 w-full text-xs"})]}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(s.Label,{htmlFor:`${t}-sale-end-at`,className:"block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",children:"Ends"}),e.jsx(s.Input,{id:`${t}-sale-end-at`,type:"datetime-local",value:d(x),disabled:u,onChange:l=>n("sale_end_at",o(l.target.value)),className:"h-8 w-full text-xs"}),r?e.jsx("p",{className:"mt-0.5 text-[10px] text-destructive",children:r}):null]})]}):e.jsxs("div",{className:h.cn("rounded border border-dashed bg-muted/5 space-y-1",i?"p-1.5":"p-2"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[e.jsx("span",{className:"shrink-0 text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Sale window"}),j,e.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground",children:[N||"local time"," · empty = always on"]})]}),m&&!i?e.jsx("p",{className:"text-[10px] leading-snug text-muted-foreground",children:m}):null,r?e.jsx("p",{className:"text-[11px] text-destructive",children:r}):null]})}exports.SaleScheduleFields=f;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as s, Fragment as f, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Label as o, Input as u } from "@nextblock-cms/ui";
|
|
4
|
+
import { cn as w } from "@nextblock-cms/utils";
|
|
5
|
+
const d = (e) => String(e).padStart(2, "0");
|
|
6
|
+
function m(e) {
|
|
7
|
+
if (!e)
|
|
8
|
+
return "";
|
|
9
|
+
const a = new Date(e);
|
|
10
|
+
return Number.isNaN(a.getTime()) ? "" : `${a.getFullYear()}-${d(a.getMonth() + 1)}-${d(
|
|
11
|
+
a.getDate()
|
|
12
|
+
)}T${d(a.getHours())}:${d(a.getMinutes())}`;
|
|
13
|
+
}
|
|
14
|
+
function i(e) {
|
|
15
|
+
if (!e)
|
|
16
|
+
return null;
|
|
17
|
+
const a = new Date(e);
|
|
18
|
+
return Number.isNaN(a.getTime()) ? null : a.toISOString();
|
|
19
|
+
}
|
|
20
|
+
function k({
|
|
21
|
+
idPrefix: e = "product",
|
|
22
|
+
startAt: a,
|
|
23
|
+
endAt: x,
|
|
24
|
+
onChange: n,
|
|
25
|
+
error: r,
|
|
26
|
+
disabled: c,
|
|
27
|
+
description: g,
|
|
28
|
+
dense: p,
|
|
29
|
+
bare: h
|
|
30
|
+
}) {
|
|
31
|
+
const v = Intl.DateTimeFormat().resolvedOptions().timeZone, N = w("h-7 text-xs", p || h ? "w-[150px]" : "w-[160px] sm:w-[180px]"), $ = /* @__PURE__ */ s(f, { children: [
|
|
32
|
+
/* @__PURE__ */ t(
|
|
33
|
+
o,
|
|
34
|
+
{
|
|
35
|
+
htmlFor: `${e}-sale-start-at`,
|
|
36
|
+
className: "text-[10px] uppercase tracking-wider text-muted-foreground",
|
|
37
|
+
children: "Starts"
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ t(
|
|
41
|
+
u,
|
|
42
|
+
{
|
|
43
|
+
id: `${e}-sale-start-at`,
|
|
44
|
+
type: "datetime-local",
|
|
45
|
+
value: m(a),
|
|
46
|
+
disabled: c,
|
|
47
|
+
onChange: (l) => n("sale_start_at", i(l.target.value)),
|
|
48
|
+
className: N
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: "→" }),
|
|
52
|
+
/* @__PURE__ */ t(
|
|
53
|
+
o,
|
|
54
|
+
{
|
|
55
|
+
htmlFor: `${e}-sale-end-at`,
|
|
56
|
+
className: "text-[10px] uppercase tracking-wider text-muted-foreground",
|
|
57
|
+
children: "Ends"
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ t(
|
|
61
|
+
u,
|
|
62
|
+
{
|
|
63
|
+
id: `${e}-sale-end-at`,
|
|
64
|
+
type: "datetime-local",
|
|
65
|
+
value: m(x),
|
|
66
|
+
disabled: c,
|
|
67
|
+
onChange: (l) => n("sale_end_at", i(l.target.value)),
|
|
68
|
+
className: N
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] });
|
|
72
|
+
return h ? /* @__PURE__ */ s(f, { children: [
|
|
73
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 space-y-1", children: [
|
|
74
|
+
/* @__PURE__ */ t(
|
|
75
|
+
o,
|
|
76
|
+
{
|
|
77
|
+
htmlFor: `${e}-sale-start-at`,
|
|
78
|
+
className: "block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",
|
|
79
|
+
children: "Starts"
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ t(
|
|
83
|
+
u,
|
|
84
|
+
{
|
|
85
|
+
id: `${e}-sale-start-at`,
|
|
86
|
+
type: "datetime-local",
|
|
87
|
+
value: m(a),
|
|
88
|
+
disabled: c,
|
|
89
|
+
onChange: (l) => n("sale_start_at", i(l.target.value)),
|
|
90
|
+
className: "h-8 w-full text-xs"
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] }),
|
|
94
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 space-y-1", children: [
|
|
95
|
+
/* @__PURE__ */ t(
|
|
96
|
+
o,
|
|
97
|
+
{
|
|
98
|
+
htmlFor: `${e}-sale-end-at`,
|
|
99
|
+
className: "block text-[10px] uppercase font-bold tracking-widest text-muted-foreground",
|
|
100
|
+
children: "Ends"
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ t(
|
|
104
|
+
u,
|
|
105
|
+
{
|
|
106
|
+
id: `${e}-sale-end-at`,
|
|
107
|
+
type: "datetime-local",
|
|
108
|
+
value: m(x),
|
|
109
|
+
disabled: c,
|
|
110
|
+
onChange: (l) => n("sale_end_at", i(l.target.value)),
|
|
111
|
+
className: "h-8 w-full text-xs"
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
r ? /* @__PURE__ */ t("p", { className: "mt-0.5 text-[10px] text-destructive", children: r }) : null
|
|
115
|
+
] })
|
|
116
|
+
] }) : /* @__PURE__ */ s(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
className: w("rounded border border-dashed bg-muted/5 space-y-1", p ? "p-1.5" : "p-2"),
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1.5", children: [
|
|
122
|
+
/* @__PURE__ */ t("span", { className: "shrink-0 text-[11px] font-bold uppercase tracking-wider text-muted-foreground", children: "Sale window" }),
|
|
123
|
+
$,
|
|
124
|
+
/* @__PURE__ */ s("span", { className: "ml-auto text-[10px] text-muted-foreground", children: [
|
|
125
|
+
v || "local time",
|
|
126
|
+
" · empty = always on"
|
|
127
|
+
] })
|
|
128
|
+
] }),
|
|
129
|
+
g && !p ? /* @__PURE__ */ t("p", { className: "text-[10px] leading-snug text-muted-foreground", children: g }) : null,
|
|
130
|
+
r ? /* @__PURE__ */ t("p", { className: "text-[11px] text-destructive", children: r }) : null
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
k as SaleScheduleFields
|
|
137
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("react"),u=require("@nextblock-cms/ui"),a=require("lucide-react"),t=require("sonner"),l=require("../actions.cjs.js");function d({title:c="Sync Full Store"}){const[r,s]=i.useState(!1),o=async()=>{s(!0);try{const e=await l.triggerFreemiusSync();e.error?t.toast.error(e.error):t.toast.success(`Full store sync complete! Found ${e.data?.count||0} products.`)}catch(e){t.toast.error(e.message||"An unexpected error occurred during sync")}finally{s(!1)}};return n.jsxs(u.Button,{variant:"secondary",onClick:o,disabled:r,className:"gap-2",children:[n.jsx(a.RefreshCw,{className:`w-4 h-4 ${r?"animate-spin":""}`}),r?"Syncing...":c]})}exports.SyncFreemiusButton=d;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as o, jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { useState as a } from "react";
|
|
4
|
+
import { Button as i } from "@nextblock-cms/ui";
|
|
5
|
+
import { RefreshCw as m } from "lucide-react";
|
|
6
|
+
import { toast as n } from "sonner";
|
|
7
|
+
import { triggerFreemiusSync as l } from "../actions.es.js";
|
|
8
|
+
function h({ title: s = "Sync Full Store" }) {
|
|
9
|
+
const [e, t] = a(!1);
|
|
10
|
+
return /* @__PURE__ */ o(
|
|
11
|
+
i,
|
|
12
|
+
{
|
|
13
|
+
variant: "secondary",
|
|
14
|
+
onClick: async () => {
|
|
15
|
+
t(!0);
|
|
16
|
+
try {
|
|
17
|
+
const r = await l();
|
|
18
|
+
r.error ? n.error(r.error) : n.success(`Full store sync complete! Found ${r.data?.count || 0} products.`);
|
|
19
|
+
} catch (r) {
|
|
20
|
+
n.error(r.message || "An unexpected error occurred during sync");
|
|
21
|
+
} finally {
|
|
22
|
+
t(!1);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
disabled: e,
|
|
26
|
+
className: "gap-2",
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ c(m, { className: `w-4 h-4 ${e ? "animate-spin" : ""}` }),
|
|
29
|
+
e ? "Syncing..." : s
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
h as SyncFreemiusButton
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),o=require("react"),u=require("@nextblock-cms/ui"),a=require("lucide-react"),r=require("sonner"),l=require("../actions.cjs.js");function g({productId:s}){const[n,t]=o.useState(!1),c=async()=>{if(!s){r.toast.error("Product ID is missing");return}t(!0);try{const e=await l.triggerSingleProductSync(s);e.error?r.toast.error(e.error):r.toast.success("Pricing sync complete!")}catch(e){r.toast.error(e.message||"An unexpected error occurred during sync")}finally{t(!1)}};return i.jsxs(u.Button,{variant:"outline",onClick:c,disabled:n,className:"gap-2",children:[i.jsx(a.RefreshCw,{className:`w-4 h-4 ${n?"animate-spin":""}`}),n?"Syncing...":"Sync Prices from Freemius"]})}exports.SyncFreemiusPricingButton=g;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as t, jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { useState as c } from "react";
|
|
4
|
+
import { Button as a } from "@nextblock-cms/ui";
|
|
5
|
+
import { RefreshCw as m } from "lucide-react";
|
|
6
|
+
import { toast as e } from "sonner";
|
|
7
|
+
import { triggerSingleProductSync as l } from "../actions.es.js";
|
|
8
|
+
function P({ productId: s }) {
|
|
9
|
+
const [n, i] = c(!1);
|
|
10
|
+
return /* @__PURE__ */ t(
|
|
11
|
+
a,
|
|
12
|
+
{
|
|
13
|
+
variant: "outline",
|
|
14
|
+
onClick: async () => {
|
|
15
|
+
if (!s) {
|
|
16
|
+
e.error("Product ID is missing");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
i(!0);
|
|
20
|
+
try {
|
|
21
|
+
const r = await l(s);
|
|
22
|
+
r.error ? e.error(r.error) : e.success("Pricing sync complete!");
|
|
23
|
+
} catch (r) {
|
|
24
|
+
e.error(r.message || "An unexpected error occurred during sync");
|
|
25
|
+
} finally {
|
|
26
|
+
i(!1);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
disabled: n,
|
|
30
|
+
className: "gap-2",
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ o(m, { className: `w-4 h-4 ${n ? "animate-spin" : ""}` }),
|
|
33
|
+
n ? "Syncing..." : "Sync Prices from Freemius"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
P as SyncFreemiusPricingButton
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),R=require("next/link"),f=require("react"),p=require("@nextblock-cms/ui"),g=require("../../../../variation-utils.cjs.js"),Q=require("./CurrencyPriceFields.cjs.js"),W=require("./SaleScheduleFields.cjs.js"),y=require("../../../../currency.cjs.js"),j=require("../product-price-sync.cjs.js"),k=require("@nextblock-cms/utils"),E=process.env.NEXT_PUBLIC_R2_BASE_URL||"",D=process.env.NEXT_PUBLIC_SUPABASE_URL||"",H=c=>c.startsWith("http")?c:E?`${E.replace(/\/+$/,"")}/${c.replace(/^\/+/,"")}`:D?`${D.replace(/\/+$/,"")}/storage/v1/object/public/media/${c.replace(/^\/+/,"")}`:c;function L(c,a="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:a}).format(c)}function J(c){return Object.entries(c).filter(([,a])=>a.length>0).map(([a,b])=>({attribute_id:a,term_ids:b}))}function Y({globalAttributes:c,currentLanguageCode:a,baseSku:b,basePrice:$,basePrices:w,baseSalePrice:T,baseSalePrices:B,currencies:o,availableVariantImages:N=[],initialVariationAttributes:C,initialVariants:V,onChange:q}){const[_,z]=f.useState(()=>C&&C.length>0?C.reduce((e,r)=>(e[r.attribute_id]=r.term_ids,e),{}):g.extractSelectedTermsByAttribute(V||[])),[h,x]=f.useState(j.sanitizeVariantDraftsForStoreManagedCurrencies(V||[],o)),S=f.useMemo(()=>c.map(e=>({attribute_id:e.id,attribute_name:g.resolveAttributeName(e,a),terms:e.terms.filter(r=>(_[e.id]||[]).includes(r.id)).map(r=>({...r,value:g.resolveTermValue(r,a)}))})).filter(e=>e.terms.length>0),[a,c,_]);f.useEffect(()=>{if(S.length===0){x([]);return}x(e=>j.sanitizeVariantDraftsForStoreManagedCurrencies(g.generateVariantDrafts({baseSku:b,basePrice:$,basePrices:y.normalizePriceMap(w),baseSalePrice:T,baseSalePrices:y.normalizeSalePriceMap(B),selectedAttributes:S,previousVariants:e}),o))},[$,w,T,B,b,o,S]),f.useEffect(()=>{q({variationAttributes:J(_),variants:h})},[q,_,h]);const I=h.reduce((e,r)=>e+(r.stock_quantity||0),0),P=o.find(e=>e.is_default)??o[0],U=f.useMemo(()=>j.getStoreManagedPriceCurrencyCodes(o),[o]),K=(e,r)=>{z(t=>{const n=new Set(t[e]||[]);return n.has(r)?n.delete(r):n.add(r),{...t,[e]:[...n]}})},M=(e,r,t)=>{x(n=>n.map(i=>{if(i.combination_key!==e)return i;if(r==="sku")return{...i,sku:t};if(r==="upc")return{...i,upc:t};if(r==="sale_price"&&t==="")return{...i,sale_price:null};if(r==="prices"||r==="sale_prices")return i;const d=t===""?0:Number(t);return{...i,[r]:Number.isFinite(d)?d:0}}))},O=(e,r,t)=>{x(n=>n.map(i=>i.combination_key===e?{...i,[r]:t}:i))},F=(e,r,t,n)=>{const i=o.find(d=>d.is_default)??o[0];x(d=>d.map(m=>{if(m.combination_key!==e)return m;const u={...t==="prices"?m.prices:m.sale_prices,[r]:n};return{...m,[t]:u,...r===i?.code?t==="prices"?{price:n??0}:{sale_price:n}:{}}}))},X=e=>{const r=o.find(n=>n.is_default)??o[0],t=new Set(U);r&&x(n=>n.map(i=>{if(i.combination_key!==e)return i;const d=o.reduce((u,l)=>{if(l.code!==r.code&&t.has(l.code))return u;const A=y.convertMinorUnitAmount({amount:k.majorUnitAmountToMinor(i.price,r.code),fromCurrencyCode:r.code,toCurrencyCode:l.code,currencies:o,applyRounding:!0});return u[l.code]=k.minorUnitAmountToMajor(A,l.code),u},{}),m=o.reduce((u,l)=>{if(l.code!==r.code&&t.has(l.code))return u;if(typeof i.sale_price!="number")return u[l.code]=null,u;const A=y.convertMinorUnitAmount({amount:k.majorUnitAmountToMinor(i.sale_price,r.code),fromCurrencyCode:r.code,toCurrencyCode:l.code,currencies:o,applyRounding:!0});return u[l.code]=k.minorUnitAmountToMajor(A,l.code),u},{});return{...i,prices:d,sale_prices:m}}))},G=(e,r)=>{const t=N.find(d=>d.media_id===r);if(!t)return;const n=t.file_path,i=H(n);x(d=>d.map(m=>m.combination_key===e?{...m,main_media_id:t.media_id,main_image_url:i}:m))},v=e=>{x(r=>r.map(t=>t.combination_key===e?{...t,main_media_id:null,main_image_url:null}:t))};return c.length===0?s.jsxs("div",{className:"rounded-lg border border-dashed p-6 text-sm text-muted-foreground",children:["No global attributes have been created yet. Create them first in"," ",s.jsx(R,{href:"/cms/products/attributes",className:"font-medium text-primary underline-offset-4 hover:underline",children:"Attribute Management"}),"."]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Attributes"}),s.jsxs(p.Badge,{variant:"outline",className:"text-[10px] px-1.5 h-4",children:[h.length," variants"]}),s.jsxs(p.Badge,{variant:"secondary",className:"text-[10px] px-1.5 h-4",children:["Stock: ",I]})]}),s.jsx(p.Button,{asChild:!0,variant:"outline",size:"sm",className:"h-7 text-xs px-3",children:s.jsx(R,{href:"/cms/products/attributes",children:"Manage"})})]}),s.jsx("div",{className:"grid gap-2 lg:grid-cols-2",children:c.map(e=>{const r=_[e.id]||[];return s.jsxs("div",{className:"flex items-center gap-3 rounded border p-2.5",children:[s.jsxs("div",{className:"shrink-0 w-[100px]",children:[s.jsx("span",{className:"text-sm font-bold block leading-tight",children:g.resolveAttributeName(e,a)}),s.jsxs("span",{className:"text-[10px] text-muted-foreground leading-none",children:[r.length," selected"]})]}),s.jsx("div",{className:"flex flex-wrap gap-1.5 flex-1",children:e.terms.map(t=>{const n=r.includes(t.id);return s.jsx("button",{type:"button",onClick:()=>K(e.id,t.id),className:`rounded-full border px-2.5 py-0.5 text-[11px] font-medium transition-colors ${n?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:border-primary/40"}`,children:g.resolveTermValue(t,a)},t.id)})})]},e.id)})})]}),h.length===0?s.jsx("div",{className:"rounded border border-dashed p-3 text-xs text-muted-foreground text-center",children:"Select terms above to generate variations."}):s.jsx("div",{className:"space-y-2",children:h.map(e=>{const r=j.resolveEditorCurrencyPriceMaps({currencies:o,prices:e.prices||{},salePrices:e.sale_prices||{},fallbackPrice:e.price,fallbackSalePrice:e.sale_price});return s.jsxs("div",{className:"rounded border p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-bold",children:e.label}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.selected_options.map(t=>`${t.attribute_name}: ${t.term_value}`).join(" · ")})]}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Reg: ",L(e.price,P?.code||"USD")]}),s.jsxs("span",{children:["Sale:"," ",e.sale_price!==null&&e.sale_price!==void 0?L(e.sale_price,P?.code||"USD"):"—"]})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(p.Label,{htmlFor:`variant-sku-${e.combination_key}`,className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"SKU"}),s.jsx(p.Input,{id:`variant-sku-${e.combination_key}`,value:e.sku,onChange:t=>M(e.combination_key,"sku",t.target.value),placeholder:"SKU",className:"h-8 text-sm font-mono"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(p.Label,{htmlFor:`variant-upc-${e.combination_key}`,className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"UPC"}),s.jsx(p.Input,{id:`variant-upc-${e.combination_key}`,value:e.upc??"",onChange:t=>M(e.combination_key,"upc",t.target.value),placeholder:"—",className:"h-8 text-sm font-mono"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(p.Label,{htmlFor:`variant-stock-${e.combination_key}`,className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"Qty"}),s.jsx(p.Input,{id:`variant-stock-${e.combination_key}`,type:"number",min:"0",value:e.stock_quantity,onChange:t=>M(e.combination_key,"stock_quantity",t.target.value),className:"h-8 text-sm font-mono w-20"})]})]}),s.jsx(Q.CurrencyPriceFields,{idPrefix:`variant-${e.combination_key}`,currencies:o,prices:r.prices,salePrices:r.salePrices,managedCurrencyCodes:U,onPriceChange:(t,n)=>F(e.combination_key,t,"prices",n),onSalePriceChange:(t,n)=>F(e.combination_key,t,"sale_prices",n),onAutoFill:()=>X(e.combination_key),helperText:U.length>0?`Store-managed currencies derive from ${P?.code||"the base currency"}.`:void 0,trailing:s.jsx(W.SaleScheduleFields,{idPrefix:`variant-${e.combination_key}`,startAt:e.sale_start_at,endAt:e.sale_end_at,onChange:(t,n)=>O(e.combination_key,t,n),bare:!0})}),s.jsxs("div",{className:"flex items-center gap-3 pt-1.5 border-t border-muted/30",children:[e.main_image_url&&s.jsx("div",{className:"h-9 w-9 overflow-hidden rounded border bg-background shrink-0",children:s.jsx("img",{src:e.main_image_url,alt:`${e.label} image`,className:"h-full w-full object-cover"})}),s.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",children:"Image"}),N.length>0?s.jsxs("select",{className:"flex h-8 rounded-md border border-input bg-background px-2 py-1 text-sm min-w-[180px]",value:e.main_media_id??"",onChange:t=>{if(!t.target.value){v(e.combination_key);return}G(e.combination_key,t.target.value)},children:[s.jsx("option",{value:"",children:"Use parent image"}),N.map((t,n)=>s.jsx("option",{value:t.media_id,children:t.alt?.trim()||`Gallery image ${n+1}`},t.media_id))]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"Add gallery images first."}),e.main_media_id&&s.jsx(p.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs px-2 text-muted-foreground hover:text-destructive",onClick:()=>v(e.combination_key),children:"Remove"})]})]},e.combination_key)})})]})}exports.VariationsEditor=Y;
|