1import{j as r}from"./vendor-query-D1Mshrk-.js";import{u as l,h as g,r as f,L as P}from"./vendor-react-BfQMi0FG.js";import{B as i,q as h,t as e}from"./index-D3kn74s7.js";import{P as x}from"./page-header-C7x1KRLA.js";import{e as y}from"./use-products-BA8Wx5nU.js";import{c as j,P as C,p as I}from"./product-form-C_LtAgRr.js";import"./vendor-ui-nQy3bJlE.js";import"./switch-vuioQ0-X.js";import"./checkbox-BJM-QpNY.js";import"./check-CXo9hMCb.js";import"./select-Da-jnnzS.js";import"./translatable-input-CuDUNKJj.js";import"./image-upload-ByAsbgsv.js";import"./image-compression-CymqulNC.js";import"./gallery-picker-CuV5FXIb.js";import"./dialog-Dt-Wm_UE.js";import"./tabs-nPG276U5.js";import"./use-gallery-DobYRn7E.js";import"./film-C-bAX8Fk.js";import"./card-C6DfUXn8.js";import"./use-categories-DeYi9QQw.js";import"./use-printers-DJv_hCJ4.js";import"./use-courses-8MLb0R9w.js";import"./flame-D5xSKf1I.js";function U(){const c=l(),[m]=g(),a=y(),s=m.get("categoryId")??"",[t,d]=f.useState(()=>{const o=j();return s&&(o.categoryId=s),o}),n=o=>{if(o.preventDefault(),!t.name.en.trim()){e.error("English name is required");return}if(!t.categoryId){e.error("Category is required");return}if(!t.mainPrice){e.error("Main price is required");return}a.mutate(I(t),{onSuccess:()=>{e.success("Product created"),c(t.categoryId?`/dashboard/products?categoryId=${t.categoryId}`:"/dashboard/products")},onError:u=>{const p=u?.response?.data?.error?.message??"Failed to create product";e.error(p)}})};return r.jsxs("div",{className:"space-y-6",children:[r.jsx(x,{title:"New Product",action:r.jsx(i,{variant:"outline",asChild:!0,children:r.jsxs(P,{to:"/dashboard/products",children:[r.jsx(h,{className:"mr-2 h-4 w-4"}),"Back"]})})}),r.jsxs("form",{onSubmit:n,className:"space-y-6",children:[r.jsx(C,{form:t,onChange:d}),r.jsx("div",{className:"flex justify-end",children:r.jsx(i,{type:"submit",disabled:a.isPending,children:a.isPending?"Creating...":"Create Product"})})]})]})}export{U as ProductCreatePage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.