(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7703],{35743:(e,a,t)=>{"use strict";t.d(a,{K:()=>s});let s={control:(e,a)=>({...e,width:"100%",boxShadow:a.isFocused?"none":e.boxShadow,borderColor:a.isFocused?"transparent":e.borderColor,"&:hover":{borderColor:a.isFocused?"transparent":e.borderColor}}),singleValue:e=>({...e}),option:(e,a)=>({...e,width:"100%",backgroundColor:a.isSelected?"#2E5386":a.isFocused?"#2e5386ba":"","&:hover":{backgroundColor:a.isSelected?"#2E5386":"#2e5386ba"}}),menu:e=>({...e,zIndex:9999})}},41624:(e,a,t)=>{"use strict";t.r(a),t.d(a,{default:()=>u});var s=t(37876),r=t(14232),l=t(92886),o=t(89099),c=t(91403),n=t(3945),i=t(1785),d=t(35743);let u=()=>{let e=(0,o.useRouter)(),{id:a}=e.query,[t,u]=(0,r.useState)({categoryName:"",status:"published",parent:null}),[m,h]=(0,r.useState)([]),p=(0,r.useCallback)(async()=>{if(a)try{let e=(await c.Ay.get("/get-category/".concat(a))).data,t=(await c.Ay.get("/categoryList")).data.filter(e=>e.id!==parseInt(a)).map(e=>({value:e.id,label:e.categoryName}));h(t),u({categoryName:e.categoryName,status:e.status||"published",parent:e.parent||null})}catch(e){console.error("Error fetching category or departments:",e)}},[a]);(0,r.useEffect)(()=>{p()},[p]);let y=async s=>{s.preventDefault();let r={categoryName:t.categoryName,parent:t.parent,status:t.status};try{let t=await c.Ay.put("/updateCategory/".concat(a),r,{headers:{"Content-Type":"application/json"}});200===t.status&&((0,i.Zx)("Category updated successfully"),e.push("/adminpanel/blog/master-module/category"))}catch(e){(0,i.Ax)("There was an error updating the category"),console.error("Error updating the category:",e)}},g=[{label:"Published",value:"published"},{label:"Draft",value:"draft"}];return(0,s.jsxs)("div",{className:"full-container",children:[(0,s.jsxs)("div",{className:"section-header",children:[(0,s.jsx)("button",{onClick:()=>e.back(),className:"btn-back",children:"Go Back"}),(0,s.jsx)("span",{className:"main-heading heading-both",children:"Edit Category"})]}),(0,s.jsx)("div",{className:"section-body",children:(0,s.jsx)("form",{onSubmit:y,children:(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("div",{className:"col-md-9",children:(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("div",{className:"col-md-6",children:(0,s.jsx)(n.wi,{label:"Category Name",name:"categoryName",value:t.categoryName,onChange:e=>{let{name:a,value:s}=e.target;u({...t,[a]:s})},placeholder:"Enter Category Name",required:!0})}),(0,s.jsx)("div",{className:"col-md-6",children:(0,s.jsxs)("div",{className:"input-outer",children:[(0,s.jsx)("label",{htmlFor:"parent",children:"Parent Category"}),(0,s.jsx)(l.Ay,{name:"parent",value:m.find(e=>e.value===t.parent),onChange:e=>{u({...t,parent:e?e.value:null})},options:m,className:"basic-single-select",classNamePrefix:"select",placeholder:"Select Parent Category",styles:d.K})]})})]})}),(0,s.jsx)("div",{className:"col-md-3",children:(0,s.jsx)("div",{className:"status-sec",children:(0,s.jsxs)("div",{className:"input-outer",children:[(0,s.jsx)("label",{htmlFor:"status",style:{marginLeft:"0px"},children:"Status"}),(0,s.jsxs)("div",{className:"profile-submit-section",style:{display:"flex"},children:[(0,s.jsx)(l.Ay,{name:"status",value:g.find(e=>e.value===t.status),onChange:e=>{u({...t,status:e.value})},options:g,className:"basic-select form_status",classNamePrefix:"select",styles:d.K}),(0,s.jsx)("button",{type:"submit",className:"btn-submit",children:"Submit"})]})]})})})]})})})]})}},98814:(e,a,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/category/EditCategory",function(){return t(41624)}])}},e=>{var a=a=>e(e.s=a);e.O(0,[636,6593,8792],()=>a(98814)),_N_E=e.O()}]);
//# sourceMappingURL=EditCategory-8f9a2572783b6c7e.js.map