2 lines
2.6 KiB
JavaScript
2 lines
2.6 KiB
JavaScript
import{r as d,u as x,j as e,H as f}from"./app-C6SiEMGn.js";import{B as h}from"./createLucideIcon-CPpF-2ww.js";import{I as g}from"./input-DYhKGVpQ.js";import{L as i}from"./label-BB9HLxkE.js";import{S as j,a as b,b as S,c as v,e as y,d as s}from"./select-BuGuwdXt.js";import{A as N,d as F}from"./app-layout-B4kweoSW.js";import{F as A,t as I,r as P,p as T,a as _}from"./index-BQ4sA8lt.js";import"./app-6D7Y1jSv.js";import"./index-B7t1D_co.js";import"./index-FUlYkgbj.js";import"./sheet-BvPq5L9Z.js";import"./index-ChxR6kRZ.js";import"./check-DEcJAs2N.js";import"./index-CxjaVpyF.js";import"./app-logo-icon-B_KiS1IV.js";import"./package-DTdg9l_D.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 <span class="filepond--label-action">Browse</span>'}),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};
|