import{W as u,a as j,j as e}from"./BulkImageUpload-DGPbX05r.js";import{I as i}from"./Input-CR3dcIBA.js";import{E as N}from"./EditModel--5YmZ-em.js";import"./bootstrap.esm-e_F80uXB.js";const b=r=>{const{data:l,setData:c,post:d,processing:m,errors:a,reset:n,clearErrors:o}=u({name:r.edit.name||"",image:"",price:r.edit.price||"",_method:"PUT"});j.useEffect(()=>{c({price:r.edit.price,name:r.edit.name,_method:"PUT"})},[r]);const t=s=>{c(s.target.name,s.target.type==="checkbox"?s.target.checked:s.target.value),o(s.target.name)},h=s=>{c(s.target.name,s.target.files[0])},x=s=>{s.preventDefault(),d(route("product.update",r.edit.id),{onSuccess:()=>{r.mymodel.hide(),n(),Swal.fire("Saved Successfully!","","success")},preserveState:p=>Object.keys(p.props.errors).length})};return e.jsx(N,{title:"Edit Product",id:"editlocation",children:e.jsxs("form",{className:"p-4",onSubmit:x,children:[e.jsxs("div",{className:"form-group  row",children:[e.jsxs("div",{className:"col-sm-4",children:[e.jsx("label",{htmlFor:"",children:"Product Name"}),e.jsx("span",{className:"form-indicat",children:":"})]}),e.jsxs("div",{className:"col-sm-8 sticky",children:[e.jsx(i,{type:"text",value:l.name,className:a.name&&"inerror",name:"name",handleChange:t,placeholder:"Enter Product Name"}),a.name&&e.jsx("div",{className:"smart-valid",children:a.name})]})]}),e.jsxs("div",{className:"form-group  row",children:[e.jsxs("div",{className:"col-sm-4",children:[e.jsx("label",{htmlFor:"",children:"Image"}),e.jsx("span",{className:"form-indicat",children:":"})]}),e.jsxs("div",{className:"col-sm-8 sticky",children:[e.jsx(i,{type:"file",className:a.image&&"inerror",name:"image",handleChange:h,placeholder:"Enter Product Image"}),a.image&&e.jsx("div",{className:"smart-valid",children:a.image})]})]}),e.jsxs("div",{className:"form-group  row",children:[e.jsxs("div",{className:"col-sm-4",children:[e.jsx("label",{htmlFor:"",children:"Price"}),e.jsx("span",{className:"form-indicat",children:":"})]}),e.jsxs("div",{className:"col-sm-8 sticky",children:[e.jsx(i,{type:"text",value:l.price,className:a.price&&"inerror",name:"price",handleChange:t,placeholder:"Enter Price"}),a.price&&e.jsx("div",{className:"smart-valid",children:a.price})]})]}),e.jsxs("div",{className:"form-group mb-1 row",children:[e.jsx("div",{className:"col-sm-4"}),e.jsx("div",{className:"col-sm-8 sticky",children:e.jsx("button",{type:"submit",disabled:m,className:"btn  btn-primary",children:"Update Product"})})]})]})})};export{b as default};
