Current Path : /home/ncdcgo/admin.ncdc.go.ug/static/js/ |
Current File : /home/ncdcgo/admin.ncdc.go.ug/static/js/10.650f683d.chunk.js |
(this["webpackJsonpncdc-admin"]=this["webpackJsonpncdc-admin"]||[]).push([[10],{731:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(732),s=r.n(n),i=r(6),a=r.n(i),c=function(e){return s()(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",s="second",i="minute",a="hour",c="day",u="week",o="month",l="quarter",d="year",f="date",h="Invalid Date",j=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|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,p={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("_")},m=function(e,t,r){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(r)+e},v={s:m,z:function(e){var t=-e.utcOffset(),r=Math.abs(t),n=Math.floor(r/60),s=r%60;return(t<=0?"+":"-")+m(n,2,"0")+":"+m(s,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()),s=t.clone().add(n,o),i=r-s<0,a=t.clone().add(n+(i?-1:1),o);return+(-(n+(r-s)/(i?s-a:a-s))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:o,y:d,w:u,d:c,D:f,h:a,m:i,s:s,ms:n,Q:l}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},O="en",x={};x[O]=p;var g=function(e){return e instanceof w},y=function(e,t,r){var n;if(!e)return O;if("string"==typeof e)x[e]&&(n=e),t&&(x[e]=t,n=e);else{var s=e.name;x[s]=e,n=s}return!r&&n&&(O=n),n||!r&&O},$=function(e,t){if(g(e))return e.clone();var r="object"==typeof t?t:{};return r.date=e,r.args=arguments,new w(r)},D=v;D.l=y,D.i=g,D.w=function(e,t){return $(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var w=function(){function p(e){this.$L=y(e.locale,null,!0),this.parse(e)}var m=p.prototype;return m.parse=function(e){this.$d=function(e){var t=e.date,r=e.utc;if(null===t)return new Date(NaN);if(D.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(j);if(n){var s=n[2]-1||0,i=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,i)):new Date(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,i)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},m.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()},m.$utils=function(){return D},m.isValid=function(){return!(this.$d.toString()===h)},m.isSame=function(e,t){var r=$(e);return this.startOf(t)<=r&&r<=this.endOf(t)},m.isAfter=function(e,t){return $(e)<this.startOf(t)},m.isBefore=function(e,t){return this.endOf(t)<$(e)},m.$g=function(e,t,r){return D.u(e)?this[t]:this.set(r,e)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(e,t){var r=this,n=!!D.u(t)||t,l=D.p(e),h=function(e,t){var s=D.w(r.$u?Date.UTC(r.$y,t,e):new Date(r.$y,t,e),r);return n?s:s.endOf(c)},j=function(e,t){return D.w(r.toDate()[e].apply(r.toDate("s"),(n?[0,0,0,0]:[23,59,59,999]).slice(t)),r)},b=this.$W,p=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(l){case d:return n?h(1,0):h(31,11);case o:return n?h(1,p):h(0,p+1);case u:var O=this.$locale().weekStart||0,x=(b<O?b+7:b)-O;return h(n?m-x:m+(6-x),p);case c:case f:return j(v+"Hours",0);case a:return j(v+"Minutes",1);case i:return j(v+"Seconds",2);case s:return j(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(e){return this.startOf(e,!1)},m.$set=function(e,t){var r,u=D.p(e),l="set"+(this.$u?"UTC":""),h=(r={},r[c]=l+"Date",r[f]=l+"Date",r[o]=l+"Month",r[d]=l+"FullYear",r[a]=l+"Hours",r[i]=l+"Minutes",r[s]=l+"Seconds",r[n]=l+"Milliseconds",r)[u],j=u===c?this.$D+(t-this.$W):t;if(u===o||u===d){var b=this.clone().set(f,1);b.$d[h](j),b.init(),this.$d=b.set(f,Math.min(this.$D,b.daysInMonth())).$d}else h&&this.$d[h](j);return this.init(),this},m.set=function(e,t){return this.clone().$set(e,t)},m.get=function(e){return this[D.p(e)]()},m.add=function(n,l){var f,h=this;n=Number(n);var j=D.p(l),b=function(e){var t=$(h);return D.w(t.date(t.date()+Math.round(e*n)),h)};if(j===o)return this.set(o,this.$M+n);if(j===d)return this.set(d,this.$y+n);if(j===c)return b(1);if(j===u)return b(7);var p=(f={},f[i]=t,f[a]=r,f[s]=e,f)[j]||1,m=this.$d.getTime()+n*p;return D.w(m,this)},m.subtract=function(e,t){return this.add(-1*e,t)},m.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return r.invalidDate||h;var n=e||"YYYY-MM-DDTHH:mm:ssZ",s=D.z(this),i=this.$H,a=this.$m,c=this.$M,u=r.weekdays,o=r.months,l=function(e,r,s,i){return e&&(e[r]||e(t,n))||s[r].substr(0,i)},d=function(e){return D.s(i%12||12,e,"0")},f=r.meridiem||function(e,t,r){var n=e<12?"AM":"PM";return r?n.toLowerCase():n},j={YY:String(this.$y).slice(-2),YYYY:this.$y,M:c+1,MM:D.s(c+1,2,"0"),MMM:l(r.monthsShort,c,o,3),MMMM:l(o,c),D:this.$D,DD:D.s(this.$D,2,"0"),d:String(this.$W),dd:l(r.weekdaysMin,this.$W,u,2),ddd:l(r.weekdaysShort,this.$W,u,3),dddd:u[this.$W],H:String(i),HH:D.s(i,2,"0"),h:d(1),hh:d(2),a:f(i,a,!0),A:f(i,a,!1),m:String(a),mm:D.s(a,2,"0"),s:String(this.$s),ss:D.s(this.$s,2,"0"),SSS:D.s(this.$ms,3,"0"),Z:s};return n.replace(b,(function(e,t){return t||j[e]||s.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(n,f,h){var j,b=D.p(f),p=$(n),m=(p.utcOffset()-this.utcOffset())*t,v=this-p,O=D.m(this,p);return O=(j={},j[d]=O/12,j[o]=O,j[l]=O/3,j[u]=(v-m)/6048e5,j[c]=(v-m)/864e5,j[a]=v/r,j[i]=v/t,j[s]=v/e,j)[b]||v,h?O:D.a(O)},m.daysInMonth=function(){return this.endOf(o).$D},m.$locale=function(){return x[this.$L]},m.locale=function(e,t){if(!e)return this.$L;var r=this.clone(),n=y(e,t,!0);return n&&(r.$L=n),r},m.clone=function(){return D.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},p}(),M=w.prototype;return $.prototype=M,[["$ms",n],["$s",s],["$m",i],["$H",a],["$W",c],["$M",o],["$y",d],["$D",f]].forEach((function(e){M[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=g,$.unix=function(e){return $(1e3*e)},$.en=x[O],$.Ls=x,$.p={},$}()},741:function(e,t,r){"use strict";r.r(t),r.d(t,"ResourcesRoutes",(function(){return k}));var n=r(15),s=r(29),i=r(61),a=r(96),c=r(731),u=r(18),o=r(47),l=r(721),d=function(e){var t=e.resourceId,r=e.config;return Object(l.a)(Object(u.a)(Object(u.a)({},r),{},{queryKey:["resource",t],queryFn:function(){return function(e){var t=e.resourceId;return o.a.get("/resources/".concat(t))}({resourceId:t})}}))},f=r(2),h=function(){var e=Object(n.j)().resourceId,t=d({resourceId:e});return t.isLoading?Object(f.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:Object(f.jsx)(s.e,{size:"lg"})}):t.data?Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)(i.a,{title:t.data.title}),Object(f.jsxs)(a.a,{title:t.data.title,children:[Object(f.jsx)("span",{className:"text-xs font-bold",children:Object(c.a)(t.data.createdAt)}),Object(f.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:Object(f.jsx)("div",{children:Object(f.jsx)("div",{className:"bg-white shadow overflow-hidden sm:rounded-lg",children:Object(f.jsx)("div",{className:"px-4 py-5 sm:px-6",children:Object(f.jsxs)("div",{className:"mt-1 max-w-2xl text-sm text-gray-500",children:[Object(f.jsx)("span",{className:"font-bold text-lg",children:t.data.title}),Object(f.jsxs)("div",{className:"bg-gray-100 p-4 my-4",children:[Object(f.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),Object(f.jsx)(s.d,{value:t.data.desc})]}),Object(f.jsxs)("span",{children:["Curriculum: ",t.data.curriculum]}),Object(f.jsx)("br",{}),Object(f.jsxs)("span",{children:["Price: ",0===t.data.price?"Free":t.data.price]})]})})})})})]})]}):null},j=r(13),b=r.n(j),p=r(23),m=r(28),v=r(98),O=r(48),x=r(21),g=r(0),y=r(97),$=r(22),D=r(171),w=r(95),M=r(6),S=r.n(M),C=r(170),R=function(e){var t=e.data;return o.a.post("/resources",t)};R.propTypes={data:S.a.shape({title:S.a.string.isRequired,price:S.a.string,desc:S.a.string,curriculum:S.a.string.isRequired}).isRequired};var N=y.a({title:y.b().min(1,"Required"),curriculum:y.b().min(1,"Required"),price:y.b(),desc:y.b()}),_=function(){var e=Object(g.useState)(null),t=Object(m.a)(e,2),r=t[0],n=t[1],i=Object(g.useState)(null),a=Object(m.a)(i,2),c=a[0],o=a[1],l=[{label:"A Level Curriculum",value:"A Level Curriculum"},{label:"Primary Curriculum",value:"Primary Curriculum"},{label:"Secondary Curriculum",value:"Secondary Curriculum"}],d=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(w.a)().addNotification;return Object(C.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(p.a)(b.a.mark((function e(t){var r;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D.a.cancelQueries("resources");case 2:return r=D.a.getQueryData("resources"),D.a.setQueryData("resources",[].concat(Object($.a)(r||[]),[t.data])),e.abrupt("return",{previousResources: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.previousResources)&&D.a.setQueryData("resources",r.previousResources)},onSuccess:function(){D.a.invalidateQueries("resources"),t({type:"success",title:"Resource Created"})}},e),{},{mutationFn:R}))}();return Object(f.jsx)(O.a,{allowedRoles:[O.c.ADMIN],children:Object(f.jsx)(v.c,{size:"sm",isDone:d.isSuccess,triggerButton:Object(f.jsx)(s.a,{size:"sm",startIcon:Object(f.jsx)(x.i,{className:"h-4 w-4"}),children:"Create Resource"}),title:"Create Resource",submitButton:Object(f.jsx)(s.a,{form:"create-resource",type:"submit",size:"sm",isLoading:d.isLoading,children:"Submit"}),children:Object(f.jsx)(v.b,{id:"create-resource",encType:"multipart/form-data",onSubmit:function(){var e=Object(p.a)(b.a.mark((function e(t){var n,s,i,a,u;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.title,s=t.price,i=t.desc,a=t.curriculum,(u=new FormData).append("title",n),u.append("price",s),u.append("desc",i),u.append("curriculum",a),u.append("cover",c),u.append("resource",r),e.next=10,d.mutateAsync({data:u});case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),schema:N,children:function(e){var t=e.register,r=e.formState,s=e.watch,i=e.setValue;return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)(v.d,{label:"Title",error:r.errors.title,registration:t("title")}),Object(f.jsx)(v.f,{label:"Description",error:r.errors.desc,editorContent:s("desc"),setValue:i,value:"desc"}),Object(f.jsx)(v.d,{label:"Price",error:r.errors.price,registration:t("price")}),Object(f.jsx)(v.a,{label:"Upload Resource Cover Photo",accept:"image/*",error:r.errors.cover,onChange:function(e){o(e.target.files[0])}}),Object(f.jsx)(v.a,{label:"Upload Resource File",accept:"application/pdf",error:r.errors.resource,onChange:function(e){n(e.target.files[0])}}),Object(f.jsx)(v.e,{label:"Select Curriculum",error:r.errors.curriculum,registration:t("curriculum"),options:null===l||void 0===l?void 0:l.map((function(e){return{label:e.label,value:e.value}}))})]})}})})})},I=function(){return o.a.get("/resources")},A=function(e){var t=e.resourceId;return o.a.delete("/resources/".concat(t))};A.propTypes={resourceId:S.a.string.isRequired};var T=function(e){var t=e.id,r=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=Object(w.a)().addNotification;return Object(C.a)(Object(u.a)(Object(u.a)({onMutate:function(){var e=Object(p.a)(b.a.mark((function e(t){var r;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D.a.cancelQueries("resources");case 2:return r=D.a.getQueryData("resources"),D.a.setQueryData("resources",null===r||void 0===r?void 0:r.filter((function(e){return e.id!==t.resourceId}))),e.abrupt("return",{previousResources: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.previousResources)&&D.a.setQueryData("resources",r.previousResources)},onSuccess:function(){D.a.invalidateQueries("resources"),t({type:"success",title:"Resources Deleted"})}},e),{},{mutationFn:A}))}();return Object(f.jsx)(O.a,{allowedRoles:[O.c.ADMIN],children:Object(f.jsx)(s.b,{icon:"danger",title:"Delete Resource",body:"Are you sure you want to delete this Resource?",triggerButton:Object(f.jsx)(s.a,{variant:"danger",startIcon:Object(f.jsx)(x.j,{className:"h-4 w-4"}),children:"Delete Resource"}),confirmButton:Object(f.jsx)(s.a,{isLoading:r.isLoading,type:"button",className:"bg-red-600",onClick:Object(p.a)(b.a.mark((function e(){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.mutateAsync({resourceId:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Resource"})})})},Y=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return Object(l.a)(Object(u.a)(Object(u.a)({},e),{},{queryKey:["resources"],queryFn:function(){return I()}}))}();return e.isLoading?Object(f.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:Object(f.jsx)(s.e,{size:"lg"})}):e.data?Object(f.jsx)(s.f,{data:e.data,columns:[{title:"Title",field:"title",Cell:function(e){var t=e.entry.title;return Object(f.jsx)("div",{className:"w-[30vw] overflow-hidden",children:Object(f.jsx)("p",{className:"break-words",children:t})})}},{title:"Created At",field:"createdAt",Cell:function(e){var t=e.entry.createdAt;return Object(f.jsx)("span",{children:Object(c.a)(t)})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return Object(f.jsx)(s.c,{to:"./".concat(t),children:"View"})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return Object(f.jsx)(T,{id:t})}}]}):null},L=function(){return Object(f.jsx)(a.a,{title:"Resources",button:Object(f.jsx)(_,{}),children:Object(f.jsx)("div",{className:"mt-4",children:Object(f.jsx)(Y,{})})})},k=function(){return Object(f.jsxs)(n.e,{children:[Object(f.jsx)(n.c,{path:"",element:Object(f.jsx)(L,{})}),Object(f.jsx)(n.c,{path:":resourceId",element:Object(f.jsx)(h,{})}),Object(f.jsx)(n.c,{path:"*",element:Object(f.jsx)(n.a,{to:"."})})]})}}}]); //# sourceMappingURL=10.650f683d.chunk.js.map