import{r as d,u as x,j as e,H as f}from"./app-Ajql0Lt4.js";import{B as h}from"./createLucideIcon-B_iAwCmA.js";import{I as g}from"./input-B0_NTiRR.js";import{L as i}from"./label-D8DO87nw.js";import{S as j,a as b,b as S,c as v,e as y,d as s}from"./select-TKsTtRMn.js";import{A as N,d as F}from"./app-layout-BTSySP9M.js";import{F as A,t as I,r as P,p as T,a as _}from"./index-DudYy9cl.js";import"./app-B4XVefei.js";import"./index-em-EQZzp.js";import"./index-CS1SDu2T.js";import"./sheet-iBbRuLZ4.js";import"./index-BXKH1Xq5.js";import"./check-D1N7nvmG.js";import"./index-UHLdfeKp.js";import"./app-logo-icon-B9D8MR-Y.js";import"./package-CgKP903x.js";P(T,_);function z(){const[l,n]=d.useState(null),{data:o,setData:a,post:m,processing:c,errors:r,wasSuccessful:p}=x({title:"",type:"traditional",image_url:null});d.useEffect(()=>{l&&a("image_url",l.file)},[l,a]);const u=t=>{t.preventDefault(),m(F.product.add().url,{forceFormData:!0}),p&&I.success("Product added successfully")};return e.jsxs(N,{children:[e.jsx(f,{title:"Add Product Image"}),e.jsxs("section",{className:"flex flex-col gap-8 px-8 py-8",children:[e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Add Product Image"}),e.jsxs("form",{onSubmit:u,method:"POST",encType:"multipart/formdata",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e.jsx(i,{htmlFor:"title",children:"Title"}),e.jsx(g,{type:"text",id:"title",value:o.title,onChange:t=>a("title",t.target.value),className:"rounded border p-2"}),r.title&&e.jsx("span",{className:"text-red-600",children:r.title})]}),e.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e.jsx(i,{htmlFor:"title",children:"Type"}),e.jsxs(j,{value:o.type,onValueChange:t=>{console.log(t),a("type",t)},children:[e.jsx(b,{children:e.jsx(S,{placeholder:"Select a type"})}),e.jsx(v,{children:e.jsxs(y,{children:[e.jsx(s,{value:"traditional",children:"Traditional"}),e.jsx(s,{value:"modern",children:"Modern"}),e.jsx(s,{value:"bespoke",children:"Bespoke"}),e.jsx(s,{value:"abstract",children:"Abstract"}),e.jsx(s,{value:"art",children:"Art in carpet"})]})})]})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx(i,{children:"Image"}),e.jsx(A,{files:l?[l]:[],onupdatefiles:t=>{n(t[0]||null)},allowMultiple:!1,maxFiles:1,name:"image_url",instantUpload:!1,storeAsFile:!0,labelIdle:'Drag & Drop your image or Browse'}),r.image_url&&e.jsx("span",{className:"text-red-600",children:r.image_url})]}),e.jsx(h,{type:"submit",disabled:c,className:"cursor-pointer",children:c?"Uploading...":"Submit"})]})]})]})}export{z as default};