Your IP : 3.137.164.200


Current Path : /home/ncdcgo/admin.ncdc.go.ug/static/js/
Upload File :
Current File : /home/ncdcgo/admin.ncdc.go.ug/static/js/355.83d29044.chunk.js

"use strict";(self.webpackChunkpanel=self.webpackChunkpanel||[]).push([[355],{223:function(e,r,t){t(2791);var n=t(3504),i=t(2506),s=t(184);r.Z=function(e){var r=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)(n.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===r||void 0===r?void 0:r.map((function(e,r){return(0,s.jsxs)("li",{className:"inline-flex items-center",children:[(0,s.jsx)(i.Z,{size:10,className:"mr-4"}),(0,s.jsx)(n.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})]},r)}))]})})}},6355:function(e,r,t){t.r(r),t.d(r,{Profile:function(){return B},Users:function(){return D}});var n=t(2412),i=t(4430),s=t(223),a=t(4165),o=t(5861),l=t(9630),u=t(806),d=t(2076),c=t(9879),m=t(2982),v=t(1413),p=t(6771),f=t(3777),g=t(7889),x=t(2007),h=t.n(x),b=t(1933),y=function(e){var r=e.data;return p.o.post("/users/create",r)};y.propTypes={data:h().shape({name:h().string.isRequired,address:h().string.isRequired,occupation:h().string.isRequired,country:h().string.isRequired,dob:h().string.isRequired,gender:h().string.isRequired,email:h().string.isRequired,role:h().string.isRequired,password:h().string.isRequired}).isRequired};var j=t(184),w=c.Ry({name:c.Z_().min(1,"Required"),address:c.Z_().min(1,"Required"),occupation:c.Z_().min(1,"Required"),country:c.Z_().min(1,"Required"),dob:c.Z_().min(1,"Required"),email:c.Z_().min(1,"Required"),role:c.Z_().min(1,"Required"),password:c.Z_().min(1,"Required")}),R=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification;return(0,b.useMutation)((0,v.Z)((0,v.Z)({onMutate:function(){var e=(0,o.Z)((0,a.Z)().mark((function e(r){var t;return(0,a.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f.E.cancelQueries("users");case 2:return t=f.E.getQueryData("users"),f.E.setQueryData("users",[].concat((0,m.Z)(t||[]),[r.data])),e.abrupt("return",{previousUsers:t});case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onError:function(e,r,t){null!==t&&void 0!==t&&t.previousUsers&&f.E.setQueryData("users",t.previousUsers)},onSuccess:function(){f.E.invalidateQueries("users"),r({type:"success",title:"User Created"})}},e),{},{mutationFn:y}))}(),r=[{label:"Admin",value:i.K$.ADMIN},{label:"Developer",value:i.K$.DEVELOPER},{label:"HR",value:i.K$.HR},{label:"Marketing",value:i.K$.MARKETING},{label:"PR",value:i.K$.PR}],t=[{label:"Male",value:"Male"},{label:"Female",value:"Female"}];return(0,j.jsx)(i._n,{allowedRoles:[i.K$.ADMIN],children:(0,j.jsx)(u._8,{size:"sm",isDone:e.isSuccess,triggerButton:(0,j.jsx)(l.zx,{variant:"create",size:"sm",startIcon:(0,j.jsx)(d.Z,{className:"h-4 w-4"}),children:"Create User"}),title:"Create User",submitButton:(0,j.jsx)(l.zx,{form:"create-user",type:"submit",size:"sm",isLoading:e.isLoading,children:"Submit"}),children:(0,j.jsx)(u.l0,{id:"create-user",onSubmit:function(){var r=(0,o.Z)((0,a.Z)().mark((function r(t){return(0,a.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e.mutateAsync({data:t});case 2:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),schema:w,children:function(e){var n=e.register,i=e.formState;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.UP,{type:"text",label:"Name",error:i.errors.name,registration:n("name")}),(0,j.jsx)(u.UP,{type:"text",label:"Physical Address",error:i.errors.address,registration:n("address")}),(0,j.jsx)(u.UP,{label:"Occupation",error:i.errors.occupation,registration:n("occupation")}),(0,j.jsx)(u.UP,{label:"Country",error:i.errors.country,registration:n("country")}),(0,j.jsx)(u.UP,{type:"date",label:"Date of Birth",error:i.errors.dob,registration:n("dob")}),(0,j.jsx)(u.UP,{type:"email",label:"Email",error:i.errors.email,registration:n("email")}),(0,j.jsx)(u.mg,{label:"Gender",error:i.errors.gender,registration:n("gender"),options:null===t||void 0===t?void 0:t.map((function(e){return{label:e.label,value:e.value}}))}),(0,j.jsx)(u.mg,{label:"Role",error:i.errors.role,registration:n("role"),options:null===r||void 0===r?void 0:r.map((function(e){return{label:e.label,value:e.value}}))}),(0,j.jsx)(u.UP,{label:"Password",type:"password",error:i.errors.password,registration:n("password")})]})}})})})},Z=t(8592),q=function(){return p.o.get("/users")},N=t(1492),U=t(803),E=function(e){var r=e.userId;return p.o.delete("/users/".concat(r))};E.propTypes={userId:h().string.isRequired};var P=function(e){var r=e.id,t=(0,N.a)().user,n=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification;return(0,b.useMutation)((0,v.Z)((0,v.Z)({onMutate:function(){var e=(0,o.Z)((0,a.Z)().mark((function e(r){var t;return(0,a.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f.E.cancelQueries("users");case 2:return t=f.E.getQueryData("users"),f.E.setQueryData("users",null===t||void 0===t?void 0:t.filter((function(e){return e.id!==r.userId}))),e.abrupt("return",{previousUsers:t});case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onError:function(e,r,t){null!==t&&void 0!==t&&t.previousUsers&&f.E.setQueryData("users",t.previousUsers)},onSuccess:function(){f.E.invalidateQueries("users"),r({type:"success",title:"User Deleted"})}},e),{},{mutationFn:E}))}();return(null===t||void 0===t?void 0:t.id)===r?null:(0,j.jsx)(l.U6,{icon:"danger",title:"Delete User",body:"Are you sure you want to delete this user?",triggerButton:(0,j.jsx)(l.zx,{variant:"danger",children:(0,j.jsx)(U.Z,{className:"h-4 w-4"})}),confirmButton:(0,j.jsx)(l.zx,{isLoading:n.isLoading,type:"button",className:"bg-red-600",onClick:function(){return n.mutate({userId:r})},children:"Delete User"})})},k=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,b.useQuery)((0,v.Z)((0,v.Z)({},e),{},{queryKey:["users"],queryFn:function(){return q()}}))}();return e.isLoading?(0,j.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,j.jsx)(l.$j,{size:"lg"})}):e.data?(0,j.jsx)(l.iA,{data:e.data,columns:[{title:"Name",field:"name"},{title:"Email",field:"email"},{title:"Role",field:"role"},{title:"Created At",field:"createdAt",Cell:function(e){var r=e.entry.createdAt;return(0,j.jsx)("span",{children:(0,Z.p)(r)})}},{title:"",field:"id",Cell:function(e){var r=e.entry._id;return(0,j.jsx)(P,{id:r})}}]}):null},D=function(){return(0,j.jsxs)(n.D,{title:"Users",button:(0,j.jsx)(R,{}),children:[(0,j.jsx)(s.Z,{routes:[{name:"Users",path:"."}]}),(0,j.jsx)("div",{className:"mt-4",children:(0,j.jsx)(i._n,{forbiddenFallback:(0,j.jsx)("div",{children:"Only admin can view this."}),allowedRoles:[i.K$.ADMIN],children:(0,j.jsx)(k,{})})})]})},M=t(8419),_=function(e){var r=e.data;return p.o.patch("/users/profile",r)};_.propTypes={data:h().shape({name:h().string.isRequired,address:h().string.isRequired,occupation:h().string.isRequired,country:h().string.isRequired,dob:h().string.isRequired,email:h().string.isRequired,role:h().string.isRequired}).isRequired};var A=c.Ry({name:c.Z_().min(1,"Required"),gender:c.Z_().min(1,"Required"),address:c.Z_().min(1,"Required"),designation:c.Z_().min(1,"Required"),country:c.Z_().min(1,"Required"),dob:c.Z_().min(1,"Required"),email:c.Z_().min(1,"Required"),role:c.Z_().min(1,"Required")}),O=[{label:"Admin",value:i.K$.ADMIN},{label:"Developer",value:i.K$.DEVELOPER},{label:"HR",value:i.K$.HR},{label:"Marketing",value:i.K$.MARKETING},{label:"PR",value:i.K$.PR}],z=[{label:"Male",value:"Male"},{label:"Female",value:"Female"}],L=function(){var e=(0,N.a)().user,r=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification,t=(0,N.a)().refetchUser;return(0,b.useMutation)((0,v.Z)((0,v.Z)({onSuccess:function(){r({type:"success",title:"User Updated"}),t()}},e),{},{mutationFn:_}))}();return(0,j.jsx)(u._8,{isDone:r.isSuccess,triggerButton:(0,j.jsx)(l.zx,{startIcon:(0,j.jsx)(M.Z,{className:"h-4 w-4"}),size:"sm",children:"Update Profile"}),title:"Update Profile",submitButton:(0,j.jsx)(l.zx,{form:"update-profile",type:"submit",size:"sm",isLoading:r.isLoading,children:"Submit"}),children:(0,j.jsx)(u.l0,{id:"update-profile",onSubmit:function(){var e=(0,o.Z)((0,a.Z)().mark((function e(t){return(0,a.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.mutateAsync({data:t});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),options:{defaultValues:{name:null===e||void 0===e?void 0:e.name,gender:null===e||void 0===e?void 0:e.gender,email:null===e||void 0===e?void 0:e.email,address:null===e||void 0===e?void 0:e.address,designation:null===e||void 0===e?void 0:e.designation,country:null===e||void 0===e?void 0:e.country,dob:null===e||void 0===e?void 0:e.dob,role:null===e||void 0===e?void 0:e.role}},schema:A,children:function(e){var r=e.register,t=e.formState;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u.UP,{type:"text",label:"Name",error:t.errors.name,registration:r("name")}),(0,j.jsx)(u.UP,{type:"text",label:"Physical Address",error:t.errors.address,registration:r("address")}),(0,j.jsx)(u.UP,{label:"Designation",error:t.errors.designation,registration:r("designation")}),(0,j.jsx)(u.UP,{label:"Country",error:t.errors.country,registration:r("country")}),(0,j.jsx)(u.UP,{type:"date",label:"Date of Birth",error:t.errors.dob,registration:r("dob")}),(0,j.jsx)(u.UP,{label:"Email",error:t.errors.email,registration:r("email")}),(0,j.jsx)(u.mg,{label:"Gender",error:t.errors.gender,registration:r("gender"),options:null===z||void 0===z?void 0:z.map((function(e){return{label:e.label,value:e.value}}))}),(0,j.jsx)(u.mg,{label:"Role",error:t.errors.role,registration:r("role"),options:null===O||void 0===O?void 0:O.map((function(e){return{label:e.label,value:e.value}}))})]})}})})},C=function(e){var r=e.label,t=e.value;return(0,j.jsxs)("div",{className:"py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6",children:[(0,j.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:r}),(0,j.jsx)("dd",{className:"mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2",children:t})]})},B=function(){var e=(0,N.a)().user;return console.log(e),e?(0,j.jsx)(n.D,{title:"Profile",button:(0,j.jsx)(L,{}),children:(0,j.jsxs)("div",{className:"bg-white shadow mt-4 overflow-hidden sm:rounded-lg",children:[(0,j.jsx)("div",{className:"px-4 py-5 sm:px-6",children:(0,j.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-gray-500",children:"Personal details of the user."})}),(0,j.jsx)("div",{className:"border-t border-gray-200 px-4 py-5 sm:p-0",children:(0,j.jsxs)("dl",{className:"sm:divide-y sm:divide-gray-200",children:[(0,j.jsx)(C,{label:"Name",value:e.name}),(0,j.jsx)(C,{label:"Gender",value:e.gender}),(0,j.jsx)(C,{label:"Physical Address",value:e.address}),(0,j.jsx)(C,{label:"Occupation",value:e.occupation}),(0,j.jsx)(C,{label:"Date of Birth",value:e.dob}),(0,j.jsx)(C,{label:"Email Address",value:e.email}),(0,j.jsx)(C,{label:"Role",value:e.role})]})})]})}):null}},2506:function(e,r,t){var n=t(2791),i=t(2007),s=t.n(i);function a(){return a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},a.apply(this,arguments)}function o(e,r){if(null==e)return{};var t,n,i=function(e,r){if(null==e)return{};var t,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)t=s[n],r.indexOf(t)>=0||(i[t]=e[t]);return i}(e,r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)t=s[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var l=(0,n.forwardRef)((function(e,r){var t=e.color,i=void 0===t?"currentColor":t,s=e.size,l=void 0===s?24:s,u=o(e,["color","size"]);return n.createElement("svg",a({ref:r,xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},u),n.createElement("polyline",{points:"9 18 15 12 9 6"}))}));l.propTypes={color:s().string,size:s().oneOfType([s().string,s().number])},l.displayName="ChevronRight",r.Z=l},2076:function(e,r,t){var n=t(2791);var i=n.forwardRef((function(e,r){return n.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:r},e),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"}))}));r.Z=i},803:function(e,r,t){var n=t(2791);var i=n.forwardRef((function(e,r){return n.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:r},e),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"}))}));r.Z=i},8419:function(e,r,t){var n=t(2791);var i=n.forwardRef((function(e,r){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:r},e),n.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"}))}));r.Z=i}}]);
//# sourceMappingURL=355.83d29044.chunk.js.map