Your IP : 18.220.222.188


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

"use strict";(self.webpackChunkpanel=self.webpackChunkpanel||[]).push([[685],{2685:function(e,t,r){r.r(t),r.d(t,{JobsRoutes:function(){return S}});var n=r(6871),i=r(9630),s=r(5528),a=r(2412),o=r(8592),u=r(1413),c=r(6771),l=r(1933),d=function(e){var t=e.jobId,r=e.config;return(0,l.useQuery)((0,u.Z)((0,u.Z)({},r),{},{queryKey:["job",t],queryFn:function(){return function(e){var t=e.jobId;return c.o.get("/jobs/".concat(t))}({jobId:t})}}))},f=r(4165),j=r(5861),v=r(806),p=r(4430),b=r(8419),x=r(9879),h=r(3777),m=r(7889),g=r(2007),y=r.n(g),w=function(e){var t=e.data,r=e.jobId;return c.o.patch("/jobs/".concat(r),t)};w.propTypes={data:y().shape({title:y().string.isRequired,desc:y().string.isRequired}).isRequired,jobId:y().string.isRequired};var Z=r(184),k=x.Ry({title:x.Z_().min(1,"Required"),desc:x.Z_().min(1,"Required")}),N=function(e){var t,r,n=e.jobId,s=d({jobId:n}),a=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,m.G)().addNotification;return(0,l.useMutation)((0,u.Z)((0,u.Z)({onMutate:function(){var e=(0,j.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,h.E.cancelQueries(["job",null===t||void 0===t?void 0:t.jobId]);case 2:return r=h.E.getQueryData[null===t||void 0===t?void 0:t.jobId],h.E.setQueryData(["job",null===t||void 0===t?void 0:t.jobId],(0,u.Z)((0,u.Z)((0,u.Z)({},r),t.data),{},{id:t.jobId})),e.abrupt("return",{previousJob: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.previousJob&&h.E.setQueryData(["job",r.previousJob.id],r.previousJob)},onSuccess:function(e){h.E.refetchQueries(["job",e.id]),t({type:"success",title:"Job Updated"})}},e),{},{mutationFn:w}))}();return a.isLoading?(0,Z.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,Z.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,Z.jsx)(i.$j,{size:"sm"})})}):(0,Z.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,Z.jsx)(v._8,{sie:"sm",isDone:a.isSuccess,triggerButton:(0,Z.jsx)(i.zx,{variant:"create",startIcon:(0,Z.jsx)(b.Z,{className:"h-4 w-4"}),size:"sm",children:"Update Job"}),title:"Update Job",submitButton:(0,Z.jsx)(i.zx,{form:"update-job",type:"submit",size:"sm",isLoading:a.isLoading,children:"Submit"}),children:(0,Z.jsx)(v.l0,{id:"update-job",onSubmit:function(){var e=(0,j.Z)((0,f.Z)().mark((function e(t){return(0,f.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.mutateAsync({data:t,jobId: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:k,children:function(e){var t=e.register,r=e.formState,n=e.watch,i=e.setValue;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(v.UP,{label:"Title",error:r.errors.title,registration:t("title")}),(0,Z.jsx)(v.N7,{label:"Description",error:r.errors.desc,editorContent:n("desc"),setValue:i,value:"desc"})]})}})})})},I=function(){var e=(0,n.UO)().jobId,t=d({jobId:e});return t.isLoading?(0,Z.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,Z.jsx)(i.$j,{size:"lg"})}):t.data?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s.F,{title:t.data.title}),(0,Z.jsxs)(a.D,{title:t.data.title,button:(0,Z.jsx)(N,{jobId:e}),children:[(0,Z.jsx)("span",{className:"text-xs text-gray-500 font-bold",children:(0,o.p)(t.data.createdAt)}),(0,Z.jsx)("div",{className:"mt-6 flex flex-col space-y-16",children:(0,Z.jsx)("div",{children:(0,Z.jsx)("div",{className:"bg-white dark:bg-gray-700 shadow overflow-hidden sm:rounded-lg",children:(0,Z.jsx)("div",{className:"px-4 py-5 sm:px-6",children:(0,Z.jsx)("div",{className:"mt-1 text-justify text-sm text-gray-400",children:(0,Z.jsx)(i.Xz,{value:t.data.desc})})})})})})]})]}):null},E=r(2076),z=r(2982),D=function(e){var t=e.data;return c.o.post("/jobs",t)};D.propTypes={data:y().shape({title:y().string.isRequired,desc:y().string.isRequired}).isRequired};var R=x.Ry({title:x.Z_().min(1,"Required"),desc:x.Z_().min(1,"Required")}),J=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,m.G)().addNotification;return(0,l.useMutation)((0,u.Z)((0,u.Z)({onMutate:function(){var e=(0,j.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,h.E.cancelQueries("jobs");case 2:return r=h.E.getQueryData("jobs"),h.E.setQueryData("jobs",[].concat((0,z.Z)(r||[]),[t.data])),e.abrupt("return",{previousJobs: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.previousJobs&&h.E.setQueryData("jobs",r.previousJobs)},onSuccess:function(){h.E.invalidateQueries("jobs"),t({type:"success",title:"Job Created"})}},e),{},{mutationFn:D}))}();return e.isLoading?(0,Z.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,Z.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,Z.jsx)(i.$j,{size:"sm"})})}):(0,Z.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,Z.jsx)(v._8,{size:"sm",isDone:e.isSuccess,triggerButton:(0,Z.jsx)(i.zx,{variant:"create",size:"sm",startIcon:(0,Z.jsx)(E.Z,{className:"h-4 w-4"}),children:"Create Job"}),title:"Create Job",submitButton:(0,Z.jsx)(i.zx,{form:"create-job",type:"submit",size:"sm",isLoading:e.isLoading,children:"Submit"}),children:(0,Z.jsx)(v.l0,{id:"create-job",onSubmit:function(){var t=(0,j.Z)((0,f.Z)().mark((function t(r){return(0,f.Z)().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:R,children:function(e){var t=e.register,r=e.formState,n=e.watch,i=e.setValue;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(v.UP,{label:"Title",error:r.errors.title,registration:t("title")}),(0,Z.jsx)(v.N7,{label:"Description",error:r.errors.desc,editorContent:n("desc"),setValue:i,value:"desc"})]})}})})})},C=function(){return c.o.get("/jobs")},L=r(803),Q=function(e){var t=e.jobId;return c.o.delete("/jobs/".concat(t))};Q.propTypes={jobId:y().string.isRequired};var q=function(e){var t=e.id,r=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config,t=(0,m.G)().addNotification;return(0,l.useMutation)((0,u.Z)((0,u.Z)({onMutate:function(){var e=(0,j.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,h.E.cancelQueries("jobs");case 2:return r=h.E.getQueryData("jobs"),h.E.setQueryData("jobs",null===r||void 0===r?void 0:r.filter((function(e){return e.id!==t.jobId}))),e.abrupt("return",{previousJobs: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.previousJobs&&h.E.setQueryData("jobs",r.previousJobs)},onSuccess:function(){h.E.invalidateQueries("jobs"),t({type:"success",title:"Career Deleted"})}},e),{},{mutationFn:Q}))}();return r.isLoading?(0,Z.jsx)("div",{id:"loading-screen",className:"w-full h-full fixed block top-0 left-0 bg-black opacity-75 z-50",children:(0,Z.jsx)("span",{className:"opacity-75 top-1/2 my-0 mx-auto block relative w-0 h-0",children:(0,Z.jsx)(i.$j,{size:"sm"})})}):(0,Z.jsx)(p._n,{allowedRoles:[p.K$.ADMIN],children:(0,Z.jsx)(i.U6,{icon:"danger",title:"Delete Job",body:"Are you sure you want to delete this Job?",triggerButton:(0,Z.jsx)(i.zx,{variant:"danger",children:(0,Z.jsx)(L.Z,{className:"h-4 w-4"})}),confirmButton:(0,Z.jsx)(i.zx,{isLoading:r.isLoading,type:"button",className:"bg-red-600",onClick:(0,j.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({jobId:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),children:"Delete Job"})})})},A=function(){var e=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).config;return(0,l.useQuery)((0,u.Z)((0,u.Z)({},e),{},{queryKey:["jobs"],queryFn:function(){return C()}}))}();return e.isLoading?(0,Z.jsx)("div",{className:"w-full h-48 flex justify-center items-center",children:(0,Z.jsx)(i.$j,{size:"lg"})}):e.data?(0,Z.jsx)(i.iA,{data:e.data,columns:[{title:"Title",field:"title"},{title:"Created At",field:"createdAt",Cell:function(e){var t=e.entry.createdAt;return(0,Z.jsx)("span",{children:(0,o.p)(t)})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return(0,Z.jsx)(i.rU,{to:"./".concat(t),className:"mr-2 text-black dark:text-gray-200 hover:text-green-400",children:"View"})}},{title:"",field:"id",Cell:function(e){var t=e.entry._id;return(0,Z.jsx)(q,{id:t})}}]}):null},M=function(){return(0,Z.jsx)(a.D,{title:"Careers",button:(0,Z.jsx)(J,{}),children:(0,Z.jsx)("div",{className:"mt-4",children:(0,Z.jsx)(A,{})})})},S=function(){return(0,Z.jsxs)(n.Z5,{children:[(0,Z.jsx)(n.AW,{path:"",element:(0,Z.jsx)(M,{})}),(0,Z.jsx)(n.AW,{path:":jobId",element:(0,Z.jsx)(I,{})}),(0,Z.jsx)(n.AW,{path:"*",element:(0,Z.jsx)(n.Fg,{to:"."})})]})}},2076:function(e,t,r){var n=r(2791);var i=n.forwardRef((function(e,t){return n.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),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"}))}));t.Z=i},803:function(e,t,r){var n=r(2791);var i=n.forwardRef((function(e,t){return n.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),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"}))}));t.Z=i},8419:function(e,t,r){var n=r(2791);var i=n.forwardRef((function(e,t){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),n.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=i}}]);
//# sourceMappingURL=685.f71201be.chunk.js.map