import{a as n,W as j,j as e}from"./BulkImageUpload-DGPbX05r.js";import{A as u}from"./Authenticated-DQno4VYw.js";import{P as v}from"./PageTitle-feHaMeNG.js";import{P as N}from"./Panel-CCKAj23D.js";import m from"./BlogMenu-DZZGOIa1.js";import{I as p}from"./Input-CR3dcIBA.js";import"./bootstrap.esm-e_F80uXB.js";const T=s=>{const[c,b]=n.useState(s.category),{data:l,setData:i,post:o,put:f,processing:y,errors:r,clearErrors:d,reset:B}=j({title:s.blog.title||"",category:s.blog.category_id||"",image:"",description:s.blog.description||""});n.useEffect(()=>{s.blog.id!=null&&i("_method","PUT")},[]);const t=a=>{i(a.target.name,a.target.type==="checkbox"?a.target.checked:a.target.value),d(a.target.name)},g=a=>{i(a.target.name,a.target.files[0]),d(a.target.name)},h=a=>{a.preventDefault(),s.blog.id!=null?o(route("blog.update",s.blog.id)):o(route("blog.store"))};return e.jsxs(u,{auth:s.auth,errors:s.errors,current:s.current,children:[e.jsx(v,{title:"Add Blog",path:"Blog",pathurl:""}),e.jsxs(N,{title:"Add Blog",md:"10",children:[e.jsx("div",{className:"card-header p-0",children:s.blog.id!=null?e.jsx(m,{active:"add",bid:s.blog.id}):e.jsx(m,{active:"add",bid:""})}),e.jsx("div",{className:"card-body tab-content p-4",children:e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"form-group row",children:[e.jsxs("div",{className:"col-md-2",children:[e.jsx("label",{children:"Blog Title"}),e.jsx("span",{className:"form-indicat",children:":"})]}),e.jsxs("div",{className:"col-md-5 pr-0",children:[e.jsx(p,{type:"text",value:l.title,className:r.title&&"inerror",name:"title",placeholder:"Enter Blog Title",handleChange:t}),r.title&&e.jsx("div",{className:"smart-valid",children:r.title})]})]}),e.jsxs("div",{className:"form-group row",children:[e.jsxs("div",{className:"col-md-2",children:[e.jsx("label",{children:"Select Category"}),e.jsx("span",{className:"form-indicat",children:":"})]}),e.jsxs("div",{className:"col-md-5 pr-0",children:[e.jsxs("select",{className:`form-control ${r.category&&"inerror"}`,value:l.category,onChange:t,name:"category",id:"",children:[e.jsx("option",{value:"",children:"Select Category"}),c&&c.map((a,x)=>e.jsx("option",{value:a.id,children:a.name},x))]}),r.category&&e.jsx("div",{className:"smart-valid",children:r.category})]})]}),e.jsxs("div",{className:"form-group row",children:[e.jsxs("div",{className:"col-md-2",children:[e.jsx("label",{children:"Select Image"}),e.jsx("span",{className:"form-indicat",children:":"})]}),e.jsxs("div",{className:"col-md-5 pr-0",children:[e.jsx("input",{type:"file",className:`form-control ${r.image&&"inerror"}`,name:"image",onChange:g}),r.image&&e.jsx("div",{className:"smart-valid",children:r.image})]})]}),e.jsxs("div",{className:"form-group row",children:[e.jsxs("div",{className:"col-md-2",children:[e.jsx("label",{children:"Blog Description"}),e.jsx("span",{className:"form-indicat",children:":"})]}),e.jsxs("div",{className:"col-md-5",children:[e.jsx("textarea",{placeholder:"Enter Blog Description",className:`form-control ${r.description&&"inerror"}`,name:"description",value:l.description,rows:"3",onChange:t}),r.description&&e.jsx("div",{className:"smart-valid",children:r.description})]})]}),e.jsxs("div",{className:"form-group row",children:[e.jsx("div",{className:"col-md-2"}),e.jsx("div",{className:"col-md-5 pr-0",children:s.blog.id!=null?e.jsx("button",{className:"btn btn-primary",children:"Update Blog"}):e.jsx("button",{className:"btn btn-primary",children:"Add Blog"})})]})]})})]})]})};export{T as default};
