Current Path : /home/ncdcgo/admin.ncdc.go.ug/static/js/ |
Current File : /home/ncdcgo/admin.ncdc.go.ug/static/js/219.aca0a7ec.chunk.js |
"use strict";(self.webpackChunkpanel=self.webpackChunkpanel||[]).push([[219],{223:function(e,a,t){t(2791);var r=t(3504),n=t(2506),s=t(184);a.Z=function(e){var a=e.routes;return(0,s.jsx)("nav",{className:"flex bg-white border border-gray-200 p-2 rounded-full px-4 mt-4","aria-label":"Breadcrumb",children:(0,s.jsxs)("ol",{className:"inline-flex items-center space-x-1 md:space-x-3",children:[(0,s.jsx)("li",{className:"inline-flex items-center text-gray-800",children:(0,s.jsxs)(r.rU,{to:"/app",className:"inline-flex items-center text-sm text-gray-800 hover:text-gray-900 dark:text-gray-800 dark:hover:text-gray-200",children:[(0,s.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{d:"M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"})}),"Home"]})}),null===a||void 0===a?void 0:a.map((function(e,a){return(0,s.jsxs)("li",{className:"inline-flex items-center",children:[(0,s.jsx)(n.Z,{size:10,className:"mr-4"}),(0,s.jsx)(r.rU,{to:e.path,className:"inline-flex items-center text-sm font-extrabold text-gray-700 hover:text-gray-900 dark:text-gray-800 dark:hover:text-gray-200",children:e.name})]},a)}))]})})}},1219:function(e,a,t){t.r(a),t.d(a,{ManagersRoutes:function(){return B}});var r=t(6871),n=t(9630),s=t(5528),i=t(2412),o=t(77),l=t(7087),c=t(8592),d=t(1413),u=t(4165),m=t(5861),g=t(6771),f=t(1933),x=function(){var e=(0,m.Z)((0,u.Z)().mark((function e(a){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.managerId,e.next=3,g.o.get("/managers/".concat(t));case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})));return function(a){return e.apply(this,arguments)}}(),p=function(e){var a=e.managerId,t=e.config;return(0,f.useQuery)((0,d.Z)((0,d.Z)({},t),{},{queryKey:["manager",a],queryFn:function(){return x({managerId:a})}}))},v=t(885),h=t(806),j=t(4430),b=t(8419),y=t(2791),w=t(9879),N=t(3777),Z=t(7889),k=t(2007),M=t.n(k),A=function(e){var a=e.data,t=e.managerId;return g.o.patch("/managers/".concat(t),a,{headers:{"Content-Type":"multipart/form-data"}})};A.propTypes={data:M().shape({firstName:M().string.isRequired,lastName:M().string.isRequired,designation:M().string.isRequired}).isRequired,managerId:M().string.isRequired};var R=t(184),D=w.Ry({firstName:w.Z_().min(1,"Required"),lastName:w.Z_().min(1,"Required"),designation:w.Z_()}),L=function(e){var a,t,r,s,i,o=e.managerId,l=(0,y.useState)(null),c=(0,v.Z)(l,2),g=c[0],x=c[1],w=(0,y.useState)(null),k=(0,v.Z)(w,2),M=k[0],L=k[1],C=(0,y.useState)(null),I=(0,v.Z)(C,2),U=I[0],V=I[1],z=(0,y.useState)(null),E=(0,v.Z)(z,2),S=E[0],F=E[1],q=(0,y.useState)(!1),Q=(0,v.Z)(q,2),_=Q[0],T=Q[1],B=p({managerId:o}),$=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,a=(0,Z.G)().addNotification;return(0,f.useMutation)((0,d.Z)((0,d.Z)({onMutate:function(){var e=(0,m.Z)((0,u.Z)().mark((function e(a){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N.E.cancelQueries(["manager",null===a||void 0===a?void 0:a.managerId]);case 2:return t=N.E.getQueryData[null===a||void 0===a?void 0:a.managerId],N.E.setQueryData(["manager",null===a||void 0===a?void 0:a.managerId],(0,d.Z)((0,d.Z)((0,d.Z)({},t),a.data),{},{id:a.managerId})),e.abrupt("return",{previousManager:t});case 5:case"end":return e.stop()}}),e)})));return function(a){return e.apply(this,arguments)}}(),onError:function(e,a,t){null!==t&&void 0!==t&&t.previousManager&&N.E.setQueryData(["manager",t.previousManager.id],t.previousManager)},onSuccess:function(e){N.E.refetchQueries(["manager",e.id]),a({type:"success",title:"Manager Updated"})}},e),{},{mutationFn:A}))}();return $.isLoading?(0,R.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,R.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,R.jsx)(n.$j,{size:"sm"})})}):(0,R.jsx)(j._n,{allowedRoles:[j.K$.ADMIN],children:(0,R.jsx)(h._8,{size:"sm",isDone:$.isSuccess,triggerButton:(0,R.jsx)(n.zx,{variant:"create",startIcon:(0,R.jsx)(b.Z,{className:"h-4 w-4"}),size:"sm",children:"Update"}),title:"Update Manager",submitButton:(0,R.jsx)(n.zx,{form:"update-manager",type:"submit",size:"sm",isLoading:$.isLoading,children:"Submit"}),children:(0,R.jsx)(h.l0,{id:"update-manager",encType:"multipart/form-data",onSubmit:function(){var e=(0,m.Z)((0,u.Z)().mark((function e(a){var t,r,n,s;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.firstName,r=a.lastName,n=a.designation,(s=new FormData).append("frontViewAvatar",g),s.append("sideViewAvatar",M),s.append("firstName",t),s.append("lastName",r),s.append("designation",n),e.next=9,$.mutateAsync({data:s,managerId:o});case 9:V(null),F(null);case 11:case"end":return e.stop()}}),e)})));return function(a){return e.apply(this,arguments)}}(),options:{defaultValues:{firstName:null===(a=B.data)||void 0===a?void 0:a.firstName,lastName:null===(t=B.data)||void 0===t?void 0:t.lastName,designation:null===(r=B.data)||void 0===r?void 0:r.designation,frontViewAvatar:null===(s=B.data)||void 0===s?void 0:s.frontViewAvatar,sideViewAvatar:null===(i=B.data)||void 0===i?void 0:i.sideViewAvatar}},schema:D,children:function(e){var a=e.register,t=e.formState;e.watch,e.setValue;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(h.UP,{label:"First Name",error:t.errors.firstName,registration:a("firstName")}),(0,R.jsx)(h.UP,{label:"Last Name",error:t.errors.lastName,registration:a("lastName")}),(0,R.jsx)(h.UP,{label:"Designation",error:t.errors.designation,registration:a("designation")}),(0,R.jsx)("div",{children:(0,R.jsx)("div",{className:"flex justify-start mx-5",children:(0,R.jsx)("div",{children:(0,R.jsxs)("div",{className:"form-check",children:[(0,R.jsx)("input",{className:"form-check-input appearance-none h-4 w-4 border border-green-300 rounded-sm bg-white checked:bg-green-600 checked:border-green-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer",type:"checkbox",value:"",id:"flexCheckDefault"}),(0,R.jsx)("label",{className:"form-check-label inline-block text-gray-800",for:"flexCheckDefault",children:"Governing Council"})]})})})}),(0,R.jsx)("div",{className:"flex justify-between items-center",children:_?(0,R.jsx)("a",{href:"#",className:"bg-green-400 text-gray-800 font-bold p-2 rounded text-sm",onClick:function(e){e.preventDefault(),T(!1)},children:"Close"}):(0,R.jsx)("a",{href:"#",className:"bg-green-400 text-gray-800 font-bold p-2 rounded text-sm",onClick:function(e){e.preventDefault(),T(!0)},children:"Update Image"})}),_&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(h.VA,{title:"Front View Avatar",subTitle:"Upload the front view of the avatar",error:t.errors.frontViewAvatar,x:1024,y:768,onChange:function(e){x(e.target.files[0]),V(URL.createObjectURL(e.target.files[0]))},preview:U}),(0,R.jsx)(h.VA,{title:"Side View Avatar",subTitle:"Upload the side view of the avatar",error:t.errors.sideViewAvatar,x:1024,y:768,onChange:function(e){L(e.target.files[1]),F(URL.createObjectURL(e.target.files[1]))},preview:S})]})]})}})})})},C=t(223),I=function(){var e,a=(0,r.UO)().managerId,t=p({managerId:a}),d=[{name:"Managers",path:"/app/managers"},{name:null===(e=t.data)||void 0===e?void 0:e.slug,path:""}];return t.isLoading?(0,R.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,R.jsx)(n.$j,{size:"lg"})}):t.data?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(s.F,{title:t.data.slug}),(0,R.jsxs)(i.D,{title:t.data.firstName+" "+t.data.lastName,button:(0,R.jsx)(L,{managerId:a}),children:[(0,R.jsx)("span",{className:"text-xs text-gray-500 font-bold",children:(0,c.p)(t.data.createdAt)}),(0,R.jsx)(C.Z,{routes:d}),(0,R.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:(0,R.jsx)("div",{children:(0,R.jsx)("div",{className:"bg-white dark:bg-gray-700 shadow overflow-hidden sm:rounded-lg",children:(0,R.jsxs)("div",{className:"px-4 py-5 sm:px-6 ",children:[(0,R.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,R.jsx)("h1",{className:"font-bold text-lg",children:"Title:"}),(0,R.jsx)("span",{className:"font-bold text-lg",children:t.data.designation})]}),(0,R.jsx)("div",{className:"border-b-2 border-gray-200"}),(0,R.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,R.jsx)(l.LazyLoadImage,{src:"".concat(o.tC,"/").concat(t.data.frontViewAvatar),alt:"front view for manager",className:"rounded-md"}),(0,R.jsx)(l.LazyLoadImage,{src:"".concat(o.tC,"/").concat(t.data.sideViewAvatar),alt:"side view for manager",className:"rounded-md"})]}),(0,R.jsx)("div",{className:"mt-1 text-sm text-gray-500",children:(0,R.jsx)(n.Xz,{value:t.data.desc})})]})})})})]})]}):null},U=t(2076),V=t(2982),z=function(e){var a=e.data;return g.o.post("/managers",a,{headers:{"Content-Type":"multipart/form-data"}})};z.propTypes={data:M().shape({firstName:M().string.isRequired,lastName:M().string.isRequired,designation:M().string.isRequired}).isRequired};var E=w.Ry({firstName:w.Z_().min(1,"Required"),lastName:w.Z_().min(1,"Required"),designation:w.Z_()}),S=function(){var e=(0,y.useState)(null),a=(0,v.Z)(e,2),t=a[0],r=a[1],s=(0,y.useState)(null),i=(0,v.Z)(s,2),o=i[0],l=i[1],c=(0,y.useState)(null),g=(0,v.Z)(c,2),x=g[0],p=g[1],b=(0,y.useState)(null),w=(0,v.Z)(b,2),k=w[0],M=w[1],A=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,a=(0,Z.G)().addNotification;return(0,f.useMutation)((0,d.Z)((0,d.Z)({onMutate:function(){var e=(0,m.Z)((0,u.Z)().mark((function e(a){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N.E.cancelQueries("managers");case 2:return t=N.E.getQueryData("managers"),N.E.setQueryData("managers",[].concat((0,V.Z)(t||[]),[a.data])),e.abrupt("return",{previousManagers:t});case 5:case"end":return e.stop()}}),e)})));return function(a){return e.apply(this,arguments)}}(),onError:function(e,a,t){null!==t&&void 0!==t&&t.previousManagers&&N.E.setQueryData("managers",t.previousManagers)},onSuccess:function(){N.E.invalidateQueries("managers"),a({type:"success",title:"Manager Created"})}},e),{},{mutationFn:z}))}();return A.isLoading?(0,R.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,R.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,R.jsx)(n.$j,{size:"sm"})})}):(0,R.jsx)(j._n,{allowedRoles:[j.K$.ADMIN],children:(0,R.jsx)(h._8,{size:"sm",isDone:A.isSuccess,triggerButton:(0,R.jsx)(n.zx,{variant:"create",size:"sm",startIcon:(0,R.jsx)(U.Z,{className:"h-4 w-4"}),children:"Create Manager"}),title:"Create Manager",submitButton:(0,R.jsx)(n.zx,{form:"create-manager",type:"submit",size:"sm",isLoading:A.isLoading,children:"Submit"}),children:(0,R.jsx)(h.l0,{id:"create-manager",encType:"multipart/form-data",onSubmit:function(){var e=(0,m.Z)((0,u.Z)().mark((function e(a){var r,n,s,i;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.firstName,n=a.lastName,s=a.designation,(i=new FormData).append("frontViewAvatar",t),i.append("sideViewAvatar",o),i.append("firstName",r),i.append("lastName",n),i.append("designation",s),e.next=9,A.mutateAsync({data:i});case 9:case"end":return e.stop()}}),e)})));return function(a){return e.apply(this,arguments)}}(),schema:E,children:function(e){var a=e.register,t=e.formState;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(h.UP,{label:"First Name",error:t.errors.firstName,registration:a("firstName")}),(0,R.jsx)(h.UP,{label:"Last Name",error:t.errors.lastName,registration:a("lastName")}),(0,R.jsx)(h.UP,{label:"Designation",error:t.errors.designation,registration:a("designation")}),(0,R.jsx)("div",{children:(0,R.jsx)("div",{className:"flex justify-start mx-5",children:(0,R.jsx)("div",{children:(0,R.jsxs)("div",{className:"form-check",children:[(0,R.jsx)("input",{className:"form-check-input appearance-none h-4 w-4 border border-green-300 rounded-sm bg-white checked:bg-green-600 checked:border-green-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer",type:"checkbox",value:"",id:"flexCheckDefault"}),(0,R.jsx)("label",{className:"form-check-label inline-block text-gray-800",for:"flexCheckDefault",children:"Governing Council"})]})})})}),(0,R.jsx)(h.VA,{title:"Front View Avatar",subTitle:"Upload the front view of the avatar",error:t.errors.frontViewAvatar,x:1024,y:768,onChange:function(e){r(e.target.files[0]),p(URL.createObjectURL(e.target.files[0]))},preview:x}),(0,R.jsx)(h.VA,{title:"Side View Avatar",subTitle:"Upload the side view of the avatar",error:t.errors.sideViewAvatar,x:1024,y:768,onChange:function(e){l(e.target.files[0]),M(URL.createObjectURL(e.target.files[0]))},preview:k})]})}})})})},F=function(){return g.o.get("/managers")},q=function(e){var a=e.managerId;return g.o.delete("/managers/".concat(a))};q.propTypes={managerId:M().string.isRequired};var Q=function(e){var a=e.id,t=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,a=(0,Z.G)().addNotification;return(0,f.useMutation)((0,d.Z)((0,d.Z)({onMutate:function(){var e=(0,m.Z)((0,u.Z)().mark((function e(a){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N.E.cancelQueries("managers");case 2:return t=N.E.getQueryData("managers"),N.E.setQueryData("managers",null===t||void 0===t?void 0:t.filter((function(e){return e.id!==a.managerId}))),e.abrupt("return",{previousManagers:t});case 5:case"end":return e.stop()}}),e)})));return function(a){return e.apply(this,arguments)}}(),onError:function(e,a,t){null!==t&&void 0!==t&&t.previousManagers&&N.E.setQueryData("managers",t.previousManagers)},onSuccess:function(){N.E.invalidateQueries("managers"),a({type:"success",title:"Manager Deleted"})}},e),{},{mutationFn:q}))}();return t.isLoading?(0,R.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,R.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,R.jsx)(n.$j,{size:"sm"})})}):(0,R.jsx)(j._n,{allowedRoles:[j.K$.ADMIN],children:(0,R.jsx)(n.U6,{icon:"danger",title:"Delete Manager",body:"Are you sure you want to permanently remove this Manager?",triggerButton:(0,R.jsx)("button",{children:"Remove"}),confirmButton:(0,R.jsx)(n.zx,{isLoading:t.isLoading,type:"button",className:"bg-red-600",onClick:(0,m.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.mutateAsync({managerId:a});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Manager"})})})},_=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,f.useQuery)((0,d.Z)((0,d.Z)({},e),{},{queryKey:["managers"],queryFn:function(){return F()}}))}();return e.isLoading?(0,R.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,R.jsx)(n.$j,{size:"lg"})}):e.data?(0,R.jsx)(n.iA,{data:e.data,className:"text-gray-400",columns:[{title:"Managers",field:"firstName",Cell:function(e){var a=e.entry,t=a.firstName,r=a.lastName;return(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)("span",{className:"text-lg",children:[t," ",r]})})}},{title:"",field:"_id",Cell:function(e){var a=e.entry._id;return(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)("div",{className:"flex flex-row justify-center items-center gap-5",children:[(0,R.jsx)(n.rU,{to:"./".concat(a),className:"mr-2 text-black dark:text-gray-200 hover:text-green-400",children:"View"})," ",(0,R.jsx)(Q,{id:a})]})})}}]}):null},T=function(){return(0,R.jsxs)(i.D,{title:"Managers",button:(0,R.jsx)(S,{}),children:[(0,R.jsx)(C.Z,{routes:[{name:"Managers",path:"."}]}),(0,R.jsx)("div",{className:"mt-4",children:(0,R.jsx)(_,{})})]})},B=function(){return(0,R.jsxs)(r.Z5,{children:[(0,R.jsx)(r.AW,{path:"",element:(0,R.jsx)(T,{})}),(0,R.jsx)(r.AW,{path:":managerId",element:(0,R.jsx)(I,{})}),(0,R.jsx)(r.AW,{path:"*",element:(0,R.jsx)(r.Fg,{to:"."})})]})}},2076:function(e,a,t){var r=t(2791);var n=r.forwardRef((function(e,a){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:a},e),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"}))}));a.Z=n},8419:function(e,a,t){var r=t(2791);var n=r.forwardRef((function(e,a){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:a},e),r.createElement("path",{d:"M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"}))}));a.Z=n}}]); //# sourceMappingURL=219.aca0a7ec.chunk.js.map