Your IP : 18.191.234.61


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

(this["webpackJsonpncdc-admin"]=this["webpackJsonpncdc-admin"]||[]).push([[11],{731:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(732),i=r.n(n),s=r(6),a=r.n(s),c=function(e){return i()(e).format("MMMM D, YYYY h:mm A")};c.propTypes={date:a.a.string.isRequired}},732:function(e,t,r){e.exports=function(){"use strict";var e=1e3,t=6e4,r=36e5,n="millisecond",i="second",s="minute",a="hour",c="day",u="week",o="month",d="quarter",l="year",f="date",v="Invalid Date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,j=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},p=function(e,t,r){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(r)+e},m={s:p,z:function(e){var t=-e.utcOffset(),r=Math.abs(t),n=Math.floor(r/60),i=r%60;return(t<=0?"+":"-")+p(n,2,"0")+":"+p(i,2,"0")},m:function e(t,r){if(t.date()<r.date())return-e(r,t);var n=12*(r.year()-t.year())+(r.month()-t.month()),i=t.clone().add(n,o),s=r-i<0,a=t.clone().add(n+(s?-1:1),o);return+(-(n+(r-i)/(s?i-a:a-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:o,y:l,w:u,d:c,D:f,h:a,m:s,s:i,ms:n,Q:d}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},O="en",g={};g[O]=b;var x=function(e){return e instanceof w},y=function(e,t,r){var n;if(!e)return O;if("string"==typeof e)g[e]&&(n=e),t&&(g[e]=t,n=e);else{var i=e.name;g[i]=e,n=i}return!r&&n&&(O=n),n||!r&&O},$=function(e,t){if(x(e))return e.clone();var r="object"==typeof t?t:{};return r.date=e,r.args=arguments,new w(r)},S=m;S.l=y,S.i=x,S.w=function(e,t){return $(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var w=function(){function b(e){this.$L=y(e.locale,null,!0),this.parse(e)}var p=b.prototype;return p.parse=function(e){this.$d=function(e){var t=e.date,r=e.utc;if(null===t)return new Date(NaN);if(S.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var n=t.match(h);if(n){var i=n[2]-1||0,s=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,s)):new Date(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,s)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},p.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},p.$utils=function(){return S},p.isValid=function(){return!(this.$d.toString()===v)},p.isSame=function(e,t){var r=$(e);return this.startOf(t)<=r&&r<=this.endOf(t)},p.isAfter=function(e,t){return $(e)<this.startOf(t)},p.isBefore=function(e,t){return this.endOf(t)<$(e)},p.$g=function(e,t,r){return S.u(e)?this[t]:this.set(r,e)},p.unix=function(){return Math.floor(this.valueOf()/1e3)},p.valueOf=function(){return this.$d.getTime()},p.startOf=function(e,t){var r=this,n=!!S.u(t)||t,d=S.p(e),v=function(e,t){var i=S.w(r.$u?Date.UTC(r.$y,t,e):new Date(r.$y,t,e),r);return n?i:i.endOf(c)},h=function(e,t){return S.w(r.toDate()[e].apply(r.toDate("s"),(n?[0,0,0,0]:[23,59,59,999]).slice(t)),r)},j=this.$W,b=this.$M,p=this.$D,m="set"+(this.$u?"UTC":"");switch(d){case l:return n?v(1,0):v(31,11);case o:return n?v(1,b):v(0,b+1);case u:var O=this.$locale().weekStart||0,g=(j<O?j+7:j)-O;return v(n?p-g:p+(6-g),b);case c:case f:return h(m+"Hours",0);case a:return h(m+"Minutes",1);case s:return h(m+"Seconds",2);case i:return h(m+"Milliseconds",3);default:return this.clone()}},p.endOf=function(e){return this.startOf(e,!1)},p.$set=function(e,t){var r,u=S.p(e),d="set"+(this.$u?"UTC":""),v=(r={},r[c]=d+"Date",r[f]=d+"Date",r[o]=d+"Month",r[l]=d+"FullYear",r[a]=d+"Hours",r[s]=d+"Minutes",r[i]=d+"Seconds",r[n]=d+"Milliseconds",r)[u],h=u===c?this.$D+(t-this.$W):t;if(u===o||u===l){var j=this.clone().set(f,1);j.$d[v](h),j.init(),this.$d=j.set(f,Math.min(this.$D,j.daysInMonth())).$d}else v&&this.$d[v](h);return this.init(),this},p.set=function(e,t){return this.clone().$set(e,t)},p.get=function(e){return this[S.p(e)]()},p.add=function(n,d){var f,v=this;n=Number(n);var h=S.p(d),j=function(e){var t=$(v);return S.w(t.date(t.date()+Math.round(e*n)),v)};if(h===o)return this.set(o,this.$M+n);if(h===l)return this.set(l,this.$y+n);if(h===c)return j(1);if(h===u)return j(7);var b=(f={},f[s]=t,f[a]=r,f[i]=e,f)[h]||1,p=this.$d.getTime()+n*b;return S.w(p,this)},p.subtract=function(e,t){return this.add(-1*e,t)},p.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return r.invalidDate||v;var n=e||"YYYY-MM-DDTHH:mm:ssZ",i=S.z(this),s=this.$H,a=this.$m,c=this.$M,u=r.weekdays,o=r.months,d=function(e,r,i,s){return e&&(e[r]||e(t,n))||i[r].substr(0,s)},l=function(e){return S.s(s%12||12,e,"0")},f=r.meridiem||function(e,t,r){var n=e<12?"AM":"PM";return r?n.toLowerCase():n},h={YY:String(this.$y).slice(-2),YYYY:this.$y,M:c+1,MM:S.s(c+1,2,"0"),MMM:d(r.monthsShort,c,o,3),MMMM:d(o,c),D:this.$D,DD:S.s(this.$D,2,"0"),d:String(this.$W),dd:d(r.weekdaysMin,this.$W,u,2),ddd:d(r.weekdaysShort,this.$W,u,3),dddd:u[this.$W],H:String(s),HH:S.s(s,2,"0"),h:l(1),hh:l(2),a:f(s,a,!0),A:f(s,a,!1),m:String(a),mm:S.s(a,2,"0"),s:String(this.$s),ss:S.s(this.$s,2,"0"),SSS:S.s(this.$ms,3,"0"),Z:i};return n.replace(j,(function(e,t){return t||h[e]||i.replace(":","")}))},p.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},p.diff=function(n,f,v){var h,j=S.p(f),b=$(n),p=(b.utcOffset()-this.utcOffset())*t,m=this-b,O=S.m(this,b);return O=(h={},h[l]=O/12,h[o]=O,h[d]=O/3,h[u]=(m-p)/6048e5,h[c]=(m-p)/864e5,h[a]=m/r,h[s]=m/t,h[i]=m/e,h)[j]||m,v?O:S.a(O)},p.daysInMonth=function(){return this.endOf(o).$D},p.$locale=function(){return g[this.$L]},p.locale=function(e,t){if(!e)return this.$L;var r=this.clone(),n=y(e,t,!0);return n&&(r.$L=n),r},p.clone=function(){return S.w(this.$d,this)},p.toDate=function(){return new Date(this.valueOf())},p.toJSON=function(){return this.isValid()?this.toISOString():null},p.toISOString=function(){return this.$d.toISOString()},p.toString=function(){return this.$d.toUTCString()},b}(),D=w.prototype;return $.prototype=D,[["$ms",n],["$s",i],["$m",s],["$H",a],["$W",c],["$M",o],["$y",l],["$D",f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),$.extend=function(e,t){return e.$i||(e(t,w,$),e.$i=!0),$},$.locale=y,$.isDayjs=x,$.unix=function(e){return $(1e3*e)},$.en=g[O],$.Ls=g,$.p={},$}()},740:function(e,t,r){"use strict";r.r(t),r.d(t,"ServicesRoutes",(function(){return k}));var n=r(15),i=r(29),s=r(61),a=r(96),c=r(731),u=r(18),o=r(47),d=r(721),l=function(e){var t=e.serviceId,r=e.config;return Object(d.a)(Object(u.a)(Object(u.a)({},r),{},{queryKey:["service",t],queryFn:function(){return function(e){var t=e.serviceId;return o.a.get("/services/".concat(t))}({serviceId:t})}}))},f=r(13),v=r.n(f),h=r(23),j=r(98),b=r(48),p=r(99),m=r(97),O=r(171),g=r(95),x=r(6),y=r.n(x),$=r(170),S=function(e){var t=e.data,r=e.serviceId;return o.a.patch("/services/".concat(r),t)};S.propTypes={data:y.a.shape({title:y.a.string.isRequired,desc:y.a.string.isRequired,image:y.a.string}).isRequired,serviceId:y.a.string.isRequired};var w=r(2),D=m.a({title:m.b().min(1,"Required"),desc:m.b().min(1,"Required")}),M=function(e){var t,r,n=e.serviceId,s=l({serviceId:n}),a=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(g.a)().addNotification;return Object($.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(h.a)(v.a.mark((function e(t){var r;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O.a.cancelQueries(["service",null===t||void 0===t?void 0:t.serviceId]);case 2:return r=O.a.getQueryData[null===t||void 0===t?void 0:t.serviceId],O.a.setQueryData(["service",null===t||void 0===t?void 0:t.serviceId],Object(u.a)(Object(u.a)(Object(u.a)({},r),t.data),{},{id:t.serviceId})),e.abrupt("return",{previousService: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?void 0:r.previousService)&&O.a.setQueryData(["service",r.previousService.id],r.previousService)},onSuccess:function(e){O.a.refetchQueries(["service",e.id]),t({type:"success",title:"Service Updated"})}},e),{},{mutationFn:S}))}();return Object(w.jsx)(b.a,{allowedRoles:[b.c.ADMIN],children:Object(w.jsx)(j.c,{size:"sm",isDone:a.isSuccess,triggerButton:Object(w.jsx)(i.a,{startIcon:Object(w.jsx)(p.a,{className:"h-4 w-4"}),size:"sm",children:"Update Service"}),title:"Update Service",submitButton:Object(w.jsx)(i.a,{form:"update-service",type:"submit",size:"sm",isLoading:a.isLoading,children:"Submit"}),children:Object(w.jsx)(j.b,{id:"update-service",onSubmit:function(){var e=Object(h.a)(v.a.mark((function e(t){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.mutateAsync({data:t,serviceId:n});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),options:{defaultValues:{title:null===(t=s.data)||void 0===t?void 0:t.title,desc:null===(r=s.data)||void 0===r?void 0:r.desc}},schema:D,children:function(e){var t=e.register,r=e.formState,n=e.watch,i=e.setValue;return Object(w.jsxs)(w.Fragment,{children:[Object(w.jsx)(j.d,{label:"Title",error:r.errors.title,registration:t("title")}),Object(w.jsx)(j.f,{label:"Content",error:r.errors.desc,editorContent:n("desc"),setValue:i,value:"desc"})]})}})})})},I=function(){var e=Object(n.j)().serviceId,t=l({serviceId:e});return t.isLoading?Object(w.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:Object(w.jsx)(i.e,{size:"lg"})}):t.data?Object(w.jsxs)(w.Fragment,{children:[Object(w.jsx)(s.a,{title:t.data.title}),Object(w.jsxs)(a.a,{title:t.data.title,button:Object(w.jsx)(M,{serviceId:e}),children:[Object(w.jsx)("span",{className:"text-xs font-bold",children:Object(c.a)(t.data.createdAt)}),Object(w.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:Object(w.jsx)("div",{children:Object(w.jsx)("div",{className:"bg-white shadow overflow-hidden sm:rounded-lg",children:Object(w.jsx)("div",{className:"px-4 py-5 sm:px-6",children:Object(w.jsx)("div",{className:"mt-1 max-w-2xl text-sm text-gray-500",children:Object(w.jsx)(i.d,{value:t.data.desc})})})})})})]})]}):null},N=r(21),_=r(22),A=function(e){var t=e.data;return o.a.post("/services",t)};A.propTypes={data:y.a.shape({title:y.a.string.isRequired,desc:y.a.string.isRequired,image:y.a.string}).isRequired};var C=m.a({title:m.b().min(1,"Required"),desc:m.b().min(1,"Required")}),q=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(g.a)().addNotification;return Object($.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(h.a)(v.a.mark((function e(t){var r;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O.a.cancelQueries("services");case 2:return r=O.a.getQueryData("services"),O.a.setQueryData("services",[].concat(Object(_.a)(r||[]),[t.data])),e.abrupt("return",{previousServices: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?void 0:r.previousServices)&&O.a.setQueryData("services",r.previousServices)},onSuccess:function(){O.a.invalidateQueries("services"),t({type:"success",title:"Service Created"})}},e),{},{mutationFn:A}))}();return Object(w.jsx)(b.a,{allowedRoles:[b.c.ADMIN],children:Object(w.jsx)(j.c,{size:"sm",isDone:e.isSuccess,triggerButton:Object(w.jsx)(i.a,{size:"sm",startIcon:Object(w.jsx)(N.i,{className:"h-4 w-4"}),children:"Create Service"}),title:"Create Service",submitButton:Object(w.jsx)(i.a,{form:"create-service",type:"submit",size:"sm",isLoading:e.isLoading,children:"Submit"}),children:Object(w.jsx)(j.b,{id:"create-service",onSubmit:function(){var t=Object(h.a)(v.a.mark((function t(r){return v.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.mutateAsync({data:r});case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),schema:C,children:function(e){var t=e.register,r=e.formState,n=e.setValue,i=e.watch;return Object(w.jsxs)(w.Fragment,{children:[Object(w.jsx)(j.d,{label:"Title",error:r.errors.title,registration:t("title")}),Object(w.jsx)(j.f,{label:"Content",error:r.errors.desc,editorContent:i("desc"),setValue:n,value:"desc"})]})}})})})},T=function(){return o.a.get("/services")},R=function(e){var t=e.serviceId;return o.a.delete("/services/".concat(t))};R.propTypes={serviceId:y.a.string.isRequired};var Y=function(e){var t=e.id,r=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(g.a)().addNotification;return Object($.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(h.a)(v.a.mark((function e(t){var r;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O.a.cancelQueries("services");case 2:return r=O.a.getQueryData("services"),O.a.setQueryData("services",null===r||void 0===r?void 0:r.filter((function(e){return e.id!==t.serviceId}))),e.abrupt("return",{previousServices: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?void 0:r.previousServices)&&O.a.setQueryData("services",r.previousServices)},onSuccess:function(){O.a.invalidateQueries("services"),t({type:"success",title:"Service Deleted"})}},e),{},{mutationFn:R}))}();return Object(w.jsx)(b.a,{allowedRoles:[b.c.ADMIN],children:Object(w.jsx)(i.b,{icon:"danger",title:"Delete Service",body:"Are you sure you want to delete this Service?",triggerButton:Object(w.jsx)(i.a,{variant:"danger",children:Object(w.jsx)(N.j,{className:"h-4 w-4"})}),confirmButton:Object(w.jsx)(i.a,{isLoading:r.isLoading,type:"button",className:"bg-red-600",onClick:Object(h.a)(v.a.mark((function e(){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.mutateAsync({serviceId:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Service"})})})},L=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return Object(d.a)(Object(u.a)(Object(u.a)({},e),{},{queryKey:["services"],queryFn:function(){return T()}}))}();return e.isLoading?Object(w.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:Object(w.jsx)(i.e,{size:"lg"})}):e.data?Object(w.jsx)(i.f,{data:e.data,columns:[{title:"Service",field:"title"},{title:"Created At",field:"createdAt",Cell:function(e){var t=e.entry.createdAt;return Object(w.jsx)("span",{children:Object(c.a)(t)})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return Object(w.jsx)(i.c,{to:"./".concat(t),children:"View"})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return Object(w.jsx)(Y,{id:t})}}]}):null},Q=function(){return Object(w.jsx)(a.a,{title:"Services",button:Object(w.jsx)(q,{}),children:Object(w.jsx)("div",{className:"mt-4",children:Object(w.jsx)(L,{})})})},k=function(){return Object(w.jsxs)(n.e,{children:[Object(w.jsx)(n.c,{path:"",element:Object(w.jsx)(Q,{})}),Object(w.jsx)(n.c,{path:":serviceId",element:Object(w.jsx)(I,{})}),Object(w.jsx)(n.c,{path:"*",element:Object(w.jsx)(n.a,{to:"."})})]})}}}]);
//# sourceMappingURL=11.45e616ec.chunk.js.map