Your IP : 3.14.244.90


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

"use strict";(self.webpackChunkpanel=self.webpackChunkpanel||[]).push([[334],{6334:function(e,t,n){n.r(t),n.d(t,{MessagesRoutes:function(){return C}});var r=n(6871),s=n(9630),a=n(5528),i=n(2412),o=n(8592),c=n(2791),l=n(2007),u=n.n(l);function d(){return d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d.apply(this,arguments)}function f(e,t){if(null==e)return{};var n,r,s=function(e,t){if(null==e)return{};var n,r,s={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var g=(0,c.forwardRef)((function(e,t){var n=e.color,r=void 0===n?"currentColor":n,s=e.size,a=void 0===s?24:s,i=f(e,["color","size"]);return c.createElement("svg",d({ref:t,xmlns:"http://www.w3.org/2000/svg",width:a,height:a,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},i),c.createElement("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),c.createElement("polyline",{points:"22,6 12,13 2,6"}))}));g.propTypes={color:u().string,size:u().oneOfType([u().string,u().number])},g.displayName="Mail";var m=g,x=n(1413),p=n(6771),v=n(1933),h=function(e){var t=e.messageId,n=e.config;return(0,v.useQuery)((0,x.Z)((0,x.Z)({},n),{},{queryKey:["message",t],queryFn:function(){return function(e){var t=e.messageId;return p.o.get("/messages/".concat(t))}({messageId:t})}}))},j=n(184),y=function(){var e=(0,r.UO)().messageId,t=h({messageId:e});return t.isLoading?(0,j.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,j.jsx)(s.$j,{size:"lg"})}):t.data?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.F,{title:t.data.subject}),(0,j.jsxs)(i.D,{title:t.data.subject,children:[(0,j.jsx)("span",{className:"text-xs font-bold",children:(0,o.p)(t.data.createdAt)}),(0,j.jsxs)("div",{className:"mt-6 flex flex-col space-y-16",children:[(0,j.jsx)("div",{children:(0,j.jsx)("div",{className:"bg-white shadow overflow-hidden sm:rounded-lg",children:(0,j.jsx)("div",{className:"px-4 py-5 sm:px-6",children:(0,j.jsx)("div",{className:"mt-1 max-w-2xl text-sm text-gray-500",children:(0,j.jsx)(s.Xz,{value:t.data.content})})})})}),(0,j.jsxs)("a",{href:"mailto:".concat(t.data.email),className:"flex flex-row space-x-2 text-gray-600",children:[(0,j.jsx)(m,{})," ",(0,j.jsx)("span",{children:"Reply From Mail"})]}),(0,j.jsx)("div",{})]})]})]}):null},w=function(){return p.o.get("/messages")},b=n(4165),M=n(5861),k=n(4430),Z=n(803),N=n(3777),O=n(7889),A=function(e){var t=e.messageId;return p.o.delete("/messages/".concat(t))};A.propTypes={messageId:u().string.isRequired};var E=function(e){var t=e.id,n=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,O.G)().addNotification;return(0,v.useMutation)((0,x.Z)((0,x.Z)({onMutate:function(){var e=(0,M.Z)((0,b.Z)().mark((function e(t){var n;return(0,b.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N.E.cancelQueries("messages");case 2:return n=N.E.getQueryData("messages"),N.E.setQueryData("messages",null===n||void 0===n?void 0:n.filter((function(e){return e.id!==t.messageId}))),e.abrupt("return",{previousMessages: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.previousMessages&&N.E.setQueryData("messages",n.previousMessages)},onSuccess:function(){N.E.invalidateQueries("messages"),t({type:"success",title:"Message Deleted"})}},e),{},{mutationFn:A}))}();return(0,j.jsx)(k._n,{allowedRoles:[k.K$.ADMIN],children:(0,j.jsx)(s.U6,{icon:"danger",title:"Delete Message",body:"Are you sure you want to delete this Message?",triggerButton:(0,j.jsx)(s.zx,{variant:"danger",children:(0,j.jsx)(Z.Z,{className:"h-4 w-4"})}),confirmButton:(0,j.jsx)(s.zx,{isLoading:n.isLoading,type:"button",className:"bg-red-600",onClick:(0,M.Z)((0,b.Z)().mark((function e(){return(0,b.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.mutateAsync({messageId:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Message"})})})},I=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,v.useQuery)((0,x.Z)((0,x.Z)({},e),{},{queryKey:["messages"],queryFn:function(){return w()}}))}();return e.isLoading?(0,j.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,j.jsx)(s.$j,{size:"lg"})}):e.data?(0,j.jsx)(s.iA,{data:e.data,columns:[{title:"Subject",field:"subject"},{title:"Created At",field:"createdAt",Cell:function(e){var t=e.entry.createdAt;return(0,j.jsx)("span",{children:(0,o.p)(t)})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return(0,j.jsx)(s.rU,{to:"./".concat(t),children:"View"})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return(0,j.jsx)(E,{id:t})}}]}):null},z=function(){return(0,j.jsx)(i.D,{title:"Messages",children:(0,j.jsx)("div",{className:"mt-4",children:(0,j.jsx)(I,{})})})},C=function(){return(0,j.jsxs)(r.Z5,{children:[(0,j.jsx)(r.AW,{path:"",element:(0,j.jsx)(z,{})}),(0,j.jsx)(r.AW,{path:":messageId",element:(0,j.jsx)(y,{})}),(0,j.jsx)(r.AW,{path:"*",element:(0,j.jsx)(r.Fg,{to:"."})})]})}},803:function(e,t,n){var r=n(2791);var s=r.forwardRef((function(e,t){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:t},e),r.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"}))}));t.Z=s}}]);
//# sourceMappingURL=334.40b7e34b.chunk.js.map