1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[85470,57026],{57026:function(e,t,r){"use strict";r.d(t,{Ph:function(){return i}});var n=r(67294),a=r(83234),s=r(38655),l=r(54520),cx=(...e)=>e.filter(Boolean).join(" "),dataAttr=e=>e?"":void 0,o=(0,s.Gp)(function(e,t){let{children:r,placeholder:a,className:l,...o}=e;return n.createElement(s.m$.select,{...o,ref:t,className:cx("chakra-select",l)},a&&n.createElement("option",{value:""},a),r)});o.displayName="SelectField";var i=(0,s.Gp)((e,t)=>{var r;let i=(0,s.jC)("Select",e),{rootProps:c,placeholder:u,icon:d,color:h,height:m,h:f,minH:p,minHeight:g,iconColor:x,iconSize:C,...y}=(0,l.Lr)(e),[v,_]=function(e,t){let r={},n={};for(let[a,s]of Object.entries(e))t.includes(a)?r[a]=s:n[a]=s;return[r,n]}(y,l.oE),j=(0,a.Yp)(_),b={paddingEnd:"2rem",...i.field,_focus:{zIndex:"unset",...null==(r=i.field)?void 0:r._focus}};return n.createElement(s.m$.div,{className:"chakra-select__wrapper",__css:{width:"100%",height:"fit-content",position:"relative",color:h},...v,...c},n.createElement(o,{ref:t,height:f??m,minH:p??g,placeholder:u,...j,__css:b},e.children),n.createElement(SelectIcon,{"data-disabled":dataAttr(j.disabled),...(x||h)&&{color:x||h},__css:i.icon,...C&&{fontSize:C}},d))});i.displayName="Select";var DefaultIcon=e=>n.createElement("svg",{viewBox:"0 0 24 24",...e},n.createElement("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})),c=(0,s.m$)("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),SelectIcon=e=>{let{children:t=n.createElement(DefaultIcon,null),...r}=e,a=(0,n.cloneElement)(t,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return n.createElement(c,{...r,className:"chakra-select__icon-wrapper"},(0,n.isValidElement)(t)?a:null)};SelectIcon.displayName="SelectIcon"},36158:function(e,t,r){"use strict";r.d(t,{Od:function(){return m},s7:function(){return SkeletonCircle},N2:function(){return SkeletonText}});var n=r(67294),a=r(51469),s=r(38655),l=r(70917),o=r(54520),cx=(...e)=>e.filter(Boolean).join(" "),i=(0,s.m$)("div",{baseStyle:{boxShadow:"none",backgroundClip:"padding-box",cursor:"default",color:"transparent",pointerEvents:"none",userSelect:"none","&::before, &::after, *":{visibility:"hidden"}}}),useIsFirstRender=()=>{let e=(0,n.useRef)(!0);return(0,n.useEffect)(()=>{e.current=!1},[]),e.current},c=(0,l.F4)({from:{opacity:0}
1,to:{opacity:1}}),u="var(--skeleton-start-color)",d="var(--skeleton-end-color)",h=(0,l.F4)({from:{borderColor:u,background:u},to:{borderColor:d,background:d}}),m=(0,s.Gp)((e,t)=>{let r=(0,s.mq)("Skeleton",e),a=useIsFirstRender(),{startColor:l,endColor:u,isLoaded:d,fadeDuration:m,speed:f,className:p,...g}=(0,o.Lr)(e),x=function(e){let t=(0,n.useRef)();return(0,n.useEffect)(()=>{t.current=e},[e]),t.current}(d),C=cx("chakra-skeleton",p);if(d){let e=a||x?"none":`${c} ${m}s`;return n.createElement(s.m$.div,{ref:t,className:C,__css:{animation:e},...g})}return n.createElement(i,{ref:t,className:C,...g,__css:{...r,animation:`${f}s linear infinite alternate ${h}`}})});m.defaultProps={fadeDuration:.4,speed:.8},m.displayName="Skeleton";var SkeletonText=e=>{let{noOfLines:t=3,spacing:r="0.5rem",skeletonHeight:l="0.5rem",className:o,startColor:i,endColor:c,isLoaded:u,fadeDuration:d,speed:h,children:f,...p}=e,g=(0,a.Sx)("number"==typeof t?[t]:t)||3,x=Array(g).fill(1).map((e,t)=>t+1),getWidth=e=>g>1&&e===x.length?"80%":"100%",C=cx("chakra-skeleton__group",o);return n.createElement(s.m$.div,{className:C,...p},x.map((e,t)=>{if(u&&t>0)return null;let a=u?null:{mb:e===x.length?"0":r,width:getWidth(e),height:l};return n.createElement(m,{key:x.length.toString()+e,startColor:i,endColor:c,isLoaded:u,fadeDuration:d,speed:h,...a},0===t?f:void 0)}))};SkeletonText.displayName="SkeletonText";var SkeletonCircle=({size:e="2rem",...t})=>n.createElement(m,{borderRadius:"full",boxSize:e,...t});SkeletonCircle.displayName="SkeletonCircle"},68185:function(e,t,r){"use strict";r.d(t,{r:function(){return o}});var n=r(67294),a=r(49184),s=r(38655),l=r(54520),cx=(...e)=>e.filter(Boolean).join(" "),dataAttr=e=>e?"":void 0,o=(0,s.Gp)(function(e,t){let r=(0,s.jC)("Switch",e),{spacing:o="0.5rem",children:i,...c}=(0,l.Lr)(e),{state:u,getInputProps:d,getCheckboxProps:h,getRootProps:m,getLabelProps:f}=(0,a.O)(c),p=(0,n.useMemo)(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...r.container}),[r.container]),g=(0,n.useMemo)(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...r.track}),[r.track]),x=(0,n.useMemo)(()=>({userSelect:"none",marginStart:o,...r.label}),[o,r.label]);return n.createElement(s.m$.label,{...m(),className:cx("chakra-switch",e.className),__css:p},n.createElement("input",{className:"chakra-switch__input",...d({},t)}),n.createElement(s.m$.span,{...h(),className:"chakra-switch__track",__css:g},n.createElement(s.m$.span,{__css:r.thumb,className:"chakra-switch__thumb","data-checked":dataAttr(u.isChecked),"data-hover":dataAttr(u.isHovered)})),i&&n.createElement(s.m$.span,{className:"chakra-switch__label",...f(),__css:x},i))});o.displayName="Switch"},36696:function(e,t,r){"use strict";r.d(t,{$R:function(){return f},Rn:function(){return d},Td:function(){return x},Th:function(){return p},Tr:function(){return g},hr:function(){return h},iA:function(){return c},p3:function(){return m},xJ:function(){return u}});var n=r(67294),a=r(38655),s=r(54520),l=r(28387),cx=(...e)=>e.filter(Boolean).join(" "),[o,i]=(0,l.k)({name:"TableStylesContext",errorMessage:"useTableStyles returned is 'undefined'. Seems you forgot to wrap the components in \"<Table />\" "}),c=(0,a.Gp)((e,t)=>{let r=(0,a.jC)("Table",e),{className:l,...i}=(0,s.Lr)(e);return n.createElement(o,{value:r},n.createElement(a.m$.table,{ref:t,__css:r.table,className:cx("chakra-table",l),...i}))});c.displayName="Table";var u=(0,a.Gp)((e,t)=>{let{overflow:r,overflowX:s,className:l,...o}=e;return n.createElement(a.m$.div,{ref:t,className:cx("chakra-table__container",l),...o,__css:{display:"block",whiteSpace:"nowrap",WebkitOverflowScrolling:"touch",overflowX:r??s??"auto",overflowY:"hidden",maxWidth:"100%"}})}),d=(0,a.Gp)((e,t)=>{let{placement:r="bottom",...s}=e,l=i();return n.createElement(a.m$.caption,{...s,ref:t,__css:{...l.caption,captionSide:r}})});d.displayName="TableCaption";var h=(0,a.Gp)((e,t)=>{let r=i();return n.createElement(a.m$.thead,{...e,ref:t,__css:r.thead})}),m=(0,a.Gp)((e,t)=>{let r=i();return n.createElement(a.m$.tbody,{...e,ref:t,__css:r.tbody})}),f=(0,a.Gp)((e,t)=>{let r=i();return n.createElement(a.m$.tfoot,{...e,ref:t,__css:r.tfoot})}),p=(0,a.Gp)(({isNumeric:e,...t},r)=>{let s=i();return n.createElement(a.m$.th,{...t,ref:r,__css:s.th,"data-is-numeric":e})}),g=(0,a.Gp)((e,t)=>{let r=i();return n.createElement(a.m$.tr,{...e,ref:t,__css:r.tr})}),x=(0,a.Gp)(({isNumeric:e,...t},r)=>{let s=i();return n.createElement(a.m$.td,{...t,ref:r,__css:s.td,"data-is-numeric":e})})},42976:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/financials/other-items-category/list",function(){return r(98728)}])},17508:function(e,t,r){"use strict";r.d(t,{H:function(){return FinancialsPage}});var n=r(85893),a=r(48641);r(67294);let FinancialsPage=e=>{let{children:t,title:r="Financials"}=e;return(0,n.jsx)(a.xu,{children:t})}},98728:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return $}});var n=r(85893),a=r(96317),s=r(17508),l=r(67294),o=r(80419),i=r(8395),c=r(90195),u=r(48641),d=r(20979),h=r(47741),m=r(36696),f=r(97026),p=r(68185),g=r(57026),x=r(76722),C=r(32683),y=r(47503),v=r(52670),_=r(6491),j=r(51992),b=r(11153),w=r(95868);let OtherItemsCategoryListActions=e=>{let{row:t,onEdit:r,onAddNew:a,onSave:s,onCancel:l,editingId:o,isSaving:i}=e;return(0,n.jsx)(u.Ug,{spacing:2,justify:"flex-start",children:(0,n.jsx)(u.kC,{align:"center",justify:"center",columnGap:5,pointerEvents:i?"none":"initial",children:o===t._id?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(w.P,{boxSize:"18px",color:"primary.500",cursor:i?"not-allowed":"pointer",onClick:()=>l()}),(0,n.jsx)(_.rE2,{boxSize:"18px",color:"primary.500",cursor:i?"not-allowed":"pointer",onClick:()=>s()})]}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(_.dY8,{boxSize:"18px",color:"primary.500",cursor:"pointer",onClick:()=>r(t._id)})})})})};var S=r(37887),E=r(21112),k=r(11595),N=r(50319);let useCreateCategory=()=>
1{let[e,t]=(0,N.D)(E.Xy,{refetchQueries:["GetCategories"]}),createCategory=async t=>{let{data:r}=await e({variables:{input:t}});if(!(null==r?void 0:r.createCategory.success))throw Error((null==r?void 0:r.createCategory.message)||"Create failed");return null==r?void 0:r.createCategory};return{createCategory,...t}},useUpdateCategory=()=>{let[e,t]=(0,N.D)(E._o,{refetchQueries:["GetCategories"]}),updateCategory=async t=>{let{data:r}=await e({variables:{input:t}});if(!(null==r?void 0:r.updateCategory.success))throw Error((null==r?void 0:r.updateCategory.message)||"Update failed");return r.updateCategory};return{updateCategory,...t}},useChangeCategoryStatus=()=>{let[e,t]=(0,N.D)(E.P5);return{changeCategoryStatus:(t,r)=>e({variables:{input:{_id:t}},...r}),...t}},T=[10,25,50],I=[{label:"All",value:""},{label:"Active",value:"ACTIVE"},{label:"Inactive",value:"INACTIVE"}],showToast=function(e,t,r,n){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3;e({title:t,description:r,status:n,duration:a,isClosable:!0})},OtherItemsCategoryList=e=>{var t;let{}=e,r=(0,o.pm)(),[a,s]=l.useState(1),[w,N]=l.useState(10),[A,$]=l.useState(""),[O,z]=l.useState(""),F=(0,j.c)(A,500),[G,P]=l.useState({status:""}),D=(0,i.ff)("gray.50","whiteAlpha.100"),W=(0,i.ff)("gray.200","whiteAlpha.200"),[L,M]=l.useState(null),[R,U]=l.useState(""),[B,H]=l.useState(!1),[V,X]=l.useState(""),[Y,q]=(0,c.kt)(!1),{createCategory:Q}=useCreateCategory(),{updateCategory:Z}=useUpdateCategory(),{changeCategoryStatus:J}=useChangeCategoryStatus(),handleFilterChange=e=>{let t={...G,isDraft:!1,...e};t.isDraft||delete t.isDraft,P(t),s(1)};l.useEffect(()=>{z(F),s(1)},[F]),l.useEffect(()=>{s(1)},[w]);let K=l.useMemo(()=>{let e={...G};return e.status||delete e.status,{input:{limit:w,offset:(a-1)*w,search:O,filter:Object.keys(e).length>0?e:{}}}},[w,a,O,G]),{data:ee,loading:et,error:er}=(0,S.a)(E.jf,{variables:K,fetchPolicy:"cache-and-network"}),en=(null==ee?void 0:ee.getCategories.results)||[],ea=null!==(t=null==ee?void 0:ee.getCategories.totalCount)&&void 0!==t?t:0,es=Math.ceil(ea/w),onEdit=e=>{H(!1);let t=en.find(t=>t._id===e);t&&(M(e),U(t.name))},onAddNew=()=>{if(B){showToast(r,"Error","You cannot create another category. Please complete the current form first.","error");return}H(!0),M("new"),U(""),X("")},onSave=async()=>{try{if(q.on(),!("new"===L?V:R).trim()){showToast(r,"Error","Category name is required","error"),q.off();return}if("new"===L){let e=await Q({name:V});showToast(r,"Success",e.message,"success")}else{let e=await Z({_id:L,name:R});showToast(r,"Success",e.message,"success")}q.off(),H(!1),M(null),X(""),U("")}catch(e){q.off(),showToast(r,"Error",e.message,"error")}finally{q.off()}},onCancel=()=>{H(!1),M(null),X(""),U("")};return l.useEffect(()=>{er&&showToast(r,"Error",er.message||"Failed to load other items category","error",5e3)},[er,r]),(0,n.jsx)(u.gC,{spacing:6,align:"stretch",children:(0,n.jsxs)(v.Z,{bg:"white",p:6,children:[(0,n.jsx)(u.kC,{justify:"space-between",mb:6,align:"center",children:(0,n.jsx)(u.xv,{fontSize:"xl",fontWeight:"semibold",children:"Other Items Category"})}),(0,n.jsxs)(u.kC,{justify:"space-between",align:{base:"left",lg:"center"},gap:4,flexDirection:{base:"column",md:"column",lg:"row"},flexWrap:"wrap",mb:6,children:[(0,n.jsxs)(u.kC,{align:{base:"left",lg:"center"},justify:{base:"left"},flexWrap:"wrap",flexDirection:{base:"column",md:"column",lg:"row"},gap:4,children:[(0,n.jsx)(u.xu,{children:(0,n.jsxs)(d.BZ,{w:"320px",children:[(0,n.jsx)(d.Z8,{pointerEvents:"none",children:(0,n.jsx)(_.W1M,{color:"gray.400"})}),(0,n.jsx)(d.II,{placeholder:"Search by Name",value:A,onChange:e=>{$(e.target.value),H(!1)},bg:"white",borderColor:"gray.300",_focus:{borderColor:"blue.500",boxShadow:"0 0 0 1px #3182ce"}})]})}),(0,n.jsx)(u.xu,{w:"150px",children:(0,n.jsx)(b.G,{value:G.status?G.status:"",placeholder:"Status",onChange:e=>{H(!1),""===e?handleFilterChange({status:null}):"draft"===e?handleFilterChange({isDraft:!0,status:null}):handleFilterChange({status:e})},options:I,maxHeight:"100%"})})]}),(0,n.jsx)(h.zx,{onClick:()=>onAddNew(),w:"max-content",children:"Create New Category"})]}),(0,n.jsxs)(u.xu,{overflow:"hidden",pb:6,children:[(0,n.jsx)(u.xu,{overflowX:"auto",minH:"40vh",borderRadius:"md",children:(0,n.jsxs)(m.iA,{size:"sm",children:[(0,n.jsx)(m.hr,{children:(0,n.jsxs)(m.Tr,{borderBottom:"1px",borderColor:W,children:[(0,n.jsx)(m.Th,{py:3,children:"Name"}),(0,n.jsx)(m.Th,{py:3,children:"Status"}),(0,n.jsx)(m.Th,{py:3,children:"Actions"})]})}),et?(0,n.jsx)(k.j,{columnCount:3,useFullWidth:!0,rows:10}):er?(0,n.jsx)(m.p3,{children:(0,n.jsx)(m.Tr,{children:(0,n.jsx)(m.Td,{colSpan:3,children:(0,n.jsx)(u.xv,{color:"red.500",children:"Failed to load other items"})})})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(m.p3,{children:[en.map(e=>{var t;return(0,n.jsxs)(m.Tr,{_hover:{bg:D},children:[(0,n.jsx)(m.Td,{children:L===e._id?(0,n.jsx)(u.kC,{gap:2,children:(0,n.jsx)(d.II,{value:R,onChange:e=>U(e.target.value),maxW:"200px",size:"sm"})}):(0,n.jsx)(f.u,{label:null!==(t=e.name)&&void 0!==t?t:"Category Name",children:(0,n.jsx)(u.xv,{width:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:e.name})})}),(0,n.jsx)(m.Td,{children:(0,n.jsx)(p.r,{colorScheme:"primary",isChecked:e.status===y.U_.ACTIVE,size:"lg",onChange:async()=>{let t=e.status===y.U_.ACTIVE?y.U_.INACTIVE:y.U_.ACTIVE;try{await J(e._id,{optimisticResponse:{changeCategoryStatus:{__typename:"ChangeCategoryStatusOutput",success:!0,message:"Status updated"}},update(r){let n=r.identify({__typename:"OtherItemCategory",_id:e._id});r.modify({id:n,fields:{status:()=>t}})}}),showToast(r,"Success","Category status updated successfully","success")}catch(e){console.error(e)}}})}),(0,n.jsx)(m.Td,{py:2,children:(0,n.jsx)(OtherItemsCategoryListActions,{row:e,onEdit:onEdit,onAddNew:onAddNew,onSave:onSave,onCancel:onCancel,editingId:L,isSaving:Y})})]},e._id)}),B&&(0,n.jsxs)(m.Tr,{_hover:{bg:D},children:[(0,n.jsx)(m.Td,{children:(0,n.jsx)(u.kC,{gap:2,children:(0,n.jsx)(d.II,{value:V,onChange:e=>X(e.target.value),maxW:"200px",size:"sm",placeholder:"Enter category name"})})}),(0,n.jsx)(m.Td,{children:(0,n.jsx)(p.r,{isDisabled:!0,isChecked:!0,size:"lg"})}),(0,n.jsx)(m.Td,{py:2,children:(0,n.jsx)(OtherItemsCategoryListActions,{row:{_id:"new",name:V},onEdit:onEdit,onAddNew:onAddNew,onSave:onSave,onCancel:onCancel,editingId:L,isSaving:Y})})]},"new")]}),!B&&0===en.length&&(0,n.jsx)(C.fQ,{children:"There are no other items category found"})]})]})}),(0,n.jsxs)(u.kC,{justify:Math.ceil(ea/w)>1?"space-between":"center",align:"center",gap:4,flexWrap:"wrap",children:[ea>10?(0,n.jsxs)(u.xu,{display:"flex",alignItems:"center",mt:6,children:[(0,n.jsx)(u.xu,{as:"span",fontSize:"sm",mr:2,children:"Showing"}),(0,n.jsx)(g.Ph,{size:"sm",width:"70px",value:w,onChange:e=>{N(Number(e.target.value)),H(!1)},mr:2,children:T.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsxs)(u.xu,{as:"span",fontSize:"sm",children:["of ",null!=ea?ea:0," entries"]})]}):(0,n.jsxs)(u.xu,{as:"span",fontSize:"sm",mt:2,children:["Showing total ",null!=ea?ea:0," entries"]}),es>1&&(0,n.jsx)(x.t,{currentPage:a,numberOfPages:Math.ceil(ea/w),onChange:e=>{s(e),H(!1)}})]})]})]})})},OtherItemsCategoryPage=()=>(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(OtherItemsCategoryList,{})});var A=r(93064),$=(0,r(52609).z)(()=>(0,n.jsx)(a.C,{children:(0,n.jsx)(s.H,{title:"Other Items Category",children:(0,n.jsx)(OtherItemsCategoryPage,{})})}),{requiresEvery:[A.lj.ADMIN_ROLE]})}},function(e){e.O(0,[64986,96317,4640,49774,92888,40179],function(){return e(e.s=42976)}),_N_E=e.O()}]); 2//# sourceMappingURL=list-ca9add0f588c9c81.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.