@nextblock-cms/ecom 0.11.2 → 0.12.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/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +56 -48
- package/lib/pages/cms/products/actions.d.ts +1 -0
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +170 -165
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.d.ts +3 -0
- package/lib/product-actions.es.js +86 -73
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.d.ts +1 -0
- package/lib/product-schema.es.js +1 -0
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@nextblock-cms/db/server"),h=require("./customer.cjs.js"),d=require("./invoice.cjs.js"),T=require("./order-tax-details.cjs.js");function w(e){return e?e.startsWith("http")||e.startsWith("/")?e:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}`:e:null}function c(e){return e??E.getServiceRoleSupabaseClient()}function L(e){if(!e)return null;const o=e.media?.object_key??e.media?.file_path??null;return{id:e.id,name:e.name??null,url:w(o),width:e.media?.width??null,height:e.media?.height??null}}const U="active_logo_id",p=`
|
|
2
2
|
id,
|
|
3
3
|
name,
|
|
4
4
|
media:media_id (
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
width,
|
|
8
8
|
height
|
|
9
9
|
)
|
|
10
|
-
|
|
10
|
+
`;async function k(e){const{data:o}=await e.from("site_settings").select("value").eq("key",U).maybeSingle(),n=o?.value,t=typeof n=="string"&&n.length>0?n:null;if(t){const{data:s}=await e.from("logos").select(p).eq("id",t).maybeSingle();if(s)return s}const{data:r}=await e.from("logos").select(p).order("created_at",{ascending:!1}).limit(1).maybeSingle();return r??null}async function g(e){const o=c(e),[n,t]=await Promise.all([o.from("site_settings").select("value").eq("key",d.INVOICE_SETTINGS_KEY).maybeSingle(),k(o)]);return{settings:d.normalizeInvoiceSettings(n.data?.value??d.DEFAULT_INVOICE_SETTINGS),logo:L(t)}}async function O(e){const o=c(e.client),{data:n,error:t}=await o.rpc("assign_order_invoice_metadata",{p_order_id:e.orderId,p_paid_at:e.paidAt??null}).single();if(t)throw new Error(t.message);return{invoiceNumber:n?.invoice_number??null,paidAt:n?.paid_at??null}}async function m(e,o){const n=c(o),{data:t,error:r}=await n.from("orders").select(`
|
|
11
11
|
id,
|
|
12
12
|
invoice_number,
|
|
13
13
|
paid_at,
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
quantity,
|
|
31
31
|
price_at_purchase
|
|
32
32
|
)
|
|
33
|
-
`).eq("id",e).single();if(
|
|
33
|
+
`).eq("id",e).single();if(r||!t)throw new Error(r?.message||"Order not found");const s=(t.order_items||[]).map(a=>a.product_id).filter(Boolean),u=(t.order_items||[]).map(a=>a.variant_id).filter(Boolean),[v,f]=await Promise.all([s.length?n.from("products").select("id, title, sku").in("id",s):Promise.resolve({data:[],error:null}),u.length?n.from("product_variants").select("id, sku").in("id",u):Promise.resolve({data:[],error:null})]),b=new Map((v.data||[]).map(a=>[a.id,a])),y=new Map((f.data||[]).map(a=>[a.id,a])),_=(t.order_items||[]).map(a=>{const i=a.product_id?b.get(a.product_id):null,l=a.variant_id?y.get(a.variant_id):null,I=i?.title||"Product",S=l?.sku?`SKU: ${l.sku}`:i?.sku?`SKU: ${i.sku}`:null;return{id:a.id,product_id:a.product_id??null,variant_id:a.variant_id??null,title:I,description:S,quantity:a.quantity,unit_amount:a.price_at_purchase,total_amount:a.price_at_purchase*a.quantity,sku:l?.sku??i?.sku??null}});return{id:t.id,invoice_number:t.invoice_number??null,paid_at:t.paid_at??null,created_at:t.created_at??null,currency:t.currency||"usd",status:t.status,provider:t.provider??null,subtotal:typeof t.subtotal=="number"?t.subtotal:_.reduce((a,i)=>a+i.total_amount,0),shipping_total:typeof t.shipping_total=="number"?t.shipping_total:0,discount_total:typeof t.discount_total=="number"?t.discount_total:0,coupon_code:t.coupon_code??null,tax_total:typeof t.tax_total=="number"?t.tax_total:0,total:t.total,customer_details:h.normalizeOrderCustomerDetails(t.customer_details??{}),tax_details:T.normalizeOrderTaxDetails(t.tax_details),items:_}}async function R(e,o){const n=c(o),[t,r]=await Promise.all([m(e,n),g(n)]);return{order:t,settings:r.settings,logo:r.logo}}exports.assignInvoiceMetadata=O;exports.getInvoiceBrandingData=g;exports.getInvoiceOrder=m;exports.getInvoicePresentationData=R;
|
package/lib/invoice-server.es.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { getServiceRoleSupabaseClient as
|
|
2
|
-
import { normalizeOrderCustomerDetails as
|
|
3
|
-
import { INVOICE_SETTINGS_KEY as
|
|
4
|
-
import { normalizeOrderTaxDetails as
|
|
5
|
-
function
|
|
1
|
+
import { getServiceRoleSupabaseClient as y } from "@nextblock-cms/db/server";
|
|
2
|
+
import { normalizeOrderCustomerDetails as E } from "./customer.es.js";
|
|
3
|
+
import { INVOICE_SETTINGS_KEY as I, normalizeInvoiceSettings as S, DEFAULT_INVOICE_SETTINGS as h } from "./invoice.es.js";
|
|
4
|
+
import { normalizeOrderTaxDetails as w } from "./order-tax-details.es.js";
|
|
5
|
+
function L(e) {
|
|
6
6
|
return e ? e.startsWith("http") || e.startsWith("/") ? e : process.env.NEXT_PUBLIC_R2_BASE_URL ? `${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}` : process.env.NEXT_PUBLIC_SUPABASE_URL ? `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}` : e : null;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
return e ??
|
|
8
|
+
function l(e) {
|
|
9
|
+
return e ?? y();
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function T(e) {
|
|
12
12
|
if (!e)
|
|
13
13
|
return null;
|
|
14
|
-
const
|
|
14
|
+
const n = e.media?.object_key ?? e.media?.file_path ?? null;
|
|
15
15
|
return {
|
|
16
16
|
id: e.id,
|
|
17
17
|
name: e.name ?? null,
|
|
18
|
-
url:
|
|
18
|
+
url: L(n),
|
|
19
19
|
width: e.media?.width ?? null,
|
|
20
20
|
height: e.media?.height ?? null
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
const o = s(e), [r, t] = await Promise.all([
|
|
25
|
-
o.from("site_settings").select("value").eq("key", h).maybeSingle(),
|
|
26
|
-
o.from("logos").select(
|
|
27
|
-
`
|
|
23
|
+
const U = "active_logo_id", _ = `
|
|
28
24
|
id,
|
|
29
25
|
name,
|
|
30
26
|
media:media_id (
|
|
@@ -33,28 +29,40 @@ async function R(e) {
|
|
|
33
29
|
width,
|
|
34
30
|
height
|
|
35
31
|
)
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
`;
|
|
33
|
+
async function k(e) {
|
|
34
|
+
const { data: n } = await e.from("site_settings").select("value").eq("key", U).maybeSingle(), o = n?.value, t = typeof o == "string" && o.length > 0 ? o : null;
|
|
35
|
+
if (t) {
|
|
36
|
+
const { data: s } = await e.from("logos").select(_).eq("id", t).maybeSingle();
|
|
37
|
+
if (s) return s;
|
|
38
|
+
}
|
|
39
|
+
const { data: r } = await e.from("logos").select(_).order("created_at", { ascending: !1 }).limit(1).maybeSingle();
|
|
40
|
+
return r ?? null;
|
|
41
|
+
}
|
|
42
|
+
async function R(e) {
|
|
43
|
+
const n = l(e), [o, t] = await Promise.all([
|
|
44
|
+
n.from("site_settings").select("value").eq("key", I).maybeSingle(),
|
|
45
|
+
k(n)
|
|
38
46
|
]);
|
|
39
47
|
return {
|
|
40
|
-
settings:
|
|
41
|
-
logo:
|
|
48
|
+
settings: S(o.data?.value ?? h),
|
|
49
|
+
logo: T(t)
|
|
42
50
|
};
|
|
43
51
|
}
|
|
44
|
-
async function
|
|
45
|
-
const
|
|
52
|
+
async function q(e) {
|
|
53
|
+
const n = l(e.client), { data: o, error: t } = await n.rpc("assign_order_invoice_metadata", {
|
|
46
54
|
p_order_id: e.orderId,
|
|
47
55
|
p_paid_at: e.paidAt ?? null
|
|
48
56
|
}).single();
|
|
49
57
|
if (t)
|
|
50
58
|
throw new Error(t.message);
|
|
51
59
|
return {
|
|
52
|
-
invoiceNumber:
|
|
53
|
-
paidAt:
|
|
60
|
+
invoiceNumber: o?.invoice_number ?? null,
|
|
61
|
+
paidAt: o?.paid_at ?? null
|
|
54
62
|
};
|
|
55
63
|
}
|
|
56
|
-
async function
|
|
57
|
-
const
|
|
64
|
+
async function C(e, n) {
|
|
65
|
+
const o = l(n), { data: t, error: r } = await o.from("orders").select(
|
|
58
66
|
`
|
|
59
67
|
id,
|
|
60
68
|
invoice_number,
|
|
@@ -80,27 +88,27 @@ async function B(e, o) {
|
|
|
80
88
|
)
|
|
81
89
|
`
|
|
82
90
|
).eq("id", e).single();
|
|
83
|
-
if (
|
|
84
|
-
throw new Error(
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
]),
|
|
89
|
-
(_.data || []).map((a) => [a.id, a])
|
|
90
|
-
), g = new Map(
|
|
91
|
+
if (r || !t)
|
|
92
|
+
throw new Error(r?.message || "Order not found");
|
|
93
|
+
const s = (t.order_items || []).map((a) => a.product_id).filter(Boolean), u = (t.order_items || []).map((a) => a.variant_id).filter(Boolean), [p, m] = await Promise.all([
|
|
94
|
+
s.length ? o.from("products").select("id, title, sku").in("id", s) : Promise.resolve({ data: [], error: null }),
|
|
95
|
+
u.length ? o.from("product_variants").select("id, sku").in("id", u) : Promise.resolve({ data: [], error: null })
|
|
96
|
+
]), g = new Map(
|
|
91
97
|
(p.data || []).map((a) => [a.id, a])
|
|
98
|
+
), v = new Map(
|
|
99
|
+
(m.data || []).map((a) => [a.id, a])
|
|
92
100
|
), c = (t.order_items || []).map((a) => {
|
|
93
|
-
const
|
|
101
|
+
const i = a.product_id ? g.get(a.product_id) : null, d = a.variant_id ? v.get(a.variant_id) : null, f = i?.title || "Product", b = d?.sku ? `SKU: ${d.sku}` : i?.sku ? `SKU: ${i.sku}` : null;
|
|
94
102
|
return {
|
|
95
103
|
id: a.id,
|
|
96
104
|
product_id: a.product_id ?? null,
|
|
97
105
|
variant_id: a.variant_id ?? null,
|
|
98
|
-
title:
|
|
106
|
+
title: f,
|
|
99
107
|
description: b,
|
|
100
108
|
quantity: a.quantity,
|
|
101
109
|
unit_amount: a.price_at_purchase,
|
|
102
110
|
total_amount: a.price_at_purchase * a.quantity,
|
|
103
|
-
sku: d?.sku ??
|
|
111
|
+
sku: d?.sku ?? i?.sku ?? null
|
|
104
112
|
};
|
|
105
113
|
});
|
|
106
114
|
return {
|
|
@@ -111,31 +119,31 @@ async function B(e, o) {
|
|
|
111
119
|
currency: t.currency || "usd",
|
|
112
120
|
status: t.status,
|
|
113
121
|
provider: t.provider ?? null,
|
|
114
|
-
subtotal: typeof t.subtotal == "number" ? t.subtotal : c.reduce((a,
|
|
122
|
+
subtotal: typeof t.subtotal == "number" ? t.subtotal : c.reduce((a, i) => a + i.total_amount, 0),
|
|
115
123
|
shipping_total: typeof t.shipping_total == "number" ? t.shipping_total : 0,
|
|
116
124
|
discount_total: typeof t.discount_total == "number" ? t.discount_total : 0,
|
|
117
125
|
coupon_code: t.coupon_code ?? null,
|
|
118
126
|
tax_total: typeof t.tax_total == "number" ? t.tax_total : 0,
|
|
119
127
|
total: t.total,
|
|
120
|
-
customer_details:
|
|
121
|
-
tax_details:
|
|
128
|
+
customer_details: E(t.customer_details ?? {}),
|
|
129
|
+
tax_details: w(t.tax_details),
|
|
122
130
|
items: c
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
|
-
async function
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
R(
|
|
133
|
+
async function M(e, n) {
|
|
134
|
+
const o = l(n), [t, r] = await Promise.all([
|
|
135
|
+
C(e, o),
|
|
136
|
+
R(o)
|
|
129
137
|
]);
|
|
130
138
|
return {
|
|
131
139
|
order: t,
|
|
132
|
-
settings:
|
|
133
|
-
logo:
|
|
140
|
+
settings: r.settings,
|
|
141
|
+
logo: r.logo
|
|
134
142
|
};
|
|
135
143
|
}
|
|
136
144
|
export {
|
|
137
|
-
|
|
145
|
+
q as assignInvoiceMetadata,
|
|
138
146
|
R as getInvoiceBrandingData,
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
C as getInvoiceOrder,
|
|
148
|
+
M as getInvoicePresentationData
|
|
141
149
|
};
|
|
@@ -83,6 +83,7 @@ export declare function getProducts(options?: {
|
|
|
83
83
|
export declare function getProduct(id: string): Promise<{
|
|
84
84
|
average_rating: number;
|
|
85
85
|
created_at: string | null;
|
|
86
|
+
custom_canonical: string | null;
|
|
86
87
|
description_json: import('../../../../../../db/src/index.ts').Json | null;
|
|
87
88
|
freemius_plan_id: string | null;
|
|
88
89
|
freemius_product_id: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),Be=require("@hookform/resolvers/zod"),L=require("lucide-react"),t=require("@nextblock-cms/ui"),Oe=require("../../../../product-schema.cjs.js"),Ue=require("react-hook-form"),ze=require("./ProductMediaManager.cjs.js"),Le=require("./SyncFreemiusPricingButton.cjs.js"),Ke=require("./VariationsEditor.cjs.js"),je=require("./CurrencyPriceFields.cjs.js"),ve=require("./SaleScheduleFields.cjs.js"),$e=require("./ProductCategorySelector.cjs.js"),H=require("../product-price-sync.cjs.js"),He=require("../../../../types.cjs.js"),Ne=require("../../../../currency.cjs.js"),K=require("@nextblock-cms/utils");function $({title:s,description:a,action:y,children:h,hideHeader:P}){return e.jsxs("section",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-3",children:[!P&&e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap border-b border-muted/50 pb-2 mb-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h2",{className:"text-sm font-bold tracking-tight",children:s}),a?e.jsx("p",{className:"text-[11px] text-muted-foreground leading-none",children:a}):null]}),y]}),e.jsx("div",{className:P?"":"pt-1",children:h})]})}function Je(s,a,y){const h=a?Number.parseInt(a,10):void 0;return s?.language_id||(Number.isFinite(h)?h:void 0)||y.find(P=>P.is_default)?.id||y[0]?.id||1}function Se(s,a,y,h,P){const k=(h.find(b=>b.is_default)??h[0])?.code||"USD",V=s?.prices&&Object.keys(s.prices).length>0?s.prices:{[k]:typeof s?.price=="number"?s.price/100:0},A=s?.sale_prices&&Object.keys(s.sale_prices).length>0?s.sale_prices:typeof s?.sale_price=="number"?{[k]:s.sale_price/100}:{},q=s?.product_type||"",F=s?.payment_provider||(s?.product_type?He.derivePaymentProviderFromProductType(s.product_type):"stripe");return{...H.sanitizeProductFormValuesForStoreManagedCurrencies({product_type:q||"physical",payment_provider:F,title:s?.title||"",slug:s?.slug||"",sku:s?.sku||"",upc:s?.upc||"",is_taxable:s?.is_taxable??!0,price:typeof s?.price=="number"?s.price/100:0,prices:V,sale_price:typeof s?.sale_price=="number"?s.sale_price/100:null,sale_prices:A,stock:s?.stock||0,meta_title:s?.meta_title||"",meta_description:s?.meta_description||"",short_description:s?.short_description||"",description_json:s?.description_json||{type:"doc",content:[{type:"paragraph"}]},freemius_product_id:s?.freemius_product_id||"",freemius_plan_id:s?.freemius_plan_id||"",trial_period_days:s?.trial_period_days??0,trial_requires_payment_method:s?.trial_requires_payment_method??!1,status:s?.status||"draft",language_id:Je(s,a,y),translation_group_id:s?.translation_group_id||P||void 0,product_media:s?.product_media?.map(b=>({media_id:b.media_id}))||[],category_ids:s?.category_ids||[],variation_attributes:s?.variation_attributes||[],variants:s?.variants?.map(b=>({...b,prices:b.prices||{},sale_prices:b.sale_prices||{}}))||[]},h),product_type:q,payment_provider:F}}function Pe(s){return s?s.map(a=>({id:a.id||a.media_id,media_id:a.media_id,file_path:a.media?.file_path||a.media?.object_key||"",alt:a.media?.alt_text||"",sort_order:a.sort_order??0})).sort((a,y)=>a.sort_order-y.sort_order):[]}function Xe(s){return s.map(a=>({media_id:a.media_id}))}function Ye(s){return s.map(a=>({media_id:a.media_id,file_path:a.file_path,alt:a.alt}))}const Qe=s=>s.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,"");function We({initialData:s,isEdit:a=!1,mediaPickerNode:y,availableLanguagesProp:h,globalAttributesProp:P,currenciesProp:J,translationGroupId:k,targetLanguageId:V,freemiusDashboardNode:A,enabledProviders:q,configStatus:F,createAction:X,updateAction:b,availableCategoriesProp:we=[]}){const[T,R]=l.useState(!1),[Y,Q]=l.useState(()=>!!s?.variants?.length),u=l.useMemo(()=>J.filter(r=>r.is_active!==!1).sort((r,d)=>r.is_default!==d.is_default?r.is_default?-1:1:r.code.localeCompare(d.code)),[J]),c=l.useMemo(()=>u.find(r=>r.is_default)??u[0],[u]),E=l.useMemo(()=>H.getStoreManagedPriceCurrencyCodes(u),[u]),ae=Ue.useForm({resolver:Be.zodResolver(Oe.productSchema),defaultValues:Se(s,V,h,u,k)}),{register:o,handleSubmit:W,setValue:i,reset:ie,watch:n,setError:B,formState:{errors:g,dirtyFields:de}}=ae,le=l.useRef(!0),Z=l.useRef(null),[Ce,O]=l.useState(!1),[ne,U]=l.useState(null),[ce,ke]=l.useState(null),G=n(),oe=ae.formState.isDirty;l.useEffect(()=>{if(!a)return;if(le.current){le.current=!1,Z.current=JSON.stringify(G);return}if(!oe)return;const r=JSON.stringify(G);if(r===Z.current)return;const d=setTimeout(()=>{T||(Z.current=r,W(be)())},1e3);return()=>clearTimeout(d)},[G,a,oe,T,W]);const ue=n("title"),I=n("product_type"),x=I==="digital"?"freemius":I==="physical"?"stripe":void 0,j=I==="physical",pe=I==="digital",D=x?q[x]:!1,ee=x?F[x].hasKeys:!1,Fe=!!n("freemius_product_id"),me=Number(n("trial_period_days")||0),xe=!!n("trial_requires_payment_method"),Me=n("variants")||[],w=n("price"),M=n("sale_price"),v=n("prices")||{},C=n("sale_prices")||{},N=(Me?.length||0)>0,Ve=n("language_id"),Ie=h.find(r=>r.id===Ve)?.code||h.find(r=>r.is_default)?.code||h[0]?.code,z=l.useMemo(()=>H.resolveEditorCurrencyPriceMaps({currencies:u,prices:v,salePrices:C,fallbackPrice:w,fallbackSalePrice:M}),[w,M,u,v,C]),Ae=l.useMemo(()=>s?.variants?.map(r=>({...r,prices:r.prices||{},sale_prices:r.sale_prices||{}})),[s?.variants]);l.useEffect(()=>{if(de.title&&!a){const r=Qe(ue);i("slug",r,{shouldValidate:!0})}},[ue,de.title,i,a]);const[se,he]=l.useState(()=>Pe(s?.product_media)),[re,ge]=l.useState(new Set);l.useEffect(()=>{ie(Se(s,V,h,u,k)),he(Pe(s?.product_media)),ge(new Set),Q(!!s?.variants?.length)},[h,u,s,ie,V,k]);const qe=r=>{const d=new Set(r.map(m=>m.id)),p=se.filter(m=>!d.has(m.id)),f=new Set(re);p.forEach(m=>{m.media_id&&f.add(m.media_id)}),ge(f),he(r),i("product_media",Xe(r),{shouldDirty:!0}),i("explicitly_removed_media_ids",Array.from(f),{shouldDirty:!0})};l.useEffect(()=>{i("explicitly_removed_media_ids",Array.from(re))},[re,i]),l.useEffect(()=>{N&&Q(!0)},[N]),l.useEffect(()=>{o("is_taxable"),o("price"),o("sale_price"),o("payment_provider"),o("trial_requires_payment_method")},[o]),l.useEffect(()=>{if(!pe){i("trial_period_days",0,{shouldDirty:!1,shouldValidate:!0}),i("trial_requires_payment_method",!1,{shouldDirty:!1,shouldValidate:!0});return}me<=0&&i("trial_requires_payment_method",!1,{shouldDirty:!1,shouldValidate:!0})},[pe,i,me]),l.useEffect(()=>{x&&i("payment_provider",x,{shouldDirty:!1,shouldValidate:!0})},[x,i]),l.useEffect(()=>{c&&v[c.code]===void 0&&i("prices",{...v,[c.code]:w||0},{shouldDirty:!1})},[w,c,v,i]);const fe=l.useCallback((r,d)=>{const p={...v,[r]:d};i("prices",p,{shouldDirty:!0,shouldValidate:!0}),r===c?.code&&i("price",d,{shouldDirty:!0,shouldValidate:!0})},[c?.code,v,i]),_e=l.useCallback((r,d)=>{const p={...C,[r]:d};i("sale_prices",p,{shouldDirty:!0,shouldValidate:!0}),r===c?.code&&i("sale_price",d,{shouldDirty:!0,shouldValidate:!0})},[c?.code,C,i]),ye=l.useCallback(()=>{if(!c)return;const r=new Set(E),d=v[c.code]??w??0,p=C[c.code]??M??null,f=u.reduce((S,_)=>{if(_.code!==c.code&&r.has(_.code))return S;const te=Ne.convertMinorUnitAmount({amount:K.majorUnitAmountToMinor(d,c.code),fromCurrencyCode:c.code,toCurrencyCode:_.code,currencies:u,applyRounding:!0});return S[_.code]=K.minorUnitAmountToMajor(te,_.code),S},{}),m=u.reduce((S,_)=>{if(_.code!==c.code&&r.has(_.code))return S;if(typeof p!="number")return(_.code===c.code||!r.has(_.code))&&(S[_.code]=null),S;const te=Ne.convertMinorUnitAmount({amount:K.majorUnitAmountToMinor(p,c.code),fromCurrencyCode:c.code,toCurrencyCode:_.code,currencies:u,applyRounding:!0});return S[_.code]=K.minorUnitAmountToMajor(te,_.code),S},{});i("prices",f,{shouldDirty:!0,shouldValidate:!0}),i("sale_prices",m,{shouldDirty:!0,shouldValidate:!0}),i("price",f[c.code]??d,{shouldDirty:!0,shouldValidate:!0}),i("sale_price",m[c.code]??null,{shouldDirty:!0,shouldValidate:!0})},[u,c,v,C,i,E,w,M]),Te=l.useCallback(({variationAttributes:r,variants:d})=>{i("variation_attributes",r,{shouldDirty:!0}),i("variants",d,{shouldDirty:!0,shouldValidate:!0})},[i]),be=async r=>{R(!0),O(!0),U(null);try{if(!x){const m="Select whether this product is physical or digital before saving.";B("product_type",{type:"manual",message:m}),a?U(m):alert(m),R(!1),O(!1);return}if(r.status==="active"&&(!D||!ee)){const m=`${x==="stripe"?"Stripe":"Freemius"} must be enabled and fully configured before this product can be published.`;B("product_type",{type:"manual",message:m}),a?U(m):alert(m),R(!1),O(!1);return}const d=j?0:Math.max(0,Number(r.trial_period_days||0)),p={...r,product_type:r.product_type,payment_provider:x,freemius_product_id:j?"":r.freemius_product_id,freemius_plan_id:j?"":r.freemius_plan_id,trial_period_days:d,trial_requires_payment_method:!j&&d>0?r.trial_requires_payment_method:!1,upc:j?r.upc:null,is_taxable:j?r.is_taxable:!1,variation_attributes:j?r.variation_attributes:[],variants:j?r.variants:[]},f=H.sanitizeProductFormValuesForStoreManagedCurrencies(p,u);if(a&&b)await b(f),ke(new Date);else if(X)await X(f);else throw new Error("Product form action is not configured.")}catch(d){if(console.error(d),d.message==="NEXT_REDIRECT")return;let p=d.message||"An error occurred while saving.";if(d.code==="23505"){const f=d.message?.toLowerCase()||"";f.includes("products_slug_key")||f.includes("slug")?(p="This slug is already in use. Please choose another one.",B("slug",{type:"manual",message:p})):(f.includes("products_sku_key")||f.includes("sku"))&&(p="This SKU is already in use.",B("sku",{type:"manual",message:p}))}a?U(p):alert(p)}finally{R(!1),O(!1)}},Re=N?"bg-muted/60 text-muted-foreground opacity-70":"",Ee=Ye(se);return e.jsxs("form",{onSubmit:W(be),className:"space-y-2.5 pb-4",children:[e.jsx("input",{type:"hidden",...o("translation_group_id")}),e.jsx("input",{type:"hidden",...o("payment_provider")}),e.jsxs("div",{className:"space-y-2.5 w-full",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-2.5 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex h-9 items-center gap-2",children:[e.jsx("span",{className:"text-sm font-bold whitespace-nowrap leading-none pt-0.5",children:"Product Type"}),g.product_type&&e.jsx(L.AlertCircle,{className:"h-4 w-4 text-destructive"})]}),e.jsx("div",{className:"flex h-9 items-center",children:e.jsxs(t.Select,{onValueChange:r=>i("product_type",r,{shouldDirty:!0,shouldValidate:!0}),value:I||void 0,children:[e.jsx(t.SelectTrigger,{className:"w-[160px] h-9 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select Type"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"physical",children:"Physical Product"}),e.jsx(t.SelectItem,{value:"digital",children:"Digital Product"})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex h-9 items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider leading-none",children:"Payment Provider"}),e.jsx(t.Badge,{variant:"outline",className:"text-xs py-1 font-bold bg-muted/30 leading-none",children:x?x==="stripe"?"Stripe":"Freemius":"—"})]}),x&&e.jsx("div",{className:"flex h-9 items-center gap-2",children:D&&ee?e.jsxs("span",{className:"flex items-center gap-1.5 text-emerald-600 text-[10px] font-bold bg-emerald-50 px-2 py-1 rounded-full border border-emerald-100 uppercase leading-none",children:[e.jsx(L.CheckCircle2,{className:"h-3 w-3"}),"Ready"]}):e.jsxs("span",{className:"flex items-center gap-1.5 text-amber-600 text-[10px] font-bold bg-amber-50 px-2 py-1 rounded-full border border-amber-100 uppercase leading-none",children:[e.jsx(L.AlertCircle,{className:"h-3 w-3"}),D?"Keys Missing":"Disabled"]})}),!ee&&x&&F[x].missing.length>0&&e.jsxs("div",{className:"hidden xl:flex h-9 items-center gap-1 text-[10px] text-muted-foreground bg-muted/50 px-2 py-1 rounded border border-dashed leading-none",children:[e.jsx(L.Info,{className:"h-3 w-3"}),"Missing: ",F[x].missing.join(", ")]})]})]}),e.jsxs($,{title:"Product Information",hideHeader:!0,children:[a&&e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground pb-2 border-b border-border/40 mb-2.5",children:[e.jsx("span",{className:"font-semibold text-[11px] uppercase tracking-wider text-muted-foreground/80",children:"Product Settings"}),e.jsx("div",{className:"flex items-center gap-1.5 min-h-[16px]",children:Ce?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-amber-500"})]}),e.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Autosaving settings..."})]}):ne?e.jsxs("span",{className:"text-red-500 font-medium",children:["Error saving settings: ",ne]}):ce?e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400 font-medium",children:["Settings autosaved at ",ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})]}):e.jsx("span",{className:"text-muted-foreground/60",children:"Settings autosave in draft mode"})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5",children:[e.jsxs("div",{className:"col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"title",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Title"}),e.jsx(t.Input,{id:"title",placeholder:"Product title",...o("title"),className:"h-8 text-sm"}),g.title&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.title.message})]}),e.jsxs("div",{className:"col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"slug",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Slug"}),e.jsx(t.Input,{id:"slug",placeholder:"product-slug",...o("slug"),className:"h-8 text-sm"}),g.slug&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.slug.message})]}),e.jsxs("div",{className:"col-span-1 space-y-1",children:[e.jsx(t.Label,{htmlFor:"sku",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"SKU"}),e.jsx(t.Input,{id:"sku",placeholder:"SKU",...o("sku"),className:"h-8 text-sm font-mono"}),g.sku&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.sku.message})]}),e.jsxs("div",{className:"col-span-1 space-y-1",children:[e.jsx(t.Label,{htmlFor:"upc_ean",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"UPC / EAN"}),e.jsx(t.Input,{id:"upc_ean",placeholder:"000000000",...o("upc"),className:"h-8 text-sm font-mono",readOnly:N})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5 mt-2",children:[e.jsxs("div",{className:"lg:col-span-2 col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"meta_title",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Meta Title"}),e.jsx(t.Input,{id:"meta_title",...o("meta_title"),placeholder:"SEO page title (50-60 chars)",className:"h-8 text-sm"})]}),e.jsxs("div",{className:`lg:col-span-${a?"3":"4"} col-span-2 space-y-1`,children:[e.jsx(t.Label,{htmlFor:"meta_description",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Meta Description"}),e.jsx(t.Input,{id:"meta_description",...o("meta_description"),placeholder:"SEO description (150-160 chars)",className:"h-8 text-sm"})]}),a&&e.jsxs("div",{className:"lg:col-span-1 col-span-2 space-y-1",children:[e.jsx(t.Label,{htmlFor:"status",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Status"}),e.jsxs(t.Select,{onValueChange:r=>i("status",r,{shouldDirty:!0}),value:n("status"),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Status"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"draft",children:"Draft"}),e.jsx(t.SelectItem,{value:"active",children:"Active"}),e.jsx(t.SelectItem,{value:"archived",children:"Archived"})]})]})]})]})]}),e.jsx($,{title:"Product Categories",description:"Assign this product to one or more categories.",children:e.jsx($e.ProductCategorySelector,{categories:we,selectedIds:n("category_ids")||[],onChange:r=>i("category_ids",r,{shouldDirty:!0,shouldValidate:!0})})}),e.jsxs("section",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-3",children:[j&&e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap border-b border-muted/50 pb-2",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h2",{className:"text-sm font-bold tracking-tight",children:"Pricing & Inventory"}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-none",children:"Manage simple or variant pricing."})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/40 rounded-md px-2.5 py-1.5",children:[e.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Stock"}),e.jsx(t.Input,{id:"stock",type:"number",min:"0",...o("stock",{valueAsNumber:!0}),placeholder:"0",readOnly:N,className:`${Re} h-8 w-20 text-sm text-center font-mono bg-background`})]}),N?e.jsx(t.Badge,{variant:"secondary",className:"text-[11px] py-0 px-2 h-5",children:"Variant pricing"}):null]})]}),j?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"w-full",children:[e.jsx(je.CurrencyPriceFields,{idPrefix:"product",currencies:u,prices:z.prices,salePrices:z.salePrices,managedCurrencyCodes:E,onPriceChange:fe,onSalePriceChange:_e,onAutoFill:ye,readOnly:N,helperText:N?"Parent prices stay as a fallback, but active variants define the live shopper price.":void 0,trailing:e.jsx(ve.SaleScheduleFields,{idPrefix:"product",startAt:n("sale_start_at"),endAt:n("sale_end_at"),onChange:(r,d)=>i(r,d,{shouldDirty:!0,shouldValidate:!0}),error:g.sale_end_at?.message,bare:!0})}),g.price&&e.jsx("p",{className:"text-destructive text-sm mt-1",children:g.price.message}),g.sale_price&&e.jsx("p",{className:"text-destructive text-sm mt-1",children:g.sale_price.message}),g.stock&&e.jsx("p",{className:"text-destructive text-[10px] font-medium leading-none mt-1",children:g.stock.message})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded border border-dashed p-2.5 bg-muted/5",children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:N?"Variations Active":"Variations"}),e.jsx(t.Button,{type:"button",variant:Y?"outline":"default",onClick:()=>Q(r=>!r),size:"sm",className:"h-7 text-xs px-3",children:Y?"Hide":"Manage"})]}),Y&&e.jsx("div",{className:"border-t pt-3",children:e.jsx(Ke.VariationsEditor,{globalAttributes:P,currentLanguageCode:Ie,baseSku:n("sku")||"",basePrice:w||0,basePrices:v,baseSalePrice:typeof M=="number"?M:null,baseSalePrices:C,currencies:u,availableVariantImages:Ee,initialVariationAttributes:s?.variation_attributes,initialVariants:Ae,onChange:Te})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-4 w-full",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(t.Label,{htmlFor:"freemius_product_id",className:"text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",children:"Freemius Product ID"}),e.jsx(t.Input,{id:"freemius_product_id",...o("freemius_product_id"),className:"h-9"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(t.Label,{htmlFor:"freemius_plan_id",className:"text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",children:"Freemius Plan ID"}),e.jsx(t.Input,{id:"freemius_plan_id",...o("freemius_plan_id"),className:"h-9"})]}),Fe?e.jsx(Le.SyncFreemiusPricingButton,{productId:n("freemius_product_id")}):null]}),e.jsxs("div",{className:"bg-muted/10 border rounded-md overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-6 bg-muted/20 border-b p-2.5 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Free Trial"}),e.jsxs(t.Badge,{variant:"outline",className:"font-mono text-xs shadow-sm bg-background",children:[String(n("trial_period_days")||0)," Days"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Card Required"}),e.jsx(t.Badge,{variant:xe?"default":"secondary",className:"text-xs shadow-sm",children:xe?"Yes":"No"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto",children:"Managed in Freemius dashboard"}),e.jsx("input",{type:"hidden",...o("trial_period_days",{valueAsNumber:!0})})]}),e.jsxs("div",{className:"w-full p-4 pt-3 space-y-2",children:[e.jsx(je.CurrencyPriceFields,{idPrefix:"product",currencies:u,prices:z.prices,salePrices:z.salePrices,managedCurrencyCodes:E,onPriceChange:fe,onSalePriceChange:_e,onAutoFill:ye,readOnly:!0,trailing:e.jsx(ve.SaleScheduleFields,{idPrefix:"product",startAt:n("sale_start_at"),endAt:n("sale_end_at"),onChange:(r,d)=>i(r,d,{shouldDirty:!0,shouldValidate:!0}),error:g.sale_end_at?.message,bare:!0})}),e.jsx("p",{className:"text-[10px] leading-snug text-muted-foreground",children:"Scheduling a sale on a Freemius product generates a time-bounded Freemius coupon so the discount is enforced at Freemius checkout."})]})]})]}),A&&e.jsx("div",{className:"pt-2 border-t",children:A})]})]}),e.jsx($,{title:"Product Description",hideHeader:!0,children:e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{htmlFor:"short_description",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Short Description"}),e.jsx(t.Input,{id:"short_description",...o("short_description"),placeholder:"Brief summary for product cards...",className:"h-8 text-sm"})]})})}),e.jsxs($,{title:"Media Gallery",description:"Drag to reorder. First image is the hero.",children:[e.jsx(ze.ProductMediaManager,{initialMedia:se,onUpdate:qe,mediaPickerNode:y}),e.jsx("input",{type:"hidden",...o("product_media")})]}),!a&&e.jsxs("div",{className:"rounded-lg border bg-card p-3 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Status"}),e.jsxs(t.Select,{onValueChange:r=>i("status",r),value:n("status"),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-[110px] text-sm",children:e.jsx(t.SelectValue,{placeholder:"Status"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"draft",children:"Draft"}),e.jsx(t.SelectItem,{value:"active",children:"Active"}),e.jsx(t.SelectItem,{value:"archived",children:"Archived"})]})]})]}),e.jsx(t.Button,{disabled:T,type:"submit",size:"sm",className:"h-8 text-sm px-5",children:T?"Saving...":"Save Changes"})]})]})]})}exports.ProductForm=We;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),Be=require("@hookform/resolvers/zod"),L=require("lucide-react"),r=require("@nextblock-cms/ui"),Ee=require("../../../../product-schema.cjs.js"),Oe=require("react-hook-form"),ze=require("./ProductMediaManager.cjs.js"),Le=require("./SyncFreemiusPricingButton.cjs.js"),Ke=require("./VariationsEditor.cjs.js"),je=require("./CurrencyPriceFields.cjs.js"),ve=require("./SaleScheduleFields.cjs.js"),$e=require("./ProductCategorySelector.cjs.js"),H=require("../product-price-sync.cjs.js"),He=require("../../../../types.cjs.js"),Ne=require("../../../../currency.cjs.js"),K=require("@nextblock-cms/utils");function $({title:s,description:a,action:y,children:h,hideHeader:P}){return e.jsxs("section",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-3",children:[!P&&e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap border-b border-muted/50 pb-2 mb-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h2",{className:"text-sm font-bold tracking-tight",children:s}),a?e.jsx("p",{className:"text-[11px] text-muted-foreground leading-none",children:a}):null]}),y]}),e.jsx("div",{className:P?"":"pt-1",children:h})]})}function Je(s,a,y){const h=a?Number.parseInt(a,10):void 0;return s?.language_id||(Number.isFinite(h)?h:void 0)||y.find(P=>P.is_default)?.id||y[0]?.id||1}function Se(s,a,y,h,P){const k=(h.find(b=>b.is_default)??h[0])?.code||"USD",V=s?.prices&&Object.keys(s.prices).length>0?s.prices:{[k]:typeof s?.price=="number"?s.price/100:0},A=s?.sale_prices&&Object.keys(s.sale_prices).length>0?s.sale_prices:typeof s?.sale_price=="number"?{[k]:s.sale_price/100}:{},q=s?.product_type||"",F=s?.payment_provider||(s?.product_type?He.derivePaymentProviderFromProductType(s.product_type):"stripe");return{...H.sanitizeProductFormValuesForStoreManagedCurrencies({product_type:q||"physical",payment_provider:F,title:s?.title||"",slug:s?.slug||"",sku:s?.sku||"",upc:s?.upc||"",is_taxable:s?.is_taxable??!0,price:typeof s?.price=="number"?s.price/100:0,prices:V,sale_price:typeof s?.sale_price=="number"?s.sale_price/100:null,sale_prices:A,stock:s?.stock||0,meta_title:s?.meta_title||"",meta_description:s?.meta_description||"",custom_canonical:s?.custom_canonical||"",short_description:s?.short_description||"",description_json:s?.description_json||{type:"doc",content:[{type:"paragraph"}]},freemius_product_id:s?.freemius_product_id||"",freemius_plan_id:s?.freemius_plan_id||"",trial_period_days:s?.trial_period_days??0,trial_requires_payment_method:s?.trial_requires_payment_method??!1,status:s?.status||"draft",language_id:Je(s,a,y),translation_group_id:s?.translation_group_id||P||void 0,product_media:s?.product_media?.map(b=>({media_id:b.media_id}))||[],category_ids:s?.category_ids||[],variation_attributes:s?.variation_attributes||[],variants:s?.variants?.map(b=>({...b,prices:b.prices||{},sale_prices:b.sale_prices||{}}))||[]},h),product_type:q,payment_provider:F}}function Pe(s){return s?s.map(a=>({id:a.id||a.media_id,media_id:a.media_id,file_path:a.media?.file_path||a.media?.object_key||"",alt:a.media?.alt_text||"",sort_order:a.sort_order??0})).sort((a,y)=>a.sort_order-y.sort_order):[]}function Xe(s){return s.map(a=>({media_id:a.media_id}))}function Ye(s){return s.map(a=>({media_id:a.media_id,file_path:a.file_path,alt:a.alt}))}const Qe=s=>s.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,"");function We({initialData:s,isEdit:a=!1,mediaPickerNode:y,availableLanguagesProp:h,globalAttributesProp:P,currenciesProp:J,translationGroupId:k,targetLanguageId:V,freemiusDashboardNode:A,enabledProviders:q,configStatus:F,createAction:X,updateAction:b,availableCategoriesProp:we=[]}){const[T,R]=l.useState(!1),[Y,Q]=l.useState(()=>!!s?.variants?.length),u=l.useMemo(()=>J.filter(t=>t.is_active!==!1).sort((t,d)=>t.is_default!==d.is_default?t.is_default?-1:1:t.code.localeCompare(d.code)),[J]),n=l.useMemo(()=>u.find(t=>t.is_default)??u[0],[u]),U=l.useMemo(()=>H.getStoreManagedPriceCurrencyCodes(u),[u]),ae=Oe.useForm({resolver:Be.zodResolver(Ee.productSchema),defaultValues:Se(s,V,h,u,k)}),{register:o,handleSubmit:W,setValue:i,reset:ie,watch:c,setError:B,formState:{errors:g,dirtyFields:de}}=ae,le=l.useRef(!0),Z=l.useRef(null),[Ce,E]=l.useState(!1),[ce,O]=l.useState(null),[ne,ke]=l.useState(null),G=c(),oe=ae.formState.isDirty;l.useEffect(()=>{if(!a)return;if(le.current){le.current=!1,Z.current=JSON.stringify(G);return}if(!oe)return;const t=JSON.stringify(G);if(t===Z.current)return;const d=setTimeout(()=>{T||(Z.current=t,W(be)())},1e3);return()=>clearTimeout(d)},[G,a,oe,T,W]);const ue=c("title"),I=c("product_type"),x=I==="digital"?"freemius":I==="physical"?"stripe":void 0,j=I==="physical",pe=I==="digital",D=x?q[x]:!1,ee=x?F[x].hasKeys:!1,Fe=!!c("freemius_product_id"),me=Number(c("trial_period_days")||0),xe=!!c("trial_requires_payment_method"),Me=c("variants")||[],w=c("price"),M=c("sale_price"),v=c("prices")||{},C=c("sale_prices")||{},N=(Me?.length||0)>0,Ve=c("language_id"),Ie=h.find(t=>t.id===Ve)?.code||h.find(t=>t.is_default)?.code||h[0]?.code,z=l.useMemo(()=>H.resolveEditorCurrencyPriceMaps({currencies:u,prices:v,salePrices:C,fallbackPrice:w,fallbackSalePrice:M}),[w,M,u,v,C]),Ae=l.useMemo(()=>s?.variants?.map(t=>({...t,prices:t.prices||{},sale_prices:t.sale_prices||{}})),[s?.variants]);l.useEffect(()=>{if(de.title&&!a){const t=Qe(ue);i("slug",t,{shouldValidate:!0})}},[ue,de.title,i,a]);const[se,he]=l.useState(()=>Pe(s?.product_media)),[te,ge]=l.useState(new Set);l.useEffect(()=>{ie(Se(s,V,h,u,k)),he(Pe(s?.product_media)),ge(new Set),Q(!!s?.variants?.length)},[h,u,s,ie,V,k]);const qe=t=>{const d=new Set(t.map(m=>m.id)),p=se.filter(m=>!d.has(m.id)),f=new Set(te);p.forEach(m=>{m.media_id&&f.add(m.media_id)}),ge(f),he(t),i("product_media",Xe(t),{shouldDirty:!0}),i("explicitly_removed_media_ids",Array.from(f),{shouldDirty:!0})};l.useEffect(()=>{i("explicitly_removed_media_ids",Array.from(te))},[te,i]),l.useEffect(()=>{N&&Q(!0)},[N]),l.useEffect(()=>{o("is_taxable"),o("price"),o("sale_price"),o("payment_provider"),o("trial_requires_payment_method")},[o]),l.useEffect(()=>{if(!pe){i("trial_period_days",0,{shouldDirty:!1,shouldValidate:!0}),i("trial_requires_payment_method",!1,{shouldDirty:!1,shouldValidate:!0});return}me<=0&&i("trial_requires_payment_method",!1,{shouldDirty:!1,shouldValidate:!0})},[pe,i,me]),l.useEffect(()=>{x&&i("payment_provider",x,{shouldDirty:!1,shouldValidate:!0})},[x,i]),l.useEffect(()=>{n&&v[n.code]===void 0&&i("prices",{...v,[n.code]:w||0},{shouldDirty:!1})},[w,n,v,i]);const fe=l.useCallback((t,d)=>{const p={...v,[t]:d};i("prices",p,{shouldDirty:!0,shouldValidate:!0}),t===n?.code&&i("price",d,{shouldDirty:!0,shouldValidate:!0})},[n?.code,v,i]),_e=l.useCallback((t,d)=>{const p={...C,[t]:d};i("sale_prices",p,{shouldDirty:!0,shouldValidate:!0}),t===n?.code&&i("sale_price",d,{shouldDirty:!0,shouldValidate:!0})},[n?.code,C,i]),ye=l.useCallback(()=>{if(!n)return;const t=new Set(U),d=v[n.code]??w??0,p=C[n.code]??M??null,f=u.reduce((S,_)=>{if(_.code!==n.code&&t.has(_.code))return S;const re=Ne.convertMinorUnitAmount({amount:K.majorUnitAmountToMinor(d,n.code),fromCurrencyCode:n.code,toCurrencyCode:_.code,currencies:u,applyRounding:!0});return S[_.code]=K.minorUnitAmountToMajor(re,_.code),S},{}),m=u.reduce((S,_)=>{if(_.code!==n.code&&t.has(_.code))return S;if(typeof p!="number")return(_.code===n.code||!t.has(_.code))&&(S[_.code]=null),S;const re=Ne.convertMinorUnitAmount({amount:K.majorUnitAmountToMinor(p,n.code),fromCurrencyCode:n.code,toCurrencyCode:_.code,currencies:u,applyRounding:!0});return S[_.code]=K.minorUnitAmountToMajor(re,_.code),S},{});i("prices",f,{shouldDirty:!0,shouldValidate:!0}),i("sale_prices",m,{shouldDirty:!0,shouldValidate:!0}),i("price",f[n.code]??d,{shouldDirty:!0,shouldValidate:!0}),i("sale_price",m[n.code]??null,{shouldDirty:!0,shouldValidate:!0})},[u,n,v,C,i,U,w,M]),Te=l.useCallback(({variationAttributes:t,variants:d})=>{i("variation_attributes",t,{shouldDirty:!0}),i("variants",d,{shouldDirty:!0,shouldValidate:!0})},[i]),be=async t=>{R(!0),E(!0),O(null);try{if(!x){const m="Select whether this product is physical or digital before saving.";B("product_type",{type:"manual",message:m}),a?O(m):alert(m),R(!1),E(!1);return}if(t.status==="active"&&(!D||!ee)){const m=`${x==="stripe"?"Stripe":"Freemius"} must be enabled and fully configured before this product can be published.`;B("product_type",{type:"manual",message:m}),a?O(m):alert(m),R(!1),E(!1);return}const d=j?0:Math.max(0,Number(t.trial_period_days||0)),p={...t,product_type:t.product_type,payment_provider:x,freemius_product_id:j?"":t.freemius_product_id,freemius_plan_id:j?"":t.freemius_plan_id,trial_period_days:d,trial_requires_payment_method:!j&&d>0?t.trial_requires_payment_method:!1,upc:j?t.upc:null,is_taxable:j?t.is_taxable:!1,variation_attributes:j?t.variation_attributes:[],variants:j?t.variants:[]},f=H.sanitizeProductFormValuesForStoreManagedCurrencies(p,u);if(a&&b)await b(f),ke(new Date);else if(X)await X(f);else throw new Error("Product form action is not configured.")}catch(d){if(console.error(d),d.message==="NEXT_REDIRECT")return;let p=d.message||"An error occurred while saving.";if(d.code==="23505"){const f=d.message?.toLowerCase()||"";f.includes("products_slug_key")||f.includes("slug")?(p="This slug is already in use. Please choose another one.",B("slug",{type:"manual",message:p})):(f.includes("products_sku_key")||f.includes("sku"))&&(p="This SKU is already in use.",B("sku",{type:"manual",message:p}))}a?O(p):alert(p)}finally{R(!1),E(!1)}},Re=N?"bg-muted/60 text-muted-foreground opacity-70":"",Ue=Ye(se);return e.jsxs("form",{onSubmit:W(be),className:"space-y-2.5 pb-4",children:[e.jsx("input",{type:"hidden",...o("translation_group_id")}),e.jsx("input",{type:"hidden",...o("payment_provider")}),e.jsxs("div",{className:"space-y-2.5 w-full",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-2.5 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex h-9 items-center gap-2",children:[e.jsx("span",{className:"text-sm font-bold whitespace-nowrap leading-none pt-0.5",children:"Product Type"}),g.product_type&&e.jsx(L.AlertCircle,{className:"h-4 w-4 text-destructive"})]}),e.jsx("div",{className:"flex h-9 items-center",children:e.jsxs(r.Select,{onValueChange:t=>i("product_type",t,{shouldDirty:!0,shouldValidate:!0}),value:I||void 0,children:[e.jsx(r.SelectTrigger,{className:"w-[160px] h-9 text-xs",children:e.jsx(r.SelectValue,{placeholder:"Select Type"})}),e.jsxs(r.SelectContent,{children:[e.jsx(r.SelectItem,{value:"physical",children:"Physical Product"}),e.jsx(r.SelectItem,{value:"digital",children:"Digital Product"})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex h-9 items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider leading-none",children:"Payment Provider"}),e.jsx(r.Badge,{variant:"outline",className:"text-xs py-1 font-bold bg-muted/30 leading-none",children:x?x==="stripe"?"Stripe":"Freemius":"—"})]}),x&&e.jsx("div",{className:"flex h-9 items-center gap-2",children:D&&ee?e.jsxs("span",{className:"flex items-center gap-1.5 text-emerald-600 text-[10px] font-bold bg-emerald-50 px-2 py-1 rounded-full border border-emerald-100 uppercase leading-none",children:[e.jsx(L.CheckCircle2,{className:"h-3 w-3"}),"Ready"]}):e.jsxs("span",{className:"flex items-center gap-1.5 text-amber-600 text-[10px] font-bold bg-amber-50 px-2 py-1 rounded-full border border-amber-100 uppercase leading-none",children:[e.jsx(L.AlertCircle,{className:"h-3 w-3"}),D?"Keys Missing":"Disabled"]})}),!ee&&x&&F[x].missing.length>0&&e.jsxs("div",{className:"hidden xl:flex h-9 items-center gap-1 text-[10px] text-muted-foreground bg-muted/50 px-2 py-1 rounded border border-dashed leading-none",children:[e.jsx(L.Info,{className:"h-3 w-3"}),"Missing: ",F[x].missing.join(", ")]})]})]}),e.jsxs($,{title:"Product Information",hideHeader:!0,children:[a&&e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground pb-2 border-b border-border/40 mb-2.5",children:[e.jsx("span",{className:"font-semibold text-[11px] uppercase tracking-wider text-muted-foreground/80",children:"Product Settings"}),e.jsx("div",{className:"flex items-center gap-1.5 min-h-[16px]",children:Ce?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-amber-500"})]}),e.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Autosaving settings..."})]}):ce?e.jsxs("span",{className:"text-red-500 font-medium",children:["Error saving settings: ",ce]}):ne?e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400 font-medium",children:["Settings autosaved at ",ne.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})]}):e.jsx("span",{className:"text-muted-foreground/60",children:"Settings autosave in draft mode"})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5",children:[e.jsxs("div",{className:"col-span-2 space-y-1",children:[e.jsx(r.Label,{htmlFor:"title",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Title"}),e.jsx(r.Input,{id:"title",placeholder:"Product title",...o("title"),className:"h-8 text-sm"}),g.title&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.title.message})]}),e.jsxs("div",{className:"col-span-2 space-y-1",children:[e.jsx(r.Label,{htmlFor:"slug",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Slug"}),e.jsx(r.Input,{id:"slug",placeholder:"product-slug",...o("slug"),className:"h-8 text-sm"}),g.slug&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.slug.message})]}),e.jsxs("div",{className:"col-span-1 space-y-1",children:[e.jsx(r.Label,{htmlFor:"sku",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"SKU"}),e.jsx(r.Input,{id:"sku",placeholder:"SKU",...o("sku"),className:"h-8 text-sm font-mono"}),g.sku&&e.jsx("p",{className:"text-destructive text-[11px] leading-none",children:g.sku.message})]}),e.jsxs("div",{className:"col-span-1 space-y-1",children:[e.jsx(r.Label,{htmlFor:"upc_ean",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"UPC / EAN"}),e.jsx(r.Input,{id:"upc_ean",placeholder:"000000000",...o("upc"),className:"h-8 text-sm font-mono",readOnly:N})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-12 gap-2.5 mt-2",children:[e.jsxs("div",{className:`${a?"lg:col-span-3":"lg:col-span-4"} col-span-2 space-y-1`,children:[e.jsx(r.Label,{htmlFor:"meta_title",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Meta Title"}),e.jsx(r.Input,{id:"meta_title",...o("meta_title"),placeholder:"SEO page title (50-60 chars)",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"lg:col-span-4 col-span-2 space-y-1",children:[e.jsx(r.Label,{htmlFor:"meta_description",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Meta Description"}),e.jsx(r.Input,{id:"meta_description",...o("meta_description"),placeholder:"SEO description (150-160 chars)",className:"h-8 text-sm"})]}),e.jsxs("div",{className:`${a?"lg:col-span-3":"lg:col-span-4"} col-span-2 space-y-1`,children:[e.jsx(r.Label,{htmlFor:"custom_canonical",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Canonical URL (optional)"}),e.jsx(r.Input,{id:"custom_canonical",...o("custom_canonical"),placeholder:"Blank = self-referencing. Absolute https://… URL or /relative path to override.",className:"h-8 text-sm"})]}),a&&e.jsxs("div",{className:"lg:col-span-2 col-span-2 space-y-1",children:[e.jsx(r.Label,{htmlFor:"status",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Status"}),e.jsxs(r.Select,{onValueChange:t=>i("status",t,{shouldDirty:!0}),value:c("status"),children:[e.jsx(r.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(r.SelectValue,{placeholder:"Status"})}),e.jsxs(r.SelectContent,{children:[e.jsx(r.SelectItem,{value:"draft",children:"Draft"}),e.jsx(r.SelectItem,{value:"active",children:"Active"}),e.jsx(r.SelectItem,{value:"archived",children:"Archived"})]})]})]})]})]}),e.jsx($,{title:"Product Categories",description:"Assign this product to one or more categories.",children:e.jsx($e.ProductCategorySelector,{categories:we,selectedIds:c("category_ids")||[],onChange:t=>i("category_ids",t,{shouldDirty:!0,shouldValidate:!0})})}),e.jsxs("section",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-3",children:[j&&e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap border-b border-muted/50 pb-2",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h2",{className:"text-sm font-bold tracking-tight",children:"Pricing & Inventory"}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-none",children:"Manage simple or variant pricing."})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/40 rounded-md px-2.5 py-1.5",children:[e.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Stock"}),e.jsx(r.Input,{id:"stock",type:"number",min:"0",...o("stock",{valueAsNumber:!0}),placeholder:"0",readOnly:N,className:`${Re} h-8 w-20 text-sm text-center font-mono bg-background`})]}),N?e.jsx(r.Badge,{variant:"secondary",className:"text-[11px] py-0 px-2 h-5",children:"Variant pricing"}):null]})]}),j?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"w-full",children:[e.jsx(je.CurrencyPriceFields,{idPrefix:"product",currencies:u,prices:z.prices,salePrices:z.salePrices,managedCurrencyCodes:U,onPriceChange:fe,onSalePriceChange:_e,onAutoFill:ye,readOnly:N,helperText:N?"Parent prices stay as a fallback, but active variants define the live shopper price.":void 0,trailing:e.jsx(ve.SaleScheduleFields,{idPrefix:"product",startAt:c("sale_start_at"),endAt:c("sale_end_at"),onChange:(t,d)=>i(t,d,{shouldDirty:!0,shouldValidate:!0}),error:g.sale_end_at?.message,bare:!0})}),g.price&&e.jsx("p",{className:"text-destructive text-sm mt-1",children:g.price.message}),g.sale_price&&e.jsx("p",{className:"text-destructive text-sm mt-1",children:g.sale_price.message}),g.stock&&e.jsx("p",{className:"text-destructive text-[10px] font-medium leading-none mt-1",children:g.stock.message})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded border border-dashed p-2.5 bg-muted/5",children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:N?"Variations Active":"Variations"}),e.jsx(r.Button,{type:"button",variant:Y?"outline":"default",onClick:()=>Q(t=>!t),size:"sm",className:"h-7 text-xs px-3",children:Y?"Hide":"Manage"})]}),Y&&e.jsx("div",{className:"border-t pt-3",children:e.jsx(Ke.VariationsEditor,{globalAttributes:P,currentLanguageCode:Ie,baseSku:c("sku")||"",basePrice:w||0,basePrices:v,baseSalePrice:typeof M=="number"?M:null,baseSalePrices:C,currencies:u,availableVariantImages:Ue,initialVariationAttributes:s?.variation_attributes,initialVariants:Ae,onChange:Te})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-4 w-full",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(r.Label,{htmlFor:"freemius_product_id",className:"text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",children:"Freemius Product ID"}),e.jsx(r.Input,{id:"freemius_product_id",...o("freemius_product_id"),className:"h-9"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(r.Label,{htmlFor:"freemius_plan_id",className:"text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",children:"Freemius Plan ID"}),e.jsx(r.Input,{id:"freemius_plan_id",...o("freemius_plan_id"),className:"h-9"})]}),Fe?e.jsx(Le.SyncFreemiusPricingButton,{productId:c("freemius_product_id")}):null]}),e.jsxs("div",{className:"bg-muted/10 border rounded-md overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-6 bg-muted/20 border-b p-2.5 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Free Trial"}),e.jsxs(r.Badge,{variant:"outline",className:"font-mono text-xs shadow-sm bg-background",children:[String(c("trial_period_days")||0)," Days"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:"Card Required"}),e.jsx(r.Badge,{variant:xe?"default":"secondary",className:"text-xs shadow-sm",children:xe?"Yes":"No"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto",children:"Managed in Freemius dashboard"}),e.jsx("input",{type:"hidden",...o("trial_period_days",{valueAsNumber:!0})})]}),e.jsxs("div",{className:"w-full p-4 pt-3 space-y-2",children:[e.jsx(je.CurrencyPriceFields,{idPrefix:"product",currencies:u,prices:z.prices,salePrices:z.salePrices,managedCurrencyCodes:U,onPriceChange:fe,onSalePriceChange:_e,onAutoFill:ye,readOnly:!0,trailing:e.jsx(ve.SaleScheduleFields,{idPrefix:"product",startAt:c("sale_start_at"),endAt:c("sale_end_at"),onChange:(t,d)=>i(t,d,{shouldDirty:!0,shouldValidate:!0}),error:g.sale_end_at?.message,bare:!0})}),e.jsx("p",{className:"text-[10px] leading-snug text-muted-foreground",children:"Scheduling a sale on a Freemius product generates a time-bounded Freemius coupon so the discount is enforced at Freemius checkout."})]})]})]}),A&&e.jsx("div",{className:"pt-2 border-t",children:A})]})]}),e.jsx($,{title:"Product Description",hideHeader:!0,children:e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(r.Label,{htmlFor:"short_description",className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Short Description"}),e.jsx(r.Input,{id:"short_description",...o("short_description"),placeholder:"Brief summary for product cards...",className:"h-8 text-sm"})]})})}),e.jsxs($,{title:"Media Gallery",description:"Drag to reorder. First image is the hero.",children:[e.jsx(ze.ProductMediaManager,{initialMedia:se,onUpdate:qe,mediaPickerNode:y}),e.jsx("input",{type:"hidden",...o("product_media")})]}),!a&&e.jsxs("div",{className:"rounded-lg border bg-card p-3 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",children:"Status"}),e.jsxs(r.Select,{onValueChange:t=>i("status",t),value:c("status"),children:[e.jsx(r.SelectTrigger,{className:"h-8 w-[110px] text-sm",children:e.jsx(r.SelectValue,{placeholder:"Status"})}),e.jsxs(r.SelectContent,{children:[e.jsx(r.SelectItem,{value:"draft",children:"Draft"}),e.jsx(r.SelectItem,{value:"active",children:"Active"}),e.jsx(r.SelectItem,{value:"archived",children:"Archived"})]})]})]}),e.jsx(r.Button,{disabled:T,type:"submit",size:"sm",className:"h-8 text-sm px-5",children:T?"Saving...":"Save Changes"})]})]})]})}exports.ProductForm=We;
|