Your IP : 18.223.241.235


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

"use strict";(self.webpackChunkpanel=self.webpackChunkpanel||[]).push([[507],{8507:function(e,t,n){n.r(t),n.d(t,{ChangeLogRoutes:function(){return $}});var s=n(6871),r=n(9630),i=n(5528),a=n(2412),u=n(8592),o=n(1413),c=n(4165),l=n(5861),d=n(6771),g=n(1933),x=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){var n;return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.changeId,e.next=3,d.o.get("/changes/".concat(n));case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),h=n(806),f=n(4430),v=n(2076),p=n(9879),m=n(2982),j=n(3777),y=n(7889),b=n(2007),w=n.n(b),Z=function(e){var t=e.data;return d.o.post("/changes",t)};Z.propTypes={data:w().shape({title:w().string.isRequired,desc:w().string.isRequired}).isRequired};var N=n(184),I=p.Ry({title:p.Z_().min(1,"Required"),desc:p.Z_()}),k=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,y.G)().addNotification;return(0,g.useMutation)((0,o.Z)((0,o.Z)({onMutate:function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){var n;return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,j.E.cancelQueries("suggestions");case 2:return n=j.E.getQueryData("suggestions"),j.E.setQueryData("suggestions",[].concat((0,m.Z)(n||[]),[t.data])),e.abrupt("return",{previousSuggestions:n});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),onError:function(e,t,n){null!==n&&void 0!==n&&n.previousSuggestions&&j.E.setQueryData("suggestions",n.previousSuggestions)},onSuccess:function(){j.E.invalidateQueries("suggestions"),t({type:"success",title:"Great, suggestion sent!"})}},e),{},{mutationFn:Z}))}();return e.isLoading?(0,N.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,N.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,N.jsx)(r.$j,{size:"sm"})})}):(0,N.jsx)(f._n,{allowedRoles:[f.K$.ADMIN],children:(0,N.jsx)(h._8,{size:"sm",isDone:e.isSuccess,triggerButton:(0,N.jsx)(r.zx,{variant:"create",size:"sm",startIcon:(0,N.jsx)(v.Z,{className:"h-4 w-4"}),children:"Submit Suggestion"}),title:"Suggestion",submitButton:(0,N.jsx)(r.zx,{form:"suggest-update",type:"submit",size:"sm",isLoading:e.isLoading,children:"Submit"}),children:(0,N.jsx)(h.l0,{id:"suggest-update",onSubmit:function(){var t=(0,l.Z)((0,c.Z)().mark((function t(n){return(0,c.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.mutateAsync({data:n});case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),schema:I,children:function(e){var t=e.register,n=e.formState;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(h.UP,{label:"Title",error:n.errors.title,registration:t("title")}),(0,N.jsx)(h.RY,{label:"Describe the change you would like to see",error:n.errors.desc,registration:t("desc")})]})}})})})},z=function(){var e=(0,s.UO)().changeId,t=function(e){var t=e.changeId,n=e.config;return(0,g.useQuery)((0,o.Z)((0,o.Z)({},n),{},{queryKey:["change",t],queryFn:function(){return x({changeId:t})}}))}({changeId:e});return t.isLoading?(0,N.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,N.jsx)(r.$j,{size:"lg"})}):t.data?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(i.F,{title:t.data.title}),(0,N.jsxs)(a.D,{title:t.data.title,button:(0,N.jsx)(k,{changeId:e}),children:[(0,N.jsx)("span",{className:"text-xs text-gray-500 font-bold",children:(0,u.p)(t.data.createdAt)}),(0,N.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:(0,N.jsx)("div",{children:(0,N.jsx)("div",{className:"bg-white dark:bg-gray-700 shadow overflow-hidden sm:rounded-lg",children:(0,N.jsx)("div",{className:"px-4 py-5 sm:px-6 ",children:(0,N.jsx)("div",{className:"mt-1 text-sm text-gray-500",children:(0,N.jsx)(r.Xz,{value:t.data.desc})})})})})})]})]}):null},R=function(){return d.o.get("/changes")},q=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,g.useQuery)((0,o.Z)((0,o.Z)({},e),{},{queryKey:["changes"],queryFn:function(){return R()}}))}();return e.isLoading?(0,N.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,N.jsx)(r.$j,{size:"lg"})}):e.data?(0,N.jsx)("ol",{class:"relative border-l border-gray-200 dark:border-gray-700",children:e.data.map((function(e,t){return(0,N.jsxs)("li",{class:"mb-10 ml-4",children:[(0,N.jsx)("div",{class:"absolute w-3 h-3 bg-gray-200 rounded-full mt-1.5 -left-1.5 border border-white dark:border-gray-900 dark:bg-gray-700"}),(0,N.jsx)("time",{class:"mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500",children:(0,u.p)(e.createdAt)}),(0,N.jsx)(r.rU,{to:"./".concat(e._id),children:(0,N.jsx)("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white",children:e.title})}),(0,N.jsx)(r.Xz,{value:e.desc})]},t)}))}):null},E=function(){return(0,N.jsx)(a.D,{title:"Changelog",button:(0,N.jsx)(k,{}),children:(0,N.jsx)("div",{className:"mt-4",children:(0,N.jsx)(q,{})})})},S=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){var n;return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.suggestionId,e.next=3,d.o.get("/changes/".concat(n));case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),D=function(e){var t=e.suggestionId,n=e.config;return(0,g.useQuery)((0,o.Z)((0,o.Z)({},n),{},{queryKey:["suggestion",t],queryFn:function(){return S({suggestionId:t})}}))},C=n(8419),L=function(e){var t=e.data,n=e.suggestionId;return d.o.patch("/changes/".concat(n),t)};L.propTypes={data:w().shape({title:w().string.isRequired,desc:w().string.isRequired,status:w().string.isRequired}).isRequired,suggestionId:w().string.isRequired};var Q=p.Ry({title:p.Z_().min(1,"Required"),desc:p.Z_().min(1,"Required"),status:p.Z_()}),A=function(e){var t,n,s,i=e.suggestionId,a=D({suggestionId:i}),u=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,y.G)().addNotification;return(0,g.useMutation)((0,o.Z)((0,o.Z)({onMutate:function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){var n;return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,j.E.cancelQueries(["change",null===t||void 0===t?void 0:t.suggestionId]);case 2:return n=j.E.getQueryData[null===t||void 0===t?void 0:t.suggestionId],j.E.setQueryData(["change",null===t||void 0===t?void 0:t.suggestionId],(0,o.Z)((0,o.Z)((0,o.Z)({},n),t.data),{},{id:t.suggestionId})),e.abrupt("return",{previousChange:n});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),onError:function(e,t,n){null!==n&&void 0!==n&&n.previousChange&&j.E.setQueryData(["change",n.previousChange.id],n.previousChange)},onSuccess:function(e){j.E.refetchQueries(["change",e.id]),t({type:"success",title:"Change Updated"})}},e),{},{mutationFn:L}))}(),d=[{label:"Approved",value:"approved"},{label:"Denied",value:"denied"}];return(0,N.jsx)(f._n,{allowedRoles:[f.K$.DEVELOPER],children:(0,N.jsx)(h._8,{size:"sm",isDone:u.isSuccess,triggerButton:(0,N.jsx)(r.zx,{variant:"create",startIcon:(0,N.jsx)(C.Z,{className:"h-4 w-4"}),size:"sm",children:"Update"}),title:"Update Change",submitButton:(0,N.jsx)(r.zx,{form:"update-change",type:"submit",size:"sm",isLoading:u.isLoading,children:"Submit"}),children:(0,N.jsx)(h.l0,{id:"update-change",onSubmit:function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.mutateAsync({data:t,suggestionId:i});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),options:{defaultValues:{title:null===(t=a.data)||void 0===t?void 0:t.title,desc:null===(n=a.data)||void 0===n?void 0:n.desc,status:null===(s=a.data)||void 0===s?void 0:s.status}},schema:Q,children:function(e){var t=e.register,n=e.formState,s=e.watch,r=e.setValue;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(h.UP,{label:"Title",error:n.errors.title,registration:t("title")}),(0,N.jsx)(h.N7,{label:"Content",error:n.errors.desc,editorContent:s("desc"),setValue:r,value:"desc"}),(0,N.jsx)(h.mg,{label:"Status",error:n.errors.status,registration:t("status"),options:null===d||void 0===d?void 0:d.map((function(e){return{label:e.label,value:e.value}}))})]})}})})})},F=function(){var e=(0,s.UO)().suggestionId,t=D({suggestionId:e});return t.isLoading?(0,N.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,N.jsx)(r.$j,{size:"lg"})}):t.data?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(i.F,{title:t.data.title}),(0,N.jsxs)(a.D,{title:t.data.title,button:(0,N.jsx)(A,{suggestionId:e}),children:[(0,N.jsx)("span",{className:"text-xs text-gray-500 font-bold",children:(0,u.p)(t.data.createdAt)}),(0,N.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:(0,N.jsx)("div",{children:(0,N.jsx)("div",{className:"bg-white dark:bg-gray-700 shadow overflow-hidden sm:rounded-lg",children:(0,N.jsx)("div",{className:"px-4 py-5 sm:px-6 ",children:(0,N.jsx)("div",{className:"mt-1 text-sm text-gray-500",children:(0,N.jsx)(r.Xz,{value:t.data.desc})})})})})})]})]}):null},_=function(){return d.o.get("/changes/suggestions")},U=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,g.useQuery)((0,o.Z)((0,o.Z)({},e),{},{queryKey:["suggestions"],queryFn:function(){return _()}}))}();return e.isLoading?(0,N.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,N.jsx)(r.$j,{size:"lg"})}):e.data?(0,N.jsx)(r.iA,{data:e.data,className:"text-gray-400",columns:[{title:"Suggestions",field:"title",Cell:function(e){var t=e.entry,n=t.title,s=t.desc,i=t._id;return(0,N.jsxs)(r.rU,{to:"./".concat(i),children:[(0,N.jsx)("span",{className:"text-lg",children:n}),(0,N.jsx)("br",{}),(0,N.jsx)("span",{className:"text-xs",children:s})]})}}]}):null},M=function(){return(0,N.jsx)(a.D,{title:"Suggestions",children:(0,N.jsx)("div",{className:"mt-4",children:(0,N.jsx)(U,{})})})},$=function(){return(0,N.jsxs)(s.Z5,{children:[(0,N.jsx)(s.AW,{path:"",element:(0,N.jsx)(E,{})}),(0,N.jsx)(s.AW,{path:"suggestions",element:(0,N.jsx)(M,{})}),(0,N.jsx)(s.AW,{path:"suggestions/:suggestionId",element:(0,N.jsx)(F,{})}),(0,N.jsx)(s.AW,{path:":changeId",element:(0,N.jsx)(z,{})}),(0,N.jsx)(s.AW,{path:"*",element:(0,N.jsx)(s.Fg,{to:"."})})]})}},2076:function(e,t,n){var s=n(2791);var r=s.forwardRef((function(e,t){return s.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:t},e),s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"}))}));t.Z=r},8419:function(e,t,n){var s=n(2791);var r=s.forwardRef((function(e,t){return s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),s.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"}))}));t.Z=r}}]);
//# sourceMappingURL=507.638f5b0e.chunk.js.map