Current Path : /home/ncdcgo/admin.ncdc.go.ug/static/js/ |
Current File : /home/ncdcgo/admin.ncdc.go.ug/static/js/897.4bed85b1.chunk.js |
"use strict";(self.webpackChunkpanel=self.webpackChunkpanel||[]).push([[897],{223:function(e,r,a){a(2791);var t=a(3504),u=a(2506),s=a(184);r.Z=function(e){var r=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)(t.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===r||void 0===r?void 0:r.map((function(e,r){return(0,s.jsxs)("li",{className:"inline-flex items-center",children:[(0,s.jsx)(u.Z,{size:10,className:"mr-4"}),(0,s.jsx)(t.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})]},r)}))]})})}},6897:function(e,r,a){a.r(r),a.d(r,{ResourcesRoutes:function(){return we}});var t=a(6871),u=a(9630),s=a(5528),i=a(2412),n=a(77),o=a(8592),l=a(1413),c=a(6771),d=a(1933),m=function(e){var r=e.resourceId,a=e.config;return(0,d.useQuery)((0,l.Z)((0,l.Z)({},a),{},{queryKey:["resource",r],queryFn:function(){return function(e){var r=e.resourceId;return c.o.get("/resources/".concat(r))}({resourceId:r})}}))},v=a(806),p=a(4430),f=a(2791),b=a(3777),g=a(7889),x=a(2007),h=a.n(x),j=function(e){var r=e.resourceId;return c.o.patch("/resources/abridged/".concat(r))};j.propTypes={resourceId:h().string.isRequired};var y=a(184),C=a(4165),S=a(5861),w=a(885),E=a(4925),Z=a(5612),R=a(7003),k=a(7369),N=a(2953),T=a(2982),P=a(4705),I=a(4159),L=a(3654),A=["passive"],D=(0,f.createContext)(null);function O(){var e=(0,f.useContext)(D);if(null===e){var r=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(r,O),r}return e}function z(){var e=(0,f.useState)([]),r=(0,w.Z)(e,2),a=r[0],t=r[1];return[a.length>0?a.join(" "):void 0,(0,f.useMemo)((function(){return function(e){var r=(0,L.z)((function(e){return t((function(r){return[].concat((0,T.Z)(r),[e])})),function(){return t((function(r){var a=r.slice(),t=a.indexOf(e);return-1!==t&&a.splice(t,1),a}))}})),a=(0,f.useMemo)((function(){return{register:r,slot:e.slot,name:e.name,props:e.props}}),[r,e.slot,e.name,e.props]);return f.createElement(D.Provider,{value:a},e.children)}}),[t])]}var F=(0,Z.yV)((function(e,r){var a=e.passive,t=void 0!==a&&a,u=(0,E.Z)(e,A),s=O(),i="headlessui-label-".concat((0,R.M)()),n=(0,I.T)(r);(0,P.e)((function(){return s.register(i)}),[i,s.register]);var o=(0,l.Z)((0,l.Z)({ref:n},s.props),{},{id:i});return t&&("onClick"in o&&delete o.onClick,"onClick"in u&&delete u.onClick),(0,Z.sY)({ourProps:o,theirProps:u,slot:s.slot||{},defaultTag:"label",name:s.name||"Label"})})),U=a(1248),B=a(4381),Q=a(3402),q=a(7762);var M=["checked","onChange","name","value"],V=(0,f.createContext)(null);V.displayName="GroupContext";var _=f.Fragment;var G=(0,Z.yV)((function(e,r){var a=e.checked,t=e.onChange,u=e.name,s=e.value,i=(0,E.Z)(e,M),n="headlessui-switch-".concat((0,R.M)()),o=(0,f.useContext)(V),c=(0,f.useRef)(null),d=(0,I.T)(c,r,null===o?null:o.setSwitch),m=(0,L.z)((function(){return t(!a)})),v=(0,L.z)((function(e){if((0,N.P)(e.currentTarget))return e.preventDefault();e.preventDefault(),m()})),p=(0,L.z)((function(e){e.key===k.R.Space?(e.preventDefault(),m()):e.key===k.R.Enter&&function(e){var r,a=null!=(r=null==e?void 0:e.form)?r:e.closest("form");if(a){var t,u=(0,q.Z)(a.elements);try{for(u.s();!(t=u.n()).done;){var s=t.value;if("INPUT"===s.tagName&&"submit"===s.type||"BUTTON"===s.tagName&&"submit"===s.type||"INPUT"===s.nodeName&&"image"===s.type)return void s.click()}}catch(i){u.e(i)}finally{u.f()}}}(e.currentTarget)})),b=(0,L.z)((function(e){return e.preventDefault()})),g=(0,f.useMemo)((function(){return{checked:a}}),[a]),x={id:n,ref:d,role:"switch",type:(0,B.f)(e,c),tabIndex:0,"aria-checked":a,"aria-labelledby":null==o?void 0:o.labelledby,"aria-describedby":null==o?void 0:o.describedby,onClick:v,onKeyUp:p,onKeyPress:b};return f.createElement(f.Fragment,null,null!=u&&a&&f.createElement(Q._,(0,l.Z)({features:Q.A.Hidden},(0,Z.oA)({as:"input",type:"checkbox",hidden:!0,readOnly:!0,checked:a,name:u,value:s}))),(0,Z.sY)({ourProps:x,theirProps:i,slot:g,defaultTag:"button",name:"Switch"}))})),Y=Object.assign(G,{Group:function(e){var r=(0,f.useState)(null),a=(0,w.Z)(r,2),t=a[0],u=a[1],s=z(),i=(0,w.Z)(s,2),n=i[0],o=i[1],l=(0,U.f)(),c=(0,w.Z)(l,2),d=c[0],m=c[1],v=(0,f.useMemo)((function(){return{switch:t,setSwitch:u,labelledby:n,describedby:d}}),[t,u,n,d]),p=e;return f.createElement(m,{name:"Switch.Description"},f.createElement(o,{name:"Switch.Label",props:{onClick:function(){!t||(t.click(),t.focus({preventScroll:!0}))}}},f.createElement(V.Provider,{value:v},(0,Z.sY)({ourProps:{},theirProps:p,defaultTag:_,name:"Switch.Group"}))))},Label:F,Description:U.d}),$=function(e){var r=e.resourceId;return c.o.patch("/resources/approve/".concat(r))};$.propTypes={resourceId:h().string.isRequired};var K=function(e){var r,a=e.resourceId,t=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification;return(0,d.useMutation)((0,l.Z)((0,l.Z)({onMutate:function(){var e=(0,S.Z)((0,C.Z)().mark((function e(r){var a;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.E.cancelQueries(["resource",null===r||void 0===r?void 0:r.resourceId]);case 2:return a=b.E.getQueryData[null===r||void 0===r?void 0:r.resourceId],b.E.setQueryData(["resource",null===r||void 0===r?void 0:r.resourceId],(0,l.Z)((0,l.Z)({},a),{},{id:r.resourceId})),e.abrupt("return",{previousResource:a});case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onError:function(e,r,a){null!==a&&void 0!==a&&a.previousResource&&b.E.setQueryData(["resource",a.previousResource.id],a.previousResource)},onSuccess:function(e){b.E.refetchQueries(["resource",e.id]),r({type:"success",title:"Resource Updated"})}},e),{},{mutationFn:$}))}(),s=m({resourceId:a}),i=(0,f.useState)(null===(r=s.data)||void 0===r?void 0:r.approved),n=(0,w.Z)(i,2),o=n[0],c=n[1];return t.isLoading?(0,y.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,y.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,y.jsx)(u.$j,{size:"sm"})})}):(0,y.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,y.jsx)(v.l0,{id:"update-resource",children:function(){return(0,y.jsx)(y.Fragment,{children:(0,y.jsx)(Y.Group,{children:(0,y.jsxs)("div",{className:"flex items-center",children:[(0,y.jsx)(Y.Label,{className:"mr-4",children:"Approved"}),(0,y.jsx)(Y,{checked:o,onChange:(0,S.Z)((0,C.Z)().mark((function e(){return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c(!o),e.next=3,t.mutateAsync({resourceId:a});case 3:case"end":return e.stop()}}),e)}))),className:"".concat(o?"bg-green-600":"bg-gray-600"," relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"),children:(0,y.jsx)("span",{className:"".concat(o?"translate-x-6":"translate-x-1"," inline-block h-4 w-4 transform rounded-full bg-white transition-transform")})})]})})})}})})},H=a(8419),W=a(9879),X=function(e){var r=e.data,a=e.resourceId;return c.o.patch("/resources/".concat(a),r)};X.propTypes={data:h().shape({title:h().string.isRequired,price:h().string.isRequired,desc:h().string.isRequired,curriculum:h().string.isRequired}).isRequired,resourceId:h().string.isRequired};var J=W.Ry({title:W.Z_().min(1,"Required"),resourceType:W.Z_().min(1,"Required"),curriculum:W.Z_().min(1,"Required"),subjectOrCourse:W.Z_().min(1,"Required"),price:W.Z_(),desc:W.Z_()}),ee=[{label:"ECCE Curriculum",value:"ECCE Curriculum"},{label:"Primary Curriculum",value:"Primary Curriculum"},{label:"Secondary Curriculum",value:"Secondary Curriculum"},{label:"BTVET Curriculum",value:"BTVET Curriculum"},{label:"Abridged Curriculum",value:"Abridged Curriculum"},{label:"Accelerated Education Programe",value:"Accelerated Education Programe"}],re=[{label:"Syllabus Books",value:"Syllabus Books"},{label:"Textbooks and Teachers Guides",value:"Textbooks and Teachers Guides"},{label:"Home Study Learning",value:"Home Study Learning"}],ae=[{label:"Basic Education Curriculum Framework for Uganda",value:"Basic Education Curriculum Framework for Uganda"},{label:"Learning Framework for Early Childhood Development (3 - 6 Years)",value:"Learning Framework for Early Childhood Development (3 - 6 Years)"},{label:"Caregivers Guide to the Learning Framework (3 - 6 Years)",value:"Caregivers Guide to the Learning Framework (3 - 6 Years)"},{label:"Thematic (Lower Primary) Curriculum",value:"Thematic (Lower Primary) Curriculum"}],te=[{label:"Upper Primary Curriculum",value:"Upper Primary Curriculum"},{label:"Transition Curriculum",value:"Transition Curriculum"}],ue=[{label:"O Level Curriculum (Revised, Competency-based)",value:"O Level Curriculum (Revised, Competency-based)"},{label:"A Level Curriculum",value:"A Level Curriculum"}],se=[{label:"Certificate Courses",value:"Certificate Courses"},{label:"Diploma Programs",value:"Diploma Programs"}],ie=[{label:"Primary 2",value:"Primary 2"},{label:"Primary 3",value:"Primary 3"},{label:"Primary 4",value:"Primary 4"},{label:"Primary 5",value:"Primary 5"},{label:"Primary 6",value:"Primary 6"},{label:"Primary 7",value:"Primary 7"},{label:"Senior 2",value:"Senior 2"},{label:"Senior 3",value:"Senior 3"},{label:"Senior 4",value:"Senior 4"},{label:"Senior 5",value:"Senior 5"},{label:"Senior 6",value:"Senior 6"}],ne=[{label:"Special Needs Education (SNE)",value:"Special Needs Education (SNE)"},{label:"Pastoral and fishing communities",value:"Pastoral and fishing communities"},{label:"Refugees and host communities",value:"Refugees and host communities"}],oe=function(e){var r,a,t,s,i,n,o,c=e.resourceId,x=m({resourceId:c}),h=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification;return(0,d.useMutation)((0,l.Z)((0,l.Z)({onMutate:function(){var e=(0,S.Z)((0,C.Z)().mark((function e(r){var a;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.E.cancelQueries(["resource",null===r||void 0===r?void 0:r.resourceId]);case 2:return a=b.E.getQueryData[null===r||void 0===r?void 0:r.resourceId],b.E.setQueryData(["resource",null===r||void 0===r?void 0:r.resourceId],(0,l.Z)((0,l.Z)((0,l.Z)({},a),r.data),{},{id:r.resourceId})),e.abrupt("return",{previousResource:a});case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onError:function(e,r,a){null!==a&&void 0!==a&&a.previousResource&&b.E.setQueryData(["resource",a.previousResource.id],a.previousResource)},onSuccess:function(e){b.E.refetchQueries(["resource",e.id]),r({type:"success",title:"Resource Updated"})}},e),{},{mutationFn:X}))}(),j=(0,f.useState)(null===(r=x.data)||void 0===r?void 0:r.curriculum),E=(0,w.Z)(j,2),Z=E[0],R=E[1];return h.isLoading?(0,y.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,y.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,y.jsx)(u.$j,{size:"sm"})})}):(0,y.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,y.jsx)(v._8,{size:"sm",isDone:h.isSuccess,triggerButton:(0,y.jsx)(u.zx,{variant:"create",startIcon:(0,y.jsx)(H.Z,{className:"h-4 w-4"}),size:"sm",children:"Update Resource"}),title:"Update Resource",submitButton:(0,y.jsx)(u.zx,{form:"update-resource-details",type:"submit",size:"sm",isLoading:h.isLoading,children:"Submit"}),children:(0,y.jsx)(v.l0,{id:"update-resource-details",onSubmit:function(){var e=(0,S.Z)((0,C.Z)().mark((function e(r){var a,t,u,s,i,n,o;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=r.title,t=r.price,u=r.desc,s=r.resourceType,i=r.curriculum,n=r.subjectOrCourse,(o=new FormData).append("title",a),o.append("price",t),o.append("resourceType",s),o.append("desc",u),o.append("curriculum",i),o.append("subjectOrCourse",n),console.log(r),e.next=11,h.mutateAsync({data:r,resourceId:c});case 11:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),options:{defaultValues:{title:null===(a=x.data)||void 0===a?void 0:a.title,resourceType:null===(t=x.data)||void 0===t?void 0:t.resourceType,price:(null===(s=x.data)||void 0===s?void 0:s.price)||"",desc:null===(i=x.data)||void 0===i?void 0:i.desc,curriculum:null===(n=x.data)||void 0===n?void 0:n.curriculum,subjectOrCourse:null===(o=x.data)||void 0===o?void 0:o.subjectOrCourse}},schema:J,children:function(e){var r=e.register,a=e.formState,t=e.watch,u=e.setValue;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v.UP,{label:"Title",error:a.errors.title,registration:r("title")}),(0,y.jsx)(v.UP,{label:"Price",error:a.errors.price,registration:r("price")}),(0,y.jsx)(v.N7,{label:"Description",error:a.errors.desc,editorContent:t("desc"),setValue:u,value:"desc"}),(0,y.jsx)(v.mg,{label:"Select Resource Type",error:a.errors.resourceType,registration:r("resourceType"),options:re}),(0,y.jsx)(v.mg,{label:"Select Curriculum",error:a.errors.curriculum,registration:r("curriculum"),options:ee,onChange:function(e){return R(e.target.value)}}),"ECCE Curriculum"===Z&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(ECCE)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===ae||void 0===ae?void 0:ae.map((function(e){return{label:e.label,value:e.value}}))}),"Primary Curriculum"===Z&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(Primary)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===te||void 0===te?void 0:te.map((function(e){return{label:e.label,value:e.value}}))}),"Secondary Curriculum"===Z&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(Secondary)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===ue||void 0===ue?void 0:ue.map((function(e){return{label:e.label,value:e.value}}))}),"BTVET Curriculum"===Z&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(BTVET)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===se||void 0===se?void 0:se.map((function(e){return{label:e.label,value:e.value}}))}),"Abridged Curriculum"===Z&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(BTVET)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===ie||void 0===ie?void 0:ie.map((function(e){return{label:e.label,value:e.value}}))}),"Accelerated Education Programe"===Z&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(Accelerated Education Programe)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===ne||void 0===ne?void 0:ne.map((function(e){return{label:e.label,value:e.value}}))})]})}})})})},le=function(e){var r=e.data,a=e.resourceId;return c.o.patch("/resources/".concat(a),r,{headers:{"Content-Type":"multipart/form-data"}})};le.propTypes={data:h().shape({cover:h().object,resource:h().object}).isRequired,resourceId:h().string.isRequired};var ce=W.Ry({}),de=function(e){var r,a,t=e.resourceId,s=(0,f.useState)(null),i=(0,w.Z)(s,2),n=i[0],o=i[1],c=(0,f.useState)(null),x=(0,w.Z)(c,2),h=x[0],j=x[1],E=(0,f.useState)(null),Z=(0,w.Z)(E,2),R=Z[0],k=Z[1],N=m({resourceId:t}),T=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification;return(0,d.useMutation)((0,l.Z)((0,l.Z)({onMutate:function(){var e=(0,S.Z)((0,C.Z)().mark((function e(r){var a;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.E.cancelQueries(["resourceAsset",null===r||void 0===r?void 0:r.resourceId]);case 2:return a=b.E.getQueryData[null===r||void 0===r?void 0:r.resourceId],b.E.setQueryData(["resourceAsset",null===r||void 0===r?void 0:r.resourceId],(0,l.Z)((0,l.Z)((0,l.Z)({},a),r.data),{},{id:r.resourceId})),e.abrupt("return",{previousResourceAsset:a});case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onError:function(e,r,a){null!==a&&void 0!==a&&a.previousResourceAsset&&b.E.setQueryData(["resourceAsset",a.previousResourceAsset.id],a.previousResourceAsset)},onSuccess:function(e){b.E.refetchQueries(["resourceAsset",e.id]),r({type:"success",title:"Resource Assets Updated"})}},e),{},{mutationFn:le}))}();return T.isLoading?(0,y.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,y.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,y.jsx)(u.$j,{size:"sm"})})}):(0,y.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,y.jsx)(v._8,{size:"sm",isDone:T.isSuccess,triggerButton:(0,y.jsx)(u.zx,{variant:"create",startIcon:(0,y.jsx)(H.Z,{className:"h-4 w-4"}),size:"sm",children:"Update Cover & Resource File"}),title:"Update Resource Asset",submitButton:(0,y.jsx)(u.zx,{form:"update-resource-assets",type:"submit",size:"sm",isLoading:T.isLoading,children:"Submit"}),children:(0,y.jsx)(v.l0,{id:"update-resource-assets",onSubmit:(0,S.Z)((0,C.Z)().mark((function e(){var r;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new FormData).append("cover",n),r.append("resource",h),e.next=5,T.mutateAsync({data:r,resourceId:t});case 5:k(null);case 6:case"end":return e.stop()}}),e)}))),options:{defaultValues:{cover:null===(r=N.data)||void 0===r?void 0:r.cover,resource:null===(a=N.data)||void 0===a?void 0:a.resource}},schema:ce,children:function(e){var r=e.formState;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v.VA,{title:"Update Cover Photo",subTitle:"This will also be used as the thumbnail in resource feeds",error:r.errors.cover,x:500,y:700,onChange:function(e){o(e.target.files[0]),k(URL.createObjectURL(e.target.files[0]))},preview:R}),(0,y.jsx)(v.cr,{label:"Update Resource File",accept:"application/pdf",error:r.errors.resource,onChange:function(e){j(e.target.files[0])}})]})}})})})},me=a(223),ve=function(){var e,r=(0,t.UO)().resourceId,a=m({resourceId:r});if(a.isLoading)return(0,y.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,y.jsx)(u.$j,{size:"lg"})});var l=[{name:"Resources",path:"/app/resources"},{name:null===(e=a.data)||void 0===e?void 0:e.title,path:""}];return a.data?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s.F,{title:a.data.title}),(0,y.jsxs)(i.D,{title:a.data.title,button:(0,y.jsx)(oe,{resourceId:r}),children:[(0,y.jsx)(me.Z,{routes:l}),(0,y.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:(0,y.jsx)("div",{children:(0,y.jsx)("div",{className:"bg-white dark:bg-gray-700 shadow overflow-hidden sm:rounded-lg",children:(0,y.jsx)("div",{className:"px-4 py-5 sm:px-6",children:(0,y.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,y.jsxs)("div",{className:"col-span-2 mt-1 text-sm text-gray-400",children:[(0,y.jsx)("span",{className:"font-bold text-lg",children:a.data.title}),(0,y.jsxs)("div",{className:"bg-gray-100 dark:bg-gray-800 p-4 my-4",children:[(0,y.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,y.jsx)(u.Xz,{value:a.data.desc})]}),(0,y.jsx)("span",{className:"font-bold",children:"Resource Type:"})," ",(0,y.jsx)("span",{children:a.data.resourceType}),(0,y.jsx)("br",{}),(0,y.jsx)("span",{className:"font-bold",children:"Curriculum:"})," ",(0,y.jsx)("span",{children:a.data.curriculum}),(0,y.jsx)("br",{}),(0,y.jsx)("span",{className:"font-bold",children:"Subject: "})," ",(0,y.jsx)("span",{children:a.data.subjectOrCourse}),(0,y.jsx)("br",{}),(0,y.jsx)("span",{className:"font-bold",children:"Price: "})," ",(0,y.jsx)("span",{children:null===a.data.price?"Free":a.data.price}),(0,y.jsx)("div",{className:"my-4",children:(0,y.jsx)(de,{resourceId:r})}),(0,y.jsx)("span",{className:"font-bold",children:"Last Updated: "})," ",(0,y.jsx)("span",{children:(0,o.p)(a.data.updatedAt)}),(0,y.jsx)("br",{}),(0,y.jsx)("div",{className:"my-4 space-x-4",children:(0,y.jsx)(K,{resourceId:r})})]}),(0,y.jsx)("div",{className:"mt-1",children:(0,y.jsx)("img",{src:n.tC+"/"+a.data.cover,alt:a.data.title,className:"border border-gray-300 rounded-lg"})})]})})})})})]})]}):null},pe=a(2076),fe=function(e){var r=e.data;return c.o.post("/resources",r,{headers:{"Content-Type":"multipart/form-data"}})};fe.propTypes={data:h().shape({title:h().string.isRequired,price:h().string,desc:h().string,curriculum:h().string.isRequired}).isRequired};var be=W.Ry({title:W.Z_().min(1,"Required"),resourceType:W.Z_().min(1,"Required"),curriculum:W.Z_().min(1,"Required"),subjectOrCourse:W.Z_().min(1,"Required"),price:W.Z_(),desc:W.Z_()}),ge=function(){var e=(0,f.useState)(null),r=(0,w.Z)(e,2),a=r[0],t=r[1],s=(0,f.useState)(null),i=(0,w.Z)(s,2),n=i[0],o=i[1],c=(0,f.useState)("ECCE Curriculum"),m=(0,w.Z)(c,2),x=m[0],h=m[1],j=[{label:"ECCE Curriculum",value:"ECCE Curriculum"},{label:"Primary Curriculum",value:"Primary Curriculum"},{label:"Secondary Curriculum",value:"Secondary Curriculum"},{label:"BTVET Curriculum",value:"BTVET Curriculum"},{label:"Abridged Curriculum",value:"Abridged Curriculum"},{label:"Accelerated Education Programe",value:"Accelerated Education Programe"}],E=[{label:"Syllabus Books",value:"Syllabus Books"},{label:"Textbooks and Teachers Guides",value:"Textbooks and Teachers Guides"},{label:"Home Study Learning",value:"Home Study Learning"}],Z=[{label:"Basic Education Curriculum Framework for Uganda",value:"Basic Education Curriculum Framework for Uganda"},{label:"Learning Framework for Early Childhood Development (3 - 6 Years)",value:"Learning Framework for Early Childhood Development (3 - 6 Years)"},{label:"Caregivers Guide to the Learning Framework (3 - 6 Years)",value:"Caregivers Guide to the Learning Framework (3 - 6 Years)"},{label:"Thematic (Lower Primary) Curriculum",value:"Thematic (Lower Primary) Curriculum"}],R=[{label:"Upper Primary Curriculum",value:"Upper Primary Curriculum"},{label:"Transition Curriculum",value:"Transition Curriculum"}],k=[{label:"O Level Curriculum (Revised, Competency-based)",value:"O Level Curriculum (Revised, Competency-based)"},{label:"A Level Curriculum",value:"A Level Curriculum"}],N=[{label:"Certificate Courses",value:"Certificate Courses"},{label:"Diploma Programs",value:"Diploma Programs"}],P=[{label:"Primary 2",value:"Primary 2"},{label:"Primary 3",value:"Primary 3"},{label:"Primary 4",value:"Primary 4"},{label:"Primary 5",value:"Primary 5"},{label:"Primary 6",value:"Primary 6"},{label:"Primary 7",value:"Primary 7"},{label:"Senior 2",value:"Senior 2"},{label:"Senior 3",value:"Senior 3"},{label:"Senior 4",value:"Senior 4"},{label:"Senior 5",value:"Senior 5"},{label:"Senior 6",value:"Senior 6"}],I=[{label:"Special Needs Education (SNE)",value:"Special Needs Education (SNE)"},{label:"Pastoral and fishing communities",value:"Pastoral and fishing communities"},{label:"Refugees and host communities",value:"Refugees and host communities"}],L=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification;return(0,d.useMutation)((0,l.Z)((0,l.Z)({onMutate:function(){var e=(0,S.Z)((0,C.Z)().mark((function e(r){var a;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.E.cancelQueries("resources");case 2:return a=b.E.getQueryData("resources"),b.E.setQueryData("resources",[].concat((0,T.Z)(a||[]),[r.data])),e.abrupt("return",{previousResources:a});case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onError:function(e,r,a){null!==a&&void 0!==a&&a.previousResources&&b.E.setQueryData("resources",a.previousResources)},onSuccess:function(){b.E.invalidateQueries("resources"),r({type:"success",title:"Resource Created"})}},e),{},{mutationFn:fe}))}();return L.isLoading?(0,y.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,y.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,y.jsx)(u.$j,{size:"sm"})})}):(0,y.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,y.jsx)(v._8,{size:"sm",isDone:L.isSuccess,triggerButton:(0,y.jsx)(u.zx,{variant:"create",size:"sm",startIcon:(0,y.jsx)(pe.Z,{className:"h-4 w-4"}),children:"Create Resource"}),title:"Create Resource",submitButton:(0,y.jsx)(u.zx,{form:"create-resource",type:"submit",size:"sm",isLoading:L.isLoading,children:"Submit"}),children:(0,y.jsx)(v.l0,{id:"create-resource",encType:"multipart/form-data",onSubmit:function(){var e=(0,S.Z)((0,C.Z)().mark((function e(r){var t,u,s,i,o,l,c;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.title,u=r.price,s=r.desc,i=r.resourceType,o=r.curriculum,l=r.subjectOrCourse,(c=new FormData).append("title",t),c.append("price",u),c.append("desc",s),c.append("resourceType",i),c.append("curriculum",o),c.append("subjectOrCourse",l),c.append("cover",n),c.append("resource",a),e.next=12,L.mutateAsync({data:c});case 12:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),schema:be,children:function(e){var r=e.register,a=e.formState,u=e.watch,s=e.setValue;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v.UP,{label:"Title",error:a.errors.title,registration:r("title")}),(0,y.jsx)(v.N7,{label:"Description",error:a.errors.desc,editorContent:u("desc"),setValue:s,value:"desc"}),(0,y.jsx)(v.UP,{label:"Price",error:a.errors.price,registration:r("price")}),(0,y.jsx)(v.cr,{label:"Upload Resource Cover Photo",accept:"image/*",error:a.errors.cover,onChange:function(e){o(e.target.files[0])}}),(0,y.jsx)(v.cr,{label:"Upload Resource File",accept:"application/pdf",error:a.errors.resource,onChange:function(e){t(e.target.files[0])}}),(0,y.jsx)(v.mg,{label:"Select Resource Type",error:a.errors.resourceType,registration:r("resourceType"),options:E}),(0,y.jsx)(v.mg,{label:"Select Curriculum",error:a.errors.curriculum,registration:r("curriculum"),options:j,onChange:function(e){return h(e.target.value)}}),"ECCE Curriculum"===x&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(ECCE)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===Z||void 0===Z?void 0:Z.map((function(e){return{label:e.label,value:e.value}}))}),"Primary Curriculum"===x&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(Primary)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===R||void 0===R?void 0:R.map((function(e){return{label:e.label,value:e.value}}))}),"Secondary Curriculum"===x&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(Secondary)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===k||void 0===k?void 0:k.map((function(e){return{label:e.label,value:e.value}}))}),"BTVET Curriculum"===x&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(BTVET)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===N||void 0===N?void 0:N.map((function(e){return{label:e.label,value:e.value}}))}),"Abridged Curriculum"===x&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(BTVET)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===P||void 0===P?void 0:P.map((function(e){return{label:e.label,value:e.value}}))}),"Accelerated Education Programe"===x&&(0,y.jsx)(v.mg,{label:"Select Subject or Course(Accelerated Education Programe)",error:a.errors.subjectOrCourse,registration:r("subjectOrCourse"),options:null===I||void 0===I?void 0:I.map((function(e){return{label:e.label,value:e.value}}))})]})}})})})},xe=a(7087),he=function(){return c.o.get("/resources")},je=function(e){var r=e.resourceId;return c.o.delete("/resources/".concat(r))};je.propTypes={resourceId:h().string.isRequired};var ye=function(e){var r=e.id,a=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,r=(0,g.G)().addNotification;return(0,d.useMutation)((0,l.Z)((0,l.Z)({onMutate:function(){var e=(0,S.Z)((0,C.Z)().mark((function e(r){var a;return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.E.cancelQueries("resources");case 2:return a=b.E.getQueryData("resources"),b.E.setQueryData("resources",null===a||void 0===a?void 0:a.filter((function(e){return e.id!==r.resourceId}))),e.abrupt("return",{previousResources:a});case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onError:function(e,r,a){null!==a&&void 0!==a&&a.previousResources&&b.E.setQueryData("resources",a.previousResources)},onSuccess:function(){b.E.invalidateQueries("resources"),r({type:"success",title:"Resources Deleted"})}},e),{},{mutationFn:je}))}();return a.isLoading?(0,y.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,y.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,y.jsx)(u.$j,{size:"sm"})})}):(0,y.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,y.jsx)(u.U6,{icon:"danger",title:"Delete Resource",body:"Are you sure you want to delete this Resource?",triggerButton:(0,y.jsx)("button",{children:"Remove"}),confirmButton:(0,y.jsx)(u.zx,{isLoading:a.isLoading,type:"button",className:"bg-red-600",onClick:(0,S.Z)((0,C.Z)().mark((function e(){return(0,C.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.mutateAsync({resourceId:r});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Resource"})})})},Ce=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,d.useQuery)((0,l.Z)((0,l.Z)({},e),{},{queryKey:["resources"],queryFn:function(){return he()}}))}();return e.isLoading?(0,y.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,y.jsx)(u.$j,{size:"lg"})}):e.data?(0,y.jsx)(u.iA,{data:e.data,columns:[{title:"Listings",field:"title",Cell:function(e){var r=e.entry,a=r.title,t=r.createdAt,u=r.cover;return(0,y.jsxs)("div",{className:"flex flex-row items-center",children:[(0,y.jsx)(xe.LazyLoadImage,{src:n.tC+"/"+u,alt:"background for post",className:"h-16 rounded-lg mr-4"}),(0,y.jsxs)("div",{className:"",children:[(0,y.jsx)("div",{className:"w-[30vw] overflow-hidden",children:(0,y.jsx)("p",{className:"break-words",children:a})}),(0,y.jsxs)("span",{className:"text-xs text-gray-200",children:["Added ",(0,o.p)(t)]})]})]})}},{title:"",field:"id",Cell:function(e){var r=e.entry._id;return(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)("div",{className:"flex flex-row justify-center items-center gap-5",children:[(0,y.jsx)(u.rU,{to:"./".concat(r),className:"mr-2 text-black dark:text-gray-200 hover:text-green-400",children:"View"})," ",(0,y.jsx)(ye,{id:r})]})})}}]}):null},Se=function(){return(0,y.jsxs)(i.D,{title:"Resources",button:(0,y.jsx)(ge,{}),children:[(0,y.jsx)(me.Z,{routes:[{name:"Resources",path:"."}]}),(0,y.jsx)("div",{className:"mt-4",children:(0,y.jsx)(Ce,{})})]})},we=function(){return(0,y.jsxs)(t.Z5,{children:[(0,y.jsx)(t.AW,{path:"",element:(0,y.jsx)(Se,{})}),(0,y.jsx)(t.AW,{path:":resourceId",element:(0,y.jsx)(ve,{})}),(0,y.jsx)(t.AW,{path:"*",element:(0,y.jsx)(t.Fg,{to:"."})})]})}},2076:function(e,r,a){var t=a(2791);var u=t.forwardRef((function(e,r){return t.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:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"}))}));r.Z=u},8419:function(e,r,a){var t=a(2791);var u=t.forwardRef((function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:r},e),t.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"}))}));r.Z=u}}]); //# sourceMappingURL=897.4bed85b1.chunk.js.map