Your IP : 3.144.119.149


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

"use strict";(self.webpackChunkpanel=self.webpackChunkpanel||[]).push([[28],{223:function(e,t,r){r(2791);var a=r(3504),n=r(2506),s=r(184);t.Z=function(e){var t=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)(a.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===t||void 0===t?void 0:t.map((function(e,t){return(0,s.jsxs)("li",{className:"inline-flex items-center",children:[(0,s.jsx)(n.Z,{size:10,className:"mr-4"}),(0,s.jsx)(a.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})]},t)}))]})})}},9028:function(e,t,r){r.r(t),r.d(t,{AdsRoutes:function(){return V}});var a=r(6871),n=r(9630),s=r(5528),i=r(2412),d=r(77),l=r(8592),o=r(7087),c=r(1413),u=r(6771),x=r(1933),p=function(e){var t=e.adId,r=e.config;return(0,x.useQuery)((0,c.Z)((0,c.Z)({},r),{},{queryKey:["ad",t],queryFn:function(){return function(e){var t=e.adId;return u.o.get("/adverts/".concat(t))}({adId:t})}}))},f=r(4165),v=r(5861),m=r(885),h=r(806),g=r(4430),j=r(8419),y=r(2791),b=r(9879),w=r(3777),Z=r(7889),A=r(2007),N=r.n(A),k=function(e){var t=e.data,r=e.adId;return u.o.patch("/adverts/".concat(r),t)};k.propTypes={data:N().shape({title:N().string,desc:N().string,image:N().string}).isRequired,adId:N().string.isRequired};var I=r(184),z=b.Ry({title:b.Z_(),desc:b.Z_()}),D=function(e){var t,r,a,s=e.adId,i=(0,y.useState)(null),d=(0,m.Z)(i,2),l=d[0],o=d[1],u=(0,y.useState)(null),b=(0,m.Z)(u,2),A=b[0],N=b[1],D=p({adId:s}),E=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,Z.G)().addNotification;return(0,x.useMutation)((0,c.Z)((0,c.Z)({onMutate:function(){var e=(0,v.Z)((0,f.Z)().mark((function e(t){var r;return(0,f.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.E.cancelQueries(["ad",null===t||void 0===t?void 0:t.adId]);case 2:return r=w.E.getQueryData[null===t||void 0===t?void 0:t.adId],w.E.setQueryData(["ad",null===t||void 0===t?void 0:t.adId],(0,c.Z)((0,c.Z)((0,c.Z)({},r),t.data),{},{id:t.adId})),e.abrupt("return",{previousAd:r});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),onError:function(e,t,r){null!==r&&void 0!==r&&r.previousAd&&w.E.setQueryData(["ad",r.previousAd.id],r.previousAd)},onSuccess:function(e){w.E.refetchQueries(["ad",e.id]),t({type:"success",title:"Ad Updated"})}},e),{},{mutationFn:k}))}();return E.isLoading?(0,I.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,I.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,I.jsx)(n.$j,{size:"sm"})})}):(0,I.jsx)(g._n,{allowedRoles:[g.K$.ADMIN],children:(0,I.jsx)(h._8,{size:"sm",isDone:E.isSuccess,triggerButton:(0,I.jsx)(n.zx,{variant:"create",startIcon:(0,I.jsx)(j.Z,{className:"h-4 w-4"}),size:"sm",children:"Update"}),title:"Update Advert",submitButton:(0,I.jsx)(n.zx,{form:"update-ad",type:"submit",size:"sm",isLoading:E.isLoading,children:"Submit"}),children:(0,I.jsx)(h.l0,{id:"update-ad",encType:"multipart/form-data",onSubmit:function(){var e=(0,v.Z)((0,f.Z)().mark((function e(t){var r,a,n;return(0,f.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.title,a=t.desc,(n=new FormData).append("title",r),n.append("desc",a),n.append("image",l),e.next=7,E.mutateAsync({data:n,adId:s});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),options:{defaultValues:{title:null===(t=D.data)||void 0===t?void 0:t.title,desc:null===(r=D.data)||void 0===r?void 0:r.desc,image:null===(a=D.data)||void 0===a?void 0:a.image}},schema:z,children:function(e){var t=e.register,r=e.formState,a=e.watch,n=e.setValue;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h.UP,{label:"Title",error:r.errors.title,registration:t("title")}),(0,I.jsx)(h.N7,{label:"Description",error:r.errors.desc,editorContent:a("desc"),setValue:n,value:"desc"}),(0,I.jsx)(h.VA,{title:"Update Banner Image",subTitle:"Upload clear image for better visibility",error:r.errors.image,x:1280,y:340,onChange:function(e){o(e.target.files[0]),N(URL.createObjectURL(e.target.files[0]))},preview:A})]})}})})})},E=r(223),L=function(){var e,t=(0,a.UO)().adId,r=p({adId:t});if(r.isLoading)return(0,I.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,I.jsx)(n.$j,{size:"lg"})});var c=[{name:"Banner Adverts",path:"/app/ads"},{name:null===(e=r.data)||void 0===e?void 0:e.title,path:""}];return r.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(s.F,{title:r.data._id}),(0,I.jsxs)(i.D,{title:r.data.title,button:(0,I.jsx)(D,{adId:t}),children:[(0,I.jsxs)("span",{className:"text-xs font-bold text-gray-500",children:["Advert created on ",(0,l.p)(r.data.createdAt)]}),(0,I.jsx)(E.Z,{routes:c}),(0,I.jsx)("div",{className:"mt-6 flex flex-col  dark:bg-gray-700 space-y-16",children:(0,I.jsx)(o.LazyLoadImage,{src:"".concat(d.tC,"/").concat(r.data.image),alt:r.data.title,className:"w-full h-full"})}),(0,I.jsxs)("div",{className:"mt-4",children:[(0,I.jsx)("div",{className:"text-sm text-gray-400 font-bold mb-4",children:"Description"}),(0,I.jsx)("div",{className:"text-gray-500 bg-white p-4",children:(0,I.jsx)(n.Xz,{value:r.data.desc})})]})]})]}):null},R=r(3504),U=function(){return u.o.get("/adverts")},Q=function(e){var t=e.adId;return u.o.delete("/adverts/".concat(t))};Q.propTypes={adId:N().string.isRequired};var C=function(e){var t=e.id,r=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,Z.G)().addNotification;return(0,x.useMutation)((0,c.Z)((0,c.Z)({onMutate:function(){var e=(0,v.Z)((0,f.Z)().mark((function e(t){var r;return(0,f.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.E.cancelQueries("ads");case 2:return r=w.E.getQueryData("ads"),w.E.setQueryData("ads",null===r||void 0===r?void 0:r.filter((function(e){return e.id!==t.managerId}))),e.abrupt("return",{previousAds:r});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),onError:function(e,t,r){null!==r&&void 0!==r&&r.previousAds&&w.E.setQueryData("ads",r.previousAds)},onSuccess:function(){w.E.invalidateQueries("ads"),t({type:"success",title:"Ad Deleted"})}},e),{},{mutationFn:Q}))}();return r.isLoading?(0,I.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,I.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,I.jsx)(n.$j,{size:"sm"})})}):(0,I.jsx)(g._n,{allowedRoles:[g.K$.ADMIN],children:(0,I.jsx)(n.U6,{icon:"danger",title:"Delete Advert",body:"Are you sure you want to delete this Advert?",triggerButton:(0,I.jsx)("button",{children:"Remove"}),confirmButton:(0,I.jsx)(n.zx,{isLoading:r.isLoading,type:"button",className:"bg-red-600",onClick:(0,v.Z)((0,f.Z)().mark((function e(){return(0,f.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.mutateAsync({adId:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Advert"})})})},B=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,x.useQuery)((0,c.Z)((0,c.Z)({},e),{},{queryKey:["ads"],queryFn:function(){return U()}}))}();return e.isLoading?(0,I.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,I.jsx)(n.$j,{size:"lg"})}):e.data?(0,I.jsx)(n.iA,{data:e.data,columns:[{title:"Lists",field:"_id",Cell:function(e){var t=e.entry,r=t._id,a=t.title,n=t.createdAt;return(0,I.jsxs)(R.rU,{to:"./".concat(r),children:[(0,I.jsx)("span",{className:"text-gray-400 text-md",children:a}),(0,I.jsx)("span",{className:"mx-4 text-gray-200 text-xs",children:(0,l.p)(n)})]})}},{title:"...",field:"_id",Cell:function(e){var t=e.entry._id;return(0,I.jsx)(C,{id:t})}}]}):null},S=r(2076),_=r(2982),M=function(e){var t=e.data;return u.o.post("/adverts",t)};M.propTypes={data:N().shape({title:N().string.isRequired,desc:N().string.isRequired,image:N().string.isRequired}).isRequired};var F=b.Ry({title:b.Z_(),desc:b.Z_()}),q=function(){var e=(0,y.useState)(null),t=(0,m.Z)(e,2),r=t[0],a=t[1],s=(0,y.useState)(null),i=(0,m.Z)(s,2),d=i[0],l=i[1],o=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,Z.G)().addNotification;return(0,x.useMutation)((0,c.Z)((0,c.Z)({onMutate:function(){var e=(0,v.Z)((0,f.Z)().mark((function e(t){var r;return(0,f.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.E.cancelQueries("ads");case 2:return r=w.E.getQueryData("ads"),w.E.setQueryData("ads",[].concat((0,_.Z)(r||[]),[t.data])),e.abrupt("return",{previousAds:r});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),onError:function(e,t,r){null!==r&&void 0!==r&&r.previousAds&&w.E.setQueryData("ads",r.previousAds)},onSuccess:function(){w.E.invalidateQueries("ads"),t({type:"success",title:"New ad successfully created"})}},e),{},{mutationFn:M}))}();return o.isLoading?(0,I.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,I.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,I.jsx)(n.$j,{size:"sm"})})}):(0,I.jsx)(g._n,{allowedRoles:[g.K$.ADMIN],children:(0,I.jsx)(h._8,{size:"sm",isDone:o.isSuccess,triggerButton:(0,I.jsx)(n.zx,{variant:"create",size:"sm",startIcon:(0,I.jsx)(S.Z,{className:"h-4 w-4"}),children:"Create Advert"}),title:"Create New Advert",submitButton:(0,I.jsx)(n.zx,{form:"create-ad",type:"submit",size:"sm",isLoading:o.isLoading,children:"Submit"}),children:(0,I.jsx)(h.l0,{id:"create-ad",encType:"multipart/form-data",onSubmit:function(){var e=(0,v.Z)((0,f.Z)().mark((function e(t){var a,n,s;return(0,f.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.title,n=t.desc,(s=new FormData).append("title",a),s.append("desc",n),s.append("image",r),e.next=7,o.mutateAsync({data:s});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),schema:F,children:function(e){var t=e.register,r=e.formState,n=e.watch,s=e.setValue;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h.UP,{label:"Title",error:r.errors.title,registration:t("title")}),(0,I.jsx)(h.N7,{label:"Content",error:r.errors.desc,editorContent:n("desc"),setValue:s,value:"desc"}),(0,I.jsx)(h.VA,{title:"Upload Ad Banner Image",subTitle:"Upload clear image for better visibility",error:r.errors.image,x:1280,y:340,onChange:function(e){a(e.target.files[0]),l(URL.createObjectURL(e.target.files[0]))},preview:d})]})}})})})},T=function(){return(0,I.jsxs)(i.D,{title:"Banner Adverts",button:(0,I.jsx)(q,{}),children:[(0,I.jsx)(E.Z,{routes:[{name:"Banner Adverts",path:"."}]}),(0,I.jsx)("div",{className:"mt-4",children:(0,I.jsx)(B,{})})]})},V=function(){return(0,I.jsxs)(a.Z5,{children:[(0,I.jsx)(a.AW,{path:"",element:(0,I.jsx)(T,{})}),(0,I.jsx)(a.AW,{path:":adId",element:(0,I.jsx)(L,{})}),(0,I.jsx)(a.AW,{path:"*",element:(0,I.jsx)(a.Fg,{to:"."})})]})}},2076:function(e,t,r){var a=r(2791);var n=a.forwardRef((function(e,t){return a.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),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"}))}));t.Z=n},8419:function(e,t,r){var a=r(2791);var n=a.forwardRef((function(e,t){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),a.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=n}}]);
//# sourceMappingURL=28.7d8198d4.chunk.js.map