Your IP : 3.135.193.70


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

(this["webpackJsonpncdc-admin"]=this["webpackJsonpncdc-admin"]||[]).push([[8],{731:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var a=n(732),r=n.n(a),i=n(6),s=n.n(i),c=function(e){return r()(e).format("MMMM D, YYYY h:mm A")};c.propTypes={date:s.a.string.isRequired}},732:function(e,t,n){e.exports=function(){"use strict";var e=1e3,t=6e4,n=36e5,a="millisecond",r="second",i="minute",s="hour",c="day",u="week",o="month",d="quarter",l="year",f="date",m="Invalid Date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,g=/\[([^\]]+)]|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,j={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("_")},b=function(e,t,n){var a=String(e);return!a||a.length>=t?e:""+Array(t+1-a.length).join(n)+e},p={s:b,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),a=Math.floor(n/60),r=n%60;return(t<=0?"+":"-")+b(a,2,"0")+":"+b(r,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var a=12*(n.year()-t.year())+(n.month()-t.month()),r=t.clone().add(a,o),i=n-r<0,s=t.clone().add(a+(i?-1:1),o);return+(-(a+(n-r)/(i?r-s:s-r))||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:s,m:i,s:r,ms:a,Q:d}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},v="en",O={};O[v]=j;var y=function(e){return e instanceof D},x=function(e,t,n){var a;if(!e)return v;if("string"==typeof e)O[e]&&(a=e),t&&(O[e]=t,a=e);else{var r=e.name;O[r]=e,a=r}return!n&&a&&(v=a),a||!n&&v},$=function(e,t){if(y(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new D(n)},M=p;M.l=x,M.i=y,M.w=function(e,t){return $(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var D=function(){function j(e){this.$L=x(e.locale,null,!0),this.parse(e)}var b=j.prototype;return b.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(M.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var a=t.match(h);if(a){var r=a[2]-1||0,i=(a[7]||"0").substring(0,3);return n?new Date(Date.UTC(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,i)):new Date(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,i)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},b.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()},b.$utils=function(){return M},b.isValid=function(){return!(this.$d.toString()===m)},b.isSame=function(e,t){var n=$(e);return this.startOf(t)<=n&&n<=this.endOf(t)},b.isAfter=function(e,t){return $(e)<this.startOf(t)},b.isBefore=function(e,t){return this.endOf(t)<$(e)},b.$g=function(e,t,n){return M.u(e)?this[t]:this.set(n,e)},b.unix=function(){return Math.floor(this.valueOf()/1e3)},b.valueOf=function(){return this.$d.getTime()},b.startOf=function(e,t){var n=this,a=!!M.u(t)||t,d=M.p(e),m=function(e,t){var r=M.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return a?r:r.endOf(c)},h=function(e,t){return M.w(n.toDate()[e].apply(n.toDate("s"),(a?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},g=this.$W,j=this.$M,b=this.$D,p="set"+(this.$u?"UTC":"");switch(d){case l:return a?m(1,0):m(31,11);case o:return a?m(1,j):m(0,j+1);case u:var v=this.$locale().weekStart||0,O=(g<v?g+7:g)-v;return m(a?b-O:b+(6-O),j);case c:case f:return h(p+"Hours",0);case s:return h(p+"Minutes",1);case i:return h(p+"Seconds",2);case r:return h(p+"Milliseconds",3);default:return this.clone()}},b.endOf=function(e){return this.startOf(e,!1)},b.$set=function(e,t){var n,u=M.p(e),d="set"+(this.$u?"UTC":""),m=(n={},n[c]=d+"Date",n[f]=d+"Date",n[o]=d+"Month",n[l]=d+"FullYear",n[s]=d+"Hours",n[i]=d+"Minutes",n[r]=d+"Seconds",n[a]=d+"Milliseconds",n)[u],h=u===c?this.$D+(t-this.$W):t;if(u===o||u===l){var g=this.clone().set(f,1);g.$d[m](h),g.init(),this.$d=g.set(f,Math.min(this.$D,g.daysInMonth())).$d}else m&&this.$d[m](h);return this.init(),this},b.set=function(e,t){return this.clone().$set(e,t)},b.get=function(e){return this[M.p(e)]()},b.add=function(a,d){var f,m=this;a=Number(a);var h=M.p(d),g=function(e){var t=$(m);return M.w(t.date(t.date()+Math.round(e*a)),m)};if(h===o)return this.set(o,this.$M+a);if(h===l)return this.set(l,this.$y+a);if(h===c)return g(1);if(h===u)return g(7);var j=(f={},f[i]=t,f[s]=n,f[r]=e,f)[h]||1,b=this.$d.getTime()+a*j;return M.w(b,this)},b.subtract=function(e,t){return this.add(-1*e,t)},b.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||m;var a=e||"YYYY-MM-DDTHH:mm:ssZ",r=M.z(this),i=this.$H,s=this.$m,c=this.$M,u=n.weekdays,o=n.months,d=function(e,n,r,i){return e&&(e[n]||e(t,a))||r[n].substr(0,i)},l=function(e){return M.s(i%12||12,e,"0")},f=n.meridiem||function(e,t,n){var a=e<12?"AM":"PM";return n?a.toLowerCase():a},h={YY:String(this.$y).slice(-2),YYYY:this.$y,M:c+1,MM:M.s(c+1,2,"0"),MMM:d(n.monthsShort,c,o,3),MMMM:d(o,c),D:this.$D,DD:M.s(this.$D,2,"0"),d:String(this.$W),dd:d(n.weekdaysMin,this.$W,u,2),ddd:d(n.weekdaysShort,this.$W,u,3),dddd:u[this.$W],H:String(i),HH:M.s(i,2,"0"),h:l(1),hh:l(2),a:f(i,s,!0),A:f(i,s,!1),m:String(s),mm:M.s(s,2,"0"),s:String(this.$s),ss:M.s(this.$s,2,"0"),SSS:M.s(this.$ms,3,"0"),Z:r};return a.replace(g,(function(e,t){return t||h[e]||r.replace(":","")}))},b.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},b.diff=function(a,f,m){var h,g=M.p(f),j=$(a),b=(j.utcOffset()-this.utcOffset())*t,p=this-j,v=M.m(this,j);return v=(h={},h[l]=v/12,h[o]=v,h[d]=v/3,h[u]=(p-b)/6048e5,h[c]=(p-b)/864e5,h[s]=p/n,h[i]=p/t,h[r]=p/e,h)[g]||p,m?v:M.a(v)},b.daysInMonth=function(){return this.endOf(o).$D},b.$locale=function(){return O[this.$L]},b.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),a=x(e,t,!0);return a&&(n.$L=a),n},b.clone=function(){return M.w(this.$d,this)},b.toDate=function(){return new Date(this.valueOf())},b.toJSON=function(){return this.isValid()?this.toISOString():null},b.toISOString=function(){return this.$d.toISOString()},b.toString=function(){return this.$d.toUTCString()},j}(),w=D.prototype;return $.prototype=w,[["$ms",a],["$s",r],["$m",i],["$H",s],["$W",c],["$M",o],["$y",l],["$D",f]].forEach((function(e){w[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),$.extend=function(e,t){return e.$i||(e(t,D,$),e.$i=!0),$},$.locale=x,$.isDayjs=y,$.unix=function(e){return $(1e3*e)},$.en=O[v],$.Ls=O,$.p={},$}()},739:function(e,t,n){"use strict";n.r(t),n.d(t,"ManagersRoutes",(function(){return z}));var a=n(15),r=n(29),i=n(61),s=n(96),c=n(731),u=n(18),o=n(47),d=n(721),l=function(e){var t=e.managerId,n=e.config;return Object(d.a)(Object(u.a)(Object(u.a)({},n),{},{queryKey:["manager",t],queryFn:function(){return function(e){var t=e.managerId;return o.a.get("/managers/".concat(t))}({managerId:t})}}))},f=n(13),m=n.n(f),h=n(23),g=n(28),j=n(98),b=n(48),p=n(99),v=n(0),O=n(97),y=n(171),x=n(95),$=n(6),M=n.n($),D=n(170),w=function(e){var t=e.data,n=e.managerId;return o.a.patch("/managers/".concat(n),t)};w.propTypes={data:M.a.shape({name:M.a.string.isRequired,image:M.a.string}).isRequired,managerId:M.a.string.isRequired};var S=n(2),I=O.a({name:O.b().min(1,"Required")}),N=function(e){var t,n=e.managerId,a=Object(v.useState)(null),i=Object(g.a)(a,2),s=i[0],c=i[1],o=Object(v.useState)(null),d=Object(g.a)(o,2),f=d[0],O=d[1],$=l({managerId:n}),M=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(x.a)().addNotification;return Object(D.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(h.a)(m.a.mark((function e(t){var n;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.a.cancelQueries(["manager",null===t||void 0===t?void 0:t.managerId]);case 2:return n=y.a.getQueryData[null===t||void 0===t?void 0:t.managerId],y.a.setQueryData(["manager",null===t||void 0===t?void 0:t.managerId],Object(u.a)(Object(u.a)(Object(u.a)({},n),t.data),{},{id:t.managerId})),e.abrupt("return",{previousManager: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?void 0:n.previousManager)&&y.a.setQueryData(["manager",n.previousManager.id],n.previousManager)},onSuccess:function(e){y.a.refetchQueries(["manager",e.id]),t({type:"success",title:"Manager Updated"})}},e),{},{mutationFn:w}))}();return Object(S.jsx)(b.a,{allowedRoles:[b.c.ADMIN],children:Object(S.jsx)(j.c,{size:"sm",isDone:M.isSuccess,triggerButton:Object(S.jsx)(r.a,{startIcon:Object(S.jsx)(p.a,{className:"h-4 w-4"}),size:"sm",children:"Update"}),title:"Update Manager",submitButton:Object(S.jsx)(r.a,{form:"update-manager",type:"submit",size:"sm",isLoading:M.isLoading,children:"Submit"}),children:Object(S.jsx)(j.b,{id:"update-manager",encType:"multipart/form-data",onSubmit:function(){var e=Object(h.a)(m.a.mark((function e(t){var a,r;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.name,(r=new FormData).append("name",a),r.append("image",s),e.next=6,M.mutateAsync({data:r,managerId:n});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),options:{defaultValues:{name:null===(t=$.data)||void 0===t?void 0:t.name}},schema:I,children:function(e){var t=e.register,n=e.formState;return Object(S.jsxs)(S.Fragment,{children:[Object(S.jsx)(j.d,{label:"Name",error:n.errors.name,registration:t("name")}),Object(S.jsx)(j.g,{title:"Update Manager's Profile Image",subTitle:"Upload clear image for better visibility",error:n.errors.image,x:500,y:500,onChange:function(e){c(e.target.files[0]),O(URL.createObjectURL(e.target.files[0]))},preview:f})]})}})})})},_=function(){var e=Object(a.j)().managerId,t=l({managerId:e});return t.isLoading?Object(S.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:Object(S.jsx)(r.e,{size:"lg"})}):t.data?Object(S.jsxs)(S.Fragment,{children:[Object(S.jsx)(i.a,{title:t.data.name}),Object(S.jsxs)(s.a,{title:t.data.name,button:Object(S.jsx)(N,{managerId:e}),children:[Object(S.jsxs)("span",{className:"text-xs font-bold text-gray-500",children:["Added on ",Object(c.a)(t.data.createdAt)]}),Object(S.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:Object(S.jsx)("div",{className:"mx-auto p-2 bg-gray-300 rounded-md",children:Object(S.jsx)("img",{src:"http://localhost:5000/uploads/managers/resized/".concat(t.data.image),alt:"manager head profile avatar",className:""})})})]})]}):null},L=n(21),T=n(22),A=function(e){var t=e.data;return o.a.post("/managers",t)};A.propTypes={data:M.a.shape({name:M.a.string.isRequired,image:M.a.string}).isRequired};var R=O.a({name:O.b().min(1,"Required")}),Y=function(){var e=Object(v.useState)(null),t=Object(g.a)(e,2),n=t[0],a=t[1],i=Object(v.useState)(null),s=Object(g.a)(i,2),c=s[0],o=s[1],d=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(x.a)().addNotification;return Object(D.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(h.a)(m.a.mark((function e(t){var n;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.a.cancelQueries("managers");case 2:return n=y.a.getQueryData("managers"),y.a.setQueryData("managers",[].concat(Object(T.a)(n||[]),[t.data])),e.abrupt("return",{previousManagers: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?void 0:n.previousManagers)&&y.a.setQueryData("managers",n.previousManagers)},onSuccess:function(){y.a.invalidateQueries("managers"),t({type:"success",title:"Manager Created"})}},e),{},{mutationFn:A}))}();return Object(S.jsx)(b.a,{allowedRoles:[b.c.ADMIN],children:Object(S.jsx)(j.c,{size:"sm",isDone:d.isSuccess,triggerButton:Object(S.jsx)(r.a,{size:"sm",startIcon:Object(S.jsx)(L.i,{className:"h-4 w-4"}),children:"Create Manager"}),title:"Create Manager",submitButton:Object(S.jsx)(r.a,{form:"create-manager",type:"submit",size:"sm",isLoading:d.isLoading,children:"Submit"}),children:Object(S.jsx)(j.b,{id:"create-manager",encType:"multipart/form-data",onSubmit:function(){var e=Object(h.a)(m.a.mark((function e(t){var a,r;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.name,(r=new FormData).append("name",a),r.append("image",n),e.next=6,d.mutateAsync({data:r});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),schema:R,children:function(e){var t=e.register,n=e.formState;return Object(S.jsxs)(S.Fragment,{children:[Object(S.jsx)(j.d,{label:"Name",error:n.errors.name,registration:t("name")}),Object(S.jsx)(j.g,{title:"Upload Manager's Profile Image",subTitle:"Upload clear image for better visibility",error:n.errors.image,x:500,y:500,onChange:function(e){a(e.target.files[0]),o(URL.createObjectURL(e.target.files[0]))},preview:c})]})}})})})},Q=n(20),U=function(){return o.a.get("/managers")},k=function(e){var t=e.managerId;return o.a.delete("/managers/".concat(t))};k.propTypes={managerId:M.a.string.isRequired};var C=function(e){var t=e.id,n=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(x.a)().addNotification;return Object(D.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(h.a)(m.a.mark((function e(t){var n;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.a.cancelQueries("managers");case 2:return n=y.a.getQueryData("managers"),y.a.setQueryData("managers",null===n||void 0===n?void 0:n.filter((function(e){return e.id!==t.managerId}))),e.abrupt("return",{previousManagers: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?void 0:n.previousManagers)&&y.a.setQueryData("managers",n.previousManagers)},onSuccess:function(){y.a.invalidateQueries("managers"),t({type:"success",title:"Manager Deleted"})}},e),{},{mutationFn:k}))}();return Object(S.jsx)(b.a,{allowedRoles:[b.c.ADMIN],children:Object(S.jsx)(r.b,{icon:"danger",title:"Delete Manager",body:"Are you sure you want to delete this Manager?",triggerButton:Object(S.jsx)(r.a,{variant:"danger",children:Object(S.jsx)(L.j,{className:"h-4 w-4"})}),confirmButton:Object(S.jsx)(r.a,{isLoading:n.isLoading,type:"button",className:"bg-red-600",onClick:Object(h.a)(m.a.mark((function e(){return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.mutateAsync({managerId:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Manager"})})})},q=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:["managers"],queryFn:function(){return U()}}))}();return e.isLoading?Object(S.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:Object(S.jsx)(r.e,{size:"lg"})}):e.data?Object(S.jsx)(r.f,{data:e.data,columns:[{title:"Manager",field:"_id",Cell:function(e){var t=e.entry,n=t._id,a=t.name,r=t.image;return Object(S.jsx)(Q.b,{to:"./".concat(n),children:Object(S.jsxs)("div",{className:"flex flex-row space-x-3 items-center",children:[Object(S.jsx)("img",{src:"http://localhost:5000/uploads/managers/resized/".concat(r),alt:"manager",className:"h-8 w-8 rounded-full"}),Object(S.jsx)("div",{className:"text-sm font-bold",children:a})]})})}},{title:"...",field:"_id",Cell:function(e){var t=e.entry._id;return Object(S.jsx)(C,{id:t})}}]}):null},F=function(){return Object(S.jsx)(s.a,{title:"Managers",button:Object(S.jsx)(Y,{}),children:Object(S.jsx)("div",{className:"mt-4",children:Object(S.jsx)(q,{})})})},z=function(){return Object(S.jsxs)(a.e,{children:[Object(S.jsx)(a.c,{path:"",element:Object(S.jsx)(F,{})}),Object(S.jsx)(a.c,{path:":managerId",element:Object(S.jsx)(_,{})}),Object(S.jsx)(a.c,{path:"*",element:Object(S.jsx)(a.a,{to:"."})})]})}}}]);
//# sourceMappingURL=8.9628b85d.chunk.js.map