(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2644],{35743:(e,a,s)=>{"use strict";s.d(a,{K:()=>t});let t={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})}},47586:(e,a,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/category/AddCategory",function(){return s(82057)}])},82057:(e,a,s)=>{"use strict";s.r(a),s.d(a,{default:()=>u});var t=s(37876),r=s(14232),l=s(92886),o=s(89099),n=s(91403),c=s(3945),d=s(1785),i=s(35743);let u=()=>{let e=(0,o.useRouter)(),[a,s]=(0,r.useState)([]),u={name:"",status:"published",department:""},[m,h]=(0,r.useState)(u);(0,r.useEffect)(()=>{n.Ay.get("/categoryList").then(e=>{s(e.data.map(e=>({value:e.id,label:e.categoryName})))}).catch(e=>{console.error("Error fetching department options:",e)})},[]);let b=async a=>{a.preventDefault();let s={categoryName:m.name,parent:m.department,status:m.status};try{let a=await n.Ay.post("/addCategory",s,{headers:{"Content-Type":"application/json"}});201===a.status&&((0,d.Zx)("Category created successfully"),e.push("/adminpanel/blog/master-module/category"),p())}catch(e){(0,d.Ax)("There was an error adding the Category"),console.error("Error adding the Category:",e)}},p=()=>{h(u)},g=[{label:"Published",value:"published"},{label:"Draft",value:"draft"}];return(0,t.jsxs)("div",{className:"full-container",children:[(0,t.jsxs)("div",{className:"section-header",children:[(0,t.jsx)("button",{onClick:()=>e.back(),className:"btn-back",children:"Go Back"}),(0,t.jsx)("span",{className:"main-heading heading-both",children:"Add category"})]}),(0,t.jsx)("div",{className:"section-body",children:(0,t.jsx)("form",{onSubmit:b,children:(0,t.jsxs)("div",{className:"row",children:[(0,t.jsx)("div",{className:"col-md-9",children:(0,t.jsxs)("div",{className:"row",children:[(0,t.jsx)("div",{className:"col-md-6",children:(0,t.jsx)(c.wi,{label:"Category Name",name:"name",value:m.name,onChange:e=>{let{name:a,value:s}=e.target;h({...m,[a]:s})},placeholder:"Enter Category Name",required:!0})}),(0,t.jsx)("div",{className:"col-md-6",children:(0,t.jsxs)("div",{className:"input-outer",children:[(0,t.jsx)("label",{htmlFor:"category",children:"Parent Category"}),(0,t.jsx)(l.Ay,{name:"parent",value:a.find(e=>e.value===m.department),onChange:e=>h({...m,department:e?e.value:""}),options:a,className:"basic-select",classNamePrefix:"select",placeholder:"Select Parent Category",isClearable:!0})]})})]})}),(0,t.jsx)("div",{className:"col-md-3",children:(0,t.jsx)("div",{className:"status-sec",children:(0,t.jsxs)("div",{className:"input-outer",children:[(0,t.jsx)("label",{htmlFor:"",children:"Status"}),(0,t.jsxs)("div",{className:"profile-submit-section",style:{display:"flex"},children:[(0,t.jsx)(l.Ay,{name:"status",value:g.find(e=>e.value===m.status),onChange:e=>{h({...m,status:e.value})},options:g,className:"basic-select form_status",classNamePrefix:"select",styles:i.K}),(0,t.jsx)("button",{type:"submit",className:"btn-submit",children:"Submit"})]})]})})})]})})})]})}}},e=>{var a=a=>e(e.s=a);e.O(0,[636,6593,8792],()=>a(47586)),_N_E=e.O()}]);
//# sourceMappingURL=AddCategory-21c887b62a766f00.js.map